File tree 3 files changed +19
-10
lines changed
3 files changed +19
-10
lines changed Original file line number Diff line number Diff line change 29
29
name : ' @sentry/packages - build + lint + test + codecov + danger [node v12]'
30
30
node_js : ' 12'
31
31
script : scripts/danger.sh
32
+ - name : ' @sentry/packages - build and test [node v6]'
33
+ node_js : ' 6'
34
+ script : scripts/test.sh
32
35
- name : ' @sentry/packages - build and test [node v8]'
33
36
node_js : ' 8'
34
37
script : scripts/test.sh
Original file line number Diff line number Diff line change @@ -13,18 +13,24 @@ import {
13
13
uuid4 ,
14
14
} from '@sentry/utils' ;
15
15
16
+ const INITIAL_TIME = Date . now ( ) ;
17
+
18
+ const performanceFallback : Pick < Performance , 'now' > = {
19
+ now ( ) : number {
20
+ return INITIAL_TIME - Date . now ( ) ;
21
+ } ,
22
+ } ;
23
+
16
24
const crossPlatformPerformance : Pick < Performance , 'now' > = ( ( ) => {
17
25
if ( isNodeEnv ( ) ) {
18
- const { performance } = dynamicRequire ( module , 'perf_hooks' ) as { performance : Performance } ;
19
- return performance ;
20
- }
21
- return (
22
- getGlobalObject < Window > ( ) . performance || {
23
- now ( ) : number {
24
- return Date . now ( ) ;
25
- } ,
26
+ try {
27
+ const perfHooks = dynamicRequire ( module , 'perf_hooks' ) as { performance : Performance } ;
28
+ return perfHooks . performance ;
29
+ } catch ( _ ) {
30
+ return performanceFallback ;
26
31
}
27
- ) ;
32
+ }
33
+ return getGlobalObject < Window > ( ) . performance || performanceFallback ;
28
34
} ) ( ) ;
29
35
30
36
// TODO: Should this be exported?
Original file line number Diff line number Diff line change 7
7
"author" : " Sentry" ,
8
8
"license" : " BSD-3-Clause" ,
9
9
"engines" : {
10
- "node" : " >=8 "
10
+ "node" : " >=6 "
11
11
},
12
12
"main" : " dist/index.js" ,
13
13
"module" : " esm/index.js" ,
You can’t perform that action at this time.
0 commit comments