From 1b0949c4b38f670bf0025ef0f528897c31fc4213 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Mon, 6 May 2024 16:51:11 -0700 Subject: [PATCH] Add partner telemetry flag (#10005) --- docfiles/pxtweb/cookieCompliance.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docfiles/pxtweb/cookieCompliance.ts b/docfiles/pxtweb/cookieCompliance.ts index 28d4c4bdf126..d2da3badfbed 100644 --- a/docfiles/pxtweb/cookieCompliance.ts +++ b/docfiles/pxtweb/cookieCompliance.ts @@ -9,6 +9,7 @@ namespace pxt { let analyticsLoaded = false; let interactiveConsent = false; let isProduction = false; + let partnerName: string; class TelemetryQueue { private q: [A, B, C][] = []; @@ -185,6 +186,16 @@ namespace pxt { } export function initializeAppInsightsInternal(includeCookie = false) { + try { + const params = new URLSearchParams(window.location.search); + if (params.has("partner")) { + partnerName = params.get("partner"); + } + } + catch (e) { + console.warn("Could not parse search string", e); + } + // loadAppInsights is defined in docfiles/tracking.html const loadAI = (window as any).loadAppInsights; if (loadAI) { @@ -221,6 +232,10 @@ namespace pxt { telemetryItem.properties["target"] = pxtConfig.targetId; telemetryItem.properties["stage"] = (pxtConfig.relprefix || "/--").replace(/[^a-z]/ig, '') + if (partnerName) { + telemetryItem.properties["partner"] = partnerName; + } + const userAgent = navigator.userAgent.toLowerCase(); const electronRegexResult = /\belectron\/(\d+\.\d+\.\d+.*?)(?: |$)/i.exec(userAgent); // Example navigator.userAgent: "Mozilla/5.0 Chrome/61.0.3163.100 Electron/2.0.0 Safari/537.36" if (electronRegexResult) {