Skip to content

Commit

Permalink
Add partner telemetry flag (#10005) (#10006)
Browse files Browse the repository at this point in the history
  • Loading branch information
riknoll committed May 7, 2024
1 parent 7292631 commit a13ef72
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docfiles/pxtweb/cookieCompliance.ts
Expand Up @@ -9,6 +9,7 @@ namespace pxt {
let analyticsLoaded = false;
let interactiveConsent = false;
let isProduction = false;
let partnerName: string;

class TelemetryQueue<A, B, C> {
private q: [A, B, C][] = [];
Expand Down Expand Up @@ -176,6 +177,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) {
Expand Down Expand Up @@ -212,6 +223,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 userAgentRegexResult = /\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 (userAgentRegexResult) {
Expand Down

0 comments on commit a13ef72

Please sign in to comment.