Skip to content

Commit a4857c9

Browse files
committed
fix: Init timestamp and started with same value
1 parent 042e20e commit a4857c9

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

packages/browser/src/client.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,6 @@ export class BrowserClient extends BaseClient<BrowserBackend, BrowserOptions> {
5757
});
5858
}
5959

60-
/**
61-
* @inheritDoc
62-
*/
63-
public captureSession(session: Session): void {
64-
// Make sure session duration is not sent
65-
session.duration = undefined;
66-
super.captureSession(session);
67-
}
68-
6960
/**
7061
* @inheritDoc
7162
*/

packages/hub/src/session.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export class Session implements SessionInterface {
2121
public release?: string;
2222
public sid: string = uuid4();
2323
public did?: string;
24-
public timestamp: number = timestampInSeconds();
25-
public started: number = timestampInSeconds();
24+
public timestamp: number;
25+
public started: number;
2626
public duration?: number = 0;
2727
public status: SessionStatus = SessionStatus.Ok;
2828
public environment?: string;
@@ -31,6 +31,9 @@ export class Session implements SessionInterface {
3131
public browser: boolean = false;
3232

3333
public constructor(context?: Omit<SessionContext, 'started' | 'status'>) {
34+
const startingTime = timestampInSeconds();
35+
this.timestamp = startingTime;
36+
this.started = startingTime;
3437
if (context) {
3538
this.update(context);
3639
}
@@ -116,8 +119,8 @@ export class Session implements SessionInterface {
116119
init: boolean;
117120
sid: string;
118121
did?: string;
119-
timestamp: number;
120-
started: number;
122+
timestamp: string;
123+
started: string;
121124
duration?: number;
122125
status: SessionStatus;
123126
errors: number;
@@ -131,8 +134,8 @@ export class Session implements SessionInterface {
131134
return dropUndefinedKeys({
132135
sid: `${this.sid}`,
133136
init: this.init,
134-
started: this.started,
135-
timestamp: this.timestamp,
137+
started: new Date(this.started).toISOString(),
138+
timestamp: new Date(this.timestamp).toISOString(),
136139
status: this.status,
137140
errors: this.errors,
138141
did: typeof this.did === 'number' || typeof this.did === 'string' ? `${this.did}` : undefined,

packages/types/src/session.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export interface Session extends SessionContext {
1515
init: boolean;
1616
sid: string;
1717
did?: string;
18-
timestamp: number;
19-
started: number;
18+
timestamp: string;
19+
started: string;
2020
duration?: number;
2121
status: SessionStatus;
2222
errors: number;
@@ -40,8 +40,8 @@ export interface SessionContext {
4040
sid?: string;
4141
did?: string;
4242
init?: boolean;
43-
timestamp?: number;
44-
started?: number;
43+
timestamp?: string;
44+
started?: string;
4545
duration?: number;
4646
status?: SessionStatus;
4747
release?: string;

0 commit comments

Comments
 (0)