Skip to content

Instantly share code, notes, and snippets.

@Nixes
Last active October 4, 2024 05:48
Show Gist options
  • Save Nixes/c7dcb71bb0d97581dbdfb8556e8b3b93 to your computer and use it in GitHub Desktop.
Save Nixes/c7dcb71bb0d97581dbdfb8556e8b3b93 to your computer and use it in GitHub Desktop.
Method of setting the sentry release value after Sentry init has already completed

Check the scopes that you want to set it in, in my case I want it set for the entire application lifespan, so I set it in all possible scopes (to also effect scopes in flight).

export const setPostInitRelease = (releaseName: string) => {
    // set the release value using an event processor
    const eventProcessor = (event: { release: string | undefined }) => {
        event.release = releaseName
        return event
    };
    Sentry.getGlobalScope().addEventProcessor(eventProcessor)
    Sentry.getCurrentScope().addEventProcessor(eventProcessor)
    Sentry.addEventProcessor(eventProcessor)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment