From c7aba8242cf713fa5c2a04e7aef080172cce8a2b Mon Sep 17 00:00:00 2001 From: Bryce Kalow Date: Fri, 22 Dec 2023 15:08:41 -0600 Subject: [PATCH] fix(shared): Disable telemetry collection from browser controlled via automation --- .changeset/happy-dolls-taste.md | 5 +++++ packages/shared/src/telemetry/collector.ts | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 .changeset/happy-dolls-taste.md diff --git a/.changeset/happy-dolls-taste.md b/.changeset/happy-dolls-taste.md new file mode 100644 index 00000000000..0f5f7fd41ad --- /dev/null +++ b/.changeset/happy-dolls-taste.md @@ -0,0 +1,5 @@ +--- +'@clerk/shared': patch +--- + +Disable telemetry collection when window.navigator.webdriver is defined, indicating traffic from an automation tool. diff --git a/packages/shared/src/telemetry/collector.ts b/packages/shared/src/telemetry/collector.ts index c9a0dc35e52..04751ae937b 100644 --- a/packages/shared/src/telemetry/collector.ts +++ b/packages/shared/src/telemetry/collector.ts @@ -91,6 +91,13 @@ export class TelemetryCollector { return false; } + // navigator.webdriver is a property generally set by headless browsers that are running in an automated testing environment. + // Data from these environments is not meaningful for us and has the potential to produce a large volume of events, so we disable + // collection in this case. (ref: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/webdriver) + if (typeof window !== 'undefined' && !!window?.navigator?.webdriver) { + return false; + } + return true; }