-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ref(core): Switch all internal uses of captureException
to use @sentry/core
#6488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 tasks
size-limit report 📦
|
bc8a7a8
to
c95132a
Compare
c95132a
to
38ba255
Compare
This pull request has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
As part of the work to add correct
handled
data to events (albeit under a different name for the moment), this switches all internal uses ofcaptureException
to use the version that lives in@sentry/core
rather than a version imported from@sentry/browser
,@sentry/node
, or any of the SDKs which wrap them. This is necessary so that we can differentiate between users'captureException
calls (which will mostly use the SDK-levelcaptureException
, and if not, eitherhub.captureException
orclient.captureException
) and our own internal ones.Key changes:
A new eslint rule which enforces two structures:
import { captureException } from '@sentry/xxx';
are only allowed ifxxx
iscore
someModule.captureException(...)
wheresomeModule
comes from an import of the formimport * as someModule from '@sentry/xxx'
are only allowed ifxxx
iscore
getCurrentHub().captureException(...)
,getCurrentHub().getClient().captureException(...)
,hub.captureException(...)
,client.captureException(...)
, and the like are disallowed.It doesn't handle unpacking (
import * as someModule from '@sentry/xxx'; const { captureException } = someModule; captureException(...)
) because it seemed unlikely we'd do that and the rule seemed like it'd be more complicated than it was worth putting a bunch of effort into given that fact, but I can add it if we think it's necessary.A new function,
captureExceptionWithHint()
has been added to@sentry/core
(because it seemed easier, less disruptive, and better for treeshaking than making the currentcaptureException
method accept anEventHint
as its second parameter).A new protected method,
_captureException
has been added to theBaseClient
class. For the moment, it's identical to the oldcaptureException
method, and the old method now just calls the new method.The mocks in the serverless tests have a slightly strange setup, and currently manually clear all of the mocks, using a function in the mocked
@sentry/node
module. Because this change required splitting the mocked functions between a mocked@sentry/node
and a mocked@sentry/core
, using that single function was no longer possible. Fortunately, it wasn't actually necessary to do it that way in the first place -clearAllMocks
works just fine.Ref: #6073