Skip to content

Commit

Permalink
Add partner telemetry flag (#10005)
Browse files Browse the repository at this point in the history
  • Loading branch information
riknoll authored May 6, 2024
1 parent 4566652 commit 1b0949c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docfiles/pxtweb/cookieCompliance.ts
Original file line number Diff line number Diff line change
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 @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 1b0949c

Please sign in to comment.