Skip to content

Commit

Permalink
name difference fix (#2445)
Browse files Browse the repository at this point in the history
  • Loading branch information
siyuniu-ms authored Nov 11, 2024
1 parent f8b6d94 commit 3dc9e3c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions tools/applicationinsights-web-snippet/src/1dsSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ let capturePage = "capturePage";
export const oneDsMethods = [
track + "Event",
track + "Exception",
trackPage + "View",
trackPage + "ViewPerformance",
track + "PageView",
track + "PageViewPerformance",
"addTelemetryInitializer",
track,
trackPage + "Action",
Expand Down
4 changes: 2 additions & 2 deletions tools/applicationinsights-web-snippet/src/aiSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ let trackEvent = "TrackEvent";
export const aiMethod = [
track + "Event",
track + "Exception",
trackPage + "View",
trackPage + "ViewPerformance",
track + "PageView",
track + "PageViewPerformance",
"addTelemetryInitializer",
track + "Trace",
track + "DependencyData",
Expand Down
26 changes: 15 additions & 11 deletions tools/applicationinsights-web-snippet/src/snippet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,33 @@ declare var cfg:ISnippetConfig;
let sdkInstanceName:string;
let aiName:string;


if (isOneDS){
sdkInstanceName = "onedsSDK";
aiName = cfg.name || "oneDSWeb"; // provide non default instance name through snipConfig name value
} else {
sdkInstanceName = "appInsightsSDK";
aiName = cfg.name || "appInsights";
}

if (cfg.name || win[sdkInstanceName]) {
// Only set if supplied or another name is defined to avoid polluting the global namespace
win[sdkInstanceName] = aiName;
}

let aiSdk = win[aiName] || (function (aiConfig: IConfiguration & IConfig , aiExtensions?: any) {
let targetSrc : string = (aiConfig as any)["url"] || cfg.src;
if (isOneDS){
sdkInstanceName = "onedsSDK";
aiName = cfg.name || "oneDSWeb"; // provide non default instance name through snipConfig name value
} else {
sdkInstanceName = "appInsightsSDK";
aiName = cfg.name || "appInsights";
}


let loadFailed = false;
let handled = false;
let appInsights: (Snippet & {cookie?:any, core?:any, extensions?:any, initialize?: boolean, isInitialized?: () => boolean;}) = null;
appInsights= {
let appInsights: (Snippet & {cookie?:any, core?:any, extensions?:any, initialize?: boolean, isInitialized?: () => boolean;}) = {
initialize: true, // initialize sdk on download
queue: [],
sv: "8", // Track the actual snippet version for reporting.
config: aiConfig,
extensions: aiExtensions,
initialize: true // initialize sdk on download
version: 2.0,
extensions: aiExtensions
};

if (isOneDS && !aiConfig["webAnalyticsConfiguration"]){
Expand Down

0 comments on commit 3dc9e3c

Please sign in to comment.