ref: Hoist flush
, close
, and lastEventId
into @sentry/core
#8731
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current duplicated implementation of
flush
,close
andlastEventId
makes those functions hard to work with in "isomorphic" SDKs like Next.js and Sveltekit.A simple example: We could make our wrapping methods in Next.js isomorphic, however, these functions make use of flush so we would need to import either from
@sentry/browser
or@sentry/node
which goes a bit against the whole isomorphism.This PR hoists these functions up into
@sentry/core
so that we can access them isomorphically.There is one thing going on that's worth wasting one or two brain cells on, namely that we change the return types of
flush
andclose
fromPromiseLike
toPromise
in the browser SDK, but that should be fine sincePromise
obviously implementsPromiseLike
.On that note, because I mentioned "isomorphic" a lot, I decided to google it to check if it was actually a thing and it even has its own wikipedia article so we gucci: https://en.wikipedia.org/wiki/Isomorphic_JavaScript