Skip to content

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

Merged
merged 2 commits into from
May 27, 2020
Merged

ref: Add tests for breadcrumbs #2620

merged 2 commits into from
May 27, 2020

Conversation

HazAT
Copy link
Member

@HazAT HazAT commented May 27, 2020

This adds tests for adding Sentry internal breadcrumbs.

This is a follow up from #2615.

@HazAT HazAT requested a review from kamilogorek as a code owner May 27, 2020 11:43
@HazAT HazAT self-assigned this May 27, 2020
Comment on lines +359 to +366
/**
* Tells the backend to send this event
* @param event The Sentry event to send
*/
protected _sendEvent(event: Event): void {
this._getBackend().sendEvent(event);
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New internal function, helper for that.

Comment on lines +112 to +114
promisedEvent.then(event => {
eventId = this.captureEvent(event, hint, scope);
});
Copy link
Member Author

@HazAT HazAT May 27, 2020

Choose a reason for hiding this comment

The 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.
Now everything goes through captureEvent as it's supposed to be.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

Copy link
Contributor

Choose a reason for hiding this comment

The 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);

@getsentry-bot
Copy link
Contributor

getsentry-bot commented May 27, 2020

Warnings
⚠️ Please add a changelog entry for your changes.
Messages
📖

@sentry/browser bundle gzip'ed minified size: (ES5: 16.7656 kB) (ES6: 15.8037 kB)

📖 ✅ TSLint passed

Generated by 🚫 dangerJS against f629f3f

logger.error(reason);
this._processing = false;
.then(event => {
eventId = this.captureEvent(event, hint, scope);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like eventId is always overwritten? Even if hint.event_id is provided? If so, we can:

return this._getBackend()
      .eventFromException(exception, hint)
      .then(event => this.captureEvent(event, hint, scope));

Also this_processing = true; is already called inside captureEvent so we can most likely remove it from here? Same goes for eventId extraction, as it's done in captureEvent too.

Copy link
Member Author

@HazAT HazAT May 27, 2020

Choose a reason for hiding this comment

The 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.
_isProcessing should also be called before first thing since stuff in captureX can be async

@HazAT HazAT merged commit 5e0bc0a into master May 27, 2020
@HazAT HazAT deleted the hazat/breadcrumbs-test branch May 27, 2020 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants