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

ref(utils): Remove getGlobalObject() usage from @sentry/utils #5831

Merged

Conversation

timfish
Copy link
Collaborator

@timfish timfish commented Sep 27, 2022

#5821 ended up being a rather huge PR so this is the first of many PRs that makes these changes per package. For now we keep the getGlobalObject() implementation until all the packages are migrated.

As discussed here, this PR:

  • Replaces getGlobalObject with a const GLOBAL_OBJ which retains the runtime detection from feat(utils): Modern implementation of getGlobalObject #5809
    • Improvement over before since we only evaluate the detection code once
    • No need to lazily evaluate since GLOBAL_OBJ is always accessed
  • Also includes a WINDOW const which returns GLOBAL_OBJ but with typeof GLOBAL_OBJ & Window type.
    • This will eventually move to @sentry/browser to ensure stricter typing around the global object
    • Maybe this should be called WINDOW_GLOBAL to remove any ambiguity?

extensions?: {
/** Extension methods for the hub, which are bound to the current Hub instance */
// eslint-disable-next-line @typescript-eslint/ban-types
[key: string]: Function;
Copy link
Member

Choose a reason for hiding this comment

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

We should probably type this stricter, but we can do that after we are done with all of the changes.

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.

2 participants