88 SessionStatus ,
99 Transport ,
1010} from '@sentry/types' ;
11- import { dropUndefinedKeys , logger , uuid4 } from '@sentry/utils' ;
11+ import { dropUndefinedKeys , logger , timestampInSeconds , uuid4 } from '@sentry/utils' ;
1212
1313import { getCurrentHub } from './hub' ;
1414
@@ -21,9 +21,9 @@ export class Session implements SessionInterface {
2121 public release ?: string ;
2222 public sid : string = uuid4 ( ) ;
2323 public did ?: string ;
24- public timestamp : number = Date . now ( ) ;
25- public started : number = Date . now ( ) ;
26- public duration : number = 0 ;
24+ public timestamp : number = timestampInSeconds ;
25+ public started : number = timestampInSeconds ;
26+ public duration ? : number = 0 ;
2727 public status : SessionStatus = SessionStatus . Ok ;
2828 public environment ?: string ;
2929 public ipAddress ?: string ;
@@ -48,7 +48,7 @@ export class Session implements SessionInterface {
4848 }
4949 }
5050
51- this . timestamp = context . timestamp || Date . now ( ) ;
51+ this . timestamp = context . timestamp || timestampInSeconds ;
5252
5353 if ( context . sid ) {
5454 // Good enough uuid validation. — Kamil
@@ -63,7 +63,7 @@ export class Session implements SessionInterface {
6363 if ( typeof context . started === 'number' ) {
6464 this . started = context . started ;
6565 }
66- if ( typeof context . duration === 'number' ) {
66+ if ( typeof context . duration === 'number' || typeof context . duration === undefined ) {
6767 this . duration = context . duration ;
6868 } else {
6969 this . duration = this . timestamp - this . started ;
@@ -104,9 +104,9 @@ export class Session implements SessionInterface {
104104 init : boolean ;
105105 sid : string ;
106106 did ?: string ;
107- timestamp : string ;
108- started : string ;
109- duration : number ;
107+ timestamp : number ;
108+ started : number ;
109+ duration ? : number ;
110110 status : SessionStatus ;
111111 errors : number ;
112112 attrs ?: {
@@ -119,8 +119,8 @@ export class Session implements SessionInterface {
119119 return dropUndefinedKeys ( {
120120 sid : `${ this . sid } ` ,
121121 init : this . init ,
122- started : new Date ( this . started ) . toISOString ( ) ,
123- timestamp : new Date ( this . timestamp ) . toISOString ( ) ,
122+ started : this . started ,
123+ timestamp : this . timestamp ,
124124 status : this . status ,
125125 errors : this . errors ,
126126 did : typeof this . did === 'number' || typeof this . did === 'string' ? `${ this . did } ` : undefined ,
0 commit comments