From 9d189b6b8b0866c09512aaba2cefc42ca56ab23a Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Thu, 12 Mar 2020 09:48:54 +0100 Subject: [PATCH 1/4] fix: Check for performance.timing in webworkers --- packages/utils/src/misc.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/utils/src/misc.ts b/packages/utils/src/misc.ts index b5912b63c6fd..ee6ec96c9cdc 100644 --- a/packages/utils/src/misc.ts +++ b/packages/utils/src/misc.ts @@ -372,6 +372,15 @@ export const crossPlatformPerformance: Pick = } if (getGlobalObject().performance) { + // tslint:disable-next-line:deprecation + if (!performance.timing) { + return performanceFallback; + } + // tslint:disable-next-line:deprecation + if (!performance.timing.navigationStart) { + return performanceFallback; + } + // Polyfill for performance.timeOrigin. // // While performance.timing.navigationStart is deprecated in favor of performance.timeOrigin, performance.timeOrigin From 2711cb95fbe301a1ab8ee74807772180983cb064 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Thu, 12 Mar 2020 09:49:59 +0100 Subject: [PATCH 2/4] chore: Changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd0a935195e4..f68fe1e7a75a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott +- [apm] fix: Check for performance.timing in webworkers #2491 + ## 5.14.0 - [apm] feat: Add a simple heartbeat check, if activities don't change in 3 beats, finish the transaction (#2478) From 2b93d5cf1b26db072aeea184fd42f9859e80ae06 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Thu, 12 Mar 2020 09:50:48 +0100 Subject: [PATCH 3/4] fix: Typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f68fe1e7a75a..df4d796cc321 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ - "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott -- [apm] fix: Check for performance.timing in webworkers #2491 +- [apm] fix: Check for performance.timing in webworkers (#2491) ## 5.14.0 From 912f04c47b3c12f16b7b3d7c5b77d2a649ef7533 Mon Sep 17 00:00:00 2001 From: Daniel Griesser Date: Thu, 12 Mar 2020 10:06:03 +0100 Subject: [PATCH 4/4] chore: Comment --- packages/utils/src/misc.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/utils/src/misc.ts b/packages/utils/src/misc.ts index ee6ec96c9cdc..958ad97c6104 100644 --- a/packages/utils/src/misc.ts +++ b/packages/utils/src/misc.ts @@ -372,21 +372,22 @@ export const crossPlatformPerformance: Pick = } if (getGlobalObject().performance) { - // tslint:disable-next-line:deprecation - if (!performance.timing) { - return performanceFallback; - } - // tslint:disable-next-line:deprecation - if (!performance.timing.navigationStart) { - return performanceFallback; - } - // Polyfill for performance.timeOrigin. // // While performance.timing.navigationStart is deprecated in favor of performance.timeOrigin, performance.timeOrigin // is not as widely supported. Namely, performance.timeOrigin is undefined in Safari as of writing. // tslint:disable-next-line:strict-type-predicates if (performance.timeOrigin === undefined) { + // For webworkers it could mean we don't have performance.timing then we fallback + // tslint:disable-next-line:deprecation + if (!performance.timing) { + return performanceFallback; + } + // tslint:disable-next-line:deprecation + if (!performance.timing.navigationStart) { + return performanceFallback; + } + // @ts-ignore // tslint:disable-next-line:deprecation performance.timeOrigin = performance.timing.navigationStart;