@@ -421,20 +421,6 @@ export class Hub implements HubInterface {
421421 this . getIsolationScope ( ) . setContext ( name , context ) ;
422422 }
423423
424- /**
425- * @inheritDoc
426- */
427- public run ( callback : ( hub : Hub ) => void ) : void {
428- // eslint-disable-next-line deprecation/deprecation
429- const oldHub = makeMain ( this ) ;
430- try {
431- callback ( this ) ;
432- } finally {
433- // eslint-disable-next-line deprecation/deprecation
434- makeMain ( oldHub ) ;
435- }
436- }
437-
438424 /**
439425 * @inheritDoc
440426 * @deprecated Use `Sentry.getClient().getIntegrationByName()` instead.
@@ -618,23 +604,8 @@ Sentry.init({...});
618604 * @deprecated Use `setCurrentClient()` instead.
619605 */
620606export function makeMain ( hub : HubInterface ) : HubInterface {
621- const registry = getMainCarrier ( ) ;
622- const oldHub = getHubFromCarrier ( registry ) ;
623- setHubOnCarrier ( registry , hub ) ;
624- return oldHub ;
625- }
626-
627- /**
628- * This will set passed {@link Hub} on the passed object's __SENTRY__.hub attribute
629- * @param carrier object
630- * @param hub Hub
631- * @returns A boolean indicating success or failure
632- */
633- export function setHubOnCarrier ( carrier : Carrier , hub : HubInterface ) : boolean {
634- if ( ! carrier ) return false ;
635- const sentry = getSentryCarrier ( carrier ) ;
636- sentry . hub = hub ;
637- return true ;
607+ // noop!
608+ return hub ;
638609}
639610
640611/**
@@ -681,69 +652,18 @@ export function getDefaultIsolationScope(): Scope {
681652 */
682653export function getGlobalHub ( ) : HubInterface {
683654 const registry = getMainCarrier ( ) ;
655+ const sentry = getSentryCarrier ( registry ) as { hub ?: HubInterface } ;
684656
685657 // If there's no hub, or its an old API, assign a new one
686-
687- if (
688- ! hasHubOnCarrier ( registry ) ||
689- // eslint-disable-next-line deprecation/deprecation
690- getHubFromCarrier ( registry ) . isOlderThan ( API_VERSION )
691- ) {
692- // eslint-disable-next-line deprecation/deprecation
693- setHubOnCarrier ( registry , new Hub ( undefined , getDefaultCurrentScope ( ) , getDefaultIsolationScope ( ) ) ) ;
694- }
695-
696- // Return hub that lives on a global object
697- return getHubFromCarrier ( registry ) ;
698- }
699-
700- /**
701- * This will tell whether a carrier has a hub on it or not
702- * @param carrier object
703- */
704- function hasHubOnCarrier ( carrier : Carrier ) : boolean {
705- return ! ! getSentryCarrier ( carrier ) . hub ;
706- }
707-
708- /**
709- * This will create a new {@link Hub} and add to the passed object on
710- * __SENTRY__.hub.
711- * @param carrier object
712- * @hidden
713- */
714- export function getHubFromCarrier ( carrier : Carrier ) : HubInterface {
715- const sentry = getSentryCarrier ( carrier ) ;
716- if ( ! sentry . hub ) {
717- // eslint-disable-next-line deprecation/deprecation
718- sentry . hub = new Hub ( ) ;
658+ if ( sentry . hub ) {
659+ return sentry . hub ;
719660 }
720661
662+ // eslint-disable-next-line deprecation/deprecation
663+ sentry . hub = new Hub ( undefined , getDefaultCurrentScope ( ) , getDefaultIsolationScope ( ) ) ;
721664 return sentry . hub ;
722665}
723666
724- /**
725- * @private Private API with no semver guarantees!
726- *
727- * If the carrier does not contain a hub, a new hub is created with the global hub client and scope.
728- */
729- export function ensureHubOnCarrier ( carrier : Carrier , parent : HubInterface = getGlobalHub ( ) ) : void {
730- // If there's no hub on current domain, or it's an old API, assign a new one
731- if (
732- ! hasHubOnCarrier ( carrier ) ||
733- // eslint-disable-next-line deprecation/deprecation
734- getHubFromCarrier ( carrier ) . isOlderThan ( API_VERSION )
735- ) {
736- // eslint-disable-next-line deprecation/deprecation
737- const client = parent . getClient ( ) ;
738- // eslint-disable-next-line deprecation/deprecation
739- const scope = parent . getScope ( ) ;
740- // eslint-disable-next-line deprecation/deprecation
741- const isolationScope = parent . getIsolationScope ( ) ;
742- // eslint-disable-next-line deprecation/deprecation
743- setHubOnCarrier ( carrier , new Hub ( client , scope . clone ( ) as Scope , isolationScope . clone ( ) as Scope ) ) ;
744- }
745- }
746-
747667/**
748668 * Get the current async context strategy.
749669 * If none has been setup, the default will be used.
0 commit comments