Skip to content

HttpContext integration not capturing user-agent when using direct client. #13536

@rodolfoBee

Description

@rodolfoBee

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.27.0

Framework Version

No response

Link to Sentry event

No response

Reproduction Example/SDK Setup

No response

Steps to Reproduce

  1. Configure a direct client:
const integrations = getDefaultIntegrations({}).filter(defaultIntegration => {
  return !['BrowserApiErrors', 'Breadcrumbs', 'GlobalHandlers'].includes(
    defaultIntegration.name
  );
});

const client = new BrowserClient({
  dsn: '...',
  transport: makeFetchTransport,
  stackParser: defaultStackParser,
  integrations: [integrations],
});

const scope = new Scope();
scope.setClient(client);
client.init(); // initializing has to be done after setting the client on the scope

scope.captureException(new Error('client init'));
  1. Initialise the SDK normally in another project:
Sentry.init({
    dsn:"...",
});

Sentry.captureException(new Error("normal init"))
  1. Send a test event on each case

Expected Result

Both events have the user-agent associated with it allowing the Sentry server to identify the browser and OS.

Actual Result

Only the event from the normal init contains the user-agent. I can see in the manual client that the HttpContext integration responsible for adding the user agent is enabled in the client.

Metadata

Metadata

Assignees

Labels

BugPackage: browserIssues related to the Sentry Browser SDK

Projects

Status

Waiting for: Community

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions