Skip to content

Commit c6a2249

Browse files
committed
remove transport from session flusher
1 parent bfa0d8d commit c6a2249

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

packages/hub/src/sessionflusher.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
AggregationCounts,
3-
RequestSessionStatus,
4-
SessionAggregates,
5-
SessionFlusherLike,
6-
Transport,
7-
} from '@sentry/types';
1+
import { AggregationCounts, Client, RequestSessionStatus, SessionAggregates, SessionFlusherLike } from '@sentry/types';
82
import { dropUndefinedKeys, logger } from '@sentry/utils';
93

104
import { IS_DEBUG_BUILD } from './flags';
@@ -24,22 +18,18 @@ export class SessionFlusher implements SessionFlusherLike {
2418
private _sessionAttrs: ReleaseHealthAttributes;
2519
private _intervalId: ReturnType<typeof setInterval>;
2620
private _isEnabled: boolean = true;
27-
private _transport: Transport;
21+
private _client: Client;
2822

29-
public constructor(transport: Transport, attrs: ReleaseHealthAttributes) {
30-
this._transport = transport;
23+
public constructor(client: Client, attrs: ReleaseHealthAttributes) {
24+
this._client = client;
3125
// Call to setInterval, so that flush is called every 60 seconds
3226
this._intervalId = setInterval(() => this.flush(), this.flushTimeout * 1000);
3327
this._sessionAttrs = attrs;
3428
}
3529

3630
/** Sends session aggregates to Transport */
3731
public sendSessionAggregates(sessionAggregates: SessionAggregates): void {
38-
if (!this._transport.sendSession) {
39-
IS_DEBUG_BUILD && logger.warn("Dropping session because custom transport doesn't implement sendSession");
40-
return;
41-
}
42-
void this._transport.sendSession(sessionAggregates).then(null, reason => {
32+
void this._client.sendSession(sessionAggregates).then(null, reason => {
4333
IS_DEBUG_BUILD && logger.error('Error while sending session:', reason);
4434
});
4535
}

packages/node/src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class NodeClient extends BaseClient<NodeClientOptions> {
9999
if (!release) {
100100
IS_DEBUG_BUILD && logger.warn('Cannot initialise an instance of SessionFlusher if no release is provided!');
101101
} else {
102-
this._sessionFlusher = new SessionFlusher(this.getTransport(), {
102+
this._sessionFlusher = new SessionFlusher(this, {
103103
release,
104104
environment,
105105
});

packages/types/src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Event, EventHint } from './event';
33
import { Integration, IntegrationClass } from './integration';
44
import { ClientOptions } from './options';
55
import { Scope } from './scope';
6-
import { Session } from './session';
6+
import { Session, SessionAggregates } from './session';
77
import { Severity, SeverityLevel } from './severity';
88
import { NewTransport } from './transport';
99

@@ -116,5 +116,5 @@ export interface Client<O extends ClientOptions = ClientOptions> {
116116
sendEvent(event: Event): void;
117117

118118
/** Submits the session to Sentry */
119-
sendSession(session: Session): void;
119+
sendSession(session: Session | SessionAggregates): void;
120120
}

0 commit comments

Comments
 (0)