@microsoft/applicationinsights-clickanalytics-js 2.8.0-beta.2203-09 → 2.8.0-beta.2203-12
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.
- package/browser/{ai.clck.2.8.0-beta.2203-09.cjs.js → ai.clck.2.8.0-beta.2203-12.cjs.js} +698 -504
- package/browser/ai.clck.2.8.0-beta.2203-12.cjs.js.map +1 -0
- package/browser/ai.clck.2.8.0-beta.2203-12.cjs.min.js +6 -0
- package/browser/ai.clck.2.8.0-beta.2203-12.cjs.min.js.map +1 -0
- package/browser/{ai.clck.2.8.0-beta.2203-09.gbl.js → ai.clck.2.8.0-beta.2203-12.gbl.js} +698 -504
- package/browser/ai.clck.2.8.0-beta.2203-12.gbl.js.map +1 -0
- package/browser/ai.clck.2.8.0-beta.2203-12.gbl.min.js +6 -0
- package/browser/ai.clck.2.8.0-beta.2203-12.gbl.min.js.map +1 -0
- package/browser/ai.clck.2.8.0-beta.2203-12.integrity.json +66 -0
- package/browser/{ai.clck.2.8.0-beta.2203-09.js → ai.clck.2.8.0-beta.2203-12.js} +698 -504
- package/browser/ai.clck.2.8.0-beta.2203-12.js.map +1 -0
- package/browser/ai.clck.2.8.0-beta.2203-12.min.js +6 -0
- package/browser/ai.clck.2.8.0-beta.2203-12.min.js.map +1 -0
- package/browser/ai.clck.2.cjs.js +697 -503
- package/browser/ai.clck.2.cjs.js.map +1 -1
- package/browser/ai.clck.2.cjs.min.js +2 -2
- package/browser/ai.clck.2.cjs.min.js.map +1 -1
- package/browser/ai.clck.2.gbl.js +697 -503
- package/browser/ai.clck.2.gbl.js.map +1 -1
- package/browser/ai.clck.2.gbl.min.js +2 -2
- package/browser/ai.clck.2.gbl.min.js.map +1 -1
- package/browser/ai.clck.2.js +697 -503
- package/browser/ai.clck.2.js.map +1 -1
- package/browser/ai.clck.2.min.js +2 -2
- package/browser/ai.clck.2.min.js.map +1 -1
- package/dist/applicationinsights-clickanalytics-js.api.json +15 -1
- package/dist/applicationinsights-clickanalytics-js.api.md +1 -0
- package/dist/applicationinsights-clickanalytics-js.d.ts +2 -5
- package/dist/applicationinsights-clickanalytics-js.js +697 -503
- package/dist/applicationinsights-clickanalytics-js.js.map +1 -1
- package/dist/applicationinsights-clickanalytics-js.min.js +2 -2
- package/dist/applicationinsights-clickanalytics-js.min.js.map +1 -1
- package/dist/applicationinsights-clickanalytics-js.rollup.d.ts +2 -5
- package/dist-esm/Behaviours.js +1 -1
- package/dist-esm/ClickAnalyticsPlugin.js +74 -50
- package/dist-esm/ClickAnalyticsPlugin.js.map +1 -1
- package/dist-esm/DataCollector.js +4 -2
- package/dist-esm/DataCollector.js.map +1 -1
- package/dist-esm/Enums.js +1 -1
- package/dist-esm/Interfaces/Datamodel.js +1 -1
- package/dist-esm/applicationinsights-clickanalytics-js.js +1 -1
- package/dist-esm/common/Utils.js +1 -1
- package/dist-esm/events/PageAction.js +128 -126
- package/dist-esm/events/PageAction.js.map +1 -1
- package/dist-esm/events/WebEvent.js +109 -94
- package/dist-esm/events/WebEvent.js.map +1 -1
- package/dist-esm/handlers/AutoCaptureHandler.js +85 -83
- package/dist-esm/handlers/AutoCaptureHandler.js.map +1 -1
- package/dist-esm/handlers/DomContentHandler.js +279 -276
- package/dist-esm/handlers/DomContentHandler.js.map +1 -1
- package/package.json +5 -5
- package/src/ClickAnalyticsPlugin.ts +92 -47
- package/src/DataCollector.ts +24 -22
- package/src/Interfaces/Datamodel.ts +20 -21
- package/src/common/Utils.ts +8 -8
- package/src/events/PageAction.ts +165 -131
- package/src/events/WebEvent.ts +147 -78
- package/src/handlers/AutoCaptureHandler.ts +89 -79
- package/src/handlers/DomContentHandler.ts +336 -303
- package/types/ClickAnalyticsPlugin.d.ts +1 -4
- package/types/Interfaces/Datamodel.d.ts +3 -2
- package/types/events/PageAction.d.ts +6 -6
- package/types/events/WebEvent.d.ts +17 -17
- package/types/handlers/AutoCaptureHandler.d.ts +2 -10
- package/types/handlers/DomContentHandler.d.ts +3 -50
- package/types/tsdoc-metadata.json +1 -1
- package/browser/ai.clck.2.8.0-beta.2203-09.cjs.js.map +0 -1
- package/browser/ai.clck.2.8.0-beta.2203-09.cjs.min.js +0 -6
- package/browser/ai.clck.2.8.0-beta.2203-09.cjs.min.js.map +0 -1
- package/browser/ai.clck.2.8.0-beta.2203-09.gbl.js.map +0 -1
- package/browser/ai.clck.2.8.0-beta.2203-09.gbl.min.js +0 -6
- package/browser/ai.clck.2.8.0-beta.2203-09.gbl.min.js.map +0 -1
- package/browser/ai.clck.2.8.0-beta.2203-09.integrity.json +0 -66
- package/browser/ai.clck.2.8.0-beta.2203-09.js.map +0 -1
- package/browser/ai.clck.2.8.0-beta.2203-09.min.js +0 -6
- package/browser/ai.clck.2.8.0-beta.2203-09.min.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Application Insights JavaScript SDK - Click Analytics, 2.8.0-beta.2203-
|
|
2
|
+
* Application Insights JavaScript SDK - Click Analytics, 2.8.0-beta.2203-12
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
(function (global, factory) {
|
|
@@ -75,7 +75,9 @@
|
|
|
75
75
|
var __assignFn = ObjAssign || __objAssignFnImpl;
|
|
76
76
|
var extendStaticsFn = function (d, b) {
|
|
77
77
|
extendStaticsFn = ObjClass["setPrototypeOf"] ||
|
|
78
|
-
({ __proto__: [] } instanceof Array && function (d, b) {
|
|
78
|
+
({ __proto__: [] } instanceof Array && function (d, b) {
|
|
79
|
+
d.__proto__ = b;
|
|
80
|
+
}) ||
|
|
79
81
|
function (d, b) {
|
|
80
82
|
for (var p in b) {
|
|
81
83
|
if (b[strShimHasOwnProperty](p)) {
|
|
@@ -90,7 +92,9 @@
|
|
|
90
92
|
throwTypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
91
93
|
}
|
|
92
94
|
extendStaticsFn(d, b);
|
|
93
|
-
function __() {
|
|
95
|
+
function __() {
|
|
96
|
+
this.constructor = d;
|
|
97
|
+
}
|
|
94
98
|
d[strShimPrototype] = b === null ? objCreateFn(b) : (__[strShimPrototype] = b[strShimPrototype], new __());
|
|
95
99
|
}
|
|
96
100
|
|
|
@@ -344,11 +348,23 @@
|
|
|
344
348
|
var strDisabled = "disabled";
|
|
345
349
|
var strDoTeardown = "_doTeardown";
|
|
346
350
|
|
|
351
|
+
var strToISOString = "toISOString";
|
|
352
|
+
var cStrEndsWith = "endsWith";
|
|
353
|
+
var cStrStartsWith = "startsWith";
|
|
354
|
+
var cStrTrim = "trim";
|
|
347
355
|
var strToString = "toString";
|
|
348
356
|
var str__Proto = "__proto__";
|
|
349
357
|
var strConstructor = "constructor";
|
|
350
358
|
var _objDefineProperty$1 = ObjDefineProperty;
|
|
351
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];
|
|
352
368
|
var _isArray = Array.isArray;
|
|
353
369
|
var _objToString = ObjProto[strToString];
|
|
354
370
|
var _fnToString = ObjHasOwnProperty[strToString];
|
|
@@ -455,6 +471,40 @@
|
|
|
455
471
|
catch (e) {
|
|
456
472
|
}
|
|
457
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
|
+
}
|
|
458
508
|
function objDefineAccessors(target, prop, getProp, setProp) {
|
|
459
509
|
if (_objDefineProperty$1) {
|
|
460
510
|
try {
|
|
@@ -1048,7 +1098,7 @@
|
|
|
1048
1098
|
}
|
|
1049
1099
|
|
|
1050
1100
|
var _objDefineProperty = ObjDefineProperty;
|
|
1051
|
-
var version = "2.
|
|
1101
|
+
var version = "2.8.0-beta.2203-12";
|
|
1052
1102
|
var instanceName = "." + newId(6);
|
|
1053
1103
|
var _dataUid = 0;
|
|
1054
1104
|
function _createAccessor(target, prop, value) {
|
|
@@ -1119,10 +1169,28 @@
|
|
|
1119
1169
|
return data;
|
|
1120
1170
|
}
|
|
1121
1171
|
|
|
1172
|
+
var strDoUnload = "_doUnload";
|
|
1122
1173
|
var pluginStateData = createElmNodeData("plugin");
|
|
1123
1174
|
function _getPluginState(plugin) {
|
|
1124
1175
|
return pluginStateData.get(plugin, "state", {}, true);
|
|
1125
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
|
+
}
|
|
1126
1194
|
|
|
1127
1195
|
var strTelemetryPluginChain = "TelemetryPluginChain";
|
|
1128
1196
|
var strHasRunFlags = "_hasRun";
|
|
@@ -1146,7 +1214,9 @@
|
|
|
1146
1214
|
var context = {
|
|
1147
1215
|
_next: _moveNext,
|
|
1148
1216
|
ctx: {
|
|
1149
|
-
core: function () {
|
|
1217
|
+
core: function () {
|
|
1218
|
+
return core;
|
|
1219
|
+
},
|
|
1150
1220
|
diagLog: function () {
|
|
1151
1221
|
return safeGetLogger(core, config);
|
|
1152
1222
|
},
|
|
@@ -1641,6 +1711,8 @@
|
|
|
1641
1711
|
var strOnPrefix = "on";
|
|
1642
1712
|
var strAttachEvent = "attachEvent";
|
|
1643
1713
|
var strAddEventHelper = "addEventListener";
|
|
1714
|
+
var strDetachEvent = "detachEvent";
|
|
1715
|
+
var strRemoveEventListener = "removeEventListener";
|
|
1644
1716
|
var strEvents = "events";
|
|
1645
1717
|
createUniqueNamespace("aiEvtPageHide");
|
|
1646
1718
|
createUniqueNamespace("aiEvtPageShow");
|
|
@@ -1680,7 +1752,7 @@
|
|
|
1680
1752
|
eventName = (eventName || "") + theNamespace_1;
|
|
1681
1753
|
}
|
|
1682
1754
|
}
|
|
1683
|
-
var parsedEvent = (eventNamespace.exec(eventName) || []);
|
|
1755
|
+
var parsedEvent = (eventNamespace.exec(eventName || "") || []);
|
|
1684
1756
|
return {
|
|
1685
1757
|
type: parsedEvent[1],
|
|
1686
1758
|
ns: ((parsedEvent[2] || "").replace(rRemoveEmptyNs, ".").replace(rRemoveTrailingEmptyNs, "").split(".").sort()).join(".")
|
|
@@ -1695,6 +1767,16 @@
|
|
|
1695
1767
|
}
|
|
1696
1768
|
return registeredEvents;
|
|
1697
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
|
+
}
|
|
1698
1780
|
function _doAttach(obj, evtName, handlerRef, useCapture) {
|
|
1699
1781
|
var result = false;
|
|
1700
1782
|
if (obj && evtName && evtName.type && handlerRef) {
|
|
@@ -1709,6 +1791,50 @@
|
|
|
1709
1791
|
}
|
|
1710
1792
|
return result;
|
|
1711
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
|
+
}
|
|
1712
1838
|
function eventOn(target, eventName, handlerRef, evtNamespace, useCapture) {
|
|
1713
1839
|
if (useCapture === void 0) { useCapture = false; }
|
|
1714
1840
|
var result = false;
|
|
@@ -1731,9 +1857,26 @@
|
|
|
1731
1857
|
}
|
|
1732
1858
|
return result;
|
|
1733
1859
|
}
|
|
1734
|
-
function
|
|
1860
|
+
function eventOff(target, eventName, handlerRef, evtNamespace, useCapture) {
|
|
1735
1861
|
if (useCapture === void 0) { useCapture = false; }
|
|
1736
|
-
|
|
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
|
+
}
|
|
1737
1880
|
}
|
|
1738
1881
|
|
|
1739
1882
|
var LoggingSeverity = createEnumStyle({
|
|
@@ -2119,188 +2262,200 @@
|
|
|
2119
2262
|
}
|
|
2120
2263
|
|
|
2121
2264
|
var WebEvent = /** @class */ (function () {
|
|
2122
|
-
function WebEvent(
|
|
2123
|
-
this
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
if (this._pageTagsCallback) {
|
|
2153
|
-
this._pageTags = extend(true, this._pageTags, this._pageTagsCallback());
|
|
2154
|
-
}
|
|
2155
|
-
if (isValueAssigned(overrideValues.pageTags)) {
|
|
2156
|
-
this._pageTags = extend(true, this._pageTags, overrideValues.pageTags);
|
|
2157
|
-
}
|
|
2158
|
-
if (this._metaTags) {
|
|
2159
|
-
this._pageTags.metaTags = {};
|
|
2160
|
-
for (var metaTag in this._metaTags) {
|
|
2161
|
-
if (metaTag != "behavior" && metaTag != "market" && metaTag != "pageType") {
|
|
2162
|
-
this._pageTags.metaTags[metaTag] = this._metaTags[metaTag];
|
|
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;
|
|
2163
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 "";
|
|
2164
2339
|
}
|
|
2165
|
-
}
|
|
2166
|
-
|
|
2167
|
-
event.properties["pageTags"] = this._pageTags;
|
|
2168
|
-
};
|
|
2169
|
-
WebEvent.prototype._getBehavior = function (overrideValues) {
|
|
2170
|
-
var behavior;
|
|
2171
|
-
if (overrideValues && isValueAssigned(overrideValues.behavior)) {
|
|
2172
|
-
behavior = overrideValues.behavior;
|
|
2173
|
-
}
|
|
2174
|
-
else if (isValueAssigned(this._behaviorMetaTag)) {
|
|
2175
|
-
behavior = this._behaviorMetaTag;
|
|
2176
|
-
}
|
|
2177
|
-
return this._getValidBehavior(behavior);
|
|
2178
|
-
};
|
|
2179
|
-
WebEvent.prototype._getValidBehavior = function (behavior) {
|
|
2180
|
-
return this._config.behaviorValidator(behavior);
|
|
2181
|
-
};
|
|
2182
|
-
WebEvent.prototype._getMetaData = function (metaTags, coreData, metaTagName) {
|
|
2183
|
-
if (coreData && coreData[metaTagName]) {
|
|
2184
|
-
return coreData[metaTagName];
|
|
2185
|
-
}
|
|
2186
|
-
else if (metaTags) {
|
|
2187
|
-
return metaTags[metaTagName];
|
|
2188
|
-
}
|
|
2189
|
-
return "";
|
|
2190
|
-
};
|
|
2340
|
+
});
|
|
2341
|
+
}
|
|
2191
2342
|
return WebEvent;
|
|
2192
2343
|
}());
|
|
2193
2344
|
|
|
2194
2345
|
var PageAction = /** @class */ (function (_super) {
|
|
2195
2346
|
__extendsFn(PageAction, _super);
|
|
2196
|
-
function PageAction() {
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
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
|
+
});
|
|
2228
2380
|
}
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
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;
|
|
2276
2430
|
}
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
if (isValueAssigned(value)) {
|
|
2282
|
-
obj[property] = value;
|
|
2283
|
-
}
|
|
2284
|
-
};
|
|
2285
|
-
PageAction.prototype._sanitizePageActionEventContent = function (pageActionContent) {
|
|
2286
|
-
if (pageActionContent) {
|
|
2287
|
-
delete pageActionContent.id;
|
|
2288
|
-
delete pageActionContent.parentid;
|
|
2289
|
-
delete pageActionContent.parentname;
|
|
2290
|
-
if (this._config && this._config.dataTags && isValueAssigned(this._config.dataTags.parentDataTag)) {
|
|
2291
|
-
delete pageActionContent[this._config.dataTags.parentDataTag];
|
|
2431
|
+
function _populateEventDataIfPresent(obj, property, value) {
|
|
2432
|
+
if (isValueAssigned(value)) {
|
|
2433
|
+
obj[property] = value;
|
|
2434
|
+
}
|
|
2292
2435
|
}
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
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
|
+
}
|
|
2304
2459
|
return PageAction;
|
|
2305
2460
|
}(WebEvent));
|
|
2306
2461
|
|
|
@@ -2323,77 +2478,83 @@
|
|
|
2323
2478
|
this._config = _config;
|
|
2324
2479
|
this._pageAction = _pageAction;
|
|
2325
2480
|
this._traceLogger = _traceLogger;
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
}
|
|
2340
|
-
};
|
|
2341
|
-
AutoCaptureHandler.prototype.capturePageAction = function (element, overrideValues, customProperties, isRightClick) {
|
|
2342
|
-
var donotTrackTag = this._config.dataTags.customDataPrefix + this._config.dataTags.dntDataTag;
|
|
2343
|
-
if (!isElementDnt(element, donotTrackTag)) {
|
|
2344
|
-
this._pageAction.capturePageAction(element, overrideValues, customProperties, isRightClick);
|
|
2345
|
-
}
|
|
2346
|
-
};
|
|
2347
|
-
AutoCaptureHandler.prototype._processClick = function (clickEvent) {
|
|
2348
|
-
var clickCaptureElements = { A: true, BUTTON: true, AREA: true, INPUT: true };
|
|
2349
|
-
var win = getWindow();
|
|
2350
|
-
if (isNullOrUndefined(clickEvent) && win) {
|
|
2351
|
-
clickEvent = win.event;
|
|
2352
|
-
}
|
|
2353
|
-
if (clickEvent) {
|
|
2354
|
-
var element = clickEvent.srcElement || clickEvent.target;
|
|
2355
|
-
var overrideValues = {
|
|
2356
|
-
clickCoordinateX: clickEvent.pageX,
|
|
2357
|
-
clickCoordinateY: clickEvent.pageY
|
|
2358
|
-
};
|
|
2359
|
-
var isRightClickObj = isRightClick(clickEvent);
|
|
2360
|
-
if (isRightClickObj) {
|
|
2361
|
-
overrideValues.actionType = ActionType.CLICKRIGHT;
|
|
2362
|
-
}
|
|
2363
|
-
else if (isLeftClick(clickEvent)) {
|
|
2364
|
-
overrideValues.actionType = ActionType.CLICKLEFT;
|
|
2365
|
-
}
|
|
2366
|
-
else if (isKeyboardEnter(clickEvent)) {
|
|
2367
|
-
overrideValues.actionType = ActionType.KEYBOARDENTER;
|
|
2368
|
-
}
|
|
2369
|
-
else if (isKeyboardSpace(clickEvent)) {
|
|
2370
|
-
overrideValues.actionType = ActionType.KEYBOARDSPACE;
|
|
2371
|
-
}
|
|
2372
|
-
else if (isMiddleClick(clickEvent)) {
|
|
2373
|
-
overrideValues.actionType = ActionType.CLICKMIDDLE;
|
|
2374
|
-
}
|
|
2375
|
-
else {
|
|
2376
|
-
return;
|
|
2377
|
-
}
|
|
2378
|
-
while (element && element.tagName) {
|
|
2379
|
-
if (element.control && clickCaptureElements[element.control.tagName.toUpperCase()]) {
|
|
2380
|
-
element = element.control;
|
|
2381
|
-
}
|
|
2382
|
-
var tagNameUpperCased = element.tagName.toUpperCase();
|
|
2383
|
-
if (!clickCaptureElements[tagNameUpperCased]) {
|
|
2384
|
-
element = element.parentElement || element.parentNode;
|
|
2385
|
-
continue;
|
|
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);
|
|
2386
2494
|
}
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
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
|
+
}
|
|
2391
2553
|
}
|
|
2392
|
-
break;
|
|
2393
2554
|
}
|
|
2394
2555
|
}
|
|
2395
|
-
}
|
|
2396
|
-
}
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2397
2558
|
return AutoCaptureHandler;
|
|
2398
2559
|
}());
|
|
2399
2560
|
|
|
@@ -2402,285 +2563,318 @@
|
|
|
2402
2563
|
function DomContentHandler(_config, _traceLogger) {
|
|
2403
2564
|
this._config = _config;
|
|
2404
2565
|
this._traceLogger = _traceLogger;
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
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
|
+
}
|
|
2431
2602
|
}
|
|
2432
|
-
|
|
2433
|
-
|
|
2603
|
+
else {
|
|
2604
|
+
elementContent = extend(elementContent, _populateElementContentwithDataTag(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag));
|
|
2434
2605
|
}
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
};
|
|
2449
|
-
DomContentHandler.prototype._captureElementContentWithDataTag = function (contentElement, elementContent, dataTagPrefix) {
|
|
2450
|
-
for (var i = 0, attrib; i < contentElement.attributes.length; i++) {
|
|
2451
|
-
attrib = contentElement.attributes[i];
|
|
2452
|
-
if (attrib.name.indexOf(dataTagPrefix) !== 0) {
|
|
2453
|
-
continue;
|
|
2454
|
-
}
|
|
2455
|
-
var attribName = attrib.name.replace(dataTagPrefix, "");
|
|
2456
|
-
elementContent[attribName] = attrib.value;
|
|
2457
|
-
}
|
|
2458
|
-
};
|
|
2459
|
-
DomContentHandler.prototype._walkUpDomChainCaptureData = function (el, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {
|
|
2460
|
-
var element = el;
|
|
2461
|
-
var parentDataTagFound = false;
|
|
2462
|
-
var elementLevelFlag = false;
|
|
2463
|
-
while (!isNullOrUndefined(element) && !isNullOrUndefined(element.attributes)) {
|
|
2464
|
-
var attributes = element.attributes;
|
|
2465
|
-
for (var i = 0; i < attributes.length; i++) {
|
|
2466
|
-
var attrib = attributes[i];
|
|
2467
|
-
if (attrib.name.indexOf(dataTagPrefix) !== 0) {
|
|
2468
|
-
continue;
|
|
2469
|
-
}
|
|
2470
|
-
if (attrib.name.indexOf(parentDataTagPrefix) === 0) {
|
|
2471
|
-
parentDataTagFound = true;
|
|
2472
|
-
}
|
|
2473
|
-
if (attrib.name.indexOf(aiBlobAttributeTag) === 0) {
|
|
2474
|
-
continue;
|
|
2475
|
-
}
|
|
2476
|
-
var attribName = attrib.name.replace(dataTagPrefix, "");
|
|
2477
|
-
if (elementLevelFlag && attribName === "id")
|
|
2478
|
-
continue;
|
|
2479
|
-
if (!isValueAssigned(elementContent[attribName])) {
|
|
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, "");
|
|
2480
2619
|
elementContent[attribName] = attrib.value;
|
|
2481
2620
|
}
|
|
2482
2621
|
}
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
if (!element)
|
|
2511
|
-
return elementContent;
|
|
2512
|
-
var htmlContent = this._getHtmlIdAndContentName(element);
|
|
2513
|
-
if (isValueAssigned(parentDataTagPrefix)) {
|
|
2514
|
-
this._walkUpDomChainCaptureData(element, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag);
|
|
2515
|
-
}
|
|
2516
|
-
else {
|
|
2517
|
-
this._captureElementContentWithDataTag(element, elementContent, dataTagPrefix);
|
|
2518
|
-
}
|
|
2519
|
-
if (this._config.dataTags.useDefaultContentNameOrId) {
|
|
2520
|
-
if (!isValueAssigned(elementContent.id)) {
|
|
2521
|
-
elementContent.id = htmlContent.id || "";
|
|
2522
|
-
}
|
|
2523
|
-
elementContent.contentName = htmlContent.contentName || "";
|
|
2524
|
-
}
|
|
2525
|
-
if (!elementContent.id && !elementContent.contentName) {
|
|
2526
|
-
this._traceLogger.throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.InvalidContentBlob, "Invalid content blob. Missing required attributes (id, contentName. " +
|
|
2527
|
-
" Content information will still be collected!");
|
|
2528
|
-
}
|
|
2529
|
-
return elementContent;
|
|
2530
|
-
};
|
|
2531
|
-
DomContentHandler.prototype._getMetaDataFromDOM = function (captureAllMetaDataContent, prefix, removePrefix) {
|
|
2532
|
-
var metaElements;
|
|
2533
|
-
var metaData = {};
|
|
2534
|
-
if (hasDocument) {
|
|
2535
|
-
metaElements = document.querySelectorAll("meta");
|
|
2536
|
-
for (var i = 0; i < metaElements.length; i++) {
|
|
2537
|
-
var meta = metaElements[i];
|
|
2538
|
-
if (meta.name) {
|
|
2539
|
-
if (captureAllMetaDataContent || meta.name.indexOf(prefix) === 0) {
|
|
2540
|
-
var name_1 = removePrefix ? meta.name.replace(prefix, "") : meta.name;
|
|
2541
|
-
metaData[name_1] = meta.content;
|
|
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;
|
|
2542
2649
|
}
|
|
2650
|
+
elementLevelFlag = true;
|
|
2651
|
+
element = element.parentNode;
|
|
2543
2652
|
}
|
|
2544
2653
|
}
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
if (useDefaultContentName === false || !element.tagName) {
|
|
2550
|
-
return "";
|
|
2551
|
-
}
|
|
2552
|
-
var doc = getDocument() || {};
|
|
2553
|
-
var contentName;
|
|
2554
|
-
switch (element.tagName) {
|
|
2555
|
-
case "A":
|
|
2556
|
-
contentName = doc.all ? element.innerText || element.innerHTML : element.text || element.innerHTML;
|
|
2557
|
-
break;
|
|
2558
|
-
case "IMG":
|
|
2559
|
-
case "AREA":
|
|
2560
|
-
contentName = element.alt;
|
|
2561
|
-
break;
|
|
2562
|
-
default:
|
|
2563
|
-
contentName = element.value || element.name || element.alt || element.innerText || element.id;
|
|
2564
|
-
}
|
|
2565
|
-
return contentName.substring(0, MAX_CONTENTNAME_LENGTH);
|
|
2566
|
-
};
|
|
2567
|
-
DomContentHandler.prototype._isTracked = function (element, dataTag, aiBlobAttributeTag) {
|
|
2568
|
-
var attrs = element.attributes;
|
|
2569
|
-
var dataTagFound = false;
|
|
2570
|
-
for (var i = 0; i < attrs.length; i++) {
|
|
2571
|
-
var attributeName = attrs[i].name;
|
|
2572
|
-
if (attributeName === aiBlobAttributeTag) {
|
|
2573
|
-
return false;
|
|
2574
|
-
}
|
|
2575
|
-
else if (attributeName.indexOf(dataTag) === 0) {
|
|
2576
|
-
dataTagFound = true;
|
|
2577
|
-
}
|
|
2578
|
-
}
|
|
2579
|
-
return dataTagFound;
|
|
2580
|
-
};
|
|
2581
|
-
DomContentHandler.prototype._getHtmlIdAndContentName = function (element) {
|
|
2582
|
-
var htmlContent = {};
|
|
2583
|
-
if (!element)
|
|
2584
|
-
return htmlContent;
|
|
2585
|
-
if (this._config.dataTags.useDefaultContentNameOrId) {
|
|
2586
|
-
var customizedContentName = this._config.callback.contentName ? this._config.callback.contentName(element, this._config.dataTags.useDefaultContentNameOrId) : "";
|
|
2587
|
-
var defaultContentName = this._getDefaultContentName(element, this._config.dataTags.useDefaultContentNameOrId);
|
|
2588
|
-
htmlContent = {
|
|
2589
|
-
id: element.id,
|
|
2590
|
-
contentName: customizedContentName || defaultContentName || element.getAttribute("alt")
|
|
2591
|
-
};
|
|
2592
|
-
}
|
|
2593
|
-
return htmlContent;
|
|
2594
|
-
};
|
|
2595
|
-
DomContentHandler.prototype._getParentDetails = function (element, elementContent, dataTagPrefix, aiBlobAttributeTag) {
|
|
2596
|
-
var parentId = elementContent["parentid"];
|
|
2597
|
-
var parentName = elementContent["parentname"];
|
|
2598
|
-
var parentInfo = {};
|
|
2599
|
-
if (parentId || parentName || !element) {
|
|
2600
|
-
return parentInfo;
|
|
2601
|
-
}
|
|
2602
|
-
return this._populateParentInfo(element, dataTagPrefix, aiBlobAttributeTag);
|
|
2603
|
-
};
|
|
2604
|
-
DomContentHandler.prototype._populateParentInfo = function (element, dataTagPrefix, aiBlobAttributeTag) {
|
|
2605
|
-
var parentInfo = {};
|
|
2606
|
-
var parentId;
|
|
2607
|
-
var closestParentElement = walkUpDomChainWithElementValidation(element.parentElement, this._isTracked, dataTagPrefix);
|
|
2608
|
-
if (closestParentElement) {
|
|
2609
|
-
var dataAttr = closestParentElement.getAttribute(aiBlobAttributeTag) || element[aiBlobAttributeTag];
|
|
2610
|
-
if (dataAttr) {
|
|
2611
|
-
try {
|
|
2612
|
-
var telemetryObject = JSON.parse(dataAttr);
|
|
2654
|
+
function _populateElementContent(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {
|
|
2655
|
+
var elementContent = {};
|
|
2656
|
+
if (!element) {
|
|
2657
|
+
return elementContent;
|
|
2613
2658
|
}
|
|
2614
|
-
|
|
2615
|
-
|
|
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);
|
|
2616
2666
|
}
|
|
2617
|
-
if (
|
|
2618
|
-
|
|
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!");
|
|
2619
2670
|
}
|
|
2671
|
+
return elementContent;
|
|
2620
2672
|
}
|
|
2621
|
-
|
|
2622
|
-
|
|
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;
|
|
2623
2804
|
}
|
|
2624
|
-
}
|
|
2625
|
-
|
|
2626
|
-
parentInfo["parentid"] = parentId;
|
|
2627
|
-
}
|
|
2628
|
-
else {
|
|
2629
|
-
var htmlContent = this._getHtmlIdAndContentName(element.parentElement);
|
|
2630
|
-
parentInfo["parentid"] = htmlContent.id;
|
|
2631
|
-
parentInfo["parentname"] = htmlContent.contentName;
|
|
2632
|
-
}
|
|
2633
|
-
return parentInfo;
|
|
2634
|
-
};
|
|
2805
|
+
});
|
|
2806
|
+
}
|
|
2635
2807
|
return DomContentHandler;
|
|
2636
2808
|
}());
|
|
2637
2809
|
|
|
2638
2810
|
var ClickAnalyticsPlugin = /** @class */ (function (_super) {
|
|
2639
2811
|
__extendsFn(ClickAnalyticsPlugin, _super);
|
|
2640
2812
|
function ClickAnalyticsPlugin() {
|
|
2641
|
-
var _this = _super
|
|
2813
|
+
var _this = _super.call(this) || this;
|
|
2642
2814
|
_this.identifier = "ClickAnalyticsPlugin";
|
|
2643
2815
|
_this.priority = 181;
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
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
|
+
};
|
|
2666
2868
|
});
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
ClickAnalyticsPlugin.prototype.processTelemetry = function (env, itemCtx) {
|
|
2673
|
-
this.processNext(env, itemCtx);
|
|
2674
|
-
};
|
|
2675
|
-
ClickAnalyticsPlugin.prototype.trackPageAction = function (pageAction, customProperties) {
|
|
2676
|
-
try {
|
|
2677
|
-
this.pageAction.trackPageAction(pageAction, customProperties);
|
|
2678
|
-
}
|
|
2679
|
-
catch (e) {
|
|
2680
|
-
this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.TrackPageActionEventFailed, "trackPageAction failed, page action event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
|
|
2869
|
+
function _initDefaults() {
|
|
2870
|
+
_config = null;
|
|
2871
|
+
_pageAction = null;
|
|
2872
|
+
_autoCaptureHandler = null;
|
|
2873
|
+
_contentHandler = null;
|
|
2681
2874
|
}
|
|
2682
|
-
|
|
2683
|
-
|
|
2875
|
+
return _this;
|
|
2876
|
+
}
|
|
2877
|
+
ClickAnalyticsPlugin.Version = "2.8.0-beta.2203-12";
|
|
2684
2878
|
return ClickAnalyticsPlugin;
|
|
2685
2879
|
}(BaseTelemetryPlugin));
|
|
2686
2880
|
|