File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -636,7 +636,7 @@ export function getHubFromCarrier(carrier: Carrier): Hub {
636
636
*/
637
637
export function setHubOnCarrier ( carrier : Carrier , hub : Hub ) : boolean {
638
638
if ( ! carrier ) return false ;
639
- const sentry = ( carrier . __SENTRY__ = carrier . __SENTRY__ || { } ) ;
640
- sentry . hub = hub ;
639
+ const __SENTRY__ = ( carrier . __SENTRY__ = carrier . __SENTRY__ || { } ) ;
640
+ __SENTRY__ . hub = hub ;
641
641
return true ;
642
642
}
Original file line number Diff line number Diff line change @@ -46,14 +46,19 @@ export function getGlobalObject<T>(): T & SentryGlobal {
46
46
}
47
47
48
48
/**
49
- * Returns a global singleton contained on the global `__SENTRY__` object.
49
+ * Returns a global singleton contained in the global `__SENTRY__` object.
50
+ *
51
+ * If the singleton doesn't already exist in `__SENTRY__`, it will be created using the given factory
52
+ * function and added to the `__SENTRY__` object.
50
53
*
51
54
* @param name name of the global singleton on __SENTRY__
52
- * @param creator creation function
55
+ * @param creator creator Factory function to create the singleton if it doesn't already exist on `__SENTRY__`
56
+ * @param obj (Optional) The global object on which to look for `__SENTRY__`, if not `getGlobalObject`'s return value
53
57
* @returns the singleton
54
58
*/
55
59
export function getGlobalSingleton < T > ( name : keyof SentryGlobal [ '__SENTRY__' ] , creator : ( ) => T , obj ?: unknown ) : T {
56
60
const global = ( obj || getGlobalObject ( ) ) as SentryGlobal ;
57
- const sentry = ( global . __SENTRY__ = global . __SENTRY__ || { } ) ;
58
- return sentry [ name ] || ( sentry [ name ] = creator ( ) ) ;
61
+ const __SENTRY__ = ( global . __SENTRY__ = global . __SENTRY__ || { } ) ;
62
+ const singleton = __SENTRY__ [ name ] || ( __SENTRY__ [ name ] = creator ( ) ) ;
63
+ return singleton ;
59
64
}
You can’t perform that action at this time.
0 commit comments