-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathai.0.15.0-build58334.js
2646 lines (2646 loc) · 133 KB
/
ai.0.15.0-build58334.js
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
var Microsoft;
(function (Microsoft) {
var ApplicationInsights;
(function (ApplicationInsights) {
(function (LoggingSeverity) {
LoggingSeverity[LoggingSeverity["CRITICAL"] = 0] = "CRITICAL";
LoggingSeverity[LoggingSeverity["WARNING"] = 1] = "WARNING";
})(ApplicationInsights.LoggingSeverity || (ApplicationInsights.LoggingSeverity = {}));
var LoggingSeverity = ApplicationInsights.LoggingSeverity;
var _InternalLogging = (function () {
function _InternalLogging() {
}
_InternalLogging.throwInternalNonUserActionable = function (severity, message) {
if (this.enableDebugExceptions()) {
throw message;
}
else {
this.warnToConsole(message);
this.logInternalMessage(severity, this.AiNonUserActionablePrefix + message);
}
};
_InternalLogging.throwInternalUserActionable = function (severity, message) {
if (this.enableDebugExceptions()) {
throw message;
}
else {
this.warnToConsole(message);
this.logInternalMessage(severity, this.AiUserActionablePrefix + message);
}
};
_InternalLogging.warnToConsole = function (message) {
if (typeof console !== "undefined" && !!console) {
if (typeof console.warn === "function") {
console.warn(message);
}
else if (typeof console.log === "function") {
console.log(message);
}
}
};
_InternalLogging.resetInternalMessageCount = function () {
this._messageCount = 0;
};
_InternalLogging.setMaxInternalMessageLimit = function (limit) {
if (!limit) {
throw new Error('limit cannot be undefined.');
}
this.MAX_INTERNAL_MESSAGE_LIMIT = limit;
};
_InternalLogging.logInternalMessage = function (severity, message) {
if (this._areInternalMessagesThrottled()) {
return;
}
if (this.verboseLogging() || severity === 0 /* CRITICAL */) {
this.queue.push(message);
this._messageCount++;
}
if (this._messageCount == this.MAX_INTERNAL_MESSAGE_LIMIT) {
var throttleLimitMessage = this.AiNonUserActionablePrefix + "Internal events throttle limit per PageView reached for this app.";
this.queue.push(throttleLimitMessage);
this.warnToConsole(throttleLimitMessage);
}
};
_InternalLogging._areInternalMessagesThrottled = function () {
return this._messageCount >= this.MAX_INTERNAL_MESSAGE_LIMIT;
};
_InternalLogging.AiUserActionablePrefix = "AI: ";
_InternalLogging.AiNonUserActionablePrefix = "AI (Internal): ";
_InternalLogging.enableDebugExceptions = function () { return false; };
_InternalLogging.verboseLogging = function () { return false; };
_InternalLogging.queue = [];
_InternalLogging.MAX_INTERNAL_MESSAGE_LIMIT = 25;
_InternalLogging._messageCount = 0;
return _InternalLogging;
})();
ApplicationInsights._InternalLogging = _InternalLogging;
})(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
})(Microsoft || (Microsoft = {}));
var Microsoft;
(function (Microsoft) {
var ApplicationInsights;
(function (ApplicationInsights) {
var Util = (function () {
function Util() {
}
Util._getStorageObject = function () {
try {
if (window.localStorage) {
return window.localStorage;
}
else {
return null;
}
}
catch (e) {
ApplicationInsights._InternalLogging.warnToConsole('Failed to get client localStorage: ' + e.message);
return null;
}
};
Util.canUseLocalStorage = function () {
return !!Util._getStorageObject();
};
Util.getStorage = function (name) {
var storage = Util._getStorageObject();
if (storage !== null) {
try {
return storage.getItem(name);
}
catch (e) {
ApplicationInsights._InternalLogging.throwInternalNonUserActionable(1 /* WARNING */, "Browser failed read of local storage." + Util.dump(e));
}
}
return null;
};
Util.setStorage = function (name, data) {
var storage = Util._getStorageObject();
if (storage !== null) {
try {
storage.setItem(name, data);
return true;
}
catch (e) {
ApplicationInsights._InternalLogging.throwInternalNonUserActionable(1 /* WARNING */, "Browser failed write to local storage." + Util.dump(e));
}
}
return false;
};
Util.removeStorage = function (name) {
var storage = Util._getStorageObject();
if (storage !== null) {
try {
storage.removeItem(name);
return true;
}
catch (e) {
ApplicationInsights._InternalLogging.throwInternalNonUserActionable(1 /* WARNING */, "Browser failed removal of local storage item." + Util.dump(e));
}
}
return false;
};
Util._getSessionStorageObject = function () {
try {
if (window.sessionStorage) {
return window.sessionStorage;
}
else {
return null;
}
}
catch (e) {
ApplicationInsights._InternalLogging.warnToConsole('Failed to get client session storage: ' + e.message);
return null;
}
};
Util.canUseSessionStorage = function () {
return !!Util._getSessionStorageObject();
};
Util.getSessionStorage = function (name) {
var storage = Util._getSessionStorageObject();
if (storage !== null) {
try {
return storage.getItem(name);
}
catch (e) {
ApplicationInsights._InternalLogging.throwInternalNonUserActionable(0 /* CRITICAL */, "Browser failed read of session storage." + Util.dump(e));
}
}
return null;
};
Util.setSessionStorage = function (name, data) {
var storage = Util._getSessionStorageObject();
if (storage !== null) {
try {
storage.setItem(name, data);
return true;
}
catch (e) {
ApplicationInsights._InternalLogging.throwInternalNonUserActionable(0 /* CRITICAL */, "Browser failed write to session storage." + Util.dump(e));
}
}
return false;
};
Util.removeSessionStorage = function (name) {
var storage = Util._getSessionStorageObject();
if (storage !== null) {
try {
storage.removeItem(name);
return true;
}
catch (e) {
ApplicationInsights._InternalLogging.throwInternalNonUserActionable(0 /* CRITICAL */, "Browser failed removal of session storage item." + Util.dump(e));
}
}
return false;
};
Util.setCookie = function (name, value) {
Util.document.cookie = name + "=" + value + ";path=/";
};
Util.stringToBoolOrDefault = function (str) {
if (!str) {
return false;
}
return str.toString().toLowerCase() === "true";
};
Util.getCookie = function (name) {
var value = "";
if (name && name.length) {
var cookieName = name + "=";
var cookies = Util.document.cookie.split(";");
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i];
cookie = Util.trim(cookie);
if (cookie && cookie.indexOf(cookieName) === 0) {
value = cookie.substring(cookieName.length, cookies[i].length);
break;
}
}
}
return value;
};
Util.deleteCookie = function (name) {
Util.document.cookie = name + "=;path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;";
};
Util.trim = function (str) {
if (typeof str !== "string")
return str;
return str.replace(/^\s+|\s+$/g, "");
};
Util.newGuid = function () {
var hexValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"];
var oct = "", tmp;
for (var a = 0; a < 4; a++) {
tmp = (4294967296 * Math.random()) | 0;
oct += hexValues[tmp & 0xF] + hexValues[tmp >> 4 & 0xF] + hexValues[tmp >> 8 & 0xF] + hexValues[tmp >> 12 & 0xF] + hexValues[tmp >> 16 & 0xF] + hexValues[tmp >> 20 & 0xF] + hexValues[tmp >> 24 & 0xF] + hexValues[tmp >> 28 & 0xF];
}
var clockSequenceHi = hexValues[8 + (Math.random() * 4) | 0];
return oct.substr(0, 8) + "-" + oct.substr(9, 4) + "-4" + oct.substr(13, 3) + "-" + clockSequenceHi + oct.substr(16, 3) + "-" + oct.substr(19, 12);
};
Util.isArray = function (obj) {
return Object.prototype.toString.call(obj) === "[object Array]";
};
Util.isError = function (obj) {
return Object.prototype.toString.call(obj) === "[object Error]";
};
Util.isDate = function (obj) {
return Object.prototype.toString.call(obj) === "[object Date]";
};
Util.toISOStringForIE8 = function (date) {
if (Util.isDate(date)) {
if (Date.prototype.toISOString) {
return date.toISOString();
}
else {
function pad(number) {
var r = String(number);
if (r.length === 1) {
r = "0" + r;
}
return r;
}
return date.getUTCFullYear() + "-" + pad(date.getUTCMonth() + 1) + "-" + pad(date.getUTCDate()) + "T" + pad(date.getUTCHours()) + ":" + pad(date.getUTCMinutes()) + ":" + pad(date.getUTCSeconds()) + "." + String((date.getUTCMilliseconds() / 1000).toFixed(3)).slice(2, 5) + "Z";
}
}
};
Util.msToTimeSpan = function (totalms) {
if (isNaN(totalms) || totalms < 0) {
totalms = 0;
}
var ms = "" + totalms % 1000;
var sec = "" + Math.floor(totalms / 1000) % 60;
var min = "" + Math.floor(totalms / (1000 * 60)) % 60;
var hour = "" + Math.floor(totalms / (1000 * 60 * 60)) % 24;
ms = ms.length === 1 ? "00" + ms : ms.length === 2 ? "0" + ms : ms;
sec = sec.length < 2 ? "0" + sec : sec;
min = min.length < 2 ? "0" + min : min;
hour = hour.length < 2 ? "0" + hour : hour;
return hour + ":" + min + ":" + sec + "." + ms;
};
Util.isCrossOriginError = function (message, url, lineNumber, columnNumber, error) {
return (message == "Script error." || message == "Script error") && url == "" && lineNumber == 0 && columnNumber == 0 && error == null;
};
Util.dump = function (object) {
var objectTypeDump = Object.prototype.toString.call(object);
var propertyValueDump = JSON.stringify(object);
if (objectTypeDump === "[object Error]") {
propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
}
return objectTypeDump + propertyValueDump;
};
Util.addEventHandler = function (eventName, callback) {
if (!window || typeof eventName !== 'string' || typeof callback !== 'function') {
return false;
}
var verbEventName = 'on' + eventName;
if (window.addEventListener) {
window.addEventListener(eventName, callback, false);
}
else if (window.attachEvent) {
window.attachEvent(verbEventName, callback);
}
else {
return false;
}
return true;
};
Util.document = typeof document !== "undefined" ? document : {};
Util.NotSpecified = "not_specified";
return Util;
})();
ApplicationInsights.Util = Util;
})(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
})(Microsoft || (Microsoft = {}));
var Microsoft;
(function (Microsoft) {
var ApplicationInsights;
(function (ApplicationInsights) {
"use strict";
var Serializer = (function () {
function Serializer() {
}
Serializer.serialize = function (input) {
var output = Serializer._serializeObject(input, "root");
return JSON.stringify(output);
};
Serializer._serializeObject = function (source, name) {
var circularReferenceCheck = "__aiCircularRefCheck";
var output = {};
if (!source) {
ApplicationInsights._InternalLogging.throwInternalUserActionable(0 /* CRITICAL */, "cannot serialize " + name + " because it is null or undefined");
return output;
}
if (source[circularReferenceCheck]) {
ApplicationInsights._InternalLogging.throwInternalUserActionable(1 /* WARNING */, "Circular reference detected while serializing: '" + name);
return output;
}
if (!source.aiDataContract) {
if (name === "measurements") {
output = Serializer._serializeStringMap(source, "number", name);
}
else if (name === "properties") {
output = Serializer._serializeStringMap(source, "string", name);
}
else if (name === "tags") {
output = Serializer._serializeStringMap(source, "string", name);
}
else if (ApplicationInsights.Util.isArray(source)) {
output = Serializer._serializeArray(source, name);
}
else {
ApplicationInsights._InternalLogging.throwInternalUserActionable(1 /* WARNING */, "Attempting to serialize an object which does not implement ISerializable: " + name);
try {
JSON.stringify(source);
output = source;
}
catch (e) {
ApplicationInsights._InternalLogging.throwInternalUserActionable(0 /* CRITICAL */, e && typeof e.toString === 'function' ? e.toString() : "Error serializing object");
}
}
return output;
}
source[circularReferenceCheck] = true;
for (var field in source.aiDataContract) {
var isRequired = source.aiDataContract[field];
var isArray = typeof isRequired !== "boolean";
var isPresent = source[field] !== undefined;
var isObject = typeof source[field] === "object" && source[field] !== null;
if (isRequired && !isPresent && !isArray) {
ApplicationInsights._InternalLogging.throwInternalNonUserActionable(0 /* CRITICAL */, "Missing required field specification: The field '" + field + "' on '" + name + "' is required but not present on source");
continue;
}
var value;
if (isObject) {
if (isArray) {
value = Serializer._serializeArray(source[field], field);
}
else {
value = Serializer._serializeObject(source[field], field);
}
}
else {
value = source[field];
}
if (value !== undefined) {
output[field] = value;
}
}
delete source[circularReferenceCheck];
return output;
};
Serializer._serializeArray = function (sources, name) {
var output = undefined;
if (!!sources) {
if (!ApplicationInsights.Util.isArray(sources)) {
ApplicationInsights._InternalLogging.throwInternalUserActionable(0 /* CRITICAL */, "This field was specified as an array in the contract but the item is not an array.\r\n" + name);
}
else {
output = [];
for (var i = 0; i < sources.length; i++) {
var source = sources[i];
var item = Serializer._serializeObject(source, name + "[" + i + "]");
output.push(item);
}
}
}
return output;
};
Serializer._serializeStringMap = function (map, expectedType, name) {
var output = undefined;
if (map) {
output = {};
for (var field in map) {
var value = map[field];
if (expectedType === "string") {
if (value === undefined) {
output[field] = "undefined";
}
else if (value === null) {
output[field] = "null";
}
else if (!value.toString) {
output[field] = "invalid field: toString() is not defined.";
}
else {
output[field] = value.toString();
}
}
else if (expectedType === "number") {
if (value === undefined) {
output[field] = "undefined";
}
else if (value === null) {
output[field] = "null";
}
else {
var num = parseFloat(value);
if (isNaN(num)) {
output[field] = "NaN";
}
else {
output[field] = num;
}
}
}
else {
output[field] = "invalid field: " + name + " is of unknown type.";
ApplicationInsights._InternalLogging.throwInternalUserActionable(0 /* CRITICAL */, output[field]);
}
}
}
return output;
};
return Serializer;
})();
ApplicationInsights.Serializer = Serializer;
})(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
})(Microsoft || (Microsoft = {}));
var Microsoft;
(function (Microsoft) {
var Telemetry;
(function (Telemetry) {
"use strict";
var Base = (function () {
function Base() {
}
return Base;
})();
Telemetry.Base = Base;
})(Telemetry = Microsoft.Telemetry || (Microsoft.Telemetry = {}));
})(Microsoft || (Microsoft = {}));
var Microsoft;
(function (Microsoft) {
var Telemetry;
(function (Telemetry) {
"use strict";
var Envelope = (function () {
function Envelope() {
this.ver = 1;
this.sampleRate = 100.0;
this.tags = {};
}
return Envelope;
})();
Telemetry.Envelope = Envelope;
})(Telemetry = Microsoft.Telemetry || (Microsoft.Telemetry = {}));
})(Microsoft || (Microsoft = {}));
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Microsoft;
(function (Microsoft) {
var ApplicationInsights;
(function (ApplicationInsights) {
var Telemetry;
(function (Telemetry) {
var Common;
(function (Common) {
"use strict";
var Envelope = (function (_super) {
__extends(Envelope, _super);
function Envelope(data, name) {
_super.call(this);
this.name = name;
this.data = data;
this.time = ApplicationInsights.Util.toISOStringForIE8(new Date());
this.aiDataContract = {
time: true,
iKey: true,
name: true,
tags: true,
data: true
};
}
return Envelope;
})(Microsoft.Telemetry.Envelope);
Common.Envelope = Envelope;
})(Common = Telemetry.Common || (Telemetry.Common = {}));
})(Telemetry = ApplicationInsights.Telemetry || (ApplicationInsights.Telemetry = {}));
})(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
})(Microsoft || (Microsoft = {}));
var Microsoft;
(function (Microsoft) {
var ApplicationInsights;
(function (ApplicationInsights) {
var Telemetry;
(function (Telemetry) {
var Common;
(function (Common) {
"use strict";
var Base = (function (_super) {
__extends(Base, _super);
function Base() {
_super.apply(this, arguments);
this.aiDataContract = {};
}
return Base;
})(Microsoft.Telemetry.Base);
Common.Base = Base;
})(Common = Telemetry.Common || (Telemetry.Common = {}));
})(Telemetry = ApplicationInsights.Telemetry || (ApplicationInsights.Telemetry = {}));
})(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
})(Microsoft || (Microsoft = {}));
var AI;
(function (AI) {
"use strict";
var ContextTagKeys = (function () {
function ContextTagKeys() {
this.applicationVersion = "ai.application.ver";
this.applicationBuild = "ai.application.build";
this.applicationTypeId = "ai.application.typeId";
this.deviceId = "ai.device.id";
this.deviceIp = "ai.device.ip";
this.deviceLanguage = "ai.device.language";
this.deviceLocale = "ai.device.locale";
this.deviceModel = "ai.device.model";
this.deviceNetwork = "ai.device.network";
this.deviceNetworkName = "ai.device.networkName";
this.deviceOEMName = "ai.device.oemName";
this.deviceOS = "ai.device.os";
this.deviceOSVersion = "ai.device.osVersion";
this.deviceRoleInstance = "ai.device.roleInstance";
this.deviceRoleName = "ai.device.roleName";
this.deviceScreenResolution = "ai.device.screenResolution";
this.deviceType = "ai.device.type";
this.deviceMachineName = "ai.device.machineName";
this.deviceVMName = "ai.device.vmName";
this.locationIp = "ai.location.ip";
this.operationId = "ai.operation.id";
this.operationName = "ai.operation.name";
this.operationParentId = "ai.operation.parentId";
this.operationRootId = "ai.operation.rootId";
this.operationSyntheticSource = "ai.operation.syntheticSource";
this.operationIsSynthetic = "ai.operation.isSynthetic";
this.sessionId = "ai.session.id";
this.sessionIsFirst = "ai.session.isFirst";
this.sessionIsNew = "ai.session.isNew";
this.userAccountAcquisitionDate = "ai.user.accountAcquisitionDate";
this.userAccountId = "ai.user.accountId";
this.userAgent = "ai.user.userAgent";
this.userId = "ai.user.id";
this.userStoreRegion = "ai.user.storeRegion";
this.userAuthUserId = "ai.user.authUserId";
this.userAnonymousUserAcquisitionDate = "ai.user.anonUserAcquisitionDate";
this.userAuthenticatedUserAcquisitionDate = "ai.user.authUserAcquisitionDate";
this.sampleRate = "ai.sample.sampleRate";
this.internalSdkVersion = "ai.internal.sdkVersion";
this.internalAgentVersion = "ai.internal.agentVersion";
this.internalDataCollectorReceivedTime = "ai.internal.dataCollectorReceivedTime";
this.internalProfileId = "ai.internal.profileId";
this.internalProfileClassId = "ai.internal.profileClassId";
this.internalAccountId = "ai.internal.accountId";
this.internalApplicationName = "ai.internal.applicationName";
this.internalInstrumentationKey = "ai.internal.instrumentationKey";
this.internalTelemetryItemId = "ai.internal.telemetryItemId";
this.internalApplicationType = "ai.internal.applicationType";
this.internalRequestSource = "ai.internal.requestSource";
this.internalFlowType = "ai.internal.flowType";
this.internalIsAudit = "ai.internal.isAudit";
this.internalTrackingSourceId = "ai.internal.trackingSourceId";
this.internalTrackingType = "ai.internal.trackingType";
}
return ContextTagKeys;
})();
AI.ContextTagKeys = ContextTagKeys;
})(AI || (AI = {}));
var Microsoft;
(function (Microsoft) {
var ApplicationInsights;
(function (ApplicationInsights) {
var Context;
(function (Context) {
"use strict";
var Application = (function () {
function Application() {
}
return Application;
})();
Context.Application = Application;
})(Context = ApplicationInsights.Context || (ApplicationInsights.Context = {}));
})(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
})(Microsoft || (Microsoft = {}));
var Microsoft;
(function (Microsoft) {
var ApplicationInsights;
(function (ApplicationInsights) {
var Context;
(function (Context) {
"use strict";
var Device = (function () {
function Device() {
this.id = "browser";
if (typeof screen !== "undefined" && screen.width && screen.height) {
this.resolution = screen.width + "X" + screen.height;
}
this.locale = (typeof screen !== "undefined" && navigator.browserLanguage) ? navigator.browserLanguage : "unknown";
}
return Device;
})();
Context.Device = Device;
})(Context = ApplicationInsights.Context || (ApplicationInsights.Context = {}));
})(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
})(Microsoft || (Microsoft = {}));
var Microsoft;
(function (Microsoft) {
var ApplicationInsights;
(function (ApplicationInsights) {
var Context;
(function (Context) {
"use strict";
var Internal = (function () {
function Internal() {
this.sdkVersion = "JavaScript:" + ApplicationInsights.Version;
}
return Internal;
})();
Context.Internal = Internal;
})(Context = ApplicationInsights.Context || (ApplicationInsights.Context = {}));
})(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
})(Microsoft || (Microsoft = {}));
var Microsoft;
(function (Microsoft) {
var ApplicationInsights;
(function (ApplicationInsights) {
var Context;
(function (Context) {
"use strict";
var Location = (function () {
function Location() {
}
return Location;
})();
Context.Location = Location;
})(Context = ApplicationInsights.Context || (ApplicationInsights.Context = {}));
})(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
})(Microsoft || (Microsoft = {}));
var Microsoft;
(function (Microsoft) {
var ApplicationInsights;
(function (ApplicationInsights) {
var Context;
(function (Context) {
"use strict";
var Operation = (function () {
function Operation() {
this.id = ApplicationInsights.Util.newGuid();
}
return Operation;
})();
Context.Operation = Operation;
})(Context = ApplicationInsights.Context || (ApplicationInsights.Context = {}));
})(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
})(Microsoft || (Microsoft = {}));
var Microsoft;
(function (Microsoft) {
var ApplicationInsights;
(function (ApplicationInsights) {
var SamplingScoreGenerator = (function () {
function SamplingScoreGenerator() {
}
SamplingScoreGenerator.getScore = function (envelope) {
var tagKeys = new AI.ContextTagKeys();
var score = 0;
if (envelope.tags[tagKeys.userId]) {
score = SamplingScoreGenerator.getSamplingHashCode(envelope.tags[tagKeys.userId]) / SamplingScoreGenerator.INT_MAX_VALUE;
}
else if (envelope.tags[tagKeys.operationId]) {
score = SamplingScoreGenerator.getSamplingHashCode(envelope.tags[tagKeys.operationId]) / SamplingScoreGenerator.INT_MAX_VALUE;
}
else {
score = Math.random();
}
return score * 100;
};
SamplingScoreGenerator.getSamplingHashCode = function (input) {
if (input == "") {
return 0;
}
var hash = 5381;
for (var i = 0; i < input.length; ++i) {
hash = ((hash << 5) + hash) + input.charCodeAt(i);
hash = hash & hash;
}
return Math.abs(hash);
};
SamplingScoreGenerator.INT_MAX_VALUE = 2147483647;
return SamplingScoreGenerator;
})();
ApplicationInsights.SamplingScoreGenerator = SamplingScoreGenerator;
})(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
})(Microsoft || (Microsoft = {}));
var Microsoft;
(function (Microsoft) {
var ApplicationInsights;
(function (ApplicationInsights) {
var Context;
(function (Context) {
"use strict";
var Sample = (function () {
function Sample(sampleRate) {
this.INT_MAX_VALUE = 2147483647;
if (sampleRate > 100 || sampleRate < 0) {
ApplicationInsights._InternalLogging.throwInternalUserActionable(1 /* WARNING */, "Sampling rate is out of range (0..100): '" + sampleRate + "'. Sampling will be disabled, you may be sending too much data which may affect your AI service level.");
this.sampleRate = 100;
}
this.sampleRate = sampleRate;
}
Sample.prototype.isSampledIn = function (envelope) {
if (this.sampleRate == 100)
return true;
var score = ApplicationInsights.SamplingScoreGenerator.getScore(envelope);
return score < this.sampleRate;
};
return Sample;
})();
Context.Sample = Sample;
})(Context = ApplicationInsights.Context || (ApplicationInsights.Context = {}));
})(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
})(Microsoft || (Microsoft = {}));
var AI;
(function (AI) {
"use strict";
(function (SessionState) {
SessionState[SessionState["Start"] = 0] = "Start";
SessionState[SessionState["End"] = 1] = "End";
})(AI.SessionState || (AI.SessionState = {}));
var SessionState = AI.SessionState;
})(AI || (AI = {}));
var Microsoft;
(function (Microsoft) {
var ApplicationInsights;
(function (ApplicationInsights) {
var Context;
(function (Context) {
"use strict";
var Session = (function () {
function Session() {
}
return Session;
})();
Context.Session = Session;
var _SessionManager = (function () {
function _SessionManager(config, sessionHandler) {
if (!config) {
config = {};
}
if (!(typeof config.sessionExpirationMs === "function")) {
config.sessionExpirationMs = function () { return _SessionManager.acquisitionSpan; };
}
if (!(typeof config.sessionRenewalMs === "function")) {
config.sessionRenewalMs = function () { return _SessionManager.renewalSpan; };
}
this.config = config;
this._sessionHandler = sessionHandler;
this.automaticSession = new Session();
}
_SessionManager.prototype.update = function () {
if (!this.automaticSession.id) {
this.initializeAutomaticSession();
}
var now = +new Date;
var acquisitionExpired = now - this.automaticSession.acquisitionDate > this.config.sessionExpirationMs();
var renewalExpired = now - this.automaticSession.renewalDate > this.config.sessionRenewalMs();
if (acquisitionExpired || renewalExpired) {
if (typeof this._sessionHandler === "function") {
this._sessionHandler(1 /* End */, this.automaticSession.renewalDate);
}
this.automaticSession.isFirst = undefined;
this.renew();
}
else {
this.automaticSession.renewalDate = +new Date;
this.setCookie(this.automaticSession.id, this.automaticSession.acquisitionDate, this.automaticSession.renewalDate);
}
};
_SessionManager.prototype.backup = function () {
this.setStorage(this.automaticSession.id, this.automaticSession.acquisitionDate, this.automaticSession.renewalDate);
};
_SessionManager.prototype.initializeAutomaticSession = function () {
var cookie = ApplicationInsights.Util.getCookie('ai_session');
if (cookie && typeof cookie.split === "function") {
this.initializeAutomaticSessionWithData(cookie);
}
else {
var storage = ApplicationInsights.Util.getStorage('ai_session');
if (storage) {
this.initializeAutomaticSessionWithData(storage);
}
}
if (!this.automaticSession.id) {
this.automaticSession.isFirst = true;
this.renew();
}
};
_SessionManager.prototype.initializeAutomaticSessionWithData = function (sessionData) {
var params = sessionData.split("|");
if (params.length > 0) {
this.automaticSession.id = params[0];
}
try {
if (params.length > 1) {
var acq = +params[1];
this.automaticSession.acquisitionDate = +new Date(acq);
this.automaticSession.acquisitionDate = this.automaticSession.acquisitionDate > 0 ? this.automaticSession.acquisitionDate : 0;
}
if (params.length > 2) {
var renewal = +params[2];
this.automaticSession.renewalDate = +new Date(renewal);
this.automaticSession.renewalDate = this.automaticSession.renewalDate > 0 ? this.automaticSession.renewalDate : 0;
}
}
catch (e) {
ApplicationInsights._InternalLogging.throwInternalNonUserActionable(0 /* CRITICAL */, "Error parsing ai_session cookie, session will be reset: " + ApplicationInsights.Util.dump(e));
}
if (this.automaticSession.renewalDate == 0) {
ApplicationInsights._InternalLogging.throwInternalNonUserActionable(1 /* WARNING */, "AI session renewal date is 0, session will be reset.");
}
};
_SessionManager.prototype.renew = function () {
var now = +new Date;
this.automaticSession.id = ApplicationInsights.Util.newGuid();
this.automaticSession.acquisitionDate = now;
this.automaticSession.renewalDate = now;
this.setCookie(this.automaticSession.id, this.automaticSession.acquisitionDate, this.automaticSession.renewalDate);
if (typeof this._sessionHandler === "function") {
this._sessionHandler(0 /* Start */, now);
}
if (!ApplicationInsights.Util.canUseLocalStorage()) {
ApplicationInsights._InternalLogging.throwInternalNonUserActionable(1 /* WARNING */, "Browser does not support local storage. Session durations will be inaccurate.");
}
};
_SessionManager.prototype.setCookie = function (guid, acq, renewal) {
var acquisitionExpiry = acq + this.config.sessionExpirationMs();
var renewalExpiry = renewal + this.config.sessionRenewalMs();
var cookieExpiry = new Date();
var cookie = [guid, acq, renewal];
if (acquisitionExpiry < renewalExpiry) {
cookieExpiry.setTime(acquisitionExpiry);
}
else {
cookieExpiry.setTime(renewalExpiry);
}
ApplicationInsights.Util.setCookie('ai_session', cookie.join('|') + ';expires=' + cookieExpiry.toUTCString());
};
_SessionManager.prototype.setStorage = function (guid, acq, renewal) {
ApplicationInsights.Util.setStorage('ai_session', [guid, acq, renewal].join('|'));
};
_SessionManager.acquisitionSpan = 86400000;
_SessionManager.renewalSpan = 1800000;
return _SessionManager;
})();
Context._SessionManager = _SessionManager;
})(Context = ApplicationInsights.Context || (ApplicationInsights.Context = {}));
})(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
})(Microsoft || (Microsoft = {}));
var Microsoft;
(function (Microsoft) {
var ApplicationInsights;
(function (ApplicationInsights) {
var Context;
(function (Context) {
"use strict";
var User = (function () {
function User(accountId) {
var cookie = ApplicationInsights.Util.getCookie(User.userCookieName);
if (cookie) {
var params = cookie.split(User.cookieSeparator);
if (params.length > 0) {
this.id = params[0];
}
}
if (!this.id) {
this.id = ApplicationInsights.Util.newGuid();
var date = new Date();
var acqStr = ApplicationInsights.Util.toISOStringForIE8(date);
this.accountAcquisitionDate = acqStr;
date.setTime(date.getTime() + 31536000000);
var newCookie = [this.id, acqStr];
ApplicationInsights.Util.setCookie(User.userCookieName, newCookie.join(User.cookieSeparator) + ';expires=' + date.toUTCString());
ApplicationInsights.Util.removeStorage('ai_session');
}
this.accountId = accountId;
var authCookie = ApplicationInsights.Util.getCookie(User.authUserCookieName);
if (authCookie) {
authCookie = decodeURI(authCookie);
var authCookieString = authCookie.split(User.cookieSeparator);
if (authCookieString[0]) {
this.authenticatedId = authCookieString[0];
}
if (authCookieString.length > 1 && authCookieString[1]) {
this.accountId = authCookieString[1];
}
}
}
User.prototype.setAuthenticatedUserContext = function (authenticatedUserId, accountId) {
var isInvalidInput = !this.validateUserInput(authenticatedUserId) || (accountId && !this.validateUserInput(accountId));
if (isInvalidInput) {
ApplicationInsights._InternalLogging.throwInternalUserActionable(1 /* WARNING */, "Setting auth user context failed. " + "User auth/account id should be of type string, and not contain commas, semi-colons, equal signs, spaces, or vertical-bars.");
return;
}
this.authenticatedId = authenticatedUserId;
var authCookie = this.authenticatedId;
if (accountId) {
this.accountId = accountId;
authCookie = [this.authenticatedId, this.accountId].join(User.cookieSeparator);
}
ApplicationInsights.Util.setCookie(User.authUserCookieName, encodeURI(authCookie));
};
User.prototype.clearAuthenticatedUserContext = function () {
this.authenticatedId = null;
this.accountId = null;
ApplicationInsights.Util.deleteCookie(User.authUserCookieName);
};
User.prototype.validateUserInput = function (id) {
if (typeof id !== 'string' || !id || id.match(/,|;|=| |\|/)) {
return false;
}
return true;
};
User.cookieSeparator = '|';
User.userCookieName = 'ai_user';
User.authUserCookieName = 'ai_authUser';
return User;
})();
Context.User = User;
})(Context = ApplicationInsights.Context || (ApplicationInsights.Context = {}));
})(ApplicationInsights = Microsoft.ApplicationInsights || (Microsoft.ApplicationInsights = {}));
})(Microsoft || (Microsoft = {}));
var Microsoft;
(function (Microsoft) {
var ApplicationInsights;
(function (ApplicationInsights) {
"use strict";
var Sender = (function () {
function Sender(config) {
this._buffer = [];
this._lastSend = 0;
this._config = config;
this._sender = null;
if (typeof XMLHttpRequest != "undefined") {
var testXhr = new XMLHttpRequest();
if ("withCredentials" in testXhr) {
this._sender = this._xhrSender;
}
else if (typeof XDomainRequest !== "undefined") {
this._sender = this._xdrSender;
}
}
}
Sender.prototype.send = function (envelope) {
var _this = this;
try {
if (this._config.disableTelemetry()) {
return;
}
if (!envelope) {
ApplicationInsights._InternalLogging.throwInternalNonUserActionable(0 /* CRITICAL */, "Cannot send empty telemetry");
return;
}