diff --git a/samples/js-application-appinsights-advanced/package.json b/samples/js-application-appinsights-advanced/package.json index 46d30aa3a..7f330565b 100644 --- a/samples/js-application-appinsights-advanced/package.json +++ b/samples/js-application-appinsights-advanced/package.json @@ -12,8 +12,8 @@ "test": "gulp test" }, "dependencies": { - "@microsoft/applicationinsights-react-js": "^2.5.4", - "@microsoft/applicationinsights-web": "^2.5.4", + "@microsoft/applicationinsights-react-js": "^3.0.3", + "@microsoft/applicationinsights-web": "^2.5.8", "@microsoft/decorators": "1.10.0", "@microsoft/sp-application-base": "1.10.0", "@microsoft/sp-core-library": "1.10.0", diff --git a/samples/js-application-appinsights/src/extensions/appInsights/AppInsightsApplicationCustomizer.ts b/samples/js-application-appinsights/src/extensions/appInsights/AppInsightsApplicationCustomizer.ts index bfe952001..f0da74e91 100644 --- a/samples/js-application-appinsights/src/extensions/appInsights/AppInsightsApplicationCustomizer.ts +++ b/samples/js-application-appinsights/src/extensions/appInsights/AppInsightsApplicationCustomizer.ts @@ -20,12 +20,15 @@ export default class AppInsightsApplicationCustomizer public onInit(): Promise { Log.info(LOG_SOURCE, `Initialized ${strings.Title}`); - let appInsightsScript: string = `var appInsights=window.appInsights||function(a){ - function b(a){c[a]=function(){var b=arguments;c.queue.push(function(){c[a].apply(c,b)})}}var c={config:a},d=document,e=window;setTimeout(function(){var b=d.createElement("script");b.src=a.url||"https://az416426.vo.msecnd.net/scripts/a/ai.0.js",d.getElementsByTagName("script")[0].parentNode.appendChild(b)});try{c.cookie=d.cookie}catch(a){}c.queue=[];for(var f=["Event","Exception","Metric","PageView","Trace","Dependency"];f.length;)b("track"+f.pop());if(b("setAuthenticatedUserContext"),b("clearAuthenticatedUserContext"),b("startTrackEvent"),b("stopTrackEvent"),b("startTrackPage"),b("stopTrackPage"),b("flush"),!a.disableExceptionTracking){f="onerror",b("_"+f);var g=e[f];e[f]=function(a,b,d,e,h){var i=g&&g(a,b,d,e,h);return!0!==i&&c["_"+f](a,b,d,e,h),i}}return c - }({ - instrumentationKey: "` + this.properties.appInsightsKey + `" - }); - window.appInsights=appInsights,appInsights.queue&&0===appInsights.queue.length&&appInsights.trackPageView();`; + let appInsightsScript: string = `!function(T,l,y){var S=T.location,u="script",k="instrumentationKey",D="ingestionendpoint",C="disableExceptionTracking",E="ai.device.",I="toLowerCase",b="crossOrigin",w="POST",e="appInsightsSDK",t=y.name||"appInsights";(y.name||T[e])&&(T[e]=t);var n=T[t]||function(d){var g=!1,f=!1,m={initialize:!0,queue:[],sv:"4",version:2,config:d};function v(e,t){var n={},a="Browser";return n[E+"id"]=a[I](),n[E+"type"]=a,n["ai.operation.name"]=S&&S.pathname||"_unknown_",n["ai.internal.sdkVersion"]="javascript:snippet_"+(m.sv||m.version),{time:function(){var e=new Date;function t(e){var t=""+e;return 1===t.length&&(t="0"+t),t}return e.getUTCFullYear()+"-"+t(1+e.getUTCMonth())+"-"+t(e.getUTCDate())+"T"+t(e.getUTCHours())+":"+t(e.getUTCMinutes())+":"+t(e.getUTCSeconds())+"."+((e.getUTCMilliseconds()/1e3).toFixed(3)+"").slice(2,5)+"Z"}(),iKey:e,name:"Microsoft.ApplicationInsights."+e.replace(/-/g,"")+"."+t,sampleRate:100,tags:n,data:{baseData:{ver:2}}}}var h=d.url||y.src;if(h){function a(e){var t,n,a,i,r,o,s,c,p,l,u;g=!0,m.queue=[],f||(f=!0,t=h,s=function(){var e={},t=d.connectionString;if(t)for(var n=t.split(";"),a=0;a