Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Stable9.0] Cherry pick "Add partner telemetry flag" (#10005) #10006

Merged
merged 1 commit into from
May 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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
Loading