Skip to content
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

feat(feedback): Add level and remove breadcrumbs from feedback event #9533

Merged
merged 7 commits into from
Nov 16, 2023

Conversation

billyvg
Copy link
Member

@billyvg billyvg commented Nov 10, 2023

Also adds a browser integration test as well

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Also adds a browser integration test
Copy link
Contributor

github-actions bot commented Nov 10, 2023

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 65.43 KB (+0.03% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 55.64 KB (+0.03% 🔺)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 30.98 KB (0%)
@sentry/browser - Webpack (gzipped) 21.3 KB (0%)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 61.97 KB (+0.03% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 29.1 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped) 21.24 KB (0%)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 195.47 KB (+0.03% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 88.32 KB (0%)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 63.3 KB (0%)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 31.81 KB (0%)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 65.79 KB (+0.03% 🔺)
@sentry/react - Webpack (gzipped) 21.34 KB (0%)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 82.51 KB (+0.02% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 48.13 KB (0%)
@sentry-internal/feedback - Webpack (gzipped) 16.08 KB (+0.48% 🔺)

@billyvg billyvg marked this pull request as ready for review November 10, 2023 19:54
@@ -39,5 +38,8 @@ export async function prepareFeedbackEvent({
// we need to do this manually.
preparedEvent.platform = preparedEvent.platform || 'javascript';

// No use for breadcrumbs in feedb
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// No use for breadcrumbs in feedb
// No use for breadcrumbs in feedback

Comment on lines 38 to 40
if (source === FEEDBACK_WIDGET_SOURCE) {
scope.setLevel('info');
}
Copy link
Member

Choose a reason for hiding this comment

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

This is not good because we mutate the scope, so that will also affect other events that have the same scope (unless I am missing something and we are always forking a scope for this scenario?). So we should do one of these:

  1. Fork a scope here, and mutate that one:
withScope(scope => 
  scope.setLevel(...);
  prepareFeedbackEvent({ scope, ... })
})
  1. put the level directly on the feedback event somehow

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! I updated to use pushScope and popScope -- I don't love the withScope API.... I wish withScope returned the new scope.

@@ -34,58 +34,28 @@ export async function sendFeedbackRequest({
type: 'feedback',
};

// Create a new scope
const scope = hub.pushScope();
Copy link
Member

Choose a reason for hiding this comment

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

I'd recommend to use withScope instead (we'll probably get rid of pushScope in v8):

withScope((scope) => {
  scope.clearBreadcrumbs(); 

    if ([FEEDBACK_API_SOURCE, FEEDBACK_WIDGET_SOURCE].includes(String(source))) {
      scope.setLevel('info');
    }

    const feedbackEvent = ...
});

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated using withScope, had to create a promise because I need the return value inside of withScope callback

@billyvg billyvg requested a review from mydea November 15, 2023 17:23
return new Promise((resolve, reject) => {
hub.withScope(async scope => {
// No use for breadcrumbs in feedback
scope.clearBreadcrumbs();
Copy link
Member

Choose a reason for hiding this comment

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

just a note, nothing to do here, but this may change a bit in v8. We're thinking to rework how/where we keep breadcrumbs, in the browser we'll probably keep them globally. At this point we'll have to change this logic here. Feel free to leave this for later, but if there is an easy way to make this forwards-compatible, we may as well do it already now 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Good to know, would it be better to delete breadcrumbs from the event rather than the scope?

@billyvg billyvg enabled auto-merge (squash) November 16, 2023 19:05
@billyvg billyvg merged commit 13aaf3c into develop Nov 16, 2023
@billyvg billyvg deleted the feat-feedback-add-level-to-fb-event branch November 16, 2023 19:06
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.

None yet

2 participants