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.
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]