Skip to content

In shared environment, additional scope (tag/context) not set #13849

@vernak2539

Description

@vernak2539

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/browser

SDK Version

8.32.0

Framework Version

No response

Link to Sentry event

https://vernacchia.sentry.io/issues/5939643523/?environment=production&project=4504945222483968&query=release:0.10.1

Reproduction Example/SDK Setup

// initialisation: https://github.com/vernak2539/chrome-extension-google-doc-default-zoom/blob/main/src/utils/sentry/base.ts
// usage: https://github.com/vernak2539/chrome-extension-google-doc-default-zoom/blob/main/src/contents/index.ts
const sentryClient = new BrowserClient({
  dsn: process.env.PLASMO_PUBLIC_SENTRY_DSN,
  tracesSampleRate: 1.0,
  environment: process.env.NODE_ENV || "development",
  release: packageJson.version,
    stackParser: defaultStackParser,
    integrations: getDefaultIntegrations({}).filter((defaultIntegration) => {
      return !["BrowserApiErrors", "Breadcrumbs", "GlobalHandlers"].includes(
        defaultIntegration.name
      );
    }),
    transport: makeFetchTransport
  });

  const sentryScope = new Scope();
  sentryScope.setTags({
    source,
    locale: chrome.i18n.getUILanguage(),
    extension: packageJson.name
  });
  sentryScope.setClient(sentryClient);

  sentryClient.init(); // initializing has to be done after setting the client on the scope

  sentryScope.setContext('extra', { extra: 'info' })

try {
  main()
} catch(err) {
  sentryClient.captureException(err);
}

Steps to Reproduce

  1. Setup client based on https://docs.sentry.io/platforms/javascript/best-practices/shared-environments/
  2. Set extra context/tags on scope
  3. Use client in try/catch

Expected Result

I would expect the tags and context set on the sentry scope to be recorded in sentry on issues.

Actual Result

The tags and context are not set on the sentry issue when an error does occur (the error is captured)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPackage: browserIssues related to the Sentry Browser SDK

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions