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(core): Extract scope application to util #9804

Merged
merged 4 commits into from
Dec 19, 2023
Merged

Conversation

mydea
Copy link
Member

@mydea mydea commented Dec 12, 2023

This is a try to move the application of scope data to events out of the scope class into a util function.

This changes the flow to be:

  1. The scope has a getScopeData() method that returns data that should be applied to events.
  2. The prepareEvent method uses that to actually apply scope data to the event etc.
  3. This also makes it much easier to do the experimentation in node-experimental (feat(node-experimental): Update to new Scope APIs #9799) because we only need to overwrite this, and can leave the rest of the event processing the same.

I think this makes sense but would appreciate some more eyes on this as well. For me the separation makes also more sense, as e.g. the application of event processors etc. should not really be tied to the scope at all.

This is also is a first step to then allow us to add global scopes more easily.

@mydea mydea self-assigned this Dec 12, 2023
Copy link
Contributor

github-actions bot commented Dec 12, 2023

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped) 75.3 KB (+0.22% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 66.72 KB (+0.23% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 60.3 KB (+0.24% 🔺)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 31.38 KB (+0.49% 🔺)
@sentry/browser (incl. Feedback) - Webpack (gzipped) 29.98 KB (+0.44% 🔺)
@sentry/browser - Webpack (gzipped) 21.68 KB (+0.69% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped) 72.71 KB (+0.2% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 64.43 KB (+0.24% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 30.71 KB (+0.54% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped) 22.75 KB (+0.74% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 202.56 KB (+0.2% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 92.66 KB (+0.44% 🔺)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 67.71 KB (+0.6% 🔺)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 33.55 KB (+0.47% 🔺)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 67.08 KB (+0.24% 🔺)
@sentry/react - Webpack (gzipped) 21.71 KB (+0.68% 🔺)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 83.87 KB (+0.19% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 48.54 KB (+0.32% 🔺)
@sentry-internal/feedback - Webpack (gzipped) 16.3 KB (+0.78% 🔺)

@mydea mydea force-pushed the fn/apply-scope-to-event branch 2 times, most recently from 97db3e4 to f2749a4 Compare December 18, 2023 13:46
@mydea mydea marked this pull request as ready for review December 18, 2023 13:48
@mydea mydea requested a review from Lms24 December 18, 2023 13:48
Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

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

This change feels reasonable enough to me, it's also nice to get the individual functions in applyScopeDataToEvent.ts that we have the flexibility to export and use in the future.

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Nice, I agree it feels better to have this function outside. Single responsibility principle also agrees with us 😅

packages/types/src/scope.ts Outdated Show resolved Hide resolved
Comment on lines +522 to +529
const eventProcessors: EventProcessor[] = [
...additionalEventProcessors,
// eslint-disable-next-line deprecation/deprecation
...getGlobalEventProcessors(),
...this._eventProcessors,
];

return notifyEventProcessors(eventProcessors, event, hint);
Copy link
Member

Choose a reason for hiding this comment

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

just to confirm since we deprecated this function: The same logic here is already present in places calling applyScopeDataToEvent, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, the behavior remains the same here as before!

@mydea mydea force-pushed the fn/apply-scope-to-event branch 3 times, most recently from 97ea3ec to 0a4b49f Compare December 19, 2023 12:56
@mydea mydea merged commit afb900c into develop Dec 19, 2023
95 checks passed
@mydea mydea deleted the fn/apply-scope-to-event branch December 19, 2023 13:46
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

3 participants