Skip to content

Passing () => scope as captureContext does not work #10686

@eamon0989

Description

@eamon0989

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

7.101.1

Framework Version

No response

Link to Sentry event

https://s1seven.sentry.io/issues/4488829135/?environment=local&project=5880685&query=is%3Aunresolved&referrer=issue-stream&statsPeriod=7d&stream_index=0&utc=true

SDK Setup

init({
      tracesSampleRate: 1.0,
      ...params,
      autoSessionTracking: true,
      integrations: [
        browserTracingIntegration(),
        ...(params.integrations || []),
      ],

Steps to Reproduce

Prior to v7.87.0 we were able to use setExtra and see the information in the ui, we set the data like this:

    const { method, statusCode, path, stack } = errorResponse;
    const request = context.getRequest<ExtendedRequest>();
    const scope = new Scope();
    if (request.currentUser) {
      scope.setUser(request.currentUser);
    } else if (request.currentCompany) {
      scope.setUser(request.currentCompany);
    }
    scope.setExtras({
      ...(!isEmpty(request.currentScopes) && {
        [SentryExtrasProps.access_scopes]: request.currentScopes,
      }),
      [SentryExtrasProps.request_id]: request.requestId,
      [SentryExtrasProps.stack]: stack,
      [SentryExtrasProps.http_headers]: request.headers,
      [SentryExtrasProps.http_method]: request.method,
      [SentryExtrasProps.http_params]: request.params,
      [SentryExtrasProps.http_query]: request.query,
      [SentryExtrasProps.http_body]: request.body,
      [SentryExtrasProps.error_message]: errorResponse.message,
      [SentryExtrasProps.error_details]: errorResponse.details,
    });
    const mode = extractModeFromHttpRequest(request);
    scope.setTags({
      requestId: request.requestId,
      statusCode,
      method,
      path,
      protocol: 'http',
      ...(mode ? { mode } : {}),
      ...tags,
    });

We used to use setExtra but that stopped working in v7.87.0, so we switched to setExtras, but that seemed to stop working in v7.89.0.

There is no deprecated tag on either of those methods, and in the release notes for v7.101.1 it says:
feat(core): Write data from setUser, setTags, setExtras, setTag, setExtra, and setContext to isolation scope ([#10163](https://github.com/getsentry/sentry-javascript/pull/10163)) so it appears that they are still in use.

However in the docs (https://docs.sentry.io/platforms/javascript/enriching-events/context/#additional-data) it says the following:

Additional Data is deprecated in favor of structured contexts.
Sentry used to support adding unstructured "Additional Data" via setExtra.

As you can see in the screenshot, we could previously see all this information:
image

Since v7.89.0 all that information is missing.

Expected Result

I should still be able to see that extra information in the UI. There should be clear documentation and deprecated tags if setExtra and setExtras are no longer to be used.

Actual Result

All that extra information is now missing:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPackage: nodeIssues related to the Sentry Node SDK

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions