1
+ import type { Client , DsnLike , Integration , Options } from '@sentry/core' ;
1
2
import {
2
3
consoleSandbox ,
3
4
dedupeIntegration ,
4
- dropUndefinedKeys ,
5
5
functionToStringIntegration ,
6
6
getCurrentScope ,
7
7
getIntegrationsToSetup ,
@@ -13,7 +13,6 @@ import {
13
13
stackParserFromStackParserOptions ,
14
14
supportsFetch ,
15
15
} from '@sentry/core' ;
16
- import type { Client , DsnLike , Integration , Options } from '@sentry/core' ;
17
16
import type { BrowserClientOptions , BrowserOptions } from './client' ;
18
17
import { BrowserClient } from './client' ;
19
18
import { DEBUG_BUILD } from './debug-build' ;
@@ -67,10 +66,27 @@ function applyDefaultOptions(optionsArg: BrowserOptions = {}): BrowserOptions {
67
66
68
67
return {
69
68
...defaultOptions ,
70
- ...dropUndefinedKeys ( optionsArg ) ,
69
+ ...dropUndefinedKeysFlat ( optionsArg ) ,
71
70
} ;
72
71
}
73
72
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
+
74
90
type ExtensionProperties = {
75
91
chrome ?: Runtime ;
76
92
browser ?: Runtime ;
0 commit comments