-
Notifications
You must be signed in to change notification settings - Fork 242
/
Copy pathHelloWorld.html
239 lines (209 loc) · 19.5 KB
/
HelloWorld.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Home Page - HelloWorld</title>
<!-- <link rel="stylesheet" href="/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="/css/site.css" /> -->
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container">
<h1 class="display-4">Welcome</h1>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
<div class="text-center">
From your repository<br/>
Perform a full build <code>rush rebuild</code><br/>
Enable the test http server <code>npm run serve</code><br />
<a href="http://localhost:9001/AISKU/Tests/Manual/HelloWorld.html">Load this page from the local service</a>
<ul>
<li>Load in different browsers and ensure that the events are attempted to be sent</li>
<li>Use different browsers, Firefox, Chrome and Edge</li>
<li>Using Edge enable IE Mode</li>
<div>
Use IEChooser to debug and change the Emulation mode
<ul>
<li>Default IE 11</li>
<li>Default IE 10</li>
<li>Default IE 9</li>
<li>Default IE 8</li>
<li>Default IE 7 - This will fail due to no JSON implementation, the console should show a warning</li>
</ul>
</div>
</ul>
Note: The send attempt will fail, but you should see the outbound network attempt. If not debug the code and find out why!
</div>
<div>
<textarea id="log" style="width:45%; min-height: 400px;"></textarea>
<textarea id="cfg" style="width:50%; min-height: 400px;"></textarea>
</div>
<script>
//Promise = null;
var _message = {
log: "",
cfg: ""
};
function logMessage(message, dest, line) {
var dateTime = new Date().toLocaleString();
var target = dest || "log";
var elm = document.getElementById(target);
_message[target] = dateTime + ": " + message + "\n" + (line ? "------------------------\n" : "") + (_message[target] ||"");
if (_message[target].length > 4096) {
_message[target] = _message[target].substring(0, 4090) + "...\n";
}
elm.innerHTML = _message[target];
}
</script>
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> -->
<!-- <script src="file://./ai.2.8.0.js"></script> -->
<script src="http://localhost:9001/AISKU/browser/es5/ai.3.js"></script>
<!-- <script src="https://js.monitor.azure.com/scripts/b/ai.2.7.4.js" crossorigin="anonymous"></script> -->
<!-- <script src="https://js.monitor.azure.com/scripts/b/ai.2.8.0.js" crossorigin="anonymous"></script> -->
<!-- <script>
// Snippet v5
var enableDebug = true;
var instrumentationKey = "2bd72339-a683-4cce-8ed7-b1b0e8700000";
!function(T,l,y){var S=T.location,k="script",D="instrumentationKey",C="ingestionendpoint",I="disableExceptionTracking",E="ai.device.",b="toLowerCase",w="crossOrigin",N="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:"5",version:2,config:d};function v(e,t){var n={},a="Browser";return n[E+"id"]=a[b](),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,u,p,l;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<n.length;a++){var i=n[a].split("=");2===i.length&&(e[i[0][b]()]=i[1])}if(!e[C]){var r=e.endpointsuffix,o=r?e.location:null;e[C]="https://"+(o?o+".":"")+"dc."+(r||"services.visualstudio.com")}return e}(),c=s[D]||d[D]||"",u=s[C],p=u?u+"/v2/track":d.endpointUrl,(l=[]).push((n="SDK LOAD Failure: Failed to load Application Insights SDK script (See stack for details)",a=t,i=p,(o=(r=v(c,"Exception")).data).baseType="ExceptionData",o.baseData.exceptions=[{typeName:"SDKLoadFailed",message:n.replace(/\./g,"-"),hasFullStack:!1,stack:n+"\nSnippet failed to load ["+a+"] -- Telemetry is disabled\nHelp Link: https://go.microsoft.com/fwlink/?linkid=2128109\nHost: "+(S&&S.pathname||"_unknown_")+"\nEndpoint: "+i,parsedStack:[]}],r)),l.push(function(e,t,n,a){var i=v(c,"Message"),r=i.data;r.baseType="MessageData";var o=r.baseData;return o.message='AI (Internal): 99 message:"'+("SDK LOAD Failure: Failed to load Application Insights SDK script (See stack for details) ("+n+")").replace(/\"/g,"")+'"',o.properties={endpoint:a},i}(0,0,t,p)),function(e,t){if(JSON){var n=T.fetch;if(n&&!y.useXhr)n(t,{method:N,body:JSON.stringify(e),mode:"cors"});else if(XMLHttpRequest){var a=new XMLHttpRequest;a.open(N,t),a.setRequestHeader("Content-type","application/json"),a.send(JSON.stringify(e))}}}(l,p))}function i(e,t){f||setTimeout(function(){!t&&m.core||a()},500)}var e=function(){var n=l.createElement(k);n.src=h;var e=y[w];return!e&&""!==e||"undefined"==n[w]||(n[w]=e),n.onload=i,n.onerror=a,n.onreadystatechange=function(e,t){"loaded"!==n.readyState&&"complete"!==n.readyState||i(0,t)},n}();y.ld<0?l.getElementsByTagName("head")[0].appendChild(e):setTimeout(function(){l.getElementsByTagName(k)[0].parentNode.appendChild(e)},y.ld||0)}try{m.cookie=l.cookie}catch(p){}function t(e){for(;e.length;)!function(t){m[t]=function(){var e=arguments;g||m.queue.push(function(){m[t].apply(m,e)})}}(e.pop())}var n="track",r="TrackPage",o="TrackEvent";t([n+"Event",n+"PageView",n+"Exception",n+"Trace",n+"DependencyData",n+"Metric",n+"PageViewPerformance","start"+r,"stop"+r,"start"+o,"stop"+o,"addTelemetryInitializer","setAuthenticatedUserContext","clearAuthenticatedUserContext","flush"]),m.SeverityLevel={Verbose:0,Information:1,Warning:2,Error:3,Critical:4};var s=(d.extensionConfig||{}).ApplicationInsightsAnalytics||{};if(!0!==d[I]&&!0!==s[I]){var c="onerror";t(["_"+c]);var u=T[c];T[c]=function(e,t,n,a,i){var r=u&&u(e,t,n,a,i);return!0!==r&&m["_"+c]({message:e,url:t,lineNumber:n,columnNumber:a,error:i}),r},d.autoExceptionInstrumented=!0}return m}(y.cfg);function a(){y.onInit&&y.onInit(n)}(T[t]=n).queue&&0===n.queue.length?(n.queue.push(a),n.trackPageView({})):a()}(window,document,{
src: "http://localhost:9001/AISKU/browser/ai.2x.js", // The SDK URL Source
// name: "appInsights", // Global SDK Instance name defaults to "appInsights" when not supplied
// ld: 0, // Defines the load delay (in ms) before attempting to load the sdk. -1 = block page load and add to head. (default) = 0ms load after timeout,
// useXhr: 1, // Use XHR instead of fetch to report failures (if available),
// crossOrigin: "anonymous", // When supplied this will add the provided value as the cross origin attribute on the script tag
// onInit: null, // Once the application insights instance has loaded and initialized this callback function will be called with 1 argument - the sdk instance (DO NOT ADD anything to the sdk.queue - As they won't get called)
cfg: { // Application Insights Configuration
connectionString: "InstrumentationKey=" + instrumentationKey + ";IngestionEndpoint=http://localhost:9001",
//extensions: [reactPlugin],
enableDebug: true,
loggingLevelConsole: enableDebug ? 2 : 0,
loggingLevelTelemetry: enableDebug ? 2 : 1,
autoTrackPageVisitTime: true,
enableAutoRouteTracking: true,
enableDebugExceptions: enableDebug,
enableUnhandledPromiseRejectionTracking: true,
enableCorsCorrelation: false,
enableRequestHeaderTracking: true,
enableResponseHeaderTracking: true
}});
</script> -->
<script>
// Snippet v5
var enableDebug = true;
var instrumentationKey = "2bd72339-a683-4cce-8ed7-b1b0e8700000";
!(function (cfg){function e(){cfg.onInit&&cfg.onInit(a)}var v,y,T,t,n,a,k=window,S=document,D=k.location,C="script",x="ingestionendpoint",w="disableExceptionTracking",I="ai.device.";"instrumentationKey"[v="toLowerCase"](),y="crossOrigin",T="POST",t="appInsightsSDK",n=cfg.name||"appInsights",(cfg.name||k[t])&&(k[t]=n),a=k[n]||function(l){var u=!1,d=!1,g={initialize:!0,queue:[],sv:"7",version:2,config:l};function f(e,t){var n={},a="Browser";function i(e){e=""+e;return 1===e.length?"0"+e:e}return n[I+"id"]=a[v](),n[I+"type"]=a,n["ai.operation.name"]=D&&D.pathname||"_unknown_",n["ai.internal.sdkVersion"]="javascript:snippet_"+(g.sv||g.version),{time:(a=new Date).getUTCFullYear()+"-"+i(1+a.getUTCMonth())+"-"+i(a.getUTCDate())+"T"+i(a.getUTCHours())+":"+i(a.getUTCMinutes())+":"+i(a.getUTCSeconds())+"."+(a.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}},ver:4,seq:"1",aiDataContract:undefined}}var n,a,e,i,m=l.url||cfg.src;m&&((o=navigator)&&(~(o=(o.userAgent||"").toLowerCase()).indexOf("msie")||~o.indexOf("trident/"))&&~m.indexOf("ai.3")&&(m=m.replace(/(\/)(ai\.3\.)([^\d]*)$/,function(e,t,n){return t+"ai.2"+n})),n=function(e){var t,n,a,i,o,r,s,c,p;u=!0,g.queue=[],d||(d=!0,i=m,s=(c=function(){var e,t={},n=l.connectionString;if(n)for(var a=n.split(";"),i=0;i<a.length;i++){var o=a[i].split("=");2===o.length&&(t[o[0][v]()]=o[1])}return t[x]||(e=(n=t.endpointsuffix)?t.location:null,t[x]="https://"+(e?e+".":"")+"dc."+(n||"services.visualstudio.com")),t}()).instrumentationkey||l.instrumentationKey||"",c=(c=c[x])?c+"/v2/track":l.endpointUrl,(p=[]).push((t="SDK LOAD Failure: Failed to load Application Insights SDK script (See stack for details)",n=i,o=c,(r=(a=f(s,"Exception")).data).baseType="ExceptionData",r.baseData.exceptions=[{typeName:"SDKLoadFailed",message:t.replace(/\./g,"-"),hasFullStack:!1,stack:t+"\nSnippet failed to load ["+n+"] -- Telemetry is disabled\nHelp Link: https://go.microsoft.com/fwlink/?linkid=2128109\nHost: "+(D&&D.pathname||"_unknown_")+"\nEndpoint: "+o,parsedStack:[]}],a)),p.push((r=i,t=c,(o=(n=f(s,"Message")).data).baseType="MessageData",(a=o.baseData).message='AI (Internal): 99 message:"'+("SDK LOAD Failure: Failed to load Application Insights SDK script (See stack for details) ("+r+")").replace(/\"/g,"")+'"',a.properties={endpoint:t},n)),i=p,s=c,JSON&&((o=k.fetch)&&!cfg.useXhr?o(s,{method:T,body:JSON.stringify(i),mode:"cors"}):XMLHttpRequest&&((r=new XMLHttpRequest).open(T,s),r.setRequestHeader("Content-type","application/json"),r.send(JSON.stringify(i)))))},a=function(e,t){d||setTimeout(function(){!t&&g.core||n()},500)},(i=S.createElement(C)).src=m,!(o=cfg[y])&&""!==o||"undefined"==i[y]||(i[y]=o),i.onload=a,i.onerror=n,i.onreadystatechange=function(e,t){"loaded"!==i.readyState&&"complete"!==i.readyState||a(0,t)},e=i,cfg.ld&&cfg.ld<0?S.getElementsByTagName("head")[0].appendChild(e):setTimeout(function(){S.getElementsByTagName(C)[0].parentNode.appendChild(e)},cfg.ld||0));try{g.cookie=S.cookie}catch(h){}function t(e){for(;e.length;)!function(t){g[t]=function(){var e=arguments;u||g.queue.push(function(){g[t].apply(g,e)})}}(e.pop())}var r,s,o="track",c="TrackPage",p="TrackEvent",o=(t([o+"Event",o+"PageView",o+"Exception",o+"Trace",o+"DependencyData",o+"Metric",o+"PageViewPerformance","start"+c,"stop"+c,"start"+p,"stop"+p,"addTelemetryInitializer","setAuthenticatedUserContext","clearAuthenticatedUserContext","flush"]),g.SeverityLevel={Verbose:0,Information:1,Warning:2,Error:3,Critical:4},(l.extensionConfig||{}).ApplicationInsightsAnalytics||{});return!0!==l[w]&&!0!==o[w]&&(t(["_"+(r="onerror")]),s=k[r],k[r]=function(e,t,n,a,i){var o=s&&s(e,t,n,a,i);return!0!==o&&g["_"+r]({message:e,url:t,lineNumber:n,columnNumber:a,error:i,evt:k.event}),o},l.autoExceptionInstrumented=!0),g}(cfg.cfg),(k[n]=a).queue&&0===a.queue.length?(a.queue.push(e),a.trackPageView({})):e();})({
src: "http://localhost:9001/AISKU/browser/ai.2x.js", // The SDK URL Source
// name: "appInsights", // Global SDK Instance name defaults to "appInsights" when not supplied
// ld: 0, // Defines the load delay (in ms) before attempting to load the sdk. -1 = block page load and add to head. (default) = 0ms load after timeout,
// useXhr: 1, // Use XHR instead of fetch to report failures (if available),
// crossOrigin: "anonymous", // When supplied this will add the provided value as the cross origin attribute on the script tag
// onInit: null, // Once the application insights instance has loaded and initialized this callback function will be called with 1 argument -- the sdk instance (DO NOT ADD anything to the sdk.queue -- As they won't get called)
cfg: { // Application Insights Configuration
connectionString: "InstrumentationKey=" + instrumentationKey + ";IngestionEndpoint=http://localhost:9001",
//extensions: [reactPlugin],
enableDebug: true,
loggingLevelConsole: enableDebug ? 2 : 0,
loggingLevelTelemetry: enableDebug ? 2 : 1,
autoTrackPageVisitTime: true,
enableAutoRouteTracking: true,
enableDebugExceptions: enableDebug,
enableUnhandledPromiseRejectionTracking: true,
enableCorsCorrelation: false,
enableRequestHeaderTracking: true,
enableResponseHeaderTracking: true
}
});
</script>
<script>
//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"),t.SeverityLevel={Verbose:0,Information:1,Warning:2,Error:3,Critical:4},!(!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}(
// {
// instrumentationKey: "2bd72339-a683-4cce-8ed7-b1b0e8767295"
// }
//); window[aiName] = aisdk, aisdk.queue && 0 === aisdk.queue.length && aisdk.trackPageView({});
// 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.8.0.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"),t.SeverityLevel={Verbose:0,Information:1,Warning:2,Error:3,Critical:4},!(!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}(
// {
// url: "./ai.2.8.0.js",
// instrumentationKey: "2bd72339-a683-4cce-8ed7-b1b0e8767295",
// enableCorsCorrelation: true,
// enableApplicationInsightsTrace: true
// }
// ); window[aiName] = aisdk;
// if (aisdk.queue && aisdk.queue.length === 0) {
// setTimeout(function() {
// aisdk.properties.context.telemetryTrace.traceID = "<server operation id>"
// aisdk.properties.context.telemetryTrace.parentID = "<server request id>"
// aisdk.properties.context.telemetryTrace.name = "<server operation name>"
// aisdk.trackPageView();
// }, 100);
// }
var enableDebug = true;
var instrumentationKey = "2bd72339-a683-4cce-8ed7-b1b0e8700000";
var appInsights = new Microsoft.ApplicationInsights.ApplicationInsights({
config: {
instrumentationKey: instrumentationKey,
endpointUrl: "http://localhost:9001/v2/track",
//extensions: [reactPlugin],
enableDebug: false,
loggingLevelConsole: enableDebug ? 2 : 0,
loggingLevelTelemetry: enableDebug ? 2 : 1,
autoTrackPageVisitTime: true,
enableAutoRouteTracking: true,
enableDebugExceptions: enableDebug,
enableUnhandledPromiseRejectionTracking: true,
enableCorsCorrelation: false,
enableRequestHeaderTracking: true,
enableResponseHeaderTracking: true,
hello: "World"
}
});
appInsights.onCfgChange(function (details) {
logMessage("onCfgChange 1 - called", null, true);
logMessage("endpointUrl: " + details.cfg.endpointUrl);
});
appInsights.onCfgChange(function (details) {
logMessage("onCfgChange 2 - called", null, true);
logMessage("instrumentationKey: " + details.cfg.instrumentationKey);
});
appInsights.onCfgChange(function (details) {
logMessage(JSON.stringify(details.cfg, stringifyReplacer, 4), "cfg");
logMessage("onCfgChange 3 - called", "cfg");
});
appInsights.onCfgChange(function (details) {
logMessage("onCfgChange 4 - called", null, true);
if (details.cfg.enableDebug) {
logMessage("Debug Enable - " + details.cfg.loggingLevelConsole);
} else {
logMessage("Debug Not enabled!");
}
});
appInsights.loadAppInsights();
appInsights.trackPageView();
function stringifyReplacer(name, value) {
if (name === "extensions" || name === "channels") {
return "[... (" + (value ? value.length : 0) + ") ...]";
}
return value;
}
//$.ajax({
// url: "https://www.mocky.io/v2/5185415ba171ea3a00704eed",
// type: 'GET',
// dataType: 'json', // added data type
// success: function(res) {
// console.log(res.hello);
// alert(res.hello);
// }
//});
</script>
</main>
</div>
<footer class="border-top footer text-muted">
<div class="container">
© 2019 - HelloWorld
</div>
</footer>
</body>
</html>