-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ref: Add tests for breadcrumbs #2620
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,15 +91,8 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement | |
|
||
this._getBackend() | ||
.eventFromException(exception, hint) | ||
.then(event => this._processEvent(event, hint, scope)) | ||
.then(finalEvent => { | ||
// We need to check for finalEvent in case beforeSend returned null | ||
eventId = finalEvent && finalEvent.event_id; | ||
this._processing = false; | ||
}) | ||
.then(null, reason => { | ||
logger.error(reason); | ||
this._processing = false; | ||
.then(event => { | ||
eventId = this.captureEvent(event, hint, scope); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like return this._getBackend()
.eventFromException(exception, hint)
.then(event => this.captureEvent(event, hint, scope)); Also There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is tricky so I would leave it like this, because depending on if there is really an async call in between this is true or not. |
||
}); | ||
|
||
return eventId; | ||
|
@@ -110,24 +103,15 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement | |
*/ | ||
public captureMessage(message: string, level?: Severity, hint?: EventHint, scope?: Scope): string | undefined { | ||
let eventId: string | undefined = hint && hint.event_id; | ||
|
||
this._processing = true; | ||
|
||
const promisedEvent = isPrimitive(message) | ||
? this._getBackend().eventFromMessage(`${message}`, level, hint) | ||
: this._getBackend().eventFromException(message, hint); | ||
|
||
promisedEvent | ||
.then(event => this._processEvent(event, hint, scope)) | ||
.then(finalEvent => { | ||
// We need to check for finalEvent in case beforeSend returned null | ||
eventId = finalEvent && finalEvent.event_id; | ||
this._processing = false; | ||
}) | ||
.then(null, reason => { | ||
logger.error(reason); | ||
this._processing = false; | ||
}); | ||
promisedEvent.then(event => { | ||
eventId = this.captureEvent(event, hint, scope); | ||
}); | ||
Comment on lines
+112
to
+114
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kamilogorek No idea why we didn't do it like this in the first place. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. Whole method can be written as: const promisedEvent = // ...;
return promisedEvent.then(event => this.captureEvent(event, hint, scope); |
||
|
||
return eventId; | ||
} | ||
|
@@ -372,6 +356,14 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement | |
} | ||
} | ||
|
||
/** | ||
* Tells the backend to send this event | ||
* @param event The Sentry event to send | ||
*/ | ||
protected _sendEvent(event: Event): void { | ||
this._getBackend().sendEvent(event); | ||
} | ||
|
||
Comment on lines
+359
to
+366
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New internal function, helper for that. |
||
/** | ||
* Processes an event (either error or message) and sends it to Sentry. | ||
* | ||
|
@@ -413,7 +405,7 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement | |
const isInternalException = hint && hint.data && (hint.data as { [key: string]: any }).__sentry__ === true; | ||
// We skip beforeSend in case of transactions | ||
if (isInternalException || !beforeSend || isTransaction) { | ||
this._getBackend().sendEvent(finalEvent); | ||
this._sendEvent(finalEvent); | ||
resolve(finalEvent); | ||
return; | ||
} | ||
|
@@ -434,7 +426,7 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement | |
} | ||
|
||
// From here on we are really async | ||
this._getBackend().sendEvent(finalEvent); | ||
this._sendEvent(finalEvent); | ||
resolve(finalEvent); | ||
} | ||
}) | ||
|
@@ -467,7 +459,7 @@ export abstract class BaseClient<B extends Backend, O extends Options> implement | |
return; | ||
} | ||
// From here on we are really async | ||
this._getBackend().sendEvent(processedEvent); | ||
this._sendEvent(processedEvent); | ||
resolve(processedEvent); | ||
}) | ||
.then(null, e => { | ||
|
Uh oh!
There was an error while loading. Please reload this page.