Skip to content

Commit 0d38856

Browse files
author
Luca Forstner
committed
More cleanup
1 parent 64ab7f6 commit 0d38856

File tree

9 files changed

+7
-127
lines changed

9 files changed

+7
-127
lines changed

dev-packages/node-integration-tests/suites/sessions/server.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { loggingTransport } from '@sentry-internal/node-integration-tests';
2-
import type { SessionFlusher } from '@sentry/core';
32
import * as Sentry from '@sentry/node';
43

54
Sentry.init({
@@ -13,14 +12,6 @@ import express from 'express';
1312

1413
const app = express();
1514

16-
// eslint-disable-next-line deprecation/deprecation
17-
const flusher = (Sentry.getClient() as Sentry.NodeClient)['_sessionFlusher'] as SessionFlusher;
18-
19-
// Flush after 2 seconds (to avoid waiting for the default 60s)
20-
setTimeout(() => {
21-
flusher?.flush();
22-
}, 2000);
23-
2415
app.get('/test/success', (_req, res) => {
2516
res.send('Success!');
2617
});

packages/core/src/scope.ts

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import type {
1313
Extras,
1414
Primitive,
1515
PropagationContext,
16-
RequestSession,
1716
Scope as ScopeInterface,
1817
ScopeContext,
1918
ScopeData,
@@ -93,10 +92,6 @@ class ScopeClass implements ScopeInterface {
9392
/** Session */
9493
protected _session?: Session;
9594

96-
/** Request Mode Session Status */
97-
// eslint-disable-next-line deprecation/deprecation
98-
protected _requestSession?: RequestSession;
99-
10095
/** The client on this scope */
10196
protected _client?: Client;
10297

@@ -145,7 +140,6 @@ class ScopeClass implements ScopeInterface {
145140
newScope._transactionName = this._transactionName;
146141
newScope._fingerprint = this._fingerprint;
147142
newScope._eventProcessors = [...this._eventProcessors];
148-
newScope._requestSession = this._requestSession;
149143
newScope._attachments = [...this._attachments];
150144
newScope._sdkProcessingMetadata = { ...this._sdkProcessingMetadata };
151145
newScope._propagationContext = { ...this._propagationContext };
@@ -228,23 +222,6 @@ class ScopeClass implements ScopeInterface {
228222
return this._user;
229223
}
230224

231-
/**
232-
* @inheritDoc
233-
*/
234-
// eslint-disable-next-line deprecation/deprecation
235-
public getRequestSession(): RequestSession | undefined {
236-
return this._requestSession;
237-
}
238-
239-
/**
240-
* @inheritDoc
241-
*/
242-
// eslint-disable-next-line deprecation/deprecation
243-
public setRequestSession(requestSession?: RequestSession): this {
244-
this._requestSession = requestSession;
245-
return this;
246-
}
247-
248225
/**
249226
* @inheritDoc
250227
*/
@@ -359,13 +336,12 @@ class ScopeClass implements ScopeInterface {
359336

360337
const scopeToMerge = typeof captureContext === 'function' ? captureContext(this) : captureContext;
361338

362-
const [scopeInstance, requestSession] =
339+
const scopeInstance =
363340
scopeToMerge instanceof Scope
364-
? // eslint-disable-next-line deprecation/deprecation
365-
[scopeToMerge.getScopeData(), scopeToMerge.getRequestSession()]
341+
? scopeToMerge.getScopeData()
366342
: isPlainObject(scopeToMerge)
367-
? [captureContext as ScopeContext, (captureContext as ScopeContext).requestSession]
368-
: [];
343+
? (captureContext as ScopeContext)
344+
: undefined;
369345

370346
const { tags, extra, user, contexts, level, fingerprint = [], propagationContext } = scopeInstance || {};
371347

@@ -389,10 +365,6 @@ class ScopeClass implements ScopeInterface {
389365
this._propagationContext = propagationContext;
390366
}
391367

392-
if (requestSession) {
393-
this._requestSession = requestSession;
394-
}
395-
396368
return this;
397369
}
398370

@@ -409,7 +381,6 @@ class ScopeClass implements ScopeInterface {
409381
this._level = undefined;
410382
this._transactionName = undefined;
411383
this._fingerprint = undefined;
412-
this._requestSession = undefined;
413384
this._session = undefined;
414385
_setSpanForScope(this, undefined);
415386
this._attachments = [];

packages/core/src/types-hoist/scope.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { Event, EventHint } from './event';
66
import type { EventProcessor } from './eventprocessor';
77
import type { Extra, Extras } from './extra';
88
import type { Primitive } from './misc';
9-
import type { RequestSession, Session } from './session';
9+
import type { Session } from './session';
1010
import type { SeverityLevel } from './severity';
1111
import type { Span } from './span';
1212
import type { PropagationContext } from './tracing';
@@ -23,8 +23,6 @@ export interface ScopeContext {
2323
contexts: Contexts;
2424
tags: { [key: string]: Primitive };
2525
fingerprint: string[];
26-
// eslint-disable-next-line deprecation/deprecation
27-
requestSession: RequestSession;
2826
propagationContext: PropagationContext;
2927
}
3028

@@ -167,22 +165,6 @@ export interface Scope {
167165
*/
168166
setSession(session?: Session): this;
169167

170-
/**
171-
* Returns the `RequestSession` if there is one
172-
*
173-
* @deprecated Use `getSession()` and `setSession()` instead of `getRequestSession()` and `setRequestSession()`;
174-
*/
175-
// eslint-disable-next-line deprecation/deprecation
176-
getRequestSession(): RequestSession | undefined;
177-
178-
/**
179-
* Sets the `RequestSession` on the scope
180-
*
181-
* @deprecated Use `getSession()` and `setSession()` instead of `getRequestSession()` and `setRequestSession()`;
182-
*/
183-
// eslint-disable-next-line deprecation/deprecation
184-
setRequestSession(requestSession?: RequestSession): this;
185-
186168
/**
187169
* Updates the scope with provided data. Can work in three variations:
188170
* - plain object containing updatable attributes

packages/core/src/types-hoist/session.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
import type { User } from './user';
22

3-
/**
4-
* @deprecated This type is deprecated and will be removed in the next major version of the SDK.
5-
*/
6-
export interface RequestSession {
7-
// eslint-disable-next-line deprecation/deprecation
8-
status?: RequestSessionStatus;
9-
}
10-
113
export interface Session {
124
sid: string;
135
did?: string | number;
@@ -40,11 +32,6 @@ export type SessionContext = Partial<Session>;
4032

4133
export type SessionStatus = 'ok' | 'exited' | 'crashed' | 'abnormal';
4234

43-
/**
44-
* @deprecated This type is deprecated and will be removed in the next major version of the SDK.
45-
*/
46-
export type RequestSessionStatus = 'ok' | 'errored' | 'crashed';
47-
4835
/** JSDoc */
4936
export interface SessionAggregates {
5037
attrs?: {

packages/core/src/utils/prepareEvent.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,6 @@ const captureContextKeys: readonly ScopeContextProperty[] = [
369369
'contexts',
370370
'tags',
371371
'fingerprint',
372-
'requestSession',
373372
'propagationContext',
374373
] as const;
375374

packages/core/test/lib/prepareEvent.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ describe('parseEventHintOrCaptureContext', () => {
162162
contexts: { os: { name: 'linux' } },
163163
tags: { foo: 'bar' },
164164
fingerprint: ['xx', 'yy'],
165-
requestSession: { status: 'ok' },
166165
propagationContext: {
167166
traceId: 'xxx',
168167
spanId: 'yyy',
@@ -175,8 +174,8 @@ describe('parseEventHintOrCaptureContext', () => {
175174

176175
it('triggers a TS error if trying to mix ScopeContext & EventHint', () => {
177176
const actual = parseEventHintOrCaptureContext({
178-
// @ts-expect-error We are specifically testing that this errors!
179177
user: { id: 'xxx' },
178+
// @ts-expect-error We are specifically testing that this errors!
180179
mechanism: { handled: false },
181180
});
182181

packages/core/test/lib/scope.test.ts

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
withIsolationScope,
77
withScope,
88
} from '../../src';
9-
import type { Breadcrumb, Client, Event, RequestSessionStatus } from '../../src/types-hoist';
9+
import type { Breadcrumb, Client, Event } from '../../src/types-hoist';
1010

1111
import { Scope } from '../../src/scope';
1212
import { TestClient, getDefaultTestClientOptions } from '../mocks/client';
@@ -259,15 +259,6 @@ describe('Scope', () => {
259259
expect(parentScope['_extra']).toEqual(scope['_extra']);
260260
});
261261

262-
test('_requestSession clone', () => {
263-
const parentScope = new Scope();
264-
// eslint-disable-next-line deprecation/deprecation
265-
parentScope.setRequestSession({ status: 'errored' });
266-
const scope = parentScope.clone();
267-
// eslint-disable-next-line deprecation/deprecation
268-
expect(parentScope.getRequestSession()).toEqual(scope.getRequestSession());
269-
});
270-
271262
test('parent changed inheritance', () => {
272263
const parentScope = new Scope();
273264
const scope = parentScope.clone();
@@ -286,26 +277,6 @@ describe('Scope', () => {
286277
expect(scope['_extra']).toEqual({ a: 2 });
287278
});
288279

289-
test('child override should set the value of parent _requestSession', () => {
290-
// Test that ensures if the status value of `status` of `_requestSession` is changed in a child scope
291-
// that it should also change in parent scope because we are copying the reference to the object
292-
const parentScope = new Scope();
293-
// eslint-disable-next-line deprecation/deprecation
294-
parentScope.setRequestSession({ status: 'errored' });
295-
296-
const scope = parentScope.clone();
297-
// eslint-disable-next-line deprecation/deprecation
298-
const requestSession = scope.getRequestSession();
299-
if (requestSession) {
300-
requestSession.status = 'ok';
301-
}
302-
303-
// eslint-disable-next-line deprecation/deprecation
304-
expect(parentScope.getRequestSession()).toEqual({ status: 'ok' });
305-
// eslint-disable-next-line deprecation/deprecation
306-
expect(scope.getRequestSession()).toEqual({ status: 'ok' });
307-
});
308-
309280
test('should clone propagation context', () => {
310281
const parentScope = new Scope();
311282
const scope = parentScope.clone();
@@ -322,12 +293,9 @@ describe('Scope', () => {
322293
scope.setUser({ id: '1' });
323294
scope.setFingerprint(['abcd']);
324295
scope.addBreadcrumb({ message: 'test' });
325-
// eslint-disable-next-line deprecation/deprecation
326-
scope.setRequestSession({ status: 'ok' });
327296
expect(scope['_extra']).toEqual({ a: 2 });
328297
scope.clear();
329298
expect(scope['_extra']).toEqual({});
330-
expect(scope['_requestSession']).toEqual(undefined);
331299
expect(scope['_propagationContext']).toEqual({
332300
traceId: expect.any(String),
333301
spanId: expect.any(String),
@@ -356,8 +324,6 @@ describe('Scope', () => {
356324
scope.setUser({ id: '1337' });
357325
scope.setLevel('info');
358326
scope.setFingerprint(['foo']);
359-
// eslint-disable-next-line deprecation/deprecation
360-
scope.setRequestSession({ status: 'ok' });
361327
});
362328

363329
test('given no data, returns the original scope', () => {
@@ -405,7 +371,6 @@ describe('Scope', () => {
405371
localScope.setUser({ id: '42' });
406372
localScope.setLevel('warning');
407373
localScope.setFingerprint(['bar']);
408-
(localScope as any)._requestSession = { status: 'ok' };
409374

410375
const updatedScope = scope.update(localScope) as any;
411376

@@ -427,7 +392,6 @@ describe('Scope', () => {
427392
expect(updatedScope._user).toEqual({ id: '42' });
428393
expect(updatedScope._level).toEqual('warning');
429394
expect(updatedScope._fingerprint).toEqual(['bar']);
430-
expect(updatedScope._requestSession.status).toEqual('ok');
431395
// @ts-expect-error accessing private property for test
432396
expect(updatedScope._propagationContext).toEqual(localScope._propagationContext);
433397
});
@@ -450,7 +414,6 @@ describe('Scope', () => {
450414
expect(updatedScope._user).toEqual({ id: '1337' });
451415
expect(updatedScope._level).toEqual('info');
452416
expect(updatedScope._fingerprint).toEqual(['foo']);
453-
expect(updatedScope._requestSession.status).toEqual('ok');
454417
});
455418

456419
test('given a plain object, it should merge two together, with the passed object having priority', () => {
@@ -461,8 +424,6 @@ describe('Scope', () => {
461424
level: 'warning' as const,
462425
tags: { bar: '3', baz: '4' },
463426
user: { id: '42' },
464-
// eslint-disable-next-line deprecation/deprecation
465-
requestSession: { status: 'errored' as RequestSessionStatus },
466427
propagationContext: {
467428
traceId: '8949daf83f4a4a70bee4c1eb9ab242ed',
468429
spanId: 'a024ad8fea82680e',
@@ -490,7 +451,6 @@ describe('Scope', () => {
490451
expect(updatedScope._user).toEqual({ id: '42' });
491452
expect(updatedScope._level).toEqual('warning');
492453
expect(updatedScope._fingerprint).toEqual(['bar']);
493-
expect(updatedScope._requestSession).toEqual({ status: 'errored' });
494454
expect(updatedScope._propagationContext).toEqual({
495455
traceId: '8949daf83f4a4a70bee4c1eb9ab242ed',
496456
spanId: 'a024ad8fea82680e',

packages/node/src/utils/prepareEvent.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ const captureContextKeys: readonly ScopeContextProperty[] = [
4949
'contexts',
5050
'tags',
5151
'fingerprint',
52-
'requestSession',
5352
'propagationContext',
5453
] as const;
5554

packages/types/src/index.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ import type {
115115
ReplayRecordingMode as ReplayRecordingMode_imported,
116116
Request as Request_imported,
117117
RequestEventData as RequestEventData_imported,
118-
RequestSession as RequestSession_imported,
119-
RequestSessionStatus as RequestSessionStatus_imported,
120118
Runtime as Runtime_imported,
121119
SamplingContext as SamplingContext_imported,
122120
SanitizedRequestData as SanitizedRequestData_imported,
@@ -422,12 +420,6 @@ export type SessionContext = SessionContext_imported;
422420
/** @deprecated This type has been moved to `@sentry/core`. */
423421
export type SessionStatus = SessionStatus_imported;
424422
/** @deprecated This type has been moved to `@sentry/core`. */
425-
// eslint-disable-next-line deprecation/deprecation
426-
export type RequestSession = RequestSession_imported;
427-
/** @deprecated This type has been moved to `@sentry/core`. */
428-
// eslint-disable-next-line deprecation/deprecation
429-
export type RequestSessionStatus = RequestSessionStatus_imported;
430-
/** @deprecated This type has been moved to `@sentry/core`. */
431423
export type SerializedSession = SerializedSession_imported;
432424
/** @deprecated This type has been moved to `@sentry/core`. */
433425
export type SeverityLevel = SeverityLevel_imported;

0 commit comments

Comments
 (0)