From 77c3b90fdd7ac189bfaee2c3588c37b33ddeda45 Mon Sep 17 00:00:00 2001 From: Timothy Mothra Lee Date: Thu, 1 Mar 2018 09:56:58 -0800 Subject: [PATCH 1/2] update JS snippet with latest from github/applicationinsights-js --- .../Resources.resx | 21 +++++++++---------- .../ApplicationInsightsJavaScriptTest.cs | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.ApplicationInsights.AspNetCore/Resources.resx b/src/Microsoft.ApplicationInsights.AspNetCore/Resources.resx index 409a3ff2..9a6857be 100644 --- a/src/Microsoft.ApplicationInsights.AspNetCore/Resources.resx +++ b/src/Microsoft.ApplicationInsights.AspNetCore/Resources.resx @@ -121,17 +121,16 @@ appInsights.setAuthenticatedUserContext("{0}"); - <script type="text/javascript"> - var appInsights=window.appInsights||function(config){{ - function i(config){{t[config]=function(){{var i=arguments;t.queue.push(function(){{t[config].apply(t,i)}})}}}}var t={{config:config}},u=document,e=window,o="script",s="AuthenticatedUserContext",h="start",c="stop",l="Track",a=l+"Event",v=l+"Page",y=u.createElement(o),r,f;y.src=config.url||"https://az416426.vo.msecnd.net/scripts/a/ai.0.js";u.getElementsByTagName(o)[0].parentNode.appendChild(y);try{{t.cookie=u.cookie}}catch(p){{}}for(t.queue=[],t.version="1.0",r=["Event","Exception","Metric","PageView","Trace","Dependency"];r.length;)i("track"+r.pop());return i("set"+s),i("clear"+s),i(h+a),i(c+a),i(h+v),i(c+v),i("flush"),config.disableExceptionTracking||(r="onerror",i("_"+r),f=e[r],e[r]=function(config,i,u,e,o){{var s=f&&f(config,i,u,e,o);return s!==!0&&t["_"+r](config,i,u,e,o),s}}),t - }}({{ - instrumentationKey: '{0}' - }}); + <script type="text/javascript"> + + 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: '{0}' + }}); - window.appInsights=appInsights; - appInsights.trackPageView(); - {1} - </script> - + window.appInsights=appInsights,appInsights.queue&&0===appInsights.queue.length&&appInsights.trackPageView(); + {1} + </script> \ No newline at end of file diff --git a/test/Microsoft.ApplicationInsights.AspNetCore.Tests/JavaScript/ApplicationInsightsJavaScriptTest.cs b/test/Microsoft.ApplicationInsights.AspNetCore.Tests/JavaScript/ApplicationInsightsJavaScriptTest.cs index 679c918c..7cfdd5c3 100644 --- a/test/Microsoft.ApplicationInsights.AspNetCore.Tests/JavaScript/ApplicationInsightsJavaScriptTest.cs +++ b/test/Microsoft.ApplicationInsights.AspNetCore.Tests/JavaScript/ApplicationInsightsJavaScriptTest.cs @@ -67,7 +67,7 @@ public static void SnippetWillNotIncludeAuthUserNameIfEnabledAndAuthenticated() string unittestkey = "unittestkey"; var telemetryConfiguration = new TelemetryConfiguration { InstrumentationKey = unittestkey }; var snippet = new JavaScriptSnippet(telemetryConfiguration, GetOptions(true), GetHttpContextAccessor("username", false), encoder); - Assert.DoesNotContain("setAuthenticatedUserContext", snippet.FullScript); + Assert.DoesNotContain("appInsights.setAuthenticatedUserContext(", snippet.FullScript); } [Fact] From 2fc9cc42dbca7c2e52428613a981be947f146b08 Mon Sep 17 00:00:00 2001 From: Timothy Mothra Lee Date: Thu, 1 Mar 2018 10:03:47 -0800 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a860330..c96ab2f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## Version 2.3.0-beta1 +- Updated Javascript Snippet with latest from [Github/ApplicationInsights-JS](https://github.com/Microsoft/ApplicationInsights-JS) + ## Version 2.2.1 - Updated Web/Base SDK version dependency to 2.5.1 which addresses a bug.