1+ import type { Client , DsnLike , Integration , Options } from '@sentry/core' ;
12import {
23 consoleSandbox ,
34 dedupeIntegration ,
4- dropUndefinedKeys ,
55 functionToStringIntegration ,
66 getCurrentScope ,
77 getIntegrationsToSetup ,
@@ -13,7 +13,6 @@ import {
1313 stackParserFromStackParserOptions ,
1414 supportsFetch ,
1515} from '@sentry/core' ;
16- import type { Client , DsnLike , Integration , Options } from '@sentry/core' ;
1716import type { BrowserClientOptions , BrowserOptions } from './client' ;
1817import { BrowserClient } from './client' ;
1918import { DEBUG_BUILD } from './debug-build' ;
@@ -67,10 +66,27 @@ function applyDefaultOptions(optionsArg: BrowserOptions = {}): BrowserOptions {
6766
6867 return {
6968 ...defaultOptions ,
70- ...dropUndefinedKeys ( optionsArg ) ,
69+ ...dropUndefinedKeysFlat ( optionsArg ) ,
7170 } ;
7271}
7372
73+ /**
74+ * In contrast to the regular `dropUndefinedKeys` method,
75+ * this one does not deep-drop keys, but only on the top level.
76+ */
77+ function dropUndefinedKeysFlat < T extends object > ( obj : T ) : Partial < T > {
78+ const mutatetedObj : Partial < T > = { } ;
79+
80+ for ( const k of Object . getOwnPropertyNames ( obj ) ) {
81+ const key = k as keyof T ;
82+ if ( obj [ key ] !== undefined ) {
83+ mutatetedObj [ key ] = obj [ key ] ;
84+ }
85+ }
86+
87+ return mutatetedObj ;
88+ }
89+
7490type ExtensionProperties = {
7591 chrome ?: Runtime ;
7692 browser ?: Runtime ;
0 commit comments