From be690d139e71e4629d06d2a687d73ed9fdea64ea Mon Sep 17 00:00:00 2001 From: Leo HC Li <36619969+Leo6Leo@users.noreply.github.com> Date: Mon, 9 Mar 2026 23:22:46 +0800 Subject: [PATCH] fix: Update telemetry configuration and sampling rate --- .../src/api/segment-analytics.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/packages/console-dynamic-plugin-sdk/src/api/segment-analytics.ts b/frontend/packages/console-dynamic-plugin-sdk/src/api/segment-analytics.ts index 49298112c2d..0ae20ef21c9 100644 --- a/frontend/packages/console-dynamic-plugin-sdk/src/api/segment-analytics.ts +++ b/frontend/packages/console-dynamic-plugin-sdk/src/api/segment-analytics.ts @@ -20,16 +20,21 @@ const TELEMETRY_JS_URL = TELEMETRY_API_KEY, )}/analytics.min.js`; +const CONSOLE_VERSION = + window.SERVER_FLAGS.releaseVersion || window.SERVER_FLAGS.consoleVersion || ''; +const IS_CI_ENVIRONMENT = /test-ci|ci-ln-|nightly/i.test(CONSOLE_VERSION); + export const TELEMETRY_DISABLED = !TELEMETRY_API_KEY || + IS_CI_ENVIRONMENT || window.SERVER_FLAGS.telemetry?.DISABLED === 'true' || window.SERVER_FLAGS.telemetry?.DEVSANDBOX_DISABLED === 'true' || window.SERVER_FLAGS.telemetry?.TELEMETER_CLIENT_DISABLED === 'true'; export const TELEMETRY_DEBUG = window.SERVER_FLAGS.telemetry?.DEBUG === 'true'; -// Sample 20% of sessions -const SAMPLE_SESSION = Math.random() < 0.2; +// Sample 10% of sessions +const SAMPLE_SESSION = Math.random() < 0.1; // TODO: replace this copy-pasted Segment init snippet with proper use of Segment package // https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/quickstart/#step-2-install-segment-to-your-site @@ -106,7 +111,6 @@ const initSegmentAnalytics = () => { options.integrations = { 'Segment.io': { apiHost: TELEMETRY_API_HOST } }; } analytics.load(TELEMETRY_API_KEY, options); - analytics.page(); // Make the first page call to load the integrations }; if (!SAMPLE_SESSION) {