Skip to content
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.

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

ref(hub): Simplify getting hub from active domain #3227

Merged
merged 3 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/hub/src/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,10 +473,13 @@ export function getCurrentHub(): Hub {

/**
* Returns the active domain, if one exists
*
* @deprecated No longer used; remove in v7
* @returns The domain, or undefined if there is no active domain
*/
// eslint-disable-next-line deprecation/deprecation
export function getActiveDomain(): DomainAsCarrier | undefined {
logger.warn('Function `getActiveDomain` is deprecated and will be removed in a future version.');

const sentry = getMainCarrier().__SENTRY__;

return sentry && sentry.extensions && sentry.extensions.domain && sentry.extensions.domain.active;
Expand All @@ -488,7 +491,7 @@ export function getActiveDomain(): DomainAsCarrier | undefined {
*/
function getHubFromActiveDomain(registry: Carrier): Hub {
try {
const activeDomain = getActiveDomain();
const activeDomain = getMainCarrier().__SENTRY__?.extensions?.domain?.active;

// If there's no active domain, just return global hub
if (!activeDomain) {
Expand Down
2 changes: 2 additions & 0 deletions packages/hub/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// eslint-disable-next-line deprecation/deprecation
export { Carrier, DomainAsCarrier, Layer } from './interfaces';
export { addGlobalEventProcessor, Scope } from './scope';
export { Session } from './session';
export {
// eslint-disable-next-line deprecation/deprecation
getActiveDomain,
getCurrentHub,
getHubFromCarrier,
Expand Down
4 changes: 4 additions & 0 deletions packages/hub/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export interface Carrier {
};
}

/**
* @hidden
* @deprecated Can be removed once `Hub.getActiveDomain` is removed.
*/
export interface DomainAsCarrier extends Carrier {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
members: { [key: string]: any }[];
Expand Down
4 changes: 2 additions & 2 deletions packages/types/src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ export interface SamplingContext extends CustomSamplingContext {
parentSampled?: boolean;

/**
* Object representing the URL of the current page or worker script. Passed by default in a browser or service worker
* context.
* Object representing the URL of the current page or worker script. Passed by default when using the `BrowserTracing`
* integration.
*/
location?: WorkerLocation;

Expand Down