Skip to content

Commit e449934

Browse files
committed
Merged PR 107786: Fix app insights
Fix app insights
1 parent 3805c43 commit e449934

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

demo/v2-demo/scripts/aisdk.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
const appUrl = 'https://powerbiplaygroundbe.azurewebsites.net/App';
2+
const appUrlEnabled = false;
3+
const defaultInstrumentationKey = "ffe7093c-af96-4df9-8452-b9f4b35ccded";
24

35
var appInsightsInstanceDeferred = $.Deferred();
46

5-
$.getJSON(appUrl, function (appConfig) {
7+
if (appUrlEnabled) {
8+
$.getJSON(appUrl, function (appConfig) {
9+
createAppInsightsInstance(appConfig.instrumentationKey);
10+
});
11+
}
12+
else {
13+
createAppInsightsInstance(defaultInstrumentationKey);
14+
}
15+
16+
function createAppInsightsInstance(instrumentationKey) {
617
// Application Insights setup
718
var sdkInstance="appInsightsSDK";window[sdkInstance]="appInsights";var aiName=window[sdkInstance],aisdk=window[aiName]||function(e){function n(e){t[e]=function(){var n=arguments;t.queue.push(function(){t[e].apply(t,n)})}}var t={config:e};t.initialize=!0;var i=document,a=window;setTimeout(function(){var n=i.createElement("script");n.src=e.url||"https://az416426.vo.msecnd.net/scripts/b/ai.2.min.js",i.getElementsByTagName("script")[0].parentNode.appendChild(n)});try{t.cookie=i.cookie}catch(e){}t.queue=[],t.version=2;for(var r=["Event","PageView","Exception","Trace","DependencyData","Metric","PageViewPerformance"];r.length;)n("track"+r.pop());n("startTrackPage"),n("stopTrackPage");var s="Track"+r[0];if(n("start"+s),n("stop"+s),n("addTelemetryInitializer"),n("setAuthenticatedUserContext"),n("clearAuthenticatedUserContext"),n("flush"),!(!0===e.disableExceptionTracking||e.extensionConfig&&e.extensionConfig.ApplicationInsightsAnalytics&&!0===e.extensionConfig.ApplicationInsightsAnalytics.disableExceptionTracking)){n("_"+(r="onerror"));var o=a[r];a[r]=function(e,n,i,a,s){var c=o&&o(e,n,i,a,s);return!0!==c&&t["_"+r]({message:e,url:n,lineNumber:i,columnNumber:a,error:s}),c},e.autoExceptionInstrumented=!0}return t}(
8-
{
9-
instrumentationKey: appConfig.instrumentationKey
10-
}
11-
);window[aiName]=aisdk,aisdk.queue&&0===aisdk.queue.length&&aisdk.trackPageView({});
19+
{
20+
instrumentationKey: instrumentationKey
21+
}
22+
);window[aiName]=aisdk,aisdk.queue&&0===aisdk.queue.length&&aisdk.trackPageView({});
1223

13-
appInsightsInstanceDeferred.resolve(appInsights);
14-
});
24+
appInsightsInstanceDeferred.resolve(appInsights);
25+
}
1526

1627
function getAppInsightsInstance() {
1728
return appInsightsInstanceDeferred;

0 commit comments

Comments
 (0)