@microsoft/applicationinsights-clickanalytics-js 2.8.0-nightly.2202-06 → 2.8.0-nightly.2204-04

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/browser/ai.clck.2.8.0-nightly.2204-04.cjs.js +2883 -0
  2. package/browser/ai.clck.2.8.0-nightly.2204-04.cjs.js.map +1 -0
  3. package/browser/ai.clck.2.8.0-nightly.2204-04.cjs.min.js +6 -0
  4. package/browser/ai.clck.2.8.0-nightly.2204-04.cjs.min.js.map +1 -0
  5. package/browser/ai.clck.2.8.0-nightly.2204-04.gbl.js +2887 -0
  6. package/browser/ai.clck.2.8.0-nightly.2204-04.gbl.js.map +1 -0
  7. package/browser/ai.clck.2.8.0-nightly.2204-04.gbl.min.js +6 -0
  8. package/browser/ai.clck.2.8.0-nightly.2204-04.gbl.min.js.map +1 -0
  9. package/browser/ai.clck.2.8.0-nightly.2204-04.integrity.json +66 -0
  10. package/browser/ai.clck.2.8.0-nightly.2204-04.js +2889 -0
  11. package/browser/ai.clck.2.8.0-nightly.2204-04.js.map +1 -0
  12. package/browser/ai.clck.2.8.0-nightly.2204-04.min.js +6 -0
  13. package/browser/ai.clck.2.8.0-nightly.2204-04.min.js.map +1 -0
  14. package/browser/ai.clck.2.cjs.js +1685 -808
  15. package/browser/ai.clck.2.cjs.js.map +1 -1
  16. package/browser/ai.clck.2.cjs.min.js +2 -2
  17. package/browser/ai.clck.2.cjs.min.js.map +1 -1
  18. package/browser/ai.clck.2.gbl.js +1685 -808
  19. package/browser/ai.clck.2.gbl.js.map +1 -1
  20. package/browser/ai.clck.2.gbl.min.js +2 -2
  21. package/browser/ai.clck.2.gbl.min.js.map +1 -1
  22. package/browser/ai.clck.2.js +1685 -808
  23. package/browser/ai.clck.2.js.map +1 -1
  24. package/browser/ai.clck.2.min.js +2 -2
  25. package/browser/ai.clck.2.min.js.map +1 -1
  26. package/dist/applicationinsights-clickanalytics-js.api.json +38 -13
  27. package/dist/applicationinsights-clickanalytics-js.api.md +1 -0
  28. package/dist/applicationinsights-clickanalytics-js.d.ts +2 -5
  29. package/dist/applicationinsights-clickanalytics-js.js +1685 -808
  30. package/dist/applicationinsights-clickanalytics-js.js.map +1 -1
  31. package/dist/applicationinsights-clickanalytics-js.min.js +2 -2
  32. package/dist/applicationinsights-clickanalytics-js.min.js.map +1 -1
  33. package/dist/applicationinsights-clickanalytics-js.rollup.d.ts +2 -5
  34. package/dist-esm/Behaviours.js +1 -1
  35. package/dist-esm/ClickAnalyticsPlugin.js +74 -50
  36. package/dist-esm/ClickAnalyticsPlugin.js.map +1 -1
  37. package/dist-esm/DataCollector.js +4 -2
  38. package/dist-esm/DataCollector.js.map +1 -1
  39. package/dist-esm/Enums.js +1 -1
  40. package/dist-esm/Interfaces/Datamodel.js +1 -1
  41. package/dist-esm/applicationinsights-clickanalytics-js.js +1 -1
  42. package/dist-esm/common/Utils.js +1 -1
  43. package/dist-esm/events/PageAction.js +128 -126
  44. package/dist-esm/events/PageAction.js.map +1 -1
  45. package/dist-esm/events/WebEvent.js +109 -94
  46. package/dist-esm/events/WebEvent.js.map +1 -1
  47. package/dist-esm/handlers/AutoCaptureHandler.js +85 -83
  48. package/dist-esm/handlers/AutoCaptureHandler.js.map +1 -1
  49. package/dist-esm/handlers/DomContentHandler.js +279 -276
  50. package/dist-esm/handlers/DomContentHandler.js.map +1 -1
  51. package/package.json +5 -5
  52. package/src/ClickAnalyticsPlugin.ts +92 -47
  53. package/src/DataCollector.ts +24 -22
  54. package/src/Interfaces/Datamodel.ts +20 -21
  55. package/src/common/Utils.ts +8 -8
  56. package/src/events/PageAction.ts +165 -131
  57. package/src/events/WebEvent.ts +147 -78
  58. package/src/handlers/AutoCaptureHandler.ts +89 -79
  59. package/src/handlers/DomContentHandler.ts +336 -303
  60. package/types/ClickAnalyticsPlugin.d.ts +1 -4
  61. package/types/Interfaces/Datamodel.d.ts +3 -2
  62. package/types/events/PageAction.d.ts +6 -6
  63. package/types/events/WebEvent.d.ts +17 -17
  64. package/types/handlers/AutoCaptureHandler.d.ts +2 -10
  65. package/types/handlers/DomContentHandler.d.ts +3 -50
  66. package/types/tsdoc-metadata.json +1 -1
  67. package/browser/ai.clck.2.8.0-nightly.2202-06.cjs.js +0 -2006
  68. package/browser/ai.clck.2.8.0-nightly.2202-06.cjs.js.map +0 -1
  69. package/browser/ai.clck.2.8.0-nightly.2202-06.cjs.min.js +0 -6
  70. package/browser/ai.clck.2.8.0-nightly.2202-06.cjs.min.js.map +0 -1
  71. package/browser/ai.clck.2.8.0-nightly.2202-06.gbl.js +0 -2010
  72. package/browser/ai.clck.2.8.0-nightly.2202-06.gbl.js.map +0 -1
  73. package/browser/ai.clck.2.8.0-nightly.2202-06.gbl.min.js +0 -6
  74. package/browser/ai.clck.2.8.0-nightly.2202-06.gbl.min.js.map +0 -1
  75. package/browser/ai.clck.2.8.0-nightly.2202-06.integrity.json +0 -66
  76. package/browser/ai.clck.2.8.0-nightly.2202-06.js +0 -2012
  77. package/browser/ai.clck.2.8.0-nightly.2202-06.js.map +0 -1
  78. package/browser/ai.clck.2.8.0-nightly.2202-06.min.js +0 -6
  79. package/browser/ai.clck.2.8.0-nightly.2202-06.min.js.map +0 -1
@@ -0,0 +1,2889 @@
1
+ /*!
2
+ * Application Insights JavaScript SDK - Click Analytics, 2.8.0-nightly.2204-04
3
+ * Copyright (c) Microsoft and contributors. All rights reserved.
4
+ */
5
+ (function (global, factory) {
6
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
7
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
8
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.Microsoft = global.Microsoft || {}, global.Microsoft.ApplicationInsights = global.Microsoft.ApplicationInsights || {})));
9
+ })(this, (function (exports) { 'use strict';
10
+
11
+ var strShimFunction = "function";
12
+ var strShimObject = "object";
13
+ var strShimUndefined = "undefined";
14
+ var strShimPrototype = "prototype";
15
+ var strShimHasOwnProperty = "hasOwnProperty";
16
+ var ObjClass = Object;
17
+ var ObjProto = ObjClass[strShimPrototype];
18
+ var ObjAssign = ObjClass["assign"];
19
+ var ObjCreate = ObjClass["create"];
20
+ var ObjDefineProperty = ObjClass["defineProperty"];
21
+ var ObjHasOwnProperty = ObjProto[strShimHasOwnProperty];
22
+
23
+ var _cachedGlobal = null;
24
+ function getGlobal(useCached) {
25
+ if (useCached === void 0) { useCached = true; }
26
+ if (!_cachedGlobal || !useCached) {
27
+ if (typeof globalThis !== strShimUndefined && globalThis) {
28
+ _cachedGlobal = globalThis;
29
+ }
30
+ if (typeof self !== strShimUndefined && self) {
31
+ _cachedGlobal = self;
32
+ }
33
+ if (typeof window !== strShimUndefined && window) {
34
+ _cachedGlobal = window;
35
+ }
36
+ if (typeof global !== strShimUndefined && global) {
37
+ _cachedGlobal = global;
38
+ }
39
+ }
40
+ return _cachedGlobal;
41
+ }
42
+ function throwTypeError(message) {
43
+ throw new TypeError(message);
44
+ }
45
+ function objCreateFn(obj) {
46
+ var func = ObjCreate;
47
+ if (func) {
48
+ return func(obj);
49
+ }
50
+ if (obj == null) {
51
+ return {};
52
+ }
53
+ var type = typeof obj;
54
+ if (type !== strShimObject && type !== strShimFunction) {
55
+ throwTypeError("Object prototype may only be an Object:" + obj);
56
+ }
57
+ function tmpFunc() { }
58
+ tmpFunc[strShimPrototype] = obj;
59
+ return new tmpFunc();
60
+ }
61
+
62
+ (getGlobal() || {})["Symbol"];
63
+ (getGlobal() || {})["Reflect"];
64
+ var __objAssignFnImpl = function (t) {
65
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
66
+ s = arguments[i];
67
+ for (var p in s) {
68
+ if (ObjProto[strShimHasOwnProperty].call(s, p)) {
69
+ t[p] = s[p];
70
+ }
71
+ }
72
+ }
73
+ return t;
74
+ };
75
+ var __assignFn = ObjAssign || __objAssignFnImpl;
76
+ var extendStaticsFn = function (d, b) {
77
+ extendStaticsFn = ObjClass["setPrototypeOf"] ||
78
+ ({ __proto__: [] } instanceof Array && function (d, b) {
79
+ d.__proto__ = b;
80
+ }) ||
81
+ function (d, b) {
82
+ for (var p in b) {
83
+ if (b[strShimHasOwnProperty](p)) {
84
+ d[p] = b[p];
85
+ }
86
+ }
87
+ };
88
+ return extendStaticsFn(d, b);
89
+ };
90
+ function __extendsFn(d, b) {
91
+ if (typeof b !== strShimFunction && b !== null) {
92
+ throwTypeError("Class extends value " + String(b) + " is not a constructor or null");
93
+ }
94
+ extendStaticsFn(d, b);
95
+ function __() {
96
+ this.constructor = d;
97
+ }
98
+ d[strShimPrototype] = b === null ? objCreateFn(b) : (__[strShimPrototype] = b[strShimPrototype], new __());
99
+ }
100
+
101
+ /*!
102
+ * Microsoft Dynamic Proto Utility, 1.1.4
103
+ * Copyright (c) Microsoft and contributors. All rights reserved.
104
+ */
105
+ var Constructor = 'constructor';
106
+ var Prototype$1 = 'prototype';
107
+ var strFunction = 'function';
108
+ var DynInstFuncTable = '_dynInstFuncs';
109
+ var DynProxyTag = '_isDynProxy';
110
+ var DynClassName = '_dynClass';
111
+ var DynClassNamePrefix = '_dynCls$';
112
+ var DynInstChkTag = '_dynInstChk';
113
+ var DynAllowInstChkTag = DynInstChkTag;
114
+ var DynProtoDefaultOptions = '_dfOpts';
115
+ var UnknownValue = '_unknown_';
116
+ var str__Proto$1 = "__proto__";
117
+ var strUseBaseInst = 'useBaseInst';
118
+ var strSetInstFuncs = 'setInstFuncs';
119
+ var Obj = Object;
120
+ var _objGetPrototypeOf$1 = Obj["getPrototypeOf"];
121
+ var _dynamicNames = 0;
122
+ function _hasOwnProperty(obj, prop) {
123
+ return obj && Obj[Prototype$1].hasOwnProperty.call(obj, prop);
124
+ }
125
+ function _isObjectOrArrayPrototype(target) {
126
+ return target && (target === Obj[Prototype$1] || target === Array[Prototype$1]);
127
+ }
128
+ function _isObjectArrayOrFunctionPrototype(target) {
129
+ return _isObjectOrArrayPrototype(target) || target === Function[Prototype$1];
130
+ }
131
+ function _getObjProto$1(target) {
132
+ if (target) {
133
+ if (_objGetPrototypeOf$1) {
134
+ return _objGetPrototypeOf$1(target);
135
+ }
136
+ var newProto = target[str__Proto$1] || target[Prototype$1] || (target[Constructor] ? target[Constructor][Prototype$1] : null);
137
+ if (newProto) {
138
+ return newProto;
139
+ }
140
+ }
141
+ return null;
142
+ }
143
+ function _forEachProp(target, func) {
144
+ var props = [];
145
+ var getOwnProps = Obj["getOwnPropertyNames"];
146
+ if (getOwnProps) {
147
+ props = getOwnProps(target);
148
+ }
149
+ else {
150
+ for (var name_1 in target) {
151
+ if (typeof name_1 === "string" && _hasOwnProperty(target, name_1)) {
152
+ props.push(name_1);
153
+ }
154
+ }
155
+ }
156
+ if (props && props.length > 0) {
157
+ for (var lp = 0; lp < props.length; lp++) {
158
+ func(props[lp]);
159
+ }
160
+ }
161
+ }
162
+ function _isDynamicCandidate(target, funcName, skipOwn) {
163
+ return (funcName !== Constructor && typeof target[funcName] === strFunction && (skipOwn || _hasOwnProperty(target, funcName)));
164
+ }
165
+ function _throwTypeError(message) {
166
+ throw new TypeError("DynamicProto: " + message);
167
+ }
168
+ function _getInstanceFuncs(thisTarget) {
169
+ var instFuncs = {};
170
+ _forEachProp(thisTarget, function (name) {
171
+ if (!instFuncs[name] && _isDynamicCandidate(thisTarget, name, false)) {
172
+ instFuncs[name] = thisTarget[name];
173
+ }
174
+ });
175
+ return instFuncs;
176
+ }
177
+ function _hasVisited(values, value) {
178
+ for (var lp = values.length - 1; lp >= 0; lp--) {
179
+ if (values[lp] === value) {
180
+ return true;
181
+ }
182
+ }
183
+ return false;
184
+ }
185
+ function _getBaseFuncs(classProto, thisTarget, instFuncs, useBaseInst) {
186
+ function _instFuncProxy(target, funcHost, funcName) {
187
+ var theFunc = funcHost[funcName];
188
+ if (theFunc[DynProxyTag] && useBaseInst) {
189
+ var instFuncTable = target[DynInstFuncTable] || {};
190
+ if (instFuncTable[DynAllowInstChkTag] !== false) {
191
+ theFunc = (instFuncTable[funcHost[DynClassName]] || {})[funcName] || theFunc;
192
+ }
193
+ }
194
+ return function () {
195
+ return theFunc.apply(target, arguments);
196
+ };
197
+ }
198
+ var baseFuncs = {};
199
+ _forEachProp(instFuncs, function (name) {
200
+ baseFuncs[name] = _instFuncProxy(thisTarget, instFuncs, name);
201
+ });
202
+ var baseProto = _getObjProto$1(classProto);
203
+ var visited = [];
204
+ while (baseProto && !_isObjectArrayOrFunctionPrototype(baseProto) && !_hasVisited(visited, baseProto)) {
205
+ _forEachProp(baseProto, function (name) {
206
+ if (!baseFuncs[name] && _isDynamicCandidate(baseProto, name, !_objGetPrototypeOf$1)) {
207
+ baseFuncs[name] = _instFuncProxy(thisTarget, baseProto, name);
208
+ }
209
+ });
210
+ visited.push(baseProto);
211
+ baseProto = _getObjProto$1(baseProto);
212
+ }
213
+ return baseFuncs;
214
+ }
215
+ function _getInstFunc(target, funcName, proto, currentDynProtoProxy) {
216
+ var instFunc = null;
217
+ if (target && _hasOwnProperty(proto, DynClassName)) {
218
+ var instFuncTable = target[DynInstFuncTable] || {};
219
+ instFunc = (instFuncTable[proto[DynClassName]] || {})[funcName];
220
+ if (!instFunc) {
221
+ _throwTypeError("Missing [" + funcName + "] " + strFunction);
222
+ }
223
+ if (!instFunc[DynInstChkTag] && instFuncTable[DynAllowInstChkTag] !== false) {
224
+ var canAddInst = !_hasOwnProperty(target, funcName);
225
+ var objProto = _getObjProto$1(target);
226
+ var visited = [];
227
+ while (canAddInst && objProto && !_isObjectArrayOrFunctionPrototype(objProto) && !_hasVisited(visited, objProto)) {
228
+ var protoFunc = objProto[funcName];
229
+ if (protoFunc) {
230
+ canAddInst = (protoFunc === currentDynProtoProxy);
231
+ break;
232
+ }
233
+ visited.push(objProto);
234
+ objProto = _getObjProto$1(objProto);
235
+ }
236
+ try {
237
+ if (canAddInst) {
238
+ target[funcName] = instFunc;
239
+ }
240
+ instFunc[DynInstChkTag] = 1;
241
+ }
242
+ catch (e) {
243
+ instFuncTable[DynAllowInstChkTag] = false;
244
+ }
245
+ }
246
+ }
247
+ return instFunc;
248
+ }
249
+ function _getProtoFunc(funcName, proto, currentDynProtoProxy) {
250
+ var protoFunc = proto[funcName];
251
+ if (protoFunc === currentDynProtoProxy) {
252
+ protoFunc = _getObjProto$1(proto)[funcName];
253
+ }
254
+ if (typeof protoFunc !== strFunction) {
255
+ _throwTypeError("[" + funcName + "] is not a " + strFunction);
256
+ }
257
+ return protoFunc;
258
+ }
259
+ function _populatePrototype(proto, className, target, baseInstFuncs, setInstanceFunc) {
260
+ function _createDynamicPrototype(proto, funcName) {
261
+ var dynProtoProxy = function () {
262
+ var instFunc = _getInstFunc(this, funcName, proto, dynProtoProxy) || _getProtoFunc(funcName, proto, dynProtoProxy);
263
+ return instFunc.apply(this, arguments);
264
+ };
265
+ dynProtoProxy[DynProxyTag] = 1;
266
+ return dynProtoProxy;
267
+ }
268
+ if (!_isObjectOrArrayPrototype(proto)) {
269
+ var instFuncTable = target[DynInstFuncTable] = target[DynInstFuncTable] || {};
270
+ var instFuncs_1 = instFuncTable[className] = (instFuncTable[className] || {});
271
+ if (instFuncTable[DynAllowInstChkTag] !== false) {
272
+ instFuncTable[DynAllowInstChkTag] = !!setInstanceFunc;
273
+ }
274
+ _forEachProp(target, function (name) {
275
+ if (_isDynamicCandidate(target, name, false) && target[name] !== baseInstFuncs[name]) {
276
+ instFuncs_1[name] = target[name];
277
+ delete target[name];
278
+ if (!_hasOwnProperty(proto, name) || (proto[name] && !proto[name][DynProxyTag])) {
279
+ proto[name] = _createDynamicPrototype(proto, name);
280
+ }
281
+ }
282
+ });
283
+ }
284
+ }
285
+ function _checkPrototype(classProto, thisTarget) {
286
+ if (_objGetPrototypeOf$1) {
287
+ var visited = [];
288
+ var thisProto = _getObjProto$1(thisTarget);
289
+ while (thisProto && !_isObjectArrayOrFunctionPrototype(thisProto) && !_hasVisited(visited, thisProto)) {
290
+ if (thisProto === classProto) {
291
+ return true;
292
+ }
293
+ visited.push(thisProto);
294
+ thisProto = _getObjProto$1(thisProto);
295
+ }
296
+ }
297
+ return false;
298
+ }
299
+ function _getObjName(target, unknownValue) {
300
+ if (_hasOwnProperty(target, Prototype$1)) {
301
+ return target.name || unknownValue || UnknownValue;
302
+ }
303
+ return (((target || {})[Constructor]) || {}).name || unknownValue || UnknownValue;
304
+ }
305
+ function dynamicProto(theClass, target, delegateFunc, options) {
306
+ if (!_hasOwnProperty(theClass, Prototype$1)) {
307
+ _throwTypeError("theClass is an invalid class definition.");
308
+ }
309
+ var classProto = theClass[Prototype$1];
310
+ if (!_checkPrototype(classProto, target)) {
311
+ _throwTypeError("[" + _getObjName(theClass) + "] is not in class hierarchy of [" + _getObjName(target) + "]");
312
+ }
313
+ var className = null;
314
+ if (_hasOwnProperty(classProto, DynClassName)) {
315
+ className = classProto[DynClassName];
316
+ }
317
+ else {
318
+ className = DynClassNamePrefix + _getObjName(theClass, "_") + "$" + _dynamicNames;
319
+ _dynamicNames++;
320
+ classProto[DynClassName] = className;
321
+ }
322
+ var perfOptions = dynamicProto[DynProtoDefaultOptions];
323
+ var useBaseInst = !!perfOptions[strUseBaseInst];
324
+ if (useBaseInst && options && options[strUseBaseInst] !== undefined) {
325
+ useBaseInst = !!options[strUseBaseInst];
326
+ }
327
+ var instFuncs = _getInstanceFuncs(target);
328
+ var baseFuncs = _getBaseFuncs(classProto, target, instFuncs, useBaseInst);
329
+ delegateFunc(target, baseFuncs);
330
+ var setInstanceFunc = !!_objGetPrototypeOf$1 && !!perfOptions[strSetInstFuncs];
331
+ if (setInstanceFunc && options) {
332
+ setInstanceFunc = !!options[strSetInstFuncs];
333
+ }
334
+ _populatePrototype(classProto, className, target, instFuncs, setInstanceFunc !== false);
335
+ }
336
+ var perfDefaults = {
337
+ setInstFuncs: true,
338
+ useBaseInst: true
339
+ };
340
+ dynamicProto[DynProtoDefaultOptions] = perfDefaults;
341
+
342
+ var strEmpty = "";
343
+ var strSetNextPlugin = "setNextPlugin";
344
+ var strIsInitialized = "isInitialized";
345
+ var strTeardown = "teardown";
346
+ var strCore = "core";
347
+ var strUpdate = "update";
348
+ var strDisabled = "disabled";
349
+ var strDoTeardown = "_doTeardown";
350
+
351
+ var strToISOString = "toISOString";
352
+ var cStrEndsWith = "endsWith";
353
+ var cStrStartsWith = "startsWith";
354
+ var cStrTrim = "trim";
355
+ var strToString = "toString";
356
+ var str__Proto = "__proto__";
357
+ var strConstructor = "constructor";
358
+ var _objDefineProperty$1 = ObjDefineProperty;
359
+ var _objFreeze = ObjClass.freeze;
360
+ ObjClass.seal;
361
+ var _objKeys = ObjClass.keys;
362
+ var StringProto = String[strShimPrototype];
363
+ StringProto[cStrTrim];
364
+ StringProto[cStrEndsWith];
365
+ StringProto[cStrStartsWith];
366
+ var DateProto = Date[strShimPrototype];
367
+ DateProto[strToISOString];
368
+ var _isArray = Array.isArray;
369
+ var _objToString = ObjProto[strToString];
370
+ var _fnToString = ObjHasOwnProperty[strToString];
371
+ var _objFunctionString = _fnToString.call(ObjClass);
372
+ var rCamelCase = /-([a-z])/g;
373
+ var rNormalizeInvalid = /([^\w\d_$])/g;
374
+ var rLeadingNumeric = /^(\d+[\w\d_$])/;
375
+ var _objGetPrototypeOf = Object["getPrototypeOf"];
376
+ function _getObjProto(target) {
377
+ if (target) {
378
+ if (_objGetPrototypeOf) {
379
+ return _objGetPrototypeOf(target);
380
+ }
381
+ var newProto = target[str__Proto] || target[strShimPrototype] || target[strConstructor];
382
+ if (newProto) {
383
+ return newProto;
384
+ }
385
+ }
386
+ return null;
387
+ }
388
+ function isUndefined(value) {
389
+ return value === undefined || typeof value === strShimUndefined;
390
+ }
391
+ function isNullOrUndefined(value) {
392
+ return (value === null || isUndefined(value));
393
+ }
394
+ function hasOwnProperty(obj, prop) {
395
+ return !!(obj && ObjHasOwnProperty.call(obj, prop));
396
+ }
397
+ function isObject(value) {
398
+ return !!(value && typeof value === strShimObject);
399
+ }
400
+ function isFunction(value) {
401
+ return !!(value && typeof value === strShimFunction);
402
+ }
403
+ function normalizeJsName(name) {
404
+ var value = name;
405
+ if (value && isString(value)) {
406
+ value = value.replace(rCamelCase, function (_all, letter) {
407
+ return letter.toUpperCase();
408
+ });
409
+ value = value.replace(rNormalizeInvalid, "_");
410
+ value = value.replace(rLeadingNumeric, function (_all, match) {
411
+ return "_" + match;
412
+ });
413
+ }
414
+ return value;
415
+ }
416
+ function objForEachKey(target, callbackfn) {
417
+ if (target) {
418
+ for (var prop in target) {
419
+ if (ObjHasOwnProperty.call(target, prop)) {
420
+ callbackfn.call(target, prop, target[prop]);
421
+ }
422
+ }
423
+ }
424
+ }
425
+ function strContains(value, search) {
426
+ if (value && search) {
427
+ return value.indexOf(search) !== -1;
428
+ }
429
+ return false;
430
+ }
431
+ var isArray = _isArray || _isArrayPoly;
432
+ function _isArrayPoly(obj) {
433
+ return !!(obj && _objToString.call(obj) === "[object Array]");
434
+ }
435
+ function isError(obj) {
436
+ return !!(obj && _objToString.call(obj) === "[object Error]");
437
+ }
438
+ function isString(value) {
439
+ return typeof value === "string";
440
+ }
441
+ function isBoolean(value) {
442
+ return typeof value === "boolean";
443
+ }
444
+ function isPlainObject(value) {
445
+ var result = false;
446
+ if (value && typeof value === "object") {
447
+ var proto = _objGetPrototypeOf ? _objGetPrototypeOf(value) : _getObjProto(value);
448
+ if (!proto) {
449
+ result = true;
450
+ }
451
+ else {
452
+ if (proto[strConstructor] && ObjHasOwnProperty.call(proto, strConstructor)) {
453
+ proto = proto[strConstructor];
454
+ }
455
+ result = typeof proto === strShimFunction && _fnToString.call(proto) === _objFunctionString;
456
+ }
457
+ }
458
+ return result;
459
+ }
460
+ function arrForEach(arr, callbackfn, thisArg) {
461
+ var len = arr.length;
462
+ try {
463
+ for (var idx = 0; idx < len; idx++) {
464
+ if (idx in arr) {
465
+ if (callbackfn.call(thisArg || arr, arr[idx], idx, arr) === -1) {
466
+ break;
467
+ }
468
+ }
469
+ }
470
+ }
471
+ catch (e) {
472
+ }
473
+ }
474
+ var _objKeysHasDontEnumBug = !({ toString: null }).propertyIsEnumerable("toString");
475
+ var _objKeysDontEnums = [
476
+ "toString",
477
+ "toLocaleString",
478
+ "valueOf",
479
+ "hasOwnProperty",
480
+ "isPrototypeOf",
481
+ "propertyIsEnumerable",
482
+ "constructor"
483
+ ];
484
+ function objKeys(obj) {
485
+ var objType = typeof obj;
486
+ if (objType !== strShimFunction && (objType !== strShimObject || obj === null)) {
487
+ throwTypeError("objKeys called on non-object");
488
+ }
489
+ if (!_objKeysHasDontEnumBug && _objKeys) {
490
+ return _objKeys(obj);
491
+ }
492
+ var result = [];
493
+ for (var prop in obj) {
494
+ if (obj && ObjHasOwnProperty.call(obj, prop)) {
495
+ result.push(prop);
496
+ }
497
+ }
498
+ if (_objKeysHasDontEnumBug) {
499
+ var dontEnumsLength = _objKeysDontEnums.length;
500
+ for (var lp = 0; lp < dontEnumsLength; lp++) {
501
+ if (obj && ObjHasOwnProperty.call(obj, _objKeysDontEnums[lp])) {
502
+ result.push(_objKeysDontEnums[lp]);
503
+ }
504
+ }
505
+ }
506
+ return result;
507
+ }
508
+ function objDefineAccessors(target, prop, getProp, setProp) {
509
+ if (_objDefineProperty$1) {
510
+ try {
511
+ var descriptor = {
512
+ enumerable: true,
513
+ configurable: true
514
+ };
515
+ if (getProp) {
516
+ descriptor.get = getProp;
517
+ }
518
+ if (setProp) {
519
+ descriptor.set = setProp;
520
+ }
521
+ _objDefineProperty$1(target, prop, descriptor);
522
+ return true;
523
+ }
524
+ catch (e) {
525
+ }
526
+ }
527
+ return false;
528
+ }
529
+ function _doNothing(value) {
530
+ return value;
531
+ }
532
+ var objFreeze = _objFreeze || _doNothing;
533
+ function dateNow() {
534
+ var dt = Date;
535
+ return dt.now ? dt.now() : new dt().getTime();
536
+ }
537
+ function getExceptionName(object) {
538
+ if (isError(object)) {
539
+ return object.name;
540
+ }
541
+ return strEmpty;
542
+ }
543
+ function setValue(target, field, value, valChk, srcChk) {
544
+ var theValue = value;
545
+ if (target) {
546
+ theValue = target[field];
547
+ if (theValue !== value && (!srcChk || srcChk(theValue)) && (!valChk || valChk(value))) {
548
+ theValue = value;
549
+ target[field] = theValue;
550
+ }
551
+ }
552
+ return theValue;
553
+ }
554
+ function throwError(message) {
555
+ throw new Error(message);
556
+ }
557
+ function _createProxyFunction(source, funcName) {
558
+ var srcFunc = null;
559
+ var src = null;
560
+ if (isFunction(source)) {
561
+ srcFunc = source;
562
+ }
563
+ else {
564
+ src = source;
565
+ }
566
+ return function () {
567
+ var originalArguments = arguments;
568
+ if (srcFunc) {
569
+ src = srcFunc();
570
+ }
571
+ if (src) {
572
+ return src[funcName].apply(src, originalArguments);
573
+ }
574
+ };
575
+ }
576
+ function proxyFunctionAs(target, name, source, theFunc, overwriteTarget) {
577
+ if (overwriteTarget === void 0) { overwriteTarget = true; }
578
+ if (target && name && source) {
579
+ if (overwriteTarget || isUndefined(target[name])) {
580
+ target[name] = _createProxyFunction(source, theFunc);
581
+ }
582
+ }
583
+ }
584
+ function createEnumStyle(values) {
585
+ var enumClass = {};
586
+ objForEachKey(values, function (field, value) {
587
+ enumClass[field] = value;
588
+ if (!isUndefined(enumClass[value])) {
589
+ throwError("[" + value + "] exists for " + field);
590
+ }
591
+ enumClass[value] = field;
592
+ });
593
+ return objFreeze(enumClass);
594
+ }
595
+ function objExtend(obj1, obj2, obj3, obj4, obj5, obj6) {
596
+ var theArgs = arguments;
597
+ var extended = theArgs[0] || {};
598
+ var argLen = theArgs.length;
599
+ var deep = false;
600
+ var idx = 1;
601
+ if (argLen > 0 && isBoolean(extended)) {
602
+ deep = extended;
603
+ extended = theArgs[idx] || {};
604
+ idx++;
605
+ }
606
+ if (!isObject(extended)) {
607
+ extended = {};
608
+ }
609
+ for (; idx < argLen; idx++) {
610
+ var arg = theArgs[idx];
611
+ var isArgArray = isArray(arg);
612
+ var isArgObj = isObject(arg);
613
+ for (var prop in arg) {
614
+ var propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty.call(arg, prop)));
615
+ if (!propOk) {
616
+ continue;
617
+ }
618
+ var newValue = arg[prop];
619
+ var isNewArray = void 0;
620
+ if (deep && newValue && ((isNewArray = isArray(newValue)) || isPlainObject(newValue))) {
621
+ var clone = extended[prop];
622
+ if (isNewArray) {
623
+ if (!isArray(clone)) {
624
+ clone = [];
625
+ }
626
+ }
627
+ else if (!isPlainObject(clone)) {
628
+ clone = {};
629
+ }
630
+ newValue = objExtend(deep, clone, newValue);
631
+ }
632
+ if (newValue !== undefined) {
633
+ extended[prop] = newValue;
634
+ }
635
+ }
636
+ }
637
+ return extended;
638
+ }
639
+
640
+ var strWindow = "window";
641
+ var strDocument = "document";
642
+ var strNavigator = "navigator";
643
+ var strLocation = "location";
644
+ var strConsole = "console";
645
+ var strPerformance = "performance";
646
+ var strJSON = "JSON";
647
+ var strCrypto = "crypto";
648
+ var strMsCrypto = "msCrypto";
649
+ var strMsie = "msie";
650
+ var strTrident = "trident/";
651
+ var _isTrident = null;
652
+ var _navUserAgentCheck = null;
653
+ var _enableMocks = false;
654
+ function getGlobalInst(name) {
655
+ var gbl = getGlobal();
656
+ if (gbl && gbl[name]) {
657
+ return gbl[name];
658
+ }
659
+ if (name === strWindow && hasWindow()) {
660
+ return window;
661
+ }
662
+ return null;
663
+ }
664
+ function hasWindow() {
665
+ return Boolean(typeof window === strShimObject && window);
666
+ }
667
+ function getWindow() {
668
+ if (hasWindow()) {
669
+ return window;
670
+ }
671
+ return getGlobalInst(strWindow);
672
+ }
673
+ function hasDocument() {
674
+ return Boolean(typeof document === strShimObject && document);
675
+ }
676
+ function getDocument() {
677
+ if (hasDocument()) {
678
+ return document;
679
+ }
680
+ return getGlobalInst(strDocument);
681
+ }
682
+ function hasNavigator() {
683
+ return Boolean(typeof navigator === strShimObject && navigator);
684
+ }
685
+ function getNavigator() {
686
+ if (hasNavigator()) {
687
+ return navigator;
688
+ }
689
+ return getGlobalInst(strNavigator);
690
+ }
691
+ function getLocation(checkForMock) {
692
+ if (checkForMock && _enableMocks) {
693
+ var mockLocation = getGlobalInst("__mockLocation");
694
+ if (mockLocation) {
695
+ return mockLocation;
696
+ }
697
+ }
698
+ if (typeof location === strShimObject && location) {
699
+ return location;
700
+ }
701
+ return getGlobalInst(strLocation);
702
+ }
703
+ function getConsole() {
704
+ if (typeof console !== strShimUndefined) {
705
+ return console;
706
+ }
707
+ return getGlobalInst(strConsole);
708
+ }
709
+ function getPerformance() {
710
+ return getGlobalInst(strPerformance);
711
+ }
712
+ function hasJSON() {
713
+ return Boolean((typeof JSON === strShimObject && JSON) || getGlobalInst(strJSON) !== null);
714
+ }
715
+ function getJSON() {
716
+ if (hasJSON()) {
717
+ return JSON || getGlobalInst(strJSON);
718
+ }
719
+ return null;
720
+ }
721
+ function getCrypto() {
722
+ return getGlobalInst(strCrypto);
723
+ }
724
+ function getMsCrypto() {
725
+ return getGlobalInst(strMsCrypto);
726
+ }
727
+ function isIE() {
728
+ var nav = getNavigator();
729
+ if (nav && (nav.userAgent !== _navUserAgentCheck || _isTrident === null)) {
730
+ _navUserAgentCheck = nav.userAgent;
731
+ var userAgent = (_navUserAgentCheck || strEmpty).toLowerCase();
732
+ _isTrident = (strContains(userAgent, strMsie) || strContains(userAgent, strTrident));
733
+ }
734
+ return _isTrident;
735
+ }
736
+ function dumpObj(object) {
737
+ var objectTypeDump = Object[strShimPrototype].toString.call(object);
738
+ var propertyValueDump = strEmpty;
739
+ if (objectTypeDump === "[object Error]") {
740
+ propertyValueDump = "{ stack: '" + object.stack + "', message: '" + object.message + "', name: '" + object.name + "'";
741
+ }
742
+ else if (hasJSON()) {
743
+ propertyValueDump = getJSON().stringify(object);
744
+ }
745
+ return objectTypeDump + propertyValueDump;
746
+ }
747
+
748
+ var _aiNamespace = null;
749
+ function _getExtensionNamespace() {
750
+ var target = getGlobalInst("Microsoft");
751
+ if (target) {
752
+ _aiNamespace = target["ApplicationInsights"];
753
+ }
754
+ return _aiNamespace;
755
+ }
756
+ function getDebugExt(config) {
757
+ var ns = _aiNamespace;
758
+ if (!ns && config.disableDbgExt !== true) {
759
+ ns = _aiNamespace || _getExtensionNamespace();
760
+ }
761
+ return ns ? ns["ChromeDbgExt"] : null;
762
+ }
763
+
764
+ var AiNonUserActionablePrefix = "AI (Internal): ";
765
+ var AiUserActionablePrefix = "AI: ";
766
+ var AIInternalMessagePrefix = "AITR_";
767
+ var strErrorToConsole = "errorToConsole";
768
+ var strWarnToConsole = "warnToConsole";
769
+ function _sanitizeDiagnosticText(text) {
770
+ if (text) {
771
+ return "\"" + text.replace(/\"/g, strEmpty) + "\"";
772
+ }
773
+ return strEmpty;
774
+ }
775
+ function _logToConsole(func, message) {
776
+ var theConsole = getConsole();
777
+ if (!!theConsole) {
778
+ var logFunc = "log";
779
+ if (theConsole[func]) {
780
+ logFunc = func;
781
+ }
782
+ if (isFunction(theConsole[logFunc])) {
783
+ theConsole[logFunc](message);
784
+ }
785
+ }
786
+ }
787
+ var _InternalLogMessage = /** @class */ (function () {
788
+ function _InternalLogMessage(msgId, msg, isUserAct, properties) {
789
+ if (isUserAct === void 0) { isUserAct = false; }
790
+ var _self = this;
791
+ _self.messageId = msgId;
792
+ _self.message =
793
+ (isUserAct ? AiUserActionablePrefix : AiNonUserActionablePrefix) +
794
+ msgId;
795
+ var strProps = strEmpty;
796
+ if (hasJSON()) {
797
+ strProps = getJSON().stringify(properties);
798
+ }
799
+ var diagnosticText = (msg ? " message:" + _sanitizeDiagnosticText(msg) : strEmpty) +
800
+ (properties ? " props:" + _sanitizeDiagnosticText(strProps) : strEmpty);
801
+ _self.message += diagnosticText;
802
+ }
803
+ _InternalLogMessage.dataType = "MessageData";
804
+ return _InternalLogMessage;
805
+ }());
806
+ function safeGetLogger(core, config) {
807
+ return (core || {}).logger || new DiagnosticLogger(config);
808
+ }
809
+ var DiagnosticLogger = /** @class */ (function () {
810
+ function DiagnosticLogger(config) {
811
+ this.identifier = "DiagnosticLogger";
812
+ this.queue = [];
813
+ var _messageCount = 0;
814
+ var _messageLogged = {};
815
+ dynamicProto(DiagnosticLogger, this, function (_self) {
816
+ if (isNullOrUndefined(config)) {
817
+ config = {};
818
+ }
819
+ _self.consoleLoggingLevel = function () { return _getConfigValue("loggingLevelConsole", 0); };
820
+ _self.telemetryLoggingLevel = function () { return _getConfigValue("loggingLevelTelemetry", 1); };
821
+ _self.maxInternalMessageLimit = function () { return _getConfigValue("maxMessageLimit", 25); };
822
+ _self.enableDebugExceptions = function () { return _getConfigValue("enableDebugExceptions", false); };
823
+ _self.throwInternal = function (severity, msgId, msg, properties, isUserAct) {
824
+ if (isUserAct === void 0) { isUserAct = false; }
825
+ var message = new _InternalLogMessage(msgId, msg, isUserAct, properties);
826
+ if (_self.enableDebugExceptions()) {
827
+ throw message;
828
+ }
829
+ else {
830
+ var logFunc = severity === 1 ? strErrorToConsole : strWarnToConsole;
831
+ if (!isUndefined(message.message)) {
832
+ var logLevel = _self.consoleLoggingLevel();
833
+ if (isUserAct) {
834
+ var messageKey = +message.messageId;
835
+ if (!_messageLogged[messageKey] && logLevel >= severity) {
836
+ _self[logFunc](message.message);
837
+ _messageLogged[messageKey] = true;
838
+ }
839
+ }
840
+ else {
841
+ if (logLevel >= severity) {
842
+ _self[logFunc](message.message);
843
+ }
844
+ }
845
+ _self.logInternalMessage(severity, message);
846
+ }
847
+ else {
848
+ _debugExtMsg("throw" + (severity === 1 ? "Critical" : "Warning"), message);
849
+ }
850
+ }
851
+ };
852
+ _self.warnToConsole = function (message) {
853
+ _logToConsole("warn", message);
854
+ _debugExtMsg("warning", message);
855
+ };
856
+ _self.errorToConsole = function (message) {
857
+ _logToConsole("error", message);
858
+ _debugExtMsg("error", message);
859
+ };
860
+ _self.resetInternalMessageCount = function () {
861
+ _messageCount = 0;
862
+ _messageLogged = {};
863
+ };
864
+ _self.logInternalMessage = function (severity, message) {
865
+ if (_areInternalMessagesThrottled()) {
866
+ return;
867
+ }
868
+ var logMessage = true;
869
+ var messageKey = AIInternalMessagePrefix + message.messageId;
870
+ if (_messageLogged[messageKey]) {
871
+ logMessage = false;
872
+ }
873
+ else {
874
+ _messageLogged[messageKey] = true;
875
+ }
876
+ if (logMessage) {
877
+ if (severity <= _self.telemetryLoggingLevel()) {
878
+ _self.queue.push(message);
879
+ _messageCount++;
880
+ _debugExtMsg((severity === 1 ? "error" : "warn"), message);
881
+ }
882
+ if (_messageCount === _self.maxInternalMessageLimit()) {
883
+ var throttleLimitMessage = "Internal events throttle limit per PageView reached for this app.";
884
+ var throttleMessage = new _InternalLogMessage(23 , throttleLimitMessage, false);
885
+ _self.queue.push(throttleMessage);
886
+ if (severity === 1 ) {
887
+ _self.errorToConsole(throttleLimitMessage);
888
+ }
889
+ else {
890
+ _self.warnToConsole(throttleLimitMessage);
891
+ }
892
+ }
893
+ }
894
+ };
895
+ function _getConfigValue(name, defValue) {
896
+ var value = config[name];
897
+ if (!isNullOrUndefined(value)) {
898
+ return value;
899
+ }
900
+ return defValue;
901
+ }
902
+ function _areInternalMessagesThrottled() {
903
+ return _messageCount >= _self.maxInternalMessageLimit();
904
+ }
905
+ function _debugExtMsg(name, data) {
906
+ var dbgExt = getDebugExt(config);
907
+ if (dbgExt && dbgExt.diagLog) {
908
+ dbgExt.diagLog(name, data);
909
+ }
910
+ }
911
+ });
912
+ }
913
+ return DiagnosticLogger;
914
+ }());
915
+ function _throwInternal(logger, severity, msgId, msg, properties, isUserAct) {
916
+ if (isUserAct === void 0) { isUserAct = false; }
917
+ (logger || new DiagnosticLogger()).throwInternal(severity, msgId, msg, properties, isUserAct);
918
+ }
919
+
920
+ var strExecutionContextKey = "ctx";
921
+ var PerfEvent = /** @class */ (function () {
922
+ function PerfEvent(name, payloadDetails, isAsync) {
923
+ var _self = this;
924
+ var accessorDefined = false;
925
+ _self.start = dateNow();
926
+ _self.name = name;
927
+ _self.isAsync = isAsync;
928
+ _self.isChildEvt = function () { return false; };
929
+ if (isFunction(payloadDetails)) {
930
+ var theDetails_1;
931
+ accessorDefined = objDefineAccessors(_self, "payload", function () {
932
+ if (!theDetails_1 && isFunction(payloadDetails)) {
933
+ theDetails_1 = payloadDetails();
934
+ payloadDetails = null;
935
+ }
936
+ return theDetails_1;
937
+ });
938
+ }
939
+ _self.getCtx = function (key) {
940
+ if (key) {
941
+ if (key === PerfEvent.ParentContextKey || key === PerfEvent.ChildrenContextKey) {
942
+ return _self[key];
943
+ }
944
+ return (_self[strExecutionContextKey] || {})[key];
945
+ }
946
+ return null;
947
+ };
948
+ _self.setCtx = function (key, value) {
949
+ if (key) {
950
+ if (key === PerfEvent.ParentContextKey) {
951
+ if (!_self[key]) {
952
+ _self.isChildEvt = function () { return true; };
953
+ }
954
+ _self[key] = value;
955
+ }
956
+ else if (key === PerfEvent.ChildrenContextKey) {
957
+ _self[key] = value;
958
+ }
959
+ else {
960
+ var ctx = _self[strExecutionContextKey] = _self[strExecutionContextKey] || {};
961
+ ctx[key] = value;
962
+ }
963
+ }
964
+ };
965
+ _self.complete = function () {
966
+ var childTime = 0;
967
+ var childEvts = _self.getCtx(PerfEvent.ChildrenContextKey);
968
+ if (isArray(childEvts)) {
969
+ for (var lp = 0; lp < childEvts.length; lp++) {
970
+ var childEvt = childEvts[lp];
971
+ if (childEvt) {
972
+ childTime += childEvt.time;
973
+ }
974
+ }
975
+ }
976
+ _self.time = dateNow() - _self.start;
977
+ _self.exTime = _self.time - childTime;
978
+ _self.complete = function () { };
979
+ if (!accessorDefined && isFunction(payloadDetails)) {
980
+ _self.payload = payloadDetails();
981
+ }
982
+ };
983
+ }
984
+ PerfEvent.ParentContextKey = "parent";
985
+ PerfEvent.ChildrenContextKey = "childEvts";
986
+ return PerfEvent;
987
+ }());
988
+ var doPerfActiveKey = "CoreUtils.doPerf";
989
+ function doPerf(mgrSource, getSource, func, details, isAsync) {
990
+ if (mgrSource) {
991
+ var perfMgr = mgrSource;
992
+ if (isFunction(perfMgr["getPerfMgr"])) {
993
+ perfMgr = perfMgr["getPerfMgr"]();
994
+ }
995
+ if (perfMgr) {
996
+ var perfEvt = void 0;
997
+ var currentActive = perfMgr.getCtx(doPerfActiveKey);
998
+ try {
999
+ perfEvt = perfMgr.create(getSource(), details, isAsync);
1000
+ if (perfEvt) {
1001
+ if (currentActive && perfEvt.setCtx) {
1002
+ perfEvt.setCtx(PerfEvent.ParentContextKey, currentActive);
1003
+ if (currentActive.getCtx && currentActive.setCtx) {
1004
+ var children = currentActive.getCtx(PerfEvent.ChildrenContextKey);
1005
+ if (!children) {
1006
+ children = [];
1007
+ currentActive.setCtx(PerfEvent.ChildrenContextKey, children);
1008
+ }
1009
+ children.push(perfEvt);
1010
+ }
1011
+ }
1012
+ perfMgr.setCtx(doPerfActiveKey, perfEvt);
1013
+ return func(perfEvt);
1014
+ }
1015
+ }
1016
+ catch (ex) {
1017
+ if (perfEvt && perfEvt.setCtx) {
1018
+ perfEvt.setCtx("exception", ex);
1019
+ }
1020
+ }
1021
+ finally {
1022
+ if (perfEvt) {
1023
+ perfMgr.fire(perfEvt);
1024
+ }
1025
+ perfMgr.setCtx(doPerfActiveKey, currentActive);
1026
+ }
1027
+ }
1028
+ }
1029
+ return func();
1030
+ }
1031
+
1032
+ var UInt32Mask = 0x100000000;
1033
+ var MaxUInt32 = 0xffffffff;
1034
+ var _mwcSeeded = false;
1035
+ var _mwcW = 123456789;
1036
+ var _mwcZ = 987654321;
1037
+ function _mwcSeed(seedValue) {
1038
+ if (seedValue < 0) {
1039
+ seedValue >>>= 0;
1040
+ }
1041
+ _mwcW = (123456789 + seedValue) & MaxUInt32;
1042
+ _mwcZ = (987654321 - seedValue) & MaxUInt32;
1043
+ _mwcSeeded = true;
1044
+ }
1045
+ function _autoSeedMwc() {
1046
+ try {
1047
+ var now = dateNow() & 0x7fffffff;
1048
+ _mwcSeed(((Math.random() * UInt32Mask) ^ now) + now);
1049
+ }
1050
+ catch (e) {
1051
+ }
1052
+ }
1053
+ function random32(signed) {
1054
+ var value = 0;
1055
+ var c = getCrypto() || getMsCrypto();
1056
+ if (c && c.getRandomValues) {
1057
+ value = c.getRandomValues(new Uint32Array(1))[0] & MaxUInt32;
1058
+ }
1059
+ if (value === 0 && isIE()) {
1060
+ if (!_mwcSeeded) {
1061
+ _autoSeedMwc();
1062
+ }
1063
+ value = mwcRandom32() & MaxUInt32;
1064
+ }
1065
+ if (value === 0) {
1066
+ value = Math.floor((UInt32Mask * Math.random()) | 0);
1067
+ }
1068
+ if (!signed) {
1069
+ value >>>= 0;
1070
+ }
1071
+ return value;
1072
+ }
1073
+ function mwcRandom32(signed) {
1074
+ _mwcZ = (36969 * (_mwcZ & 0xFFFF) + (_mwcZ >> 16)) & MaxUInt32;
1075
+ _mwcW = (18000 * (_mwcW & 0xFFFF) + (_mwcW >> 16)) & MaxUInt32;
1076
+ var value = (((_mwcZ << 16) + (_mwcW & 0xFFFF)) >>> 0) & MaxUInt32 | 0;
1077
+ if (!signed) {
1078
+ value >>>= 0;
1079
+ }
1080
+ return value;
1081
+ }
1082
+ function newId(maxLength) {
1083
+ if (maxLength === void 0) { maxLength = 22; }
1084
+ var base64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1085
+ var number = random32() >>> 0;
1086
+ var chars = 0;
1087
+ var result = strEmpty;
1088
+ while (result.length < maxLength) {
1089
+ chars++;
1090
+ result += base64chars.charAt(number & 0x3F);
1091
+ number >>>= 6;
1092
+ if (chars === 5) {
1093
+ number = (((random32() << 2) & 0xFFFFFFFF) | (number & 0x03)) >>> 0;
1094
+ chars = 0;
1095
+ }
1096
+ }
1097
+ return result;
1098
+ }
1099
+
1100
+ var _objDefineProperty = ObjDefineProperty;
1101
+ var version = "2.8.0-nightly.2204-04";
1102
+ var instanceName = "." + newId(6);
1103
+ var _dataUid = 0;
1104
+ function _createAccessor(target, prop, value) {
1105
+ if (_objDefineProperty) {
1106
+ try {
1107
+ _objDefineProperty(target, prop, {
1108
+ value: value,
1109
+ enumerable: false,
1110
+ configurable: true
1111
+ });
1112
+ return true;
1113
+ }
1114
+ catch (e) {
1115
+ }
1116
+ }
1117
+ return false;
1118
+ }
1119
+ function _canAcceptData(target) {
1120
+ return target.nodeType === 1 || target.nodeType === 9 || !(+target.nodeType);
1121
+ }
1122
+ function _getCache(data, target) {
1123
+ var theCache = target[data.id];
1124
+ if (!theCache) {
1125
+ theCache = {};
1126
+ try {
1127
+ if (_canAcceptData(target)) {
1128
+ if (!_createAccessor(target, data.id, theCache)) {
1129
+ target[data.id] = theCache;
1130
+ }
1131
+ }
1132
+ }
1133
+ catch (e) {
1134
+ }
1135
+ }
1136
+ return theCache;
1137
+ }
1138
+ function createUniqueNamespace(name, includeVersion) {
1139
+ if (includeVersion === void 0) { includeVersion = false; }
1140
+ return normalizeJsName(name + (_dataUid++) + (includeVersion ? "." + version : "") + instanceName);
1141
+ }
1142
+ function createElmNodeData(name) {
1143
+ var data = {
1144
+ id: createUniqueNamespace("_aiData-" + (name || "") + "." + version),
1145
+ accept: function (target) {
1146
+ return _canAcceptData(target);
1147
+ },
1148
+ get: function (target, name, defValue, addDefault) {
1149
+ var theCache = target[data.id];
1150
+ if (!theCache) {
1151
+ if (addDefault) {
1152
+ theCache = _getCache(data, target);
1153
+ theCache[normalizeJsName(name)] = defValue;
1154
+ }
1155
+ return defValue;
1156
+ }
1157
+ return theCache[normalizeJsName(name)];
1158
+ },
1159
+ kill: function (target, name) {
1160
+ if (target && target[name]) {
1161
+ try {
1162
+ delete target[name];
1163
+ }
1164
+ catch (e) {
1165
+ }
1166
+ }
1167
+ }
1168
+ };
1169
+ return data;
1170
+ }
1171
+
1172
+ var strDoUnload = "_doUnload";
1173
+ var pluginStateData = createElmNodeData("plugin");
1174
+ function _getPluginState(plugin) {
1175
+ return pluginStateData.get(plugin, "state", {}, true);
1176
+ }
1177
+ function unloadComponents(components, unloadCtx, unloadState, asyncCallback) {
1178
+ var idx = 0;
1179
+ function _doUnload() {
1180
+ while (idx < components.length) {
1181
+ var component = components[idx++];
1182
+ if (component) {
1183
+ var func = component[strDoUnload] || component[strDoTeardown];
1184
+ if (isFunction(func)) {
1185
+ if (func.call(component, unloadCtx, unloadState, _doUnload) === true) {
1186
+ return true;
1187
+ }
1188
+ }
1189
+ }
1190
+ }
1191
+ }
1192
+ return _doUnload();
1193
+ }
1194
+
1195
+ var strTelemetryPluginChain = "TelemetryPluginChain";
1196
+ var strHasRunFlags = "_hasRun";
1197
+ var strGetTelCtx = "_getTelCtx";
1198
+ var _chainId = 0;
1199
+ function _getNextProxyStart(proxy, config, core, startAt) {
1200
+ while (proxy) {
1201
+ if (proxy.getPlugin() === startAt) {
1202
+ return proxy;
1203
+ }
1204
+ proxy = proxy.getNext();
1205
+ }
1206
+ return createTelemetryProxyChain([startAt], config, core);
1207
+ }
1208
+ function _createInternalContext(telemetryChain, config, core, startAt) {
1209
+ var _nextProxy = null;
1210
+ var _onComplete = [];
1211
+ if (startAt !== null) {
1212
+ _nextProxy = startAt ? _getNextProxyStart(telemetryChain, config, core, startAt) : telemetryChain;
1213
+ }
1214
+ var context = {
1215
+ _next: _moveNext,
1216
+ ctx: {
1217
+ core: function () {
1218
+ return core;
1219
+ },
1220
+ diagLog: function () {
1221
+ return safeGetLogger(core, config);
1222
+ },
1223
+ getCfg: function () {
1224
+ return config;
1225
+ },
1226
+ getExtCfg: _getExtCfg,
1227
+ getConfig: _getConfig,
1228
+ hasNext: function () {
1229
+ return !!_nextProxy;
1230
+ },
1231
+ getNext: function () {
1232
+ return _nextProxy;
1233
+ },
1234
+ setNext: function (nextPlugin) {
1235
+ _nextProxy = nextPlugin;
1236
+ },
1237
+ iterate: _iterateChain,
1238
+ onComplete: _addOnComplete
1239
+ }
1240
+ };
1241
+ function _addOnComplete(onComplete, that) {
1242
+ var args = [];
1243
+ for (var _i = 2; _i < arguments.length; _i++) {
1244
+ args[_i - 2] = arguments[_i];
1245
+ }
1246
+ if (onComplete) {
1247
+ _onComplete.push({
1248
+ func: onComplete,
1249
+ self: !isUndefined(that) ? that : context.ctx,
1250
+ args: args
1251
+ });
1252
+ }
1253
+ }
1254
+ function _moveNext() {
1255
+ var nextProxy = _nextProxy;
1256
+ _nextProxy = nextProxy ? nextProxy.getNext() : null;
1257
+ if (!nextProxy) {
1258
+ var onComplete = _onComplete;
1259
+ if (onComplete && onComplete.length > 0) {
1260
+ arrForEach(onComplete, function (completeDetails) {
1261
+ try {
1262
+ completeDetails.func.call(completeDetails.self, completeDetails.args);
1263
+ }
1264
+ catch (e) {
1265
+ _throwInternal(core.logger, 2 , 73 , "Unexpected Exception during onComplete - " + dumpObj(e));
1266
+ }
1267
+ });
1268
+ _onComplete = [];
1269
+ }
1270
+ }
1271
+ return nextProxy;
1272
+ }
1273
+ function _getExtCfg(identifier, defaultValue, mergeDefault) {
1274
+ if (defaultValue === void 0) { defaultValue = {}; }
1275
+ if (mergeDefault === void 0) { mergeDefault = 0 ; }
1276
+ var theConfig;
1277
+ if (config) {
1278
+ var extConfig = config.extensionConfig;
1279
+ if (extConfig && identifier) {
1280
+ theConfig = extConfig[identifier];
1281
+ }
1282
+ }
1283
+ if (!theConfig) {
1284
+ theConfig = defaultValue;
1285
+ }
1286
+ else if (isObject(defaultValue)) {
1287
+ if (mergeDefault !== 0 ) {
1288
+ var newConfig_1 = objExtend(true, defaultValue, theConfig);
1289
+ if (config && mergeDefault === 2 ) {
1290
+ objForEachKey(defaultValue, function (field) {
1291
+ if (isNullOrUndefined(newConfig_1[field])) {
1292
+ var cfgValue = config[field];
1293
+ if (!isNullOrUndefined(cfgValue)) {
1294
+ newConfig_1[field] = cfgValue;
1295
+ }
1296
+ }
1297
+ });
1298
+ }
1299
+ }
1300
+ }
1301
+ return theConfig;
1302
+ }
1303
+ function _getConfig(identifier, field, defaultValue) {
1304
+ if (defaultValue === void 0) { defaultValue = false; }
1305
+ var theValue;
1306
+ var extConfig = _getExtCfg(identifier, null);
1307
+ if (extConfig && !isNullOrUndefined(extConfig[field])) {
1308
+ theValue = extConfig[field];
1309
+ }
1310
+ else if (config && !isNullOrUndefined(config[field])) {
1311
+ theValue = config[field];
1312
+ }
1313
+ return !isNullOrUndefined(theValue) ? theValue : defaultValue;
1314
+ }
1315
+ function _iterateChain(cb) {
1316
+ var nextPlugin;
1317
+ while (!!(nextPlugin = context._next())) {
1318
+ var plugin = nextPlugin.getPlugin();
1319
+ if (plugin) {
1320
+ cb(plugin);
1321
+ }
1322
+ }
1323
+ }
1324
+ return context;
1325
+ }
1326
+ function createProcessTelemetryContext(telemetryChain, config, core, startAt) {
1327
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1328
+ var context = internalContext.ctx;
1329
+ function _processNext(env) {
1330
+ var nextPlugin = internalContext._next();
1331
+ nextPlugin && nextPlugin.processTelemetry(env, context);
1332
+ return !nextPlugin;
1333
+ }
1334
+ function _createNew(plugins, startAt) {
1335
+ if (plugins === void 0) { plugins = null; }
1336
+ if (isArray(plugins)) {
1337
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1338
+ }
1339
+ return createProcessTelemetryContext(plugins || context.getNext(), config, core, startAt);
1340
+ }
1341
+ context.processNext = _processNext;
1342
+ context.createNew = _createNew;
1343
+ return context;
1344
+ }
1345
+ function createProcessTelemetryUnloadContext(telemetryChain, config, core, startAt) {
1346
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1347
+ var context = internalContext.ctx;
1348
+ function _processNext(unloadState) {
1349
+ var nextPlugin = internalContext._next();
1350
+ nextPlugin && nextPlugin.unload(context, unloadState);
1351
+ return !nextPlugin;
1352
+ }
1353
+ function _createNew(plugins, startAt) {
1354
+ if (plugins === void 0) { plugins = null; }
1355
+ if (isArray(plugins)) {
1356
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1357
+ }
1358
+ return createProcessTelemetryUnloadContext(plugins || context.getNext(), config, core, startAt);
1359
+ }
1360
+ context.processNext = _processNext;
1361
+ context.createNew = _createNew;
1362
+ return context;
1363
+ }
1364
+ function createProcessTelemetryUpdateContext(telemetryChain, config, core, startAt) {
1365
+ var internalContext = _createInternalContext(telemetryChain, config, core, startAt);
1366
+ var context = internalContext.ctx;
1367
+ function _processNext(updateState) {
1368
+ return context.iterate(function (plugin) {
1369
+ if (isFunction(plugin[strUpdate])) {
1370
+ plugin[strUpdate](context, updateState);
1371
+ }
1372
+ });
1373
+ }
1374
+ function _createNew(plugins, startAt) {
1375
+ if (plugins === void 0) { plugins = null; }
1376
+ if (isArray(plugins)) {
1377
+ plugins = createTelemetryProxyChain(plugins, config, core, startAt);
1378
+ }
1379
+ return createProcessTelemetryUpdateContext(plugins || context.getNext(), config, core, startAt);
1380
+ }
1381
+ context.processNext = _processNext;
1382
+ context.createNew = _createNew;
1383
+ return context;
1384
+ }
1385
+ function createTelemetryProxyChain(plugins, config, core, startAt) {
1386
+ var firstProxy = null;
1387
+ var add = startAt ? false : true;
1388
+ if (isArray(plugins) && plugins.length > 0) {
1389
+ var lastProxy_1 = null;
1390
+ arrForEach(plugins, function (thePlugin) {
1391
+ if (!add && startAt === thePlugin) {
1392
+ add = true;
1393
+ }
1394
+ if (add && thePlugin && isFunction(thePlugin.processTelemetry)) {
1395
+ var newProxy = createTelemetryPluginProxy(thePlugin, config, core);
1396
+ if (!firstProxy) {
1397
+ firstProxy = newProxy;
1398
+ }
1399
+ if (lastProxy_1) {
1400
+ lastProxy_1._setNext(newProxy);
1401
+ }
1402
+ lastProxy_1 = newProxy;
1403
+ }
1404
+ });
1405
+ }
1406
+ if (startAt && !firstProxy) {
1407
+ return createTelemetryProxyChain([startAt], config, core);
1408
+ }
1409
+ return firstProxy;
1410
+ }
1411
+ function createTelemetryPluginProxy(plugin, config, core) {
1412
+ var nextProxy = null;
1413
+ var hasProcessTelemetry = isFunction(plugin.processTelemetry);
1414
+ var hasSetNext = isFunction(plugin.setNextPlugin);
1415
+ var chainId;
1416
+ if (plugin) {
1417
+ chainId = plugin.identifier + "-" + plugin.priority + "-" + _chainId++;
1418
+ }
1419
+ else {
1420
+ chainId = "Unknown-0-" + _chainId++;
1421
+ }
1422
+ var proxyChain = {
1423
+ getPlugin: function () {
1424
+ return plugin;
1425
+ },
1426
+ getNext: function () {
1427
+ return nextProxy;
1428
+ },
1429
+ processTelemetry: _processTelemetry,
1430
+ unload: _unloadPlugin,
1431
+ update: _updatePlugin,
1432
+ _id: chainId,
1433
+ _setNext: function (nextPlugin) {
1434
+ nextProxy = nextPlugin;
1435
+ }
1436
+ };
1437
+ function _getTelCtx() {
1438
+ var itemCtx;
1439
+ if (plugin && isFunction(plugin[strGetTelCtx])) {
1440
+ itemCtx = plugin[strGetTelCtx]();
1441
+ }
1442
+ if (!itemCtx) {
1443
+ itemCtx = createProcessTelemetryContext(proxyChain, config, core);
1444
+ }
1445
+ return itemCtx;
1446
+ }
1447
+ function _processChain(itemCtx, processPluginFn, name, details, isAsync) {
1448
+ var hasRun = false;
1449
+ var identifier = plugin ? plugin.identifier : strTelemetryPluginChain;
1450
+ var hasRunContext = itemCtx[strHasRunFlags];
1451
+ if (!hasRunContext) {
1452
+ hasRunContext = itemCtx[strHasRunFlags] = {};
1453
+ }
1454
+ itemCtx.setNext(nextProxy);
1455
+ if (plugin) {
1456
+ doPerf(itemCtx[strCore](), function () { return identifier + ":" + name; }, function () {
1457
+ hasRunContext[chainId] = true;
1458
+ try {
1459
+ var nextId = nextProxy ? nextProxy._id : strEmpty;
1460
+ if (nextId) {
1461
+ hasRunContext[nextId] = false;
1462
+ }
1463
+ hasRun = processPluginFn(itemCtx);
1464
+ }
1465
+ catch (error) {
1466
+ var hasNextRun = nextProxy ? hasRunContext[nextProxy._id] : true;
1467
+ if (hasNextRun) {
1468
+ hasRun = true;
1469
+ }
1470
+ if (!nextProxy || !hasNextRun) {
1471
+ _throwInternal(itemCtx.diagLog(), 1 , 73 , "Plugin [" + plugin.identifier + "] failed during " + name + " - " + dumpObj(error) + ", run flags: " + dumpObj(hasRunContext));
1472
+ }
1473
+ }
1474
+ }, details, isAsync);
1475
+ }
1476
+ return hasRun;
1477
+ }
1478
+ function _processTelemetry(env, itemCtx) {
1479
+ itemCtx = itemCtx || _getTelCtx();
1480
+ function _callProcessTelemetry(itemCtx) {
1481
+ if (!plugin || !hasProcessTelemetry) {
1482
+ return false;
1483
+ }
1484
+ var pluginState = _getPluginState(plugin);
1485
+ if (pluginState[strTeardown] || pluginState[strDisabled]) {
1486
+ return false;
1487
+ }
1488
+ if (hasSetNext) {
1489
+ plugin.setNextPlugin(nextProxy);
1490
+ }
1491
+ plugin.processTelemetry(env, itemCtx);
1492
+ return true;
1493
+ }
1494
+ if (!_processChain(itemCtx, _callProcessTelemetry, "processTelemetry", function () { return ({ item: env }); }, !(env.sync))) {
1495
+ itemCtx.processNext(env);
1496
+ }
1497
+ }
1498
+ function _unloadPlugin(unloadCtx, unloadState) {
1499
+ function _callTeardown() {
1500
+ var hasRun = false;
1501
+ if (plugin) {
1502
+ var pluginState = _getPluginState(plugin);
1503
+ var pluginCore = plugin[strCore] || pluginState.core;
1504
+ if (plugin && (!pluginCore || pluginCore === unloadCtx[strCore]()) && !pluginState[strTeardown]) {
1505
+ pluginState[strCore] = null;
1506
+ pluginState[strTeardown] = true;
1507
+ pluginState[strIsInitialized] = false;
1508
+ if (plugin[strTeardown] && plugin[strTeardown](unloadCtx, unloadState) === true) {
1509
+ hasRun = true;
1510
+ }
1511
+ }
1512
+ }
1513
+ return hasRun;
1514
+ }
1515
+ if (!_processChain(unloadCtx, _callTeardown, "unload", function () { }, unloadState.isAsync)) {
1516
+ unloadCtx.processNext(unloadState);
1517
+ }
1518
+ }
1519
+ function _updatePlugin(updateCtx, updateState) {
1520
+ function _callUpdate() {
1521
+ var hasRun = false;
1522
+ if (plugin) {
1523
+ var pluginState = _getPluginState(plugin);
1524
+ var pluginCore = plugin[strCore] || pluginState.core;
1525
+ if (plugin && (!pluginCore || pluginCore === updateCtx[strCore]()) && !pluginState[strTeardown]) {
1526
+ if (plugin[strUpdate] && plugin[strUpdate](updateCtx, updateState) === true) {
1527
+ hasRun = true;
1528
+ }
1529
+ }
1530
+ }
1531
+ return hasRun;
1532
+ }
1533
+ if (!_processChain(updateCtx, _callUpdate, "update", function () { }, false)) {
1534
+ updateCtx.processNext(updateState);
1535
+ }
1536
+ }
1537
+ return objFreeze(proxyChain);
1538
+ }
1539
+
1540
+ var strExtensionConfig = "extensionConfig";
1541
+
1542
+ function createUnloadHandlerContainer() {
1543
+ var handlers = [];
1544
+ function _addHandler(handler) {
1545
+ if (handler) {
1546
+ handlers.push(handler);
1547
+ }
1548
+ }
1549
+ function _runHandlers(unloadCtx, unloadState) {
1550
+ arrForEach(handlers, function (handler) {
1551
+ try {
1552
+ handler(unloadCtx, unloadState);
1553
+ }
1554
+ catch (e) {
1555
+ _throwInternal(unloadCtx.diagLog(), 2 , 73 , "Unexpected error calling unload handler - " + dumpObj(e));
1556
+ }
1557
+ });
1558
+ handlers = [];
1559
+ }
1560
+ return {
1561
+ add: _addHandler,
1562
+ run: _runHandlers
1563
+ };
1564
+ }
1565
+
1566
+ var strGetPlugin = "getPlugin";
1567
+ var BaseTelemetryPlugin = /** @class */ (function () {
1568
+ function BaseTelemetryPlugin() {
1569
+ var _self = this;
1570
+ var _isinitialized;
1571
+ var _rootCtx;
1572
+ var _nextPlugin;
1573
+ var _unloadHandlerContainer;
1574
+ var _hooks;
1575
+ _initDefaults();
1576
+ dynamicProto(BaseTelemetryPlugin, _self, function (_self) {
1577
+ _self.initialize = function (config, core, extensions, pluginChain) {
1578
+ _setDefaults(config, core, pluginChain);
1579
+ _isinitialized = true;
1580
+ };
1581
+ _self.teardown = function (unloadCtx, unloadState) {
1582
+ if (!_self.core || (unloadCtx && _self.core !== unloadCtx.core())) {
1583
+ return;
1584
+ }
1585
+ var result;
1586
+ var unloadDone = false;
1587
+ var theUnloadCtx = unloadCtx || createProcessTelemetryUnloadContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1588
+ var theUnloadState = unloadState || {
1589
+ reason: 0 ,
1590
+ isAsync: false
1591
+ };
1592
+ function _unloadCallback() {
1593
+ if (!unloadDone) {
1594
+ unloadDone = true;
1595
+ _unloadHandlerContainer.run(theUnloadCtx, unloadState);
1596
+ arrForEach(_hooks, function (fn) {
1597
+ fn.rm();
1598
+ });
1599
+ _hooks = [];
1600
+ if (result === true) {
1601
+ theUnloadCtx.processNext(theUnloadState);
1602
+ }
1603
+ _initDefaults();
1604
+ }
1605
+ }
1606
+ if (!_self[strDoTeardown] || _self[strDoTeardown](theUnloadCtx, theUnloadState, _unloadCallback) !== true) {
1607
+ _unloadCallback();
1608
+ }
1609
+ else {
1610
+ result = true;
1611
+ }
1612
+ return result;
1613
+ };
1614
+ _self.update = function (updateCtx, updateState) {
1615
+ if (!_self.core || (updateCtx && _self.core !== updateCtx.core())) {
1616
+ return;
1617
+ }
1618
+ var result;
1619
+ var updateDone = false;
1620
+ var theUpdateCtx = updateCtx || createProcessTelemetryUpdateContext(null, {}, _self.core, _nextPlugin && _nextPlugin[strGetPlugin] ? _nextPlugin[strGetPlugin]() : _nextPlugin);
1621
+ var theUpdateState = updateState || {
1622
+ reason: 0
1623
+ };
1624
+ function _updateCallback() {
1625
+ if (!updateDone) {
1626
+ updateDone = true;
1627
+ _setDefaults(theUpdateCtx.getCfg(), theUpdateCtx.core(), theUpdateCtx.getNext());
1628
+ }
1629
+ }
1630
+ if (!_self._doUpdate || _self._doUpdate(theUpdateCtx, theUpdateState, _updateCallback) !== true) {
1631
+ _updateCallback();
1632
+ }
1633
+ else {
1634
+ result = true;
1635
+ }
1636
+ return result;
1637
+ };
1638
+ _self._addHook = function (hooks) {
1639
+ if (hooks) {
1640
+ if (isArray(hooks)) {
1641
+ _hooks = _hooks.concat(hooks);
1642
+ }
1643
+ else {
1644
+ _hooks.push(hooks);
1645
+ }
1646
+ }
1647
+ };
1648
+ proxyFunctionAs(_self, "_addUnloadCb", function () { return _unloadHandlerContainer; }, "add");
1649
+ });
1650
+ _self.diagLog = function (itemCtx) {
1651
+ return _getTelCtx(itemCtx).diagLog();
1652
+ };
1653
+ _self[strIsInitialized] = function () {
1654
+ return _isinitialized;
1655
+ };
1656
+ _self.setInitialized = function (isInitialized) {
1657
+ _isinitialized = isInitialized;
1658
+ };
1659
+ _self[strSetNextPlugin] = function (next) {
1660
+ _nextPlugin = next;
1661
+ };
1662
+ _self.processNext = function (env, itemCtx) {
1663
+ if (itemCtx) {
1664
+ itemCtx.processNext(env);
1665
+ }
1666
+ else if (_nextPlugin && isFunction(_nextPlugin.processTelemetry)) {
1667
+ _nextPlugin.processTelemetry(env, null);
1668
+ }
1669
+ };
1670
+ _self._getTelCtx = _getTelCtx;
1671
+ function _getTelCtx(currentCtx) {
1672
+ if (currentCtx === void 0) { currentCtx = null; }
1673
+ var itemCtx = currentCtx;
1674
+ if (!itemCtx) {
1675
+ var rootCtx = _rootCtx || createProcessTelemetryContext(null, {}, _self.core);
1676
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1677
+ itemCtx = rootCtx.createNew(null, _nextPlugin[strGetPlugin]);
1678
+ }
1679
+ else {
1680
+ itemCtx = rootCtx.createNew(null, _nextPlugin);
1681
+ }
1682
+ }
1683
+ return itemCtx;
1684
+ }
1685
+ function _setDefaults(config, core, pluginChain) {
1686
+ if (config) {
1687
+ setValue(config, strExtensionConfig, [], null, isNullOrUndefined);
1688
+ }
1689
+ if (!pluginChain && core) {
1690
+ pluginChain = core.getProcessTelContext().getNext();
1691
+ }
1692
+ var nextPlugin = _nextPlugin;
1693
+ if (_nextPlugin && _nextPlugin[strGetPlugin]) {
1694
+ nextPlugin = _nextPlugin[strGetPlugin]();
1695
+ }
1696
+ _self.core = core;
1697
+ _rootCtx = createProcessTelemetryContext(pluginChain, config, core, nextPlugin);
1698
+ }
1699
+ function _initDefaults() {
1700
+ _isinitialized = false;
1701
+ _self.core = null;
1702
+ _rootCtx = null;
1703
+ _nextPlugin = null;
1704
+ _hooks = [];
1705
+ _unloadHandlerContainer = createUnloadHandlerContainer();
1706
+ }
1707
+ }
1708
+ return BaseTelemetryPlugin;
1709
+ }());
1710
+
1711
+ var strOnPrefix = "on";
1712
+ var strAttachEvent = "attachEvent";
1713
+ var strAddEventHelper = "addEventListener";
1714
+ var strDetachEvent = "detachEvent";
1715
+ var strRemoveEventListener = "removeEventListener";
1716
+ var strEvents = "events";
1717
+ createUniqueNamespace("aiEvtPageHide");
1718
+ createUniqueNamespace("aiEvtPageShow");
1719
+ var rRemoveEmptyNs = /\.[\.]+/g;
1720
+ var rRemoveTrailingEmptyNs = /[\.]+$/;
1721
+ var _guid = 1;
1722
+ var elmNodeData = createElmNodeData("events");
1723
+ var eventNamespace = /^([^.]*)(?:\.(.+)|)/;
1724
+ function _normalizeNamespace(name) {
1725
+ if (name && name.replace) {
1726
+ return name.replace(/^\s*\.*|\.*\s*$/g, "");
1727
+ }
1728
+ return name;
1729
+ }
1730
+ function _getEvtNamespace(eventName, evtNamespace) {
1731
+ if (evtNamespace) {
1732
+ var theNamespace_1 = "";
1733
+ if (isArray(evtNamespace)) {
1734
+ theNamespace_1 = "";
1735
+ arrForEach(evtNamespace, function (name) {
1736
+ name = _normalizeNamespace(name);
1737
+ if (name) {
1738
+ if (name[0] !== ".") {
1739
+ name = "." + name;
1740
+ }
1741
+ theNamespace_1 += name;
1742
+ }
1743
+ });
1744
+ }
1745
+ else {
1746
+ theNamespace_1 = _normalizeNamespace(evtNamespace);
1747
+ }
1748
+ if (theNamespace_1) {
1749
+ if (theNamespace_1[0] !== ".") {
1750
+ theNamespace_1 = "." + theNamespace_1;
1751
+ }
1752
+ eventName = (eventName || "") + theNamespace_1;
1753
+ }
1754
+ }
1755
+ var parsedEvent = (eventNamespace.exec(eventName || "") || []);
1756
+ return {
1757
+ type: parsedEvent[1],
1758
+ ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
1759
+ };
1760
+ }
1761
+ function _getRegisteredEvents(target, evtName, addDefault) {
1762
+ if (addDefault === void 0) { addDefault = true; }
1763
+ var aiEvts = elmNodeData.get(target, strEvents, {}, addDefault);
1764
+ var registeredEvents = aiEvts[evtName];
1765
+ if (!registeredEvents) {
1766
+ registeredEvents = aiEvts[evtName] = [];
1767
+ }
1768
+ return registeredEvents;
1769
+ }
1770
+ function _doDetach(obj, evtName, handlerRef, useCapture) {
1771
+ if (obj && evtName && evtName.type) {
1772
+ if (obj[strRemoveEventListener]) {
1773
+ obj[strRemoveEventListener](evtName.type, handlerRef, useCapture);
1774
+ }
1775
+ else if (obj[strDetachEvent]) {
1776
+ obj[strDetachEvent](strOnPrefix + evtName.type, handlerRef);
1777
+ }
1778
+ }
1779
+ }
1780
+ function _doAttach(obj, evtName, handlerRef, useCapture) {
1781
+ var result = false;
1782
+ if (obj && evtName && evtName.type && handlerRef) {
1783
+ if (obj[strAddEventHelper]) {
1784
+ obj[strAddEventHelper](evtName.type, handlerRef, useCapture);
1785
+ result = true;
1786
+ }
1787
+ else if (obj[strAttachEvent]) {
1788
+ obj[strAttachEvent](strOnPrefix + evtName.type, handlerRef);
1789
+ result = true;
1790
+ }
1791
+ }
1792
+ return result;
1793
+ }
1794
+ function _doUnregister(target, events, evtName, unRegFn) {
1795
+ var idx = events.length;
1796
+ while (idx--) {
1797
+ var theEvent = events[idx];
1798
+ if (theEvent) {
1799
+ if (!evtName.ns || evtName.ns === theEvent.evtName.ns) {
1800
+ if (!unRegFn || unRegFn(theEvent)) {
1801
+ _doDetach(target, theEvent.evtName, theEvent.handler, theEvent.capture);
1802
+ events.splice(idx, 1);
1803
+ }
1804
+ }
1805
+ }
1806
+ }
1807
+ }
1808
+ function _unregisterEvents(target, evtName, unRegFn) {
1809
+ if (evtName.type) {
1810
+ _doUnregister(target, _getRegisteredEvents(target, evtName.type), evtName, unRegFn);
1811
+ }
1812
+ else {
1813
+ var eventCache = elmNodeData.get(target, strEvents, {});
1814
+ objForEachKey(eventCache, function (evtType, events) {
1815
+ _doUnregister(target, events, evtName, unRegFn);
1816
+ });
1817
+ if (objKeys(eventCache).length === 0) {
1818
+ elmNodeData.kill(target, strEvents);
1819
+ }
1820
+ }
1821
+ }
1822
+ function mergeEvtNamespace(theNamespace, namespaces) {
1823
+ var newNamespaces;
1824
+ if (namespaces) {
1825
+ if (isArray(namespaces)) {
1826
+ newNamespaces = [theNamespace].concat(namespaces);
1827
+ }
1828
+ else {
1829
+ newNamespaces = [theNamespace, namespaces];
1830
+ }
1831
+ newNamespaces = (_getEvtNamespace("xx", newNamespaces).ns).split(".");
1832
+ }
1833
+ else {
1834
+ newNamespaces = theNamespace;
1835
+ }
1836
+ return newNamespaces;
1837
+ }
1838
+ function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
1839
+ if (useCapture === void 0) { useCapture = false; }
1840
+ var result = false;
1841
+ if (target) {
1842
+ try {
1843
+ var evtName = _getEvtNamespace(eventName, evtNamespace);
1844
+ result = _doAttach(target, evtName, handlerRef, useCapture);
1845
+ if (result && elmNodeData.accept(target)) {
1846
+ var registeredEvent = {
1847
+ guid: _guid++,
1848
+ evtName: evtName,
1849
+ handler: handlerRef,
1850
+ capture: useCapture
1851
+ };
1852
+ _getRegisteredEvents(target, evtName.type).push(registeredEvent);
1853
+ }
1854
+ }
1855
+ catch (e) {
1856
+ }
1857
+ }
1858
+ return result;
1859
+ }
1860
+ function eventOff(target, eventName, handlerRef, evtNamespace, useCapture) {
1861
+ if (useCapture === void 0) { useCapture = false; }
1862
+ if (target) {
1863
+ try {
1864
+ var evtName_1 = _getEvtNamespace(eventName, evtNamespace);
1865
+ var found_1 = false;
1866
+ _unregisterEvents(target, evtName_1, function (regEvent) {
1867
+ if ((evtName_1.ns && !handlerRef) || regEvent.handler === handlerRef) {
1868
+ found_1 = true;
1869
+ return true;
1870
+ }
1871
+ return false;
1872
+ });
1873
+ if (!found_1) {
1874
+ _doDetach(target, evtName_1, handlerRef, useCapture);
1875
+ }
1876
+ }
1877
+ catch (e) {
1878
+ }
1879
+ }
1880
+ }
1881
+
1882
+ var LoggingSeverity = createEnumStyle({
1883
+ CRITICAL: 1 ,
1884
+ WARNING: 2
1885
+ });
1886
+ var _InternalMessageId = createEnumStyle({
1887
+ BrowserDoesNotSupportLocalStorage: 0 ,
1888
+ BrowserCannotReadLocalStorage: 1 ,
1889
+ BrowserCannotReadSessionStorage: 2 ,
1890
+ BrowserCannotWriteLocalStorage: 3 ,
1891
+ BrowserCannotWriteSessionStorage: 4 ,
1892
+ BrowserFailedRemovalFromLocalStorage: 5 ,
1893
+ BrowserFailedRemovalFromSessionStorage: 6 ,
1894
+ CannotSendEmptyTelemetry: 7 ,
1895
+ ClientPerformanceMathError: 8 ,
1896
+ ErrorParsingAISessionCookie: 9 ,
1897
+ ErrorPVCalc: 10 ,
1898
+ ExceptionWhileLoggingError: 11 ,
1899
+ FailedAddingTelemetryToBuffer: 12 ,
1900
+ FailedMonitorAjaxAbort: 13 ,
1901
+ FailedMonitorAjaxDur: 14 ,
1902
+ FailedMonitorAjaxOpen: 15 ,
1903
+ FailedMonitorAjaxRSC: 16 ,
1904
+ FailedMonitorAjaxSend: 17 ,
1905
+ FailedMonitorAjaxGetCorrelationHeader: 18 ,
1906
+ FailedToAddHandlerForOnBeforeUnload: 19 ,
1907
+ FailedToSendQueuedTelemetry: 20 ,
1908
+ FailedToReportDataLoss: 21 ,
1909
+ FlushFailed: 22 ,
1910
+ MessageLimitPerPVExceeded: 23 ,
1911
+ MissingRequiredFieldSpecification: 24 ,
1912
+ NavigationTimingNotSupported: 25 ,
1913
+ OnError: 26 ,
1914
+ SessionRenewalDateIsZero: 27 ,
1915
+ SenderNotInitialized: 28 ,
1916
+ StartTrackEventFailed: 29 ,
1917
+ StopTrackEventFailed: 30 ,
1918
+ StartTrackFailed: 31 ,
1919
+ StopTrackFailed: 32 ,
1920
+ TelemetrySampledAndNotSent: 33 ,
1921
+ TrackEventFailed: 34 ,
1922
+ TrackExceptionFailed: 35 ,
1923
+ TrackMetricFailed: 36 ,
1924
+ TrackPVFailed: 37 ,
1925
+ TrackPVFailedCalc: 38 ,
1926
+ TrackTraceFailed: 39 ,
1927
+ TransmissionFailed: 40 ,
1928
+ FailedToSetStorageBuffer: 41 ,
1929
+ FailedToRestoreStorageBuffer: 42 ,
1930
+ InvalidBackendResponse: 43 ,
1931
+ FailedToFixDepricatedValues: 44 ,
1932
+ InvalidDurationValue: 45 ,
1933
+ TelemetryEnvelopeInvalid: 46 ,
1934
+ CreateEnvelopeError: 47 ,
1935
+ CannotSerializeObject: 48 ,
1936
+ CannotSerializeObjectNonSerializable: 49 ,
1937
+ CircularReferenceDetected: 50 ,
1938
+ ClearAuthContextFailed: 51 ,
1939
+ ExceptionTruncated: 52 ,
1940
+ IllegalCharsInName: 53 ,
1941
+ ItemNotInArray: 54 ,
1942
+ MaxAjaxPerPVExceeded: 55 ,
1943
+ MessageTruncated: 56 ,
1944
+ NameTooLong: 57 ,
1945
+ SampleRateOutOfRange: 58 ,
1946
+ SetAuthContextFailed: 59 ,
1947
+ SetAuthContextFailedAccountName: 60 ,
1948
+ StringValueTooLong: 61 ,
1949
+ StartCalledMoreThanOnce: 62 ,
1950
+ StopCalledWithoutStart: 63 ,
1951
+ TelemetryInitializerFailed: 64 ,
1952
+ TrackArgumentsNotSpecified: 65 ,
1953
+ UrlTooLong: 66 ,
1954
+ SessionStorageBufferFull: 67 ,
1955
+ CannotAccessCookie: 68 ,
1956
+ IdTooLong: 69 ,
1957
+ InvalidEvent: 70 ,
1958
+ FailedMonitorAjaxSetRequestHeader: 71 ,
1959
+ SendBrowserInfoOnUserInit: 72 ,
1960
+ PluginException: 73 ,
1961
+ NotificationException: 74 ,
1962
+ SnippetScriptLoadFailure: 99 ,
1963
+ InvalidInstrumentationKey: 100 ,
1964
+ CannotParseAiBlobValue: 101 ,
1965
+ InvalidContentBlob: 102 ,
1966
+ TrackPageActionEventFailed: 103 ,
1967
+ FailedAddingCustomDefinedRequestContext: 104 ,
1968
+ InMemoryStorageBufferFull: 105
1969
+ });
1970
+
1971
+ var strNotSpecified = "not_specified";
1972
+
1973
+ var PropertiesPluginIdentifier = "AppInsightsPropertiesPlugin";
1974
+
1975
+ var Prototype = "prototype";
1976
+ var DEFAULT_DONOT_TRACK_TAG = "ai-dnt";
1977
+ var DEFAULT_AI_BLOB_ATTRIBUTE_TAG = "ai-blob";
1978
+ var DEFAULT_DATA_PREFIX = "data-";
1979
+ var _ExtendedInternalMessageId = __assignFn(__assignFn({}, _InternalMessageId), { CannotParseAiBlobValue: 101, InvalidContentBlob: 102, TrackPageActionEventFailed: 103 });
1980
+ function removeNonObjectsAndInvalidElements(overrideConfig, attributeNamesExpectedObjects) {
1981
+ removeInvalidElements(overrideConfig);
1982
+ for (var i in attributeNamesExpectedObjects) {
1983
+ if (attributeNamesExpectedObjects.hasOwnProperty(i)) {
1984
+ var objectName = attributeNamesExpectedObjects[i];
1985
+ if (typeof overrideConfig[objectName] === "object") {
1986
+ removeInvalidElements(overrideConfig[objectName]);
1987
+ }
1988
+ else {
1989
+ delete overrideConfig[objectName];
1990
+ }
1991
+ }
1992
+ }
1993
+ }
1994
+ function removeInvalidElements(object) {
1995
+ for (var property in object) {
1996
+ if (!isValueAssigned(object[property]) ||
1997
+ (JSON.stringify(object[property]) === "{}" && (property !== "callback"))) {
1998
+ delete object[property];
1999
+ }
2000
+ }
2001
+ }
2002
+ function isValueAssigned(value) {
2003
+ return !(isNullOrUndefined(value) || value === "");
2004
+ }
2005
+ function isRightClick(evt) {
2006
+ try {
2007
+ if ("which" in evt) {
2008
+ return (evt.which === 3);
2009
+ }
2010
+ else if ("button" in evt) {
2011
+ return (evt.button === 2);
2012
+ }
2013
+ }
2014
+ catch (e) {
2015
+ }
2016
+ }
2017
+ function isLeftClick(evt) {
2018
+ try {
2019
+ if ("which" in evt) {
2020
+ return (evt.which === 1);
2021
+ }
2022
+ else if ("button" in evt) {
2023
+ return (evt.button === 1);
2024
+ }
2025
+ }
2026
+ catch (e) {
2027
+ }
2028
+ }
2029
+ function isMiddleClick(evt) {
2030
+ try {
2031
+ if ("which" in evt) {
2032
+ return (evt.which === 2);
2033
+ }
2034
+ else if ("button" in evt) {
2035
+ return (evt.button === 4);
2036
+ }
2037
+ }
2038
+ catch (e) {
2039
+ }
2040
+ }
2041
+ function isKeyboardEnter(evt) {
2042
+ try {
2043
+ if ("keyCode" in evt) {
2044
+ return (evt.keyCode === 13);
2045
+ }
2046
+ }
2047
+ catch (e) {
2048
+ }
2049
+ }
2050
+ function isKeyboardSpace(evt) {
2051
+ try {
2052
+ if ("keyCode" in evt) {
2053
+ return (evt.keyCode === 32);
2054
+ }
2055
+ }
2056
+ catch (e) {
2057
+ }
2058
+ }
2059
+ function isElementDnt(element, doNotTrackFieldName) {
2060
+ var dntElement = findClosestByAttribute(element, doNotTrackFieldName);
2061
+ if (!isValueAssigned(dntElement)) {
2062
+ return false;
2063
+ }
2064
+ return true;
2065
+ }
2066
+ function findClosestByAttribute(el, attribute) {
2067
+ return walkUpDomChainWithElementValidation(el, isAttributeInElement, attribute);
2068
+ }
2069
+ function isAttributeInElement(element, attributeToLookFor) {
2070
+ var value = element.getAttribute(attributeToLookFor);
2071
+ return isValueAssigned(value);
2072
+ }
2073
+ function walkUpDomChainWithElementValidation(el, validationMethod, validationMethodParam) {
2074
+ var element = el;
2075
+ if (element) {
2076
+ while (!validationMethod(element, validationMethodParam)) {
2077
+ element = element.parentNode;
2078
+ if (!element || !(element.getAttribute)) {
2079
+ return null;
2080
+ }
2081
+ }
2082
+ return element;
2083
+ }
2084
+ }
2085
+ function isElementAnAnchor(element) {
2086
+ return element.nodeName === "A";
2087
+ }
2088
+ function findClosestAnchor(element) {
2089
+ return walkUpDomChainWithElementValidation(element, isElementAnAnchor);
2090
+ }
2091
+ function extractFieldFromObject(obj, fieldName) {
2092
+ var fieldValue;
2093
+ if (obj && obj[fieldName]) {
2094
+ fieldValue = obj[fieldName];
2095
+ delete obj[fieldName];
2096
+ }
2097
+ return fieldValue;
2098
+ }
2099
+ function bracketIt(str) {
2100
+ return "[" + str + "]";
2101
+ }
2102
+ function extend(obj, obj2, obj3, obj4, obj5) {
2103
+ var extended = {};
2104
+ var deep = false;
2105
+ var i = 0;
2106
+ var length = arguments.length;
2107
+ var objProto = Object[Prototype];
2108
+ var theArgs = arguments;
2109
+ if (objProto.toString.call(theArgs[0]) === "[object Boolean]") {
2110
+ deep = theArgs[0];
2111
+ i++;
2112
+ }
2113
+ var merge = function (obj) {
2114
+ for (var prop in obj) {
2115
+ if (hasOwnProperty(obj, prop)) {
2116
+ if (deep && objProto.toString.call(obj[prop]) === "[object Object]") {
2117
+ extended[prop] = extend(true, extended[prop], obj[prop]);
2118
+ }
2119
+ else {
2120
+ extended[prop] = obj[prop];
2121
+ }
2122
+ }
2123
+ }
2124
+ };
2125
+ for (; i < length; i++) {
2126
+ var obj = theArgs[i];
2127
+ merge(obj);
2128
+ }
2129
+ return extended;
2130
+ }
2131
+ function validateContentNamePrefix(config, defaultDataPrefix) {
2132
+ return isValueAssigned(config.dataTags.customDataPrefix) && (config.dataTags.customDataPrefix.indexOf(defaultDataPrefix) === 0);
2133
+ }
2134
+ function mergeConfig(overrideConfig) {
2135
+ var defaultConfig = {
2136
+ autoCapture: true,
2137
+ callback: {
2138
+ pageActionPageTags: null
2139
+ },
2140
+ pageTags: {},
2141
+ coreData: {
2142
+ referrerUri: hasDocument ? document.referrer : "",
2143
+ requestUri: "",
2144
+ pageName: "",
2145
+ pageType: ""
2146
+ },
2147
+ dataTags: {
2148
+ useDefaultContentNameOrId: false,
2149
+ aiBlobAttributeTag: DEFAULT_AI_BLOB_ATTRIBUTE_TAG,
2150
+ customDataPrefix: DEFAULT_DATA_PREFIX,
2151
+ captureAllMetaDataContent: false,
2152
+ dntDataTag: DEFAULT_DONOT_TRACK_TAG
2153
+ },
2154
+ behaviorValidator: function (key) { return key || ""; },
2155
+ defaultRightClickBhvr: "",
2156
+ dropInvalidEvents: false
2157
+ };
2158
+ var attributesThatAreObjectsInConfig = [];
2159
+ for (var attribute in defaultConfig) {
2160
+ if (typeof defaultConfig[attribute] === "object") {
2161
+ attributesThatAreObjectsInConfig.push(attribute);
2162
+ }
2163
+ }
2164
+ if (overrideConfig) {
2165
+ removeNonObjectsAndInvalidElements(overrideConfig, attributesThatAreObjectsInConfig);
2166
+ if (isValueAssigned(overrideConfig.dataTags)) {
2167
+ overrideConfig.dataTags.customDataPrefix = validateContentNamePrefix(overrideConfig, DEFAULT_DATA_PREFIX) ? overrideConfig.dataTags.customDataPrefix : DEFAULT_DATA_PREFIX;
2168
+ }
2169
+ return extend(true, defaultConfig, overrideConfig);
2170
+ }
2171
+ }
2172
+ function BehaviorMapValidator(map) {
2173
+ return function (key) { return map[key] || ""; };
2174
+ }
2175
+ function BehaviorValueValidator(behaviorArray) {
2176
+ return function (key) {
2177
+ var result;
2178
+ arrForEach(behaviorArray, function (value) {
2179
+ if (value === key) {
2180
+ result = value;
2181
+ return -1;
2182
+ }
2183
+ });
2184
+ return result || "";
2185
+ };
2186
+ }
2187
+ function BehaviorEnumValidator(enumObj) {
2188
+ return function (key) { return enumObj[key] || ""; };
2189
+ }
2190
+
2191
+ var clickCaptureInputTypes$1 = { BUTTON: true, CHECKBOX: true, RADIO: true, RESET: true, SUBMIT: true };
2192
+ function getImageHref(element) {
2193
+ var temp = element;
2194
+ if (temp) {
2195
+ var parent = findClosestAnchor(temp);
2196
+ if (parent.length === 1) {
2197
+ var firstParent = parent[0];
2198
+ if (firstParent.href) {
2199
+ return firstParent.href;
2200
+ }
2201
+ else if (firstParent.src) {
2202
+ return (firstParent.src);
2203
+ }
2204
+ }
2205
+ }
2206
+ return "";
2207
+ }
2208
+ function getClickTarget(element) {
2209
+ var clickTarget = "";
2210
+ switch (element.tagName) {
2211
+ case "A":
2212
+ case "AREA":
2213
+ clickTarget = element.href || "";
2214
+ break;
2215
+ case "IMG":
2216
+ clickTarget = getImageHref(element);
2217
+ break;
2218
+ case "INPUT":
2219
+ var type = element.type;
2220
+ if (type && (clickCaptureInputTypes$1[type.toUpperCase()])) {
2221
+ var loc = getLocation() || {};
2222
+ if (element.form) {
2223
+ clickTarget = element.form.action || (loc.pathname || "");
2224
+ }
2225
+ else {
2226
+ clickTarget = loc.pathname || "";
2227
+ }
2228
+ }
2229
+ break;
2230
+ }
2231
+ return clickTarget;
2232
+ }
2233
+ function getPageName(config, overrideValues) {
2234
+ if (overrideValues && overrideValues.pageName) {
2235
+ return overrideValues.pageName;
2236
+ }
2237
+ else if (config.callback && isFunction(config.callback.pageName)) {
2238
+ return config.callback.pageName();
2239
+ }
2240
+ else if (config.coreData && config.coreData.pageName) {
2241
+ return config.coreData.pageName;
2242
+ }
2243
+ else {
2244
+ var doc = getDocument();
2245
+ return doc && doc.title || "";
2246
+ }
2247
+ }
2248
+ function sanitizeUrl(config, location) {
2249
+ if (!location) {
2250
+ return null;
2251
+ }
2252
+ var url = location.protocol + "//" + (location.hostname || location.host) +
2253
+ (isValueAssigned(location.port) ? ":" + location.port : "") +
2254
+ location.pathname;
2255
+ return url;
2256
+ }
2257
+ function getUri(config, location) {
2258
+ if (config.coreData && config.coreData.requestUri && config.coreData.requestUri !== "") {
2259
+ return config.coreData.requestUri;
2260
+ }
2261
+ return sanitizeUrl(config, location);
2262
+ }
2263
+
2264
+ var WebEvent = /** @class */ (function () {
2265
+ function WebEvent(clickAnalyticsPlugin, config, contentHandler, pageTagsCallback, metaTags, traceLogger) {
2266
+ dynamicProto(WebEvent, this, function (_self) {
2267
+ _initDefaults();
2268
+ function _initDefaults() {
2269
+ _self._pageTags = {};
2270
+ _self._clickAnalyticsPlugin = clickAnalyticsPlugin;
2271
+ _self._config = config;
2272
+ _self._contentHandler = contentHandler;
2273
+ _self._pageTagsCallback = pageTagsCallback;
2274
+ _self._metaTags = metaTags;
2275
+ _self._traceLogger = traceLogger;
2276
+ }
2277
+ _self.setBasicProperties = function (event, overrideValues) {
2278
+ if (!isValueAssigned(event.name)) {
2279
+ event.pageName = getPageName(_self._config, overrideValues);
2280
+ }
2281
+ if (!isValueAssigned(event.uri) && hasWindow) {
2282
+ event.uri = getUri(_self._config, getLocation());
2283
+ }
2284
+ };
2285
+ _self.setCommonProperties = function (event, overrideValues) {
2286
+ _self.setBasicProperties(event, overrideValues);
2287
+ _self._setPageTags(event, overrideValues);
2288
+ _self._pageTypeMetaTag = _getMetaData(_self._metaTags, _self._config.coreData, "pageType");
2289
+ _self._behaviorMetaTag = _getMetaData(_self._metaTags, _self._config.coreData, "behavior");
2290
+ if (isValueAssigned(overrideValues.pageType)) {
2291
+ event.pageType = overrideValues.pageType;
2292
+ }
2293
+ if (isValueAssigned(_self._pageTypeMetaTag) && !isValueAssigned(event.pageType)) {
2294
+ event.pageType = _self._pageTypeMetaTag;
2295
+ }
2296
+ };
2297
+ _self._setPageTags = function (event, overrideValues) {
2298
+ if (_self._pageTagsCallback) {
2299
+ _self._pageTags = extend(true, _self._pageTags, _self._pageTagsCallback());
2300
+ }
2301
+ if (isValueAssigned(overrideValues.pageTags)) {
2302
+ _self._pageTags = extend(true, _self._pageTags, overrideValues.pageTags);
2303
+ }
2304
+ if (_self._metaTags) {
2305
+ _self._pageTags.metaTags = {};
2306
+ for (var metaTag in _self._metaTags) {
2307
+ if (metaTag != "behavior" && metaTag != "market" && metaTag != "pageType") {
2308
+ _self._pageTags.metaTags[metaTag] = _self._metaTags[metaTag];
2309
+ }
2310
+ }
2311
+ }
2312
+ event.properties = event.properties || {};
2313
+ event.properties["pageTags"] = _self._pageTags;
2314
+ };
2315
+ _self._getBehavior = function (overrideValues) {
2316
+ var behavior;
2317
+ if (overrideValues && isValueAssigned(overrideValues.behavior)) {
2318
+ behavior = overrideValues.behavior;
2319
+ }
2320
+ else if (isValueAssigned(_self._behaviorMetaTag)) {
2321
+ behavior = _self._behaviorMetaTag;
2322
+ }
2323
+ return _self._getValidBehavior(behavior);
2324
+ };
2325
+ _self._getValidBehavior = function (behavior) {
2326
+ return _self._config.behaviorValidator(behavior);
2327
+ };
2328
+ _self._doUnload = function (unloadCtx, unloadState, asyncCallback) {
2329
+ _initDefaults();
2330
+ };
2331
+ function _getMetaData(metaTags, coreData, metaTagName) {
2332
+ if (coreData && coreData[metaTagName]) {
2333
+ return coreData[metaTagName];
2334
+ }
2335
+ if (metaTags) {
2336
+ return metaTags[metaTagName];
2337
+ }
2338
+ return "";
2339
+ }
2340
+ });
2341
+ }
2342
+ return WebEvent;
2343
+ }());
2344
+
2345
+ var PageAction = /** @class */ (function (_super) {
2346
+ __extendsFn(PageAction, _super);
2347
+ function PageAction(clickAnalyticsPlugin, config, contentHandler, pageTagsCallback, metaTags, traceLogger) {
2348
+ var _this = _super.call(this, clickAnalyticsPlugin, config, contentHandler, pageTagsCallback, metaTags, traceLogger) || this;
2349
+ dynamicProto(PageAction, _this, function (_self, _base) {
2350
+ _self.trackPageAction = function (pageActionEvent, properties) {
2351
+ var ext = {};
2352
+ ext["web"] = {};
2353
+ var event = {
2354
+ name: "Microsoft.ApplicationInsights.{0}.Event",
2355
+ baseType: "EventData",
2356
+ ext: ext,
2357
+ data: {},
2358
+ baseData: {}
2359
+ };
2360
+ _populateEventDataIfPresent(event.baseData, "name", pageActionEvent.name);
2361
+ _populateEventDataIfPresent(event.data, "baseTypeSource", "ClickEvent");
2362
+ _populateEventDataIfPresent(event.data, "uri", pageActionEvent.uri);
2363
+ _populateEventDataIfPresent(event.data, "pageType", pageActionEvent.pageType);
2364
+ _populateEventDataIfPresent(event.data, "properties", pageActionEvent.properties);
2365
+ _populateEventDataIfPresent(event.data, "actionType", pageActionEvent.actionType);
2366
+ _populateEventDataIfPresent(event.data, "behavior", pageActionEvent.behavior);
2367
+ _populateEventDataIfPresent(event.data, "clickCoordinates", pageActionEvent.clickCoordinates);
2368
+ _populateEventDataIfPresent(event.data, "content", pageActionEvent.content);
2369
+ _populateEventDataIfPresent(event.data, "targetUri", pageActionEvent.targetUri);
2370
+ _populateEventDataIfPresent(event.data, "timeToAction", pageActionEvent.timeToAction);
2371
+ _populateEventDataIfPresent(event.data, "refUri", pageActionEvent.refUri);
2372
+ _populateEventDataIfPresent(event.data, "pageName", pageActionEvent.pageName);
2373
+ _populateEventDataIfPresent(event.data, "parentId", pageActionEvent.parentId);
2374
+ if (properties) {
2375
+ objForEachKey(properties, function (property, value) {
2376
+ if (!event.data[property]) {
2377
+ _populateEventDataIfPresent(event.data, property, value);
2378
+ }
2379
+ });
2380
+ }
2381
+ _self._clickAnalyticsPlugin.core.track(event);
2382
+ };
2383
+ _self.capturePageAction = function (element, overrideValues, customProperties, isRightClick) {
2384
+ overrideValues = !isValueAssigned(overrideValues) ? {} : overrideValues;
2385
+ var pageActionEvent = { name: "" };
2386
+ var pageActionProperties = isValueAssigned(customProperties) ? customProperties : {};
2387
+ _self.setCommonProperties(pageActionEvent, overrideValues);
2388
+ pageActionEvent.behavior = _self._getBehavior(overrideValues);
2389
+ var elementContent = {};
2390
+ if (isRightClick) {
2391
+ pageActionEvent.behavior = _self._config.defaultRightClickBhvr;
2392
+ }
2393
+ if (element) {
2394
+ pageActionEvent.targetUri = getClickTarget(element);
2395
+ elementContent = _self._contentHandler.getElementContent(element);
2396
+ if (elementContent.bhvr && !isValueAssigned(overrideValues.behavior)) {
2397
+ var currentBehavior = extractFieldFromObject(elementContent, "bhvr");
2398
+ pageActionEvent.behavior = _self._getValidBehavior(currentBehavior);
2399
+ }
2400
+ if (!isValueAssigned(elementContent.id) && !isValueAssigned(elementContent.contentName)) {
2401
+ _self._traceLogger.throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.InvalidContentBlob, "Missing attributes id or contentName in click event. Click event information will still be collected!");
2402
+ }
2403
+ }
2404
+ pageActionEvent.name = elementContent.id || elementContent.contentName || strNotSpecified;
2405
+ pageActionEvent.parentId = elementContent.parentid || elementContent.parentName || strNotSpecified;
2406
+ if (isValueAssigned(overrideValues.actionType)) {
2407
+ pageActionEvent.actionType = overrideValues.actionType;
2408
+ }
2409
+ if (isValueAssigned(overrideValues.clickCoordinateX) && isValueAssigned(overrideValues.clickCoordinateY)) {
2410
+ pageActionEvent.clickCoordinates = overrideValues.clickCoordinateX + "X" + overrideValues.clickCoordinateY;
2411
+ }
2412
+ _sanitizePageActionEventContent(elementContent);
2413
+ pageActionEvent.content = bracketIt(JSON.stringify(extend(elementContent, overrideValues && overrideValues.contentTags ? overrideValues.contentTags : {})));
2414
+ pageActionEvent.timeToAction = _getTimeToClick();
2415
+ pageActionEvent.refUri = isValueAssigned(overrideValues.refUri) ? overrideValues.refUri : _self._config.coreData.referrerUri;
2416
+ if (_isUndefinedEvent(pageActionEvent)) {
2417
+ return;
2418
+ }
2419
+ _self.trackPageAction(pageActionEvent, pageActionProperties);
2420
+ };
2421
+ function _getTimeToClick() {
2422
+ var perf = getPerformance();
2423
+ if (perf && perf.timing) {
2424
+ var isNavigationStart = perf.timing.navigationStart;
2425
+ if (isNavigationStart && isNavigationStart !== 0) {
2426
+ return new Date().getTime() - isNavigationStart;
2427
+ }
2428
+ }
2429
+ return -1;
2430
+ }
2431
+ function _populateEventDataIfPresent(obj, property, value) {
2432
+ if (isValueAssigned(value)) {
2433
+ obj[property] = value;
2434
+ }
2435
+ }
2436
+ function _sanitizePageActionEventContent(pageActionContent) {
2437
+ if (pageActionContent) {
2438
+ delete pageActionContent.id;
2439
+ delete pageActionContent.parentid;
2440
+ delete pageActionContent.parentname;
2441
+ if (_self._config && _self._config.dataTags && isValueAssigned(_self._config.dataTags.parentDataTag)) {
2442
+ delete pageActionContent[_self._config.dataTags.parentDataTag];
2443
+ }
2444
+ }
2445
+ }
2446
+ function _isUndefinedEvent(pageActionEvent) {
2447
+ if (_self._config.dropInvalidEvents) {
2448
+ if (pageActionEvent.name === strNotSpecified
2449
+ && pageActionEvent.parentId === strNotSpecified
2450
+ && pageActionEvent.content === "[{}]") {
2451
+ return true;
2452
+ }
2453
+ }
2454
+ return false;
2455
+ }
2456
+ });
2457
+ return _this;
2458
+ }
2459
+ return PageAction;
2460
+ }(WebEvent));
2461
+
2462
+ var ActionType = {
2463
+ CLICKLEFT: "CL",
2464
+ CLICKRIGHT: "CR",
2465
+ CLICKMIDDLE: "CM",
2466
+ SCROLL: "S",
2467
+ ZOOM: "Z",
2468
+ RESIZE: "R",
2469
+ KEYBOARDENTER: "KE",
2470
+ KEYBOARDSPACE: "KS",
2471
+ OTHER: "O"
2472
+ };
2473
+
2474
+ var clickCaptureInputTypes = { BUTTON: true, CHECKBOX: true, RADIO: true, RESET: true, SUBMIT: true };
2475
+ var AutoCaptureHandler = /** @class */ (function () {
2476
+ function AutoCaptureHandler(_analyticsPlugin, _config, _pageAction, _traceLogger) {
2477
+ this._analyticsPlugin = _analyticsPlugin;
2478
+ this._config = _config;
2479
+ this._pageAction = _pageAction;
2480
+ this._traceLogger = _traceLogger;
2481
+ var _evtNamespace = mergeEvtNamespace(createUniqueNamespace("AutoCaptureHandler"), _analyticsPlugin._evtNamespace);
2482
+ dynamicProto(AutoCaptureHandler, this, function (_self) {
2483
+ _self.click = function () {
2484
+ var win = getWindow();
2485
+ var doc = getDocument();
2486
+ if (win) {
2487
+ var event_1 = (navigator.appVersion.indexOf("MSIE") !== -1) ? "click" : "mousedown";
2488
+ eventOn(win, event_1, _processClick, _evtNamespace);
2489
+ eventOn(win, "keyup", _processClick, _evtNamespace);
2490
+ }
2491
+ else if (doc) {
2492
+ eventOn(doc, "click", _processClick, _evtNamespace);
2493
+ eventOn(doc, "keyup", _processClick, _evtNamespace);
2494
+ }
2495
+ };
2496
+ _self._doUnload = function (unloadCtx, unloadState, asyncCallback) {
2497
+ eventOff(getWindow(), null, null, _evtNamespace);
2498
+ eventOff(getDocument(), null, null, _evtNamespace);
2499
+ };
2500
+ function _capturePageAction(element, overrideValues, customProperties, isRightClick) {
2501
+ var donotTrackTag = _self._config.dataTags.customDataPrefix + _self._config.dataTags.dntDataTag;
2502
+ if (!isElementDnt(element, donotTrackTag)) {
2503
+ _self._pageAction.capturePageAction(element, overrideValues, customProperties, isRightClick);
2504
+ }
2505
+ }
2506
+ function _processClick(clickEvent) {
2507
+ var clickCaptureElements = { A: true, BUTTON: true, AREA: true, INPUT: true };
2508
+ var win = getWindow();
2509
+ if (isNullOrUndefined(clickEvent) && win) {
2510
+ clickEvent = win.event;
2511
+ }
2512
+ if (clickEvent) {
2513
+ var element = clickEvent.srcElement || clickEvent.target;
2514
+ var overrideValues = {
2515
+ clickCoordinateX: clickEvent.pageX,
2516
+ clickCoordinateY: clickEvent.pageY
2517
+ };
2518
+ var isRightClickObj = isRightClick(clickEvent);
2519
+ if (isRightClickObj) {
2520
+ overrideValues.actionType = ActionType.CLICKRIGHT;
2521
+ }
2522
+ else if (isLeftClick(clickEvent)) {
2523
+ overrideValues.actionType = ActionType.CLICKLEFT;
2524
+ }
2525
+ else if (isKeyboardEnter(clickEvent)) {
2526
+ overrideValues.actionType = ActionType.KEYBOARDENTER;
2527
+ }
2528
+ else if (isKeyboardSpace(clickEvent)) {
2529
+ overrideValues.actionType = ActionType.KEYBOARDSPACE;
2530
+ }
2531
+ else if (isMiddleClick(clickEvent)) {
2532
+ overrideValues.actionType = ActionType.CLICKMIDDLE;
2533
+ }
2534
+ else {
2535
+ return;
2536
+ }
2537
+ while (element && element.tagName) {
2538
+ if (element.control && clickCaptureElements[element.control.tagName.toUpperCase()]) {
2539
+ element = element.control;
2540
+ }
2541
+ var tagNameUpperCased = element.tagName.toUpperCase();
2542
+ if (!clickCaptureElements[tagNameUpperCased]) {
2543
+ element = element.parentElement || element.parentNode;
2544
+ continue;
2545
+ }
2546
+ else {
2547
+ var sendEvent = tagNameUpperCased === "INPUT" ? clickCaptureInputTypes[element.type.toUpperCase()] : true;
2548
+ if (sendEvent) {
2549
+ _capturePageAction(element, overrideValues, {}, isRightClickObj);
2550
+ }
2551
+ break;
2552
+ }
2553
+ }
2554
+ }
2555
+ }
2556
+ });
2557
+ }
2558
+ return AutoCaptureHandler;
2559
+ }());
2560
+
2561
+ var MAX_CONTENTNAME_LENGTH = 200;
2562
+ var DomContentHandler = /** @class */ (function () {
2563
+ function DomContentHandler(_config, _traceLogger) {
2564
+ this._config = _config;
2565
+ this._traceLogger = _traceLogger;
2566
+ dynamicProto(DomContentHandler, this, function (_self) {
2567
+ _self.getMetadata = function () {
2568
+ var dataTags = (_self._config || {}).dataTags;
2569
+ var metaTags = {};
2570
+ if (hasDocument) {
2571
+ metaTags = isValueAssigned(dataTags.metaDataPrefix) ? _getMetaDataFromDOM(dataTags.captureAllMetaDataContent, dataTags.metaDataPrefix, false) :
2572
+ _getMetaDataFromDOM(dataTags.captureAllMetaDataContent, "", false);
2573
+ }
2574
+ return metaTags;
2575
+ };
2576
+ _self.getElementContent = function (element) {
2577
+ if (!element) {
2578
+ return {};
2579
+ }
2580
+ var dataTags = (_self._config || {}).dataTags;
2581
+ var elementContent = {};
2582
+ var biBlobValue;
2583
+ var parentDataTagPrefix;
2584
+ var dataTagPrefix = dataTags.customDataPrefix;
2585
+ var aiBlobAttributeTag = dataTagPrefix + dataTags.aiBlobAttributeTag;
2586
+ if (isValueAssigned(dataTags.parentDataTag)) {
2587
+ parentDataTagPrefix = dataTagPrefix + dataTags.parentDataTag;
2588
+ }
2589
+ if (!_isTracked(element, dataTagPrefix, aiBlobAttributeTag)) {
2590
+ biBlobValue = element.getAttribute(aiBlobAttributeTag);
2591
+ if (biBlobValue) {
2592
+ try {
2593
+ elementContent = JSON.parse(biBlobValue);
2594
+ }
2595
+ catch (e) {
2596
+ _self._traceLogger.throwInternal(LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.CannotParseAiBlobValue, "Can not parse " + biBlobValue);
2597
+ }
2598
+ }
2599
+ else {
2600
+ elementContent = extend(elementContent, _populateElementContent(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag));
2601
+ }
2602
+ }
2603
+ else {
2604
+ elementContent = extend(elementContent, _populateElementContentwithDataTag(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag));
2605
+ }
2606
+ removeInvalidElements(elementContent);
2607
+ if (parentDataTagPrefix) {
2608
+ elementContent = extend(elementContent, _getParentDetails(element, elementContent, dataTagPrefix, aiBlobAttributeTag));
2609
+ }
2610
+ return elementContent;
2611
+ };
2612
+ function _captureElementContentWithDataTag(contentElement, elementContent, dataTagPrefix) {
2613
+ for (var i = 0, attrib; i < contentElement.attributes.length; i++) {
2614
+ attrib = contentElement.attributes[i];
2615
+ if (attrib.name.indexOf(dataTagPrefix) !== 0) {
2616
+ continue;
2617
+ }
2618
+ var attribName = attrib.name.replace(dataTagPrefix, "");
2619
+ elementContent[attribName] = attrib.value;
2620
+ }
2621
+ }
2622
+ function _walkUpDomChainCaptureData(el, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {
2623
+ var element = el;
2624
+ var parentDataTagFound = false;
2625
+ var elementLevelFlag = false;
2626
+ while (!isNullOrUndefined(element) && !isNullOrUndefined(element.attributes)) {
2627
+ var attributes = element.attributes;
2628
+ for (var i = 0; i < attributes.length; i++) {
2629
+ var attrib = attributes[i];
2630
+ if (attrib.name.indexOf(dataTagPrefix) !== 0) {
2631
+ continue;
2632
+ }
2633
+ if (attrib.name.indexOf(parentDataTagPrefix) === 0) {
2634
+ parentDataTagFound = true;
2635
+ }
2636
+ if (attrib.name.indexOf(aiBlobAttributeTag) === 0) {
2637
+ continue;
2638
+ }
2639
+ var attribName = attrib.name.replace(dataTagPrefix, "");
2640
+ if (elementLevelFlag && attribName === "id") {
2641
+ continue;
2642
+ }
2643
+ if (!isValueAssigned(elementContent[attribName])) {
2644
+ elementContent[attribName] = attrib.value;
2645
+ }
2646
+ }
2647
+ if (parentDataTagFound) {
2648
+ break;
2649
+ }
2650
+ elementLevelFlag = true;
2651
+ element = element.parentNode;
2652
+ }
2653
+ }
2654
+ function _populateElementContent(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {
2655
+ var elementContent = {};
2656
+ if (!element) {
2657
+ return elementContent;
2658
+ }
2659
+ var htmlContent = _getHtmlIdAndContentName(element);
2660
+ elementContent = {
2661
+ id: htmlContent.id || "",
2662
+ contentName: htmlContent.contentName || ""
2663
+ };
2664
+ if (isValueAssigned(parentDataTagPrefix)) {
2665
+ _walkUpDomChainCaptureData(element, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag);
2666
+ }
2667
+ if (!elementContent.id && !elementContent.contentName) {
2668
+ _traceLogger.throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.InvalidContentBlob, "Invalid content blob. Missing required attributes (id, contentName. " +
2669
+ " Content information will still be collected!");
2670
+ }
2671
+ return elementContent;
2672
+ }
2673
+ function _populateElementContentwithDataTag(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {
2674
+ var dataTags = (_self._config || {}).dataTags;
2675
+ var elementContent = {};
2676
+ if (!element) {
2677
+ return elementContent;
2678
+ }
2679
+ var htmlContent = _getHtmlIdAndContentName(element);
2680
+ if (isValueAssigned(parentDataTagPrefix)) {
2681
+ _walkUpDomChainCaptureData(element, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag);
2682
+ }
2683
+ else {
2684
+ _captureElementContentWithDataTag(element, elementContent, dataTagPrefix);
2685
+ }
2686
+ if (dataTags.useDefaultContentNameOrId) {
2687
+ if (!isValueAssigned(elementContent.id)) {
2688
+ elementContent.id = htmlContent.id || "";
2689
+ }
2690
+ elementContent.contentName = htmlContent.contentName || "";
2691
+ }
2692
+ if (!elementContent.id && !elementContent.contentName) {
2693
+ _traceLogger.throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.InvalidContentBlob, "Invalid content blob. Missing required attributes (id, contentName. " +
2694
+ " Content information will still be collected!");
2695
+ }
2696
+ return elementContent;
2697
+ }
2698
+ function _getMetaDataFromDOM(captureAllMetaDataContent, prefix, removePrefix) {
2699
+ var metaElements;
2700
+ var metaData = {};
2701
+ if (hasDocument) {
2702
+ metaElements = document.querySelectorAll("meta");
2703
+ for (var i = 0; i < metaElements.length; i++) {
2704
+ var meta = metaElements[i];
2705
+ if (meta.name) {
2706
+ if (captureAllMetaDataContent || meta.name.indexOf(prefix) === 0) {
2707
+ var name_1 = removePrefix ? meta.name.replace(prefix, "") : meta.name;
2708
+ metaData[name_1] = meta.content;
2709
+ }
2710
+ }
2711
+ }
2712
+ }
2713
+ return metaData;
2714
+ }
2715
+ function _getDefaultContentName(element, useDefaultContentName) {
2716
+ if (useDefaultContentName === false || !element.tagName) {
2717
+ return "";
2718
+ }
2719
+ var doc = getDocument() || {};
2720
+ var contentName;
2721
+ switch (element.tagName) {
2722
+ case "A":
2723
+ contentName = doc.all ? element.innerText || element.innerHTML : element.text || element.innerHTML;
2724
+ break;
2725
+ case "IMG":
2726
+ case "AREA":
2727
+ contentName = element.alt;
2728
+ break;
2729
+ default:
2730
+ contentName = element.value || element.name || element.alt || element.innerText || element.id;
2731
+ }
2732
+ return contentName.substring(0, MAX_CONTENTNAME_LENGTH);
2733
+ }
2734
+ function _isTracked(element, dataTag, aiBlobAttributeTag) {
2735
+ var attrs = element.attributes;
2736
+ var dataTagFound = false;
2737
+ for (var i = 0; i < attrs.length; i++) {
2738
+ var attributeName = attrs[i].name;
2739
+ if (attributeName === aiBlobAttributeTag) {
2740
+ return false;
2741
+ }
2742
+ else if (attributeName.indexOf(dataTag) === 0) {
2743
+ dataTagFound = true;
2744
+ }
2745
+ }
2746
+ return dataTagFound;
2747
+ }
2748
+ function _getHtmlIdAndContentName(element) {
2749
+ var dataTags = (_self._config || {}).dataTags;
2750
+ var callback = (_self._config || {}).callback;
2751
+ var htmlContent = {};
2752
+ if (!element) {
2753
+ return htmlContent;
2754
+ }
2755
+ if (dataTags.useDefaultContentNameOrId) {
2756
+ var customizedContentName = callback.contentName ? callback.contentName(element, dataTags.useDefaultContentNameOrId) : "";
2757
+ var defaultContentName = _getDefaultContentName(element, dataTags.useDefaultContentNameOrId);
2758
+ htmlContent = {
2759
+ id: element.id,
2760
+ contentName: customizedContentName || defaultContentName || element.getAttribute("alt")
2761
+ };
2762
+ }
2763
+ return htmlContent;
2764
+ }
2765
+ function _getParentDetails(element, elementContent, dataTagPrefix, aiBlobAttributeTag) {
2766
+ var parentId = elementContent["parentid"];
2767
+ var parentName = elementContent["parentname"];
2768
+ var parentInfo = {};
2769
+ if (parentId || parentName || !element) {
2770
+ return parentInfo;
2771
+ }
2772
+ return _populateParentInfo(element, dataTagPrefix, aiBlobAttributeTag);
2773
+ }
2774
+ function _populateParentInfo(element, dataTagPrefix, aiBlobAttributeTag) {
2775
+ var parentInfo = {};
2776
+ var parentId;
2777
+ var closestParentElement = walkUpDomChainWithElementValidation(element.parentElement, _isTracked, dataTagPrefix);
2778
+ if (closestParentElement) {
2779
+ var dataAttr = closestParentElement.getAttribute(aiBlobAttributeTag) || element[aiBlobAttributeTag];
2780
+ if (dataAttr) {
2781
+ try {
2782
+ var telemetryObject = JSON.parse(dataAttr);
2783
+ }
2784
+ catch (e) {
2785
+ _traceLogger.throwInternal(LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.CannotParseAiBlobValue, "Can not parse " + dataAttr);
2786
+ }
2787
+ if (telemetryObject) {
2788
+ parentId = telemetryObject.id;
2789
+ }
2790
+ }
2791
+ else {
2792
+ parentId = closestParentElement.getAttribute(dataTagPrefix + "id");
2793
+ }
2794
+ }
2795
+ if (parentId) {
2796
+ parentInfo["parentid"] = parentId;
2797
+ }
2798
+ else {
2799
+ var htmlContent = _getHtmlIdAndContentName(element.parentElement);
2800
+ parentInfo["parentid"] = htmlContent.id;
2801
+ parentInfo["parentname"] = htmlContent.contentName;
2802
+ }
2803
+ return parentInfo;
2804
+ }
2805
+ });
2806
+ }
2807
+ return DomContentHandler;
2808
+ }());
2809
+
2810
+ var ClickAnalyticsPlugin = /** @class */ (function (_super) {
2811
+ __extendsFn(ClickAnalyticsPlugin, _super);
2812
+ function ClickAnalyticsPlugin() {
2813
+ var _this = _super.call(this) || this;
2814
+ _this.identifier = "ClickAnalyticsPlugin";
2815
+ _this.priority = 181;
2816
+ var _config;
2817
+ var _pageAction;
2818
+ var _autoCaptureHandler;
2819
+ var _contentHandler;
2820
+ dynamicProto(ClickAnalyticsPlugin, _this, function (_self, _base) {
2821
+ var _identifier = _self.identifier;
2822
+ _initDefaults();
2823
+ _self.initialize = function (config, core, extensions, pluginChain) {
2824
+ if (isNullOrUndefined(core)) {
2825
+ throwError("Error initializing");
2826
+ }
2827
+ config.extensionConfig = config.extensionConfig || [];
2828
+ config.extensionConfig[_identifier] = config.extensionConfig[_identifier] || {};
2829
+ _config = mergeConfig(config.extensionConfig[_identifier]);
2830
+ _super.prototype.initialize.call(_this, config, core, extensions, pluginChain);
2831
+ var logger = _self.diagLog();
2832
+ _contentHandler = _contentHandler ? _contentHandler : new DomContentHandler(_config, logger);
2833
+ var metaTags = _contentHandler.getMetadata();
2834
+ _pageAction = new PageAction(_this, _config, _contentHandler, _config.callback.pageActionPageTags, metaTags, logger);
2835
+ _autoCaptureHandler = _autoCaptureHandler ? _autoCaptureHandler : new AutoCaptureHandler(_self, _config, _pageAction, logger);
2836
+ if (_config.autoCapture) {
2837
+ _autoCaptureHandler.click();
2838
+ }
2839
+ var _propertiesExtension;
2840
+ arrForEach(extensions, function (extension) {
2841
+ if (extension.identifier === PropertiesPluginIdentifier) {
2842
+ _propertiesExtension = extension;
2843
+ }
2844
+ });
2845
+ if (_propertiesExtension && _propertiesExtension.context &&
2846
+ _propertiesExtension.context.internal && _propertiesExtension.context.internal.sdkVersion) {
2847
+ _propertiesExtension.context.internal.sdkVersion += "_ClickPlugin" + ClickAnalyticsPlugin.Version;
2848
+ }
2849
+ };
2850
+ _self.processTelemetry = function (env, itemCtx) {
2851
+ _self.processNext(env, itemCtx);
2852
+ };
2853
+ _self.trackPageAction = function (pageAction, customProperties) {
2854
+ try {
2855
+ _pageAction.trackPageAction(pageAction, customProperties);
2856
+ }
2857
+ catch (e) {
2858
+ _throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.TrackPageActionEventFailed, "trackPageAction failed, page action event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
2859
+ }
2860
+ };
2861
+ _self._doTeardown = function (unloadCtx, unloadState, asyncCallback) {
2862
+ return unloadComponents([
2863
+ _autoCaptureHandler,
2864
+ _contentHandler,
2865
+ _pageAction
2866
+ ], unloadCtx, unloadState);
2867
+ };
2868
+ });
2869
+ function _initDefaults() {
2870
+ _config = null;
2871
+ _pageAction = null;
2872
+ _autoCaptureHandler = null;
2873
+ _contentHandler = null;
2874
+ }
2875
+ return _this;
2876
+ }
2877
+ ClickAnalyticsPlugin.Version = "2.8.0-nightly.2204-04";
2878
+ return ClickAnalyticsPlugin;
2879
+ }(BaseTelemetryPlugin));
2880
+
2881
+ exports.BehaviorEnumValidator = BehaviorEnumValidator;
2882
+ exports.BehaviorMapValidator = BehaviorMapValidator;
2883
+ exports.BehaviorValueValidator = BehaviorValueValidator;
2884
+ exports.ClickAnalyticsPlugin = ClickAnalyticsPlugin;
2885
+
2886
+ (function(obj, prop, descriptor) { /* ai_es3_polyfil defineProperty */ var func = Object["defineProperty"]; if (func) { try { return func(obj, prop, descriptor); } catch(e) { /* IE8 defines defineProperty, but will throw */ } } if (descriptor && typeof descriptor.value !== undefined) { obj[prop] = descriptor.value; } return obj; })(exports, '__esModule', { value: true });
2887
+
2888
+ }));
2889
+ //# sourceMappingURL=ai.clck.2.8.0-nightly.2204-04.js.map