Skip to content

Commit 4bb4b62

Browse files
authored
ref(v8): Remove pushScope, popScope, isOlderThan, shouldSendDefaultPii from hub (#11404)
These are the things that will be fully removed in v8 as they do not work anymore at all. The other stuff will remain shimmed for the v8 cycle. I think it is OK to remove `isOlderThan` and `shouldSendDefaultPii` even though they can technically be shimmed as they are not really "main" APIs - but happy to leave this in if we think they are important...?
1 parent 2981b85 commit 4bb4b62

File tree

3 files changed

+32
-130
lines changed

3 files changed

+32
-130
lines changed

packages/core/src/hub.ts

Lines changed: 31 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,6 @@ export class Hub implements HubInterface {
142142
this._isolationScope = assignedIsolationScope;
143143
}
144144

145-
/**
146-
* Checks if this hub's version is older than the given version.
147-
*
148-
* @param version A version number to compare to.
149-
* @return True if the given version is newer; otherwise false.
150-
*
151-
* @deprecated This will be removed in v8.
152-
*/
153-
public isOlderThan(version: number): boolean {
154-
return this._version < version;
155-
}
156-
157145
/**
158146
* This binds the given client to the current scope.
159147
* @param client An SDK client (client) instance.
@@ -170,72 +158,37 @@ export class Hub implements HubInterface {
170158
}
171159
}
172160

173-
/**
174-
* @inheritDoc
175-
*
176-
* @deprecated Use `withScope` instead.
177-
*/
178-
public pushScope(): ScopeInterface {
179-
// We want to clone the content of prev scope
180-
// eslint-disable-next-line deprecation/deprecation
181-
const scope = this.getScope().clone();
182-
// eslint-disable-next-line deprecation/deprecation
183-
this.getStack().push({
184-
// eslint-disable-next-line deprecation/deprecation
185-
client: this.getClient(),
186-
scope,
187-
});
188-
return scope;
189-
}
190-
191-
/**
192-
* @inheritDoc
193-
*
194-
* @deprecated Use `withScope` instead.
195-
*/
196-
public popScope(): boolean {
197-
// eslint-disable-next-line deprecation/deprecation
198-
if (this.getStack().length <= 1) return false;
199-
// eslint-disable-next-line deprecation/deprecation
200-
return !!this.getStack().pop();
201-
}
202-
203161
/**
204162
* @inheritDoc
205163
*
206164
* @deprecated Use `Sentry.withScope()` instead.
207165
*/
208166
public withScope<T>(callback: (scope: ScopeInterface) => T): T {
209-
// eslint-disable-next-line deprecation/deprecation
210-
const scope = this.pushScope();
167+
const scope = this._pushScope();
211168

212169
let maybePromiseResult: T;
213170
try {
214171
maybePromiseResult = callback(scope);
215172
} catch (e) {
216-
// eslint-disable-next-line deprecation/deprecation
217-
this.popScope();
173+
this._popScope();
218174
throw e;
219175
}
220176

221177
if (isThenable(maybePromiseResult)) {
222178
// @ts-expect-error - isThenable returns the wrong type
223179
return maybePromiseResult.then(
224180
res => {
225-
// eslint-disable-next-line deprecation/deprecation
226-
this.popScope();
181+
this._popScope();
227182
return res;
228183
},
229184
e => {
230-
// eslint-disable-next-line deprecation/deprecation
231-
this.popScope();
185+
this._popScope();
232186
throw e;
233187
},
234188
);
235189
}
236190

237-
// eslint-disable-next-line deprecation/deprecation
238-
this.popScope();
191+
this._popScope();
239192
return maybePromiseResult;
240193
}
241194

@@ -501,20 +454,6 @@ export class Hub implements HubInterface {
501454
return session;
502455
}
503456

504-
/**
505-
* Returns if default PII should be sent to Sentry and propagated in ourgoing requests
506-
* when Tracing is used.
507-
*
508-
* @deprecated Use top-level `getClient().getOptions().sendDefaultPii` instead. This function
509-
* only unnecessarily increased API surface but only wrapped accessing the option.
510-
*/
511-
public shouldSendDefaultPii(): boolean {
512-
// eslint-disable-next-line deprecation/deprecation
513-
const client = this.getClient();
514-
const options = client && client.getOptions();
515-
return Boolean(options && options.sendDefaultPii);
516-
}
517-
518457
/**
519458
* Sends the current Session on the scope
520459
*/
@@ -527,6 +466,32 @@ export class Hub implements HubInterface {
527466
client.captureSession(session);
528467
}
529468
}
469+
470+
/**
471+
* Push a scope to the stack.
472+
*/
473+
private _pushScope(): ScopeInterface {
474+
// We want to clone the content of prev scope
475+
// eslint-disable-next-line deprecation/deprecation
476+
const scope = this.getScope().clone();
477+
// eslint-disable-next-line deprecation/deprecation
478+
this.getStack().push({
479+
// eslint-disable-next-line deprecation/deprecation
480+
client: this.getClient(),
481+
scope,
482+
});
483+
return scope;
484+
}
485+
486+
/**
487+
* Pop a scope from the stack.
488+
*/
489+
private _popScope(): boolean {
490+
// eslint-disable-next-line deprecation/deprecation
491+
if (this.getStack().length <= 1) return false;
492+
// eslint-disable-next-line deprecation/deprecation
493+
return !!this.getStack().pop();
494+
}
530495
}
531496

532497
/**

packages/opentelemetry/src/custom/getCurrentHub.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client, EventHint, Hub, Integration, IntegrationClass, Scope, SeverityLevel } from '@sentry/types';
1+
import type { Client, EventHint, Hub, Integration, IntegrationClass, SeverityLevel } from '@sentry/types';
22

33
import {
44
addBreadcrumb,
@@ -23,25 +23,11 @@ import {
2323
*/
2424
export function getCurrentHub(): Hub {
2525
return {
26-
isOlderThan(_version: number): boolean {
27-
return false;
28-
},
29-
3026
bindClient(client: Client): void {
3127
const scope = getCurrentScope();
3228
scope.setClient(client);
3329
},
3430

35-
pushScope(): Scope {
36-
// TODO: This does not work and is actually deprecated
37-
return getCurrentScope();
38-
},
39-
40-
popScope(): boolean {
41-
// TODO: This does not work and is actually deprecated
42-
return false;
43-
},
44-
4531
withScope,
4632
getClient: <C extends Client>() => getClient() as C | undefined,
4733
getScope: getCurrentScope,
@@ -79,11 +65,6 @@ export function getCurrentHub(): Hub {
7965
// only send the update
8066
_sendSessionUpdate();
8167
},
82-
83-
shouldSendDefaultPii(): boolean {
84-
const client = getClient();
85-
return Boolean(client ? client.getOptions().sendDefaultPii : false);
86-
},
8768
};
8869
}
8970

packages/types/src/hub.ts

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@ import type { User } from './user';
1414
* working in case we have a version conflict.
1515
*/
1616
export interface Hub {
17-
/**
18-
* Checks if this hub's version is older than the given version.
19-
*
20-
* @param version A version number to compare to.
21-
* @return True if the given version is newer; otherwise false.
22-
*
23-
* @deprecated This will be removed in v8.
24-
*/
25-
isOlderThan(version: number): boolean;
26-
2717
/**
2818
* This binds the given client to the current scope.
2919
* @param client An SDK client (client) instance.
@@ -32,31 +22,6 @@ export interface Hub {
3222
*/
3323
bindClient(client?: Client): void;
3424

35-
/**
36-
* Create a new scope to store context information.
37-
*
38-
* The scope will be layered on top of the current one. It is isolated, i.e. all
39-
* breadcrumbs and context information added to this scope will be removed once
40-
* the scope ends. Be sure to always remove this scope with {@link this.popScope}
41-
* when the operation finishes or throws.
42-
*
43-
* @returns Scope, the new cloned scope
44-
*
45-
* @deprecated Use `withScope` instead.
46-
*/
47-
pushScope(): Scope;
48-
49-
/**
50-
* Removes a previously pushed scope from the stack.
51-
*
52-
* This restores the state before the scope was pushed. All breadcrumbs and
53-
* context information added since the last call to {@link this.pushScope} are
54-
* discarded.
55-
*
56-
* @deprecated Use `withScope` instead.
57-
*/
58-
popScope(): boolean;
59-
6025
/**
6126
* Creates a new scope with and executes the given operation within.
6227
* The scope is automatically removed once the operation
@@ -234,13 +199,4 @@ export interface Hub {
234199
* @deprecated Use top-level `captureSession` instead.
235200
*/
236201
captureSession(endSession?: boolean): void;
237-
238-
/**
239-
* Returns if default PII should be sent to Sentry and propagated in outgoing requests
240-
* when Tracing is used.
241-
*
242-
* @deprecated Use top-level `getClient().getOptions().sendDefaultPii` instead. This function
243-
* only unnecessarily increased API surface but only wrapped accessing the option.
244-
*/
245-
shouldSendDefaultPii(): boolean;
246202
}

0 commit comments

Comments
 (0)