GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(core): Report user-set integrations and their options in SDK config by logaretm · Pull Request #26708 · getsentry/sentry-javascript

feat(core): Report user-set integrations and their options in SDK config #26708

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.

Sign up for GitHub

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

Merged
logaretm merged 4 commits into awad/define-integration-capture-options from awad/sdk-config-integration-options
Nov 23, 2026
+497 −114
Merged

feat(core): Report user-set integrations and their options in SDK config #26708

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
4 commits
Select commit Hold shift + click to select a range
cf8a7d1
feat(core): Report user-set integrations and their options in SDK config
logaretm Nov 23, 2026
373e0cc
fix(core): Harden SDK config integration reporting
logaretm Nov 23, 2026
9a9261f
fix(solid): Capture user options before adding Solid Cloudflare integ…
logaretm Nov 23, 2026
a57fadb
fix(core): Report in-place callback changes and default integration o…
logaretm Nov 23, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

3 changes: 2 additions & 1 deletion 3 packages/angular/src/sdk.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '@sentry/browser';
import type { Client, Integration } from '@sentry/core';
import {
_INTERNAL_captureOptionsSetByUser,
Comment thread

@nicohrubec nicohrubec Nov 23, 2026

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

do we want to already add this everywhere? we got all the sdk inits that matter for our experiment covered so I don't think there is a need to add these atm

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@logaretm logaretm Nov 23, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

no need but will have to do it anyways, so might as well just do it today. WDYT?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
applySdkMetadata,
consoleIntegration,
conversationIdIntegration,
Expand Down Expand Up @@ -55,7 +56,7 @@ export function getDefaultIntegrations(_options: BrowserOptions = {}): Integrati
export function init(options: BrowserOptions): Client | undefined {
const opts = {
defaultIntegrations: getDefaultIntegrations(),
...options,
..._INTERNAL_captureOptionsSetByUser(options),
};

applySdkMetadata(opts, 'angular');
Expand Down
4 changes: 2 additions & 2 deletions 4 packages/astro/src/client/sdk.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { BrowserOptions } from '@sentry/browser';
import { getDefaultIntegrations as getBrowserDefaultIntegrations, init as initBrowserSdk } from '@sentry/browser';
import type { Client, Integration } from '@sentry/core';
import { applySdkMetadata } from '@sentry/core';
import { _INTERNAL_captureOptionsSetByUser, applySdkMetadata } from '@sentry/core';
import { applyAstroTunnelOptions } from '../tunnel';
import { browserTracingIntegration } from './browserTracingIntegration';
import { createAstroRouteProvider } from './routeProvider';
Expand All @@ -20,7 +20,7 @@ export function init(options: BrowserOptions): Client | undefined {
// The middleware injects the route into the document, so route parameterization works from `init` on,
// even with tracing disabled.
routeProvider: createAstroRouteProvider(),
...options,
..._INTERNAL_captureOptionsSetByUser(options),
};

applySdkMetadata(opts, 'astro', ['astro', 'browser']);
Expand Down
4 changes: 2 additions & 2 deletions 4 packages/astro/src/server/sdk.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SENTRY_ORIGIN } from '@sentry/conventions/attributes';
import { HTTP_SERVER } from '@sentry/conventions/op';
import { applySdkMetadata, debug, getClient } from '@sentry/core';
import { _INTERNAL_captureOptionsSetByUser, applySdkMetadata, debug, getClient } from '@sentry/core';
import type { NodeClient, NodeOptions } from '@sentry/node';
import { init as initNodeSdk } from '@sentry/node';
import { isDeno } from '@sentry/server-utils';
Expand Down Expand Up @@ -30,7 +30,7 @@ export function init(options: NodeOptions): NodeClient | undefined {
}

const opts = {
...options,
..._INTERNAL_captureOptionsSetByUser(options),
};

applySdkMetadata(opts, 'astro', ['astro', 'node']);
Expand Down
1 change: 1 addition & 0 deletions 1 packages/astro/test/client/sdk.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('Sentry client SDK', () => {
expect(browserInit).toHaveBeenCalledWith(
expect.objectContaining({
_metadata: {
optionsSetByUser: [],
sdk: {
name: 'sentry.javascript.astro',
version: SDK_VERSION,
Expand Down
1 change: 1 addition & 0 deletions 1 packages/astro/test/server/sdk.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('Sentry server SDK', () => {
expect(nodeInit).toHaveBeenCalledWith(
expect.objectContaining({
_metadata: {
optionsSetByUser: [],
sdk: {
name: 'sentry.javascript.astro',
version: SDK_VERSION,
Expand Down
4 changes: 2 additions & 2 deletions 4 packages/aws-serverless/src/init.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HTTP_REQUEST_METHOD, URL_PATH } from '@sentry/conventions/attributes';
import { FUNCTION_AWS } from '@sentry/conventions/op';
import type { Integration, Options } from '@sentry/core';
import { applySdkMetadata, debug, envToBool, getSDKSource } from '@sentry/core';
import { _INTERNAL_captureOptionsSetByUser, applySdkMetadata, debug, envToBool, getSDKSource } from '@sentry/core';
import type { NodeClient, NodeOptions } from '@sentry/node';
import { getDefaultIntegrationsWithoutPerformance, initWithoutDefaultIntegrations } from '@sentry/node';
import { awsIntegration } from '@sentry/server-utils';
Expand Down Expand Up @@ -91,7 +91,7 @@ export function init(options: AwsServerlessOptions = {}): NodeClient | undefined
const opts = {
defaultIntegrations: getDefaultIntegrations(options),
useLayerExtension,
...options,
..._INTERNAL_captureOptionsSetByUser(options),
ignoreSpans: getIgnoreSpans(options),
};

Expand Down
1 change: 1 addition & 0 deletions 1 packages/aws-serverless/test/sdk.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ describe('AWSLambda', () => {
expect(mockInit).toBeCalledWith(
expect.objectContaining({
_metadata: {
optionsSetByUser: [],
sdk: {
name: 'sentry.javascript.aws-serverless',
packages: [
Expand Down
3 changes: 2 additions & 1 deletion 3 packages/bun/src/sdk.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as os from 'node:os';
import type { Integration, Options } from '@sentry/core';
import {
_INTERNAL_captureOptionsSetByUser,
applySdkMetadata,
conversationIdIntegration,
dedupeIntegration,
Expand Down Expand Up @@ -150,7 +151,7 @@ function _init(
applySdkMetadata(userOptions, 'bun');

const options = {
...userOptions,
..._INTERNAL_captureOptionsSetByUser(userOptions),
platform: 'javascript',
runtime: userOptions.runtime || { name: 'bun', version: typeof Bun !== 'undefined' ? Bun.version : 'unknown' },
serverName: userOptions.serverName || global.process.env.SENTRY_NAME || os.hostname(),
Expand Down
8 changes: 5 additions & 3 deletions 8 packages/cloudflare/src/options.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isObjectLike, envToBool } from '@sentry/core';
import { _INTERNAL_captureOptionsSetByUser, isObjectLike, envToBool } from '@sentry/core';
import type { CloudflareOptions } from './client';

/**
Expand Down Expand Up @@ -33,12 +33,14 @@ function getEnvVar<T extends Record<string, unknown>>(env: unknown, varName: key
* 2. SENTRY_RELEASE environment variable
* 3. CF_VERSION_METADATA.id binding (if configured in the wrangler config)
*
* @param userOptions - The options passed in from the user.
* @param options - The options passed in from the user.
* @param env - The environment variables.
*
* @returns The final options.
*/
export function getFinalOptions(userOptions: CloudflareOptions = {}, env: unknown): CloudflareOptions {
export function getFinalOptions(options: CloudflareOptions = {}, env: unknown): CloudflareOptions {
const userOptions = _INTERNAL_captureOptionsSetByUser(options);

if (!isObjectLike(env)) {
return userOptions;
}
Expand Down
5 changes: 4 additions & 1 deletion 5 packages/cloudflare/src/sdk.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { _INTERNAL_captureOptionsSetByUser } from '@sentry/core';
import { initBaseSdk } from './baseSdk';
import type { CloudflareClient, CloudflareOptions } from './client';
import { setupOpenTelemetryTracer } from './opentelemetry/tracer';
Expand All @@ -11,7 +12,9 @@ export { getDefaultIntegrations } from './baseSdk';
/**
* Initializes the cloudflare SDK.
*/
export function init(options: CloudflareOptions): CloudflareClient | undefined {
export function init(userOptions: CloudflareOptions): CloudflareClient | undefined {
const options = _INTERNAL_captureOptionsSetByUser(userOptions);

// Like most Node-based SDKs, Cloudflare defaults to running without a Sentry OpenTelemetry tracer
// provider. Scope isolation is handled by the entrypoint wrappers' AsyncLocalStorage strategy.
options.enableOpenTelemetrySetup ??= false;
Expand Down
3 changes: 2 additions & 1 deletion 3 packages/cloudflare/src/workflows.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { FUNCTION } from '@sentry/conventions/op';
import type { PropagationContext, Scope } from '@sentry/core';
import {
_INTERNAL_captureOptionsSetByUser,
captureException,
checkOrSetAlreadyCaught,
flush,
Expand Down Expand Up @@ -279,7 +280,7 @@ export function instrumentWorkflowWithSentry<
construct(target: C, args: [ctx: ExecutionContext, env: any], newTarget) {
const [ctx, env] = args;
const context = instrumentContext(ctx);
const options = optionsCallback(env);
const options = _INTERNAL_captureOptionsSetByUser(optionsCallback(env) || {});
args[0] = context;
args[1] = instrumentEnv(env as Record<string, unknown>, options) as E;
const instance = Reflect.construct(target, args, newTarget) as T;
Expand Down
2 changes: 1 addition & 1 deletion 2 packages/cloudflare/test/options.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('getFinalOptions', () => {

const result = getFinalOptions(userOptions, env);

expect(result).toEqual(userOptions);
expect(result).toEqual({ ...userOptions, _metadata: { optionsSetByUser: ['dsn', 'release'] } });
});

it('returns user options when env is null', () => {
Expand Down
60 changes: 54 additions & 6 deletions 60 packages/core/src/integrations/reportSdkConfig.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,16 @@ function serialize(value: unknown, ancestors = new Set<object>()): unknown {
return result;
}

// Integrations are reported at the top level; serverName would split configurations by host.
// Integrations hold the SDK defaults by the time the client has them; serverName would split configurations by host.
const EXCLUDED_OPTIONS = new Set(['dist', 'dsn', 'integrations', 'release', 'serverName']);

function buildConfigAttributes(client: Client): Record<string, string> {
const { sdk, optionsSetByUser = [] } = client.getSdkMetadata() || {};
const {
sdk,
optionsSetByUser = [],
integrationsSetByUser,
removedDefaultIntegrations,
} = client.getSdkMetadata() || {};
const clientOptions = client.getOptions();
const { environment } = clientOptions;
const runtime = 'runtime' in clientOptions ? clientOptions.runtime : undefined;
Expand All @@ -108,10 +113,19 @@ function buildConfigAttributes(client: Client): Record<string, string> {
Object.entries(clientOptions).filter(([key]) => optionsSetByUser.includes(key) && !EXCLUDED_OPTIONS.has(key)),
);

if (integrationsSetByUser) {
options.integrations = integrationsSetByUser.map(name => {
const integration: (Integration & { isDefaultInstance?: true }) | undefined = client.getIntegrationByName(name);
// A default instance kept by an `integrations` function got its options from the SDK, not the user.
return describeIntegration(name, integration?.isDefaultInstance ? undefined : integration?._options);
});
}

if (Array.isArray(options.defaultIntegrations)) {
options.defaultIntegrations = options.defaultIntegrations.map((integration: Integration) => ({
name: integration.name,
}));
// `getIntegrationsToSetup` flags these as default instances, but the user passed them.
options.defaultIntegrations = options.defaultIntegrations.map((integration: Integration) =>
describeIntegration(integration.name, integration._options),
);
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

}

// The hash covers the whole payload, so a payload cached by its hash is never stale.
Expand All @@ -120,7 +134,8 @@ function buildConfigAttributes(client: Client): Record<string, string> {
sdk: serialize(sdk),
runtime: serialize(runtime),
environment,
integrations: client.getIntegrationNames().map(name => ({ name })),
// Not an init() option, so it stays out of `options`.
...(removedDefaultIntegrations && { removed_default_integrations: removedDefaultIntegrations }),
Comment thread

@cursor cursor Bot Nov 23, 2026

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Feat PR lacks integration or E2E test

Low Severity

This feat PR changes the SDK config payload: integrations moves into options and removed_default_integrations is added. Only unit tests cover it, with no integration or E2E test checking the payload a real SDK init sends. I flagged this because the review rules ask for one on feat PRs.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit a57fadb. Configure here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
options: serialize(options),
});

Expand All @@ -129,3 +144,36 @@ function buildConfigAttributes(client: Client): Record<string, string> {
'sentry.sdk_config.payload': payload,
};
}

function describeIntegration(name: string, options: unknown): { name: string; options?: unknown } {
if (options === undefined) {
return { name };
}

if (!isPlainObject(options)) {
return { name, options: describeOptionValue(options) };
}

const keys = Object.keys(options);
// `fooIntegration()` and `fooIntegration({})` both mean no options were passed.
if (!keys.length) {
return { name };
}

const described: Record<string, unknown> = {};
for (const key of keys) {
described[key] = describeOptionValue(options[key]);
}

return { name, options: described };
}
Comment thread

@cursor cursor Bot Nov 23, 2026

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Wrapped integrations report SDK-injected options as user's

Medium Severity

describeIntegration reports integration._options, but framework wrappers often spread an inner integration, for example SvelteKit's browserTracingIntegration spreading the browser one with instrumentNavigation: false, instrumentPageLoad: false. The inner _options gets copied onto the result, and defineIntegration only sets _options when it is still undefined, so the outer wrapper keeps the inner value. As a result, options injected by the SDK show up in the payload as if the user set them.

Additional Locations (1)
  • packages/core/src/utils/sdkMetadata.ts#L42-L51
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c57b7ba. Configure here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

// Options can hold live objects such as a router, a store or an SDK client, which carry URLs, app state or keys.
// Arrays are kept, since lists like `levels` or `tracePropagationTargets` are configuration.
function describeOptionValue(value: unknown): unknown {
return Array.isArray(value) ? value.map(redactObject) : redactObject(value);
}

function redactObject(value: unknown): unknown {
return value === null || typeof value !== 'object' || value instanceof RegExp ? value : '[Object]';
}
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

4 changes: 4 additions & 0 deletions 4 packages/core/src/types/sdkmetadata.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ export interface SdkMetadata {
sdk?: SdkInfo;
/** Option keys explicitly supplied to the outermost init call. */
optionsSetByUser?: string[];
/** Names of the integrations the user added in the outermost init call. */
integrationsSetByUser?: string[];
/** Sorted names of the default integrations an `integrations` function dropped. */
removedDefaultIntegrations?: string[];
}
62 changes: 55 additions & 7 deletions 62 packages/core/src/utils/sdkMetadata.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -1,23 +1,71 @@
import type { Integration } from '../types/integration';
import type { CoreOptions } from '../types/options';
import type { SdkMetadata } from '../types/sdkmetadata';
import { uniq } from './array';
import { SDK_VERSION } from '../utils/version';

/**
* Preserve user-provided option keys before SDK wrappers add defaults.
* @internal
*/
export function captureOptionsSetByUser<T extends Pick<CoreOptions, '_metadata'>>(options: T): T {
export function captureOptionsSetByUser<T extends Pick<CoreOptions, '_metadata' | 'integrations'>>(options: T): T {
if (options._metadata?.optionsSetByUser) {
return options;
}

const { integrations } = options;
const metadata: SdkMetadata = {
...options._metadata,
optionsSetByUser: Object.keys(options)
.filter(key => key !== '_metadata')
.sort(),
};

// SDKs merge their defaults into `integrations` before the client gets it.
if (Array.isArray(integrations)) {
metadata.integrationsSetByUser = uniq(integrations.map(integration => integration.name));
}

return {
...options,
_metadata: {
...options._metadata,
optionsSetByUser: Object.keys(options)
.filter(key => key !== '_metadata')
.sort(),
},
_metadata: metadata,
// Report the function as a change to the defaults, the same way the array form reads.
...(typeof integrations === 'function' && {
integrations: (defaults: Integration[]) => {
// Copied before the function runs, since it can change `defaults` in place. SDK wrappers also pass their own
// integrations in with the defaults, without flagging them as default instances.
const passedIn = new Set(defaults);
const result = integrations(defaults);
// `getIntegrationsToSetup` also accepts a single integration.
const resolved: Integration[] = Array.isArray(result) ? result : [result];

const resolvedNames = new Set<string>();
const setByUser = new Set<string>();
for (const integration of resolved) {
resolvedNames.add(integration.name);
if (
!passedIn.has(integration) &&
!(integration as Integration & { isDefaultInstance?: true }).isDefaultInstance
) {
setByUser.add(integration.name);
}
}

const removed = new Set<string>();
for (const integration of passedIn) {
if (!resolvedNames.has(integration.name)) {
removed.add(integration.name);
}
}

metadata.integrationsSetByUser = Array.from(setByUser);
if (removed.size) {
metadata.removedDefaultIntegrations = Array.from(removed).sort();
}

return resolved;
},
Comment thread
logaretm marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

}),
};
}

Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.