@microsoft/applicationinsights-clickanalytics-js 2.8.5-nightly.2206-03 → 2.8.5-nightly.2207-01
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.5-nightly.2206-03.cjs.js → ai.clck.2.8.5-nightly.2207-01.cjs.js} +658 -566
- package/browser/ai.clck.2.8.5-nightly.2207-01.cjs.js.map +1 -0
- package/browser/ai.clck.2.8.5-nightly.2207-01.cjs.min.js +6 -0
- package/browser/ai.clck.2.8.5-nightly.2207-01.cjs.min.js.map +1 -0
- package/browser/{ai.clck.2.8.5-nightly.2206-03.gbl.js → ai.clck.2.8.5-nightly.2207-01.gbl.js} +658 -566
- package/browser/ai.clck.2.8.5-nightly.2207-01.gbl.js.map +1 -0
- package/browser/ai.clck.2.8.5-nightly.2207-01.gbl.min.js +6 -0
- package/browser/ai.clck.2.8.5-nightly.2207-01.gbl.min.js.map +1 -0
- package/browser/ai.clck.2.8.5-nightly.2207-01.integrity.json +66 -0
- package/browser/{ai.clck.2.8.5-nightly.2206-03.js → ai.clck.2.8.5-nightly.2207-01.js} +658 -566
- package/browser/ai.clck.2.8.5-nightly.2207-01.js.map +1 -0
- package/browser/ai.clck.2.8.5-nightly.2207-01.min.js +6 -0
- package/browser/ai.clck.2.8.5-nightly.2207-01.min.js.map +1 -0
- package/browser/ai.clck.2.cjs.js +657 -565
- 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 +657 -565
- 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 +657 -565
- 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 +5 -2
- package/dist/applicationinsights-clickanalytics-js.d.ts +1 -1
- package/dist/applicationinsights-clickanalytics-js.js +657 -565
- 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 +1 -1
- package/dist-esm/Behaviours.js +1 -1
- package/dist-esm/ClickAnalyticsPlugin.js +13 -12
- package/dist-esm/ClickAnalyticsPlugin.js.map +1 -1
- package/dist-esm/DataCollector.js +21 -20
- 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/__DynamicConstants.js +62 -0
- package/dist-esm/__DynamicConstants.js.map +1 -0
- package/dist-esm/applicationinsights-clickanalytics-js.js +1 -1
- package/dist-esm/common/Utils.js +45 -82
- package/dist-esm/common/Utils.js.map +1 -1
- package/dist-esm/events/PageAction.js +50 -49
- package/dist-esm/events/PageAction.js.map +1 -1
- package/dist-esm/events/WebEvent.js +40 -39
- package/dist-esm/events/WebEvent.js.map +1 -1
- package/dist-esm/handlers/AutoCaptureHandler.js +24 -22
- package/dist-esm/handlers/AutoCaptureHandler.js.map +1 -1
- package/dist-esm/handlers/DomContentHandler.js +61 -60
- package/dist-esm/handlers/DomContentHandler.js.map +1 -1
- package/package.json +8 -5
- package/src/ClickAnalyticsPlugin.ts +20 -27
- package/src/DataCollector.ts +9 -12
- package/src/Interfaces/Datamodel.ts +1 -1
- package/src/__DynamicConstants.ts +60 -0
- package/src/common/Utils.ts +28 -69
- package/src/events/PageAction.ts +19 -16
- package/src/events/WebEvent.ts +20 -18
- package/src/handlers/AutoCaptureHandler.ts +16 -16
- package/src/handlers/DomContentHandler.ts +15 -17
- package/types/ClickAnalyticsPlugin.d.ts +4 -4
- package/types/DataCollector.d.ts +2 -2
- package/types/__DynamicConstants.d.ts +48 -0
- package/types/common/Utils.d.ts +94 -96
- package/types/events/PageAction.d.ts +4 -4
- package/types/events/WebEvent.d.ts +4 -4
- package/types/handlers/AutoCaptureHandler.d.ts +3 -3
- package/types/handlers/DomContentHandler.d.ts +2 -2
- package/types/tsdoc-metadata.json +1 -1
- package/browser/ai.clck.2.8.5-nightly.2206-03.cjs.js.map +0 -1
- package/browser/ai.clck.2.8.5-nightly.2206-03.cjs.min.js +0 -6
- package/browser/ai.clck.2.8.5-nightly.2206-03.cjs.min.js.map +0 -1
- package/browser/ai.clck.2.8.5-nightly.2206-03.gbl.js.map +0 -1
- package/browser/ai.clck.2.8.5-nightly.2206-03.gbl.min.js +0 -6
- package/browser/ai.clck.2.8.5-nightly.2206-03.gbl.min.js.map +0 -1
- package/browser/ai.clck.2.8.5-nightly.2206-03.integrity.json +0 -66
- package/browser/ai.clck.2.8.5-nightly.2206-03.js.map +0 -1
- package/browser/ai.clck.2.8.5-nightly.2206-03.min.js +0 -6
- package/browser/ai.clck.2.8.5-nightly.2206-03.min.js.map +0 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Click Analytics, 2.8.5-nightly.
|
|
2
|
+
* Application Insights JavaScript SDK - Click Analytics, 2.8.5-nightly.2207-01
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
* @copyright Microsoft 2020
|
|
7
|
+
*/
|
|
8
8
|
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { _throwInternal, getDocument, hasDocument, isNullOrUndefined, objExtend } from "@microsoft/applicationinsights-core-js";
|
|
10
|
+
import { _DYN_AI_BLOB_ATTRIBUTE_TA2, _DYN_ATTRIBUTES, _DYN_CAPTURE_ALL_META_DAT3, _DYN_CONTENT, _DYN_CONTENT_NAME, _DYN_CUSTOM_DATA_PREFIX, _DYN_DATA_TAGS, _DYN_GET_ATTRIBUTE, _DYN_GET_ELEMENT_CONTENT, _DYN_INDEX_OF, _DYN_LENGTH, _DYN_NAME, _DYN_PARENT_DATA_TAG, _DYN_PARENT_ELEMENT, _DYN_PARENT_NODE, _DYN_TAG_NAME, _DYN_USE_DEFAULT_CONTENT_1, _DYN__CONFIG, _DYN__TRACE_LOGGER } from "../__DynamicConstants";
|
|
11
|
+
import { isValueAssigned, removeInvalidElements, walkUpDomChainWithElementValidation } from "../common/Utils";
|
|
11
12
|
var MAX_CONTENTNAME_LENGTH = 200;
|
|
12
13
|
var DomContentHandler = /** @class */ (function () {
|
|
13
14
|
/**
|
|
@@ -19,50 +20,50 @@ var DomContentHandler = /** @class */ (function () {
|
|
|
19
20
|
this._traceLogger = _traceLogger;
|
|
20
21
|
dynamicProto(DomContentHandler, this, function (_self) {
|
|
21
22
|
_self.getMetadata = function () {
|
|
22
|
-
var dataTags = (_self._config || {})
|
|
23
|
+
var dataTags = (_self._config || {})[_DYN_DATA_TAGS /* @min:%2edataTags */];
|
|
23
24
|
var metaTags = {};
|
|
24
25
|
if (hasDocument) {
|
|
25
|
-
metaTags = isValueAssigned(dataTags.metaDataPrefix) ? _getMetaDataFromDOM(dataTags
|
|
26
|
-
_getMetaDataFromDOM(dataTags
|
|
26
|
+
metaTags = isValueAssigned(dataTags.metaDataPrefix) ? _getMetaDataFromDOM(dataTags[_DYN_CAPTURE_ALL_META_DAT3 /* @min:%2ecaptureAllMetaDataContent */], dataTags.metaDataPrefix, false) :
|
|
27
|
+
_getMetaDataFromDOM(dataTags[_DYN_CAPTURE_ALL_META_DAT3 /* @min:%2ecaptureAllMetaDataContent */], "", false);
|
|
27
28
|
}
|
|
28
29
|
return metaTags;
|
|
29
30
|
};
|
|
30
|
-
_self
|
|
31
|
+
_self[_DYN_GET_ELEMENT_CONTENT /* @min:%2egetElementContent */] = function (element) {
|
|
31
32
|
if (!element) {
|
|
32
33
|
return {};
|
|
33
34
|
}
|
|
34
|
-
var dataTags = (_self._config || {})
|
|
35
|
+
var dataTags = (_self._config || {})[_DYN_DATA_TAGS /* @min:%2edataTags */];
|
|
35
36
|
var elementContent = {};
|
|
36
37
|
var biBlobValue;
|
|
37
38
|
var parentDataTagPrefix;
|
|
38
|
-
var dataTagPrefix = dataTags
|
|
39
|
-
var aiBlobAttributeTag = dataTagPrefix + dataTags
|
|
40
|
-
if (isValueAssigned(dataTags
|
|
41
|
-
parentDataTagPrefix = dataTagPrefix + dataTags
|
|
39
|
+
var dataTagPrefix = dataTags[_DYN_CUSTOM_DATA_PREFIX /* @min:%2ecustomDataPrefix */];
|
|
40
|
+
var aiBlobAttributeTag = dataTagPrefix + dataTags[_DYN_AI_BLOB_ATTRIBUTE_TA2 /* @min:%2eaiBlobAttributeTag */];
|
|
41
|
+
if (isValueAssigned(dataTags[_DYN_PARENT_DATA_TAG /* @min:%2eparentDataTag */])) {
|
|
42
|
+
parentDataTagPrefix = dataTagPrefix + dataTags[_DYN_PARENT_DATA_TAG /* @min:%2eparentDataTag */];
|
|
42
43
|
}
|
|
43
44
|
if (!_isTracked(element, dataTagPrefix, aiBlobAttributeTag)) {
|
|
44
45
|
// capture blob from element or hierarchy
|
|
45
|
-
biBlobValue = element
|
|
46
|
+
biBlobValue = element[_DYN_GET_ATTRIBUTE /* @min:%2egetAttribute */](aiBlobAttributeTag);
|
|
46
47
|
if (biBlobValue) {
|
|
47
48
|
try {
|
|
48
49
|
elementContent = JSON.parse(biBlobValue);
|
|
49
50
|
}
|
|
50
51
|
catch (e) {
|
|
51
|
-
_throwInternal(_self
|
|
52
|
+
_throwInternal(_self[_DYN__TRACE_LOGGER /* @min:%2e_traceLogger */], 1 /* eLoggingSeverity.CRITICAL */, 101 /* _eInternalMessageId.CannotParseAiBlobValue */, "Can not parse " + biBlobValue);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
else {
|
|
55
56
|
// traverse up the DOM to find the closest parent with data-* tag defined
|
|
56
57
|
//contentElement = walkUpDomChainWithElementValidation(element, _self._isTracked, dataTagPrefix);
|
|
57
|
-
elementContent =
|
|
58
|
+
elementContent = objExtend(elementContent, _populateElementContent(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag));
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
else {
|
|
61
|
-
elementContent =
|
|
62
|
+
elementContent = objExtend(elementContent, _populateElementContentwithDataTag(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag));
|
|
62
63
|
}
|
|
63
64
|
removeInvalidElements(elementContent);
|
|
64
65
|
if (parentDataTagPrefix) {
|
|
65
|
-
elementContent =
|
|
66
|
+
elementContent = objExtend(elementContent, _getParentDetails(element, elementContent, dataTagPrefix, aiBlobAttributeTag));
|
|
66
67
|
}
|
|
67
68
|
return elementContent;
|
|
68
69
|
};
|
|
@@ -70,12 +71,12 @@ var DomContentHandler = /** @class */ (function () {
|
|
|
70
71
|
* Capture current level Element content
|
|
71
72
|
*/
|
|
72
73
|
function _captureElementContentWithDataTag(contentElement, elementContent, dataTagPrefix) {
|
|
73
|
-
for (var i = 0, attrib; i < contentElement.attributes
|
|
74
|
-
attrib = contentElement
|
|
75
|
-
if (attrib.name
|
|
74
|
+
for (var i = 0, attrib; i < contentElement.attributes[_DYN_LENGTH /* @min:%2elength */]; i++) {
|
|
75
|
+
attrib = contentElement[_DYN_ATTRIBUTES /* @min:%2eattributes */][i];
|
|
76
|
+
if (attrib.name[_DYN_INDEX_OF /* @min:%2eindexOf */](dataTagPrefix) !== 0) {
|
|
76
77
|
continue;
|
|
77
78
|
}
|
|
78
|
-
var attribName = attrib.
|
|
79
|
+
var attribName = attrib[_DYN_NAME /* @min:%2ename */].replace(dataTagPrefix, "");
|
|
79
80
|
elementContent[attribName] = attrib.value;
|
|
80
81
|
}
|
|
81
82
|
}
|
|
@@ -86,21 +87,21 @@ var DomContentHandler = /** @class */ (function () {
|
|
|
86
87
|
var element = el;
|
|
87
88
|
var parentDataTagFound = false;
|
|
88
89
|
var elementLevelFlag = false; // Use this flag to capture 'id' only at the incoming html element level.
|
|
89
|
-
while (!isNullOrUndefined(element) && !isNullOrUndefined(element
|
|
90
|
-
var attributes = element
|
|
91
|
-
for (var i = 0; i < attributes
|
|
90
|
+
while (!isNullOrUndefined(element) && !isNullOrUndefined(element[_DYN_ATTRIBUTES /* @min:%2eattributes */])) {
|
|
91
|
+
var attributes = element[_DYN_ATTRIBUTES /* @min:%2eattributes */];
|
|
92
|
+
for (var i = 0; i < attributes[_DYN_LENGTH /* @min:%2elength */]; i++) {
|
|
92
93
|
var attrib = attributes[i];
|
|
93
|
-
if (attrib.name
|
|
94
|
+
if (attrib.name[_DYN_INDEX_OF /* @min:%2eindexOf */](dataTagPrefix) !== 0) {
|
|
94
95
|
continue;
|
|
95
96
|
}
|
|
96
|
-
if (attrib.name
|
|
97
|
+
if (attrib.name[_DYN_INDEX_OF /* @min:%2eindexOf */](parentDataTagPrefix) === 0) {
|
|
97
98
|
parentDataTagFound = true;
|
|
98
99
|
}
|
|
99
100
|
// Todo handle blob data
|
|
100
|
-
if (attrib.name
|
|
101
|
+
if (attrib.name[_DYN_INDEX_OF /* @min:%2eindexOf */](aiBlobAttributeTag) === 0) {
|
|
101
102
|
continue;
|
|
102
103
|
}
|
|
103
|
-
var attribName = attrib.
|
|
104
|
+
var attribName = attrib[_DYN_NAME /* @min:%2ename */].replace(dataTagPrefix, "");
|
|
104
105
|
if (elementLevelFlag && attribName === "id") {
|
|
105
106
|
continue; // skip capturing id if not at the first level.
|
|
106
107
|
}
|
|
@@ -113,7 +114,7 @@ var DomContentHandler = /** @class */ (function () {
|
|
|
113
114
|
break;
|
|
114
115
|
}
|
|
115
116
|
elementLevelFlag = true; // after the initial level set this flag to true.
|
|
116
|
-
element = element
|
|
117
|
+
element = element[_DYN_PARENT_NODE /* @min:%2eparentNode */];
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
/**
|
|
@@ -127,7 +128,7 @@ var DomContentHandler = /** @class */ (function () {
|
|
|
127
128
|
var htmlContent = _getHtmlIdAndContentName(element);
|
|
128
129
|
elementContent = {
|
|
129
130
|
id: htmlContent.id || "",
|
|
130
|
-
contentName: htmlContent
|
|
131
|
+
contentName: htmlContent[_DYN_CONTENT_NAME /* @min:%2econtentName */] || ""
|
|
131
132
|
};
|
|
132
133
|
if (isValueAssigned(parentDataTagPrefix)) {
|
|
133
134
|
_walkUpDomChainCaptureData(element, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag);
|
|
@@ -136,7 +137,7 @@ var DomContentHandler = /** @class */ (function () {
|
|
|
136
137
|
// The content schema defines id, aN and sN as required fields. However,
|
|
137
138
|
// requiring these fields would result in majority of adopter's content from being collected.
|
|
138
139
|
// Just throw a warning and continue collection.
|
|
139
|
-
if (!elementContent.id && !elementContent
|
|
140
|
+
if (!elementContent.id && !elementContent[_DYN_CONTENT_NAME /* @min:%2econtentName */]) {
|
|
140
141
|
_throwInternal(_traceLogger, 2 /* eLoggingSeverity.WARNING */, 102 /* _eInternalMessageId.InvalidContentBlob */, "Invalid content blob. Missing required attributes (id, contentName. " +
|
|
141
142
|
" Content information will still be collected!");
|
|
142
143
|
}
|
|
@@ -146,7 +147,7 @@ var DomContentHandler = /** @class */ (function () {
|
|
|
146
147
|
* Capture Element content along with Data Tag attributes and values
|
|
147
148
|
*/
|
|
148
149
|
function _populateElementContentwithDataTag(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {
|
|
149
|
-
var dataTags = (_self._config || {})
|
|
150
|
+
var dataTags = (_self._config || {})[_DYN_DATA_TAGS /* @min:%2edataTags */];
|
|
150
151
|
var elementContent = {};
|
|
151
152
|
if (!element) {
|
|
152
153
|
return elementContent;
|
|
@@ -158,17 +159,17 @@ var DomContentHandler = /** @class */ (function () {
|
|
|
158
159
|
else {
|
|
159
160
|
_captureElementContentWithDataTag(element, elementContent, dataTagPrefix);
|
|
160
161
|
}
|
|
161
|
-
if (dataTags
|
|
162
|
+
if (dataTags[_DYN_USE_DEFAULT_CONTENT_1 /* @min:%2euseDefaultContentNameOrId */]) {
|
|
162
163
|
if (!isValueAssigned(elementContent.id)) {
|
|
163
164
|
elementContent.id = htmlContent.id || "";
|
|
164
165
|
}
|
|
165
|
-
elementContent
|
|
166
|
+
elementContent[_DYN_CONTENT_NAME /* @min:%2econtentName */] = htmlContent[_DYN_CONTENT_NAME /* @min:%2econtentName */] || "";
|
|
166
167
|
}
|
|
167
168
|
// Validate to ensure the minimum required field 'id' or 'contentName' is present.
|
|
168
169
|
// The content schema defines id, aN and sN as required fields. However,
|
|
169
170
|
// requiring these fields would result in majority of adopter's content from being collected.
|
|
170
171
|
// Just throw a warning and continue collection.
|
|
171
|
-
if (!elementContent.id && !elementContent
|
|
172
|
+
if (!elementContent.id && !elementContent[_DYN_CONTENT_NAME /* @min:%2econtentName */]) {
|
|
172
173
|
_throwInternal(_traceLogger, 2 /* eLoggingSeverity.WARNING */, 102 /* _eInternalMessageId.InvalidContentBlob */, "Invalid content blob. Missing required attributes (id, contentName. " +
|
|
173
174
|
" Content information will still be collected!");
|
|
174
175
|
}
|
|
@@ -186,12 +187,12 @@ var DomContentHandler = /** @class */ (function () {
|
|
|
186
187
|
var metaData = {};
|
|
187
188
|
if (hasDocument) {
|
|
188
189
|
metaElements = document.querySelectorAll("meta");
|
|
189
|
-
for (var i = 0; i < metaElements
|
|
190
|
+
for (var i = 0; i < metaElements[_DYN_LENGTH /* @min:%2elength */]; i++) {
|
|
190
191
|
var meta = metaElements[i];
|
|
191
|
-
if (meta
|
|
192
|
-
if (captureAllMetaDataContent || meta.name
|
|
193
|
-
var name_1 = removePrefix ? meta.
|
|
194
|
-
metaData[name_1] = meta
|
|
192
|
+
if (meta[_DYN_NAME /* @min:%2ename */]) {
|
|
193
|
+
if (captureAllMetaDataContent || meta.name[_DYN_INDEX_OF /* @min:%2eindexOf */](prefix) === 0) {
|
|
194
|
+
var name_1 = removePrefix ? meta[_DYN_NAME /* @min:%2ename */].replace(prefix, "") : meta[_DYN_NAME /* @min:%2ename */];
|
|
195
|
+
metaData[name_1] = meta[_DYN_CONTENT /* @min:%2econtent */];
|
|
195
196
|
}
|
|
196
197
|
}
|
|
197
198
|
}
|
|
@@ -205,12 +206,12 @@ var DomContentHandler = /** @class */ (function () {
|
|
|
205
206
|
* @returns Content name
|
|
206
207
|
*/
|
|
207
208
|
function _getDefaultContentName(element, useDefaultContentName) {
|
|
208
|
-
if (useDefaultContentName === false || !element
|
|
209
|
+
if (useDefaultContentName === false || !element[_DYN_TAG_NAME /* @min:%2etagName */]) {
|
|
209
210
|
return "";
|
|
210
211
|
}
|
|
211
212
|
var doc = getDocument() || {};
|
|
212
213
|
var contentName;
|
|
213
|
-
switch (element
|
|
214
|
+
switch (element[_DYN_TAG_NAME /* @min:%2etagName */]) {
|
|
214
215
|
case "A":
|
|
215
216
|
contentName = doc.all ? element.innerText || element.innerHTML : element.text || element.innerHTML;
|
|
216
217
|
break;
|
|
@@ -219,7 +220,7 @@ var DomContentHandler = /** @class */ (function () {
|
|
|
219
220
|
contentName = element.alt;
|
|
220
221
|
break;
|
|
221
222
|
default:
|
|
222
|
-
contentName = element.value || element
|
|
223
|
+
contentName = element.value || element[_DYN_NAME /* @min:%2ename */] || element.alt || element.innerText || element.id;
|
|
223
224
|
}
|
|
224
225
|
return contentName.substring(0, MAX_CONTENTNAME_LENGTH);
|
|
225
226
|
}
|
|
@@ -229,33 +230,33 @@ var DomContentHandler = /** @class */ (function () {
|
|
|
229
230
|
* @returns true if any data-* exist, otherwise return false
|
|
230
231
|
*/
|
|
231
232
|
function _isTracked(element, dataTag, aiBlobAttributeTag) {
|
|
232
|
-
var attrs = element
|
|
233
|
+
var attrs = element[_DYN_ATTRIBUTES /* @min:%2eattributes */];
|
|
233
234
|
var dataTagFound = false;
|
|
234
|
-
for (var i = 0; i < attrs
|
|
235
|
-
var attributeName = attrs[i]
|
|
235
|
+
for (var i = 0; i < attrs[_DYN_LENGTH /* @min:%2elength */]; i++) {
|
|
236
|
+
var attributeName = attrs[i][_DYN_NAME /* @min:%2ename */];
|
|
236
237
|
if (attributeName === aiBlobAttributeTag) {
|
|
237
238
|
// ignore if the attribute name is equal to aiBlobAttributeTag
|
|
238
239
|
return false;
|
|
239
240
|
}
|
|
240
|
-
else if (attributeName
|
|
241
|
+
else if (attributeName[_DYN_INDEX_OF /* @min:%2eindexOf */](dataTag) === 0) {
|
|
241
242
|
dataTagFound = true;
|
|
242
243
|
}
|
|
243
244
|
}
|
|
244
245
|
return dataTagFound;
|
|
245
246
|
}
|
|
246
247
|
function _getHtmlIdAndContentName(element) {
|
|
247
|
-
var dataTags = (_self._config || {})
|
|
248
|
-
var callback = (_self
|
|
248
|
+
var dataTags = (_self._config || {})[_DYN_DATA_TAGS /* @min:%2edataTags */];
|
|
249
|
+
var callback = (_self[_DYN__CONFIG /* @min:%2e_config */] || {}).callback;
|
|
249
250
|
var htmlContent = {};
|
|
250
251
|
if (!element) {
|
|
251
252
|
return htmlContent;
|
|
252
253
|
}
|
|
253
|
-
if (dataTags
|
|
254
|
-
var customizedContentName = callback.contentName ? callback.contentName(element, dataTags
|
|
255
|
-
var defaultContentName = _getDefaultContentName(element, dataTags
|
|
254
|
+
if (dataTags[_DYN_USE_DEFAULT_CONTENT_1 /* @min:%2euseDefaultContentNameOrId */]) {
|
|
255
|
+
var customizedContentName = callback.contentName ? callback.contentName(element, dataTags[_DYN_USE_DEFAULT_CONTENT_1 /* @min:%2euseDefaultContentNameOrId */]) : "";
|
|
256
|
+
var defaultContentName = _getDefaultContentName(element, dataTags[_DYN_USE_DEFAULT_CONTENT_1 /* @min:%2euseDefaultContentNameOrId */]);
|
|
256
257
|
htmlContent = {
|
|
257
258
|
id: element.id,
|
|
258
|
-
contentName: customizedContentName || defaultContentName || element
|
|
259
|
+
contentName: customizedContentName || defaultContentName || element[_DYN_GET_ATTRIBUTE /* @min:%2egetAttribute */]("alt")
|
|
259
260
|
};
|
|
260
261
|
}
|
|
261
262
|
return htmlContent;
|
|
@@ -283,9 +284,9 @@ var DomContentHandler = /** @class */ (function () {
|
|
|
283
284
|
var parentInfo = {};
|
|
284
285
|
var parentId;
|
|
285
286
|
// if the user does not set up parent info, walk to the DOM, find the closest parent element (with tags) and populate the info
|
|
286
|
-
var closestParentElement = walkUpDomChainWithElementValidation(element
|
|
287
|
+
var closestParentElement = walkUpDomChainWithElementValidation(element[_DYN_PARENT_ELEMENT /* @min:%2eparentElement */], _isTracked, dataTagPrefix);
|
|
287
288
|
if (closestParentElement) {
|
|
288
|
-
var dataAttr = closestParentElement
|
|
289
|
+
var dataAttr = closestParentElement[_DYN_GET_ATTRIBUTE /* @min:%2egetAttribute */](aiBlobAttributeTag) || element[aiBlobAttributeTag];
|
|
289
290
|
if (dataAttr) {
|
|
290
291
|
try {
|
|
291
292
|
var telemetryObject = JSON.parse(dataAttr);
|
|
@@ -298,16 +299,16 @@ var DomContentHandler = /** @class */ (function () {
|
|
|
298
299
|
}
|
|
299
300
|
}
|
|
300
301
|
else {
|
|
301
|
-
parentId = closestParentElement
|
|
302
|
+
parentId = closestParentElement[_DYN_GET_ATTRIBUTE /* @min:%2egetAttribute */](dataTagPrefix + "id");
|
|
302
303
|
}
|
|
303
304
|
}
|
|
304
305
|
if (parentId) {
|
|
305
306
|
parentInfo["parentid"] = parentId;
|
|
306
307
|
}
|
|
307
308
|
else {
|
|
308
|
-
var htmlContent = _getHtmlIdAndContentName(element
|
|
309
|
+
var htmlContent = _getHtmlIdAndContentName(element[_DYN_PARENT_ELEMENT /* @min:%2eparentElement */]);
|
|
309
310
|
parentInfo["parentid"] = htmlContent.id;
|
|
310
|
-
parentInfo["parentname"] = htmlContent
|
|
311
|
+
parentInfo["parentname"] = htmlContent[_DYN_CONTENT_NAME /* @min:%2econtentName */];
|
|
311
312
|
}
|
|
312
313
|
return parentInfo;
|
|
313
314
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DomContentHandler.js.map","sources":["DomContentHandler.js"],"sourcesContent":["/**\r\n * @copyright Microsoft 2020\r\n */\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { removeInvalidElements, walkUpDomChainWithElementValidation, extend, isValueAssigned } from \"../common/Utils\";\r\nimport { getDocument, isNullOrUndefined, hasDocument, _throwInternal } from \"@microsoft/applicationinsights-core-js\";\r\nvar MAX_CONTENTNAME_LENGTH = 200;\r\nvar DomContentHandler = /** @class */ (function () {\r\n /**\r\n * @param config - ClickAnalytics configuration object\r\n * @param traceLogger - Trace logger to log to console.\r\n */\r\n function DomContentHandler(_config, _traceLogger) {\r\n this._config = _config;\r\n this._traceLogger = _traceLogger;\r\n dynamicProto(DomContentHandler, this, function (_self) {\r\n _self.getMetadata = function () {\r\n var dataTags = (_self._config || {}).dataTags;\r\n var metaTags = {};\r\n if (hasDocument) {\r\n metaTags = isValueAssigned(dataTags.metaDataPrefix) ? _getMetaDataFromDOM(dataTags.captureAllMetaDataContent, dataTags.metaDataPrefix, false) :\r\n _getMetaDataFromDOM(dataTags.captureAllMetaDataContent, \"\", false);\r\n }\r\n return metaTags;\r\n };\r\n _self.getElementContent = function (element) {\r\n if (!element) {\r\n return {};\r\n }\r\n var dataTags = (_self._config || {}).dataTags;\r\n var elementContent = {};\r\n var biBlobValue;\r\n var parentDataTagPrefix;\r\n var dataTagPrefix = dataTags.customDataPrefix;\r\n var aiBlobAttributeTag = dataTagPrefix + dataTags.aiBlobAttributeTag;\r\n if (isValueAssigned(dataTags.parentDataTag)) {\r\n parentDataTagPrefix = dataTagPrefix + dataTags.parentDataTag;\r\n }\r\n if (!_isTracked(element, dataTagPrefix, aiBlobAttributeTag)) {\r\n // capture blob from element or hierarchy\r\n biBlobValue = element.getAttribute(aiBlobAttributeTag);\r\n if (biBlobValue) {\r\n try {\r\n elementContent = JSON.parse(biBlobValue);\r\n }\r\n catch (e) {\r\n _throwInternal(_self._traceLogger, 1 /* eLoggingSeverity.CRITICAL */, 101 /* _eInternalMessageId.CannotParseAiBlobValue */, \"Can not parse \" + biBlobValue);\r\n }\r\n }\r\n else {\r\n // traverse up the DOM to find the closest parent with data-* tag defined\r\n //contentElement = walkUpDomChainWithElementValidation(element, _self._isTracked, dataTagPrefix);\r\n elementContent = extend(elementContent, _populateElementContent(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag));\r\n }\r\n }\r\n else {\r\n elementContent = extend(elementContent, _populateElementContentwithDataTag(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag));\r\n }\r\n removeInvalidElements(elementContent);\r\n if (parentDataTagPrefix) {\r\n elementContent = extend(elementContent, _getParentDetails(element, elementContent, dataTagPrefix, aiBlobAttributeTag));\r\n }\r\n return elementContent;\r\n };\r\n /**\r\n * Capture current level Element content\r\n */\r\n function _captureElementContentWithDataTag(contentElement, elementContent, dataTagPrefix) {\r\n for (var i = 0, attrib; i < contentElement.attributes.length; i++) {\r\n attrib = contentElement.attributes[i];\r\n if (attrib.name.indexOf(dataTagPrefix) !== 0) {\r\n continue;\r\n }\r\n var attribName = attrib.name.replace(dataTagPrefix, \"\");\r\n elementContent[attribName] = attrib.value;\r\n }\r\n }\r\n /**\r\n * Walk Up the DOM to capture Element content\r\n */\r\n function _walkUpDomChainCaptureData(el, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {\r\n var element = el;\r\n var parentDataTagFound = false;\r\n var elementLevelFlag = false; // Use this flag to capture 'id' only at the incoming html element level.\r\n while (!isNullOrUndefined(element) && !isNullOrUndefined(element.attributes)) {\r\n var attributes = element.attributes;\r\n for (var i = 0; i < attributes.length; i++) {\r\n var attrib = attributes[i];\r\n if (attrib.name.indexOf(dataTagPrefix) !== 0) {\r\n continue;\r\n }\r\n if (attrib.name.indexOf(parentDataTagPrefix) === 0) {\r\n parentDataTagFound = true;\r\n }\r\n // Todo handle blob data\r\n if (attrib.name.indexOf(aiBlobAttributeTag) === 0) {\r\n continue;\r\n }\r\n var attribName = attrib.name.replace(dataTagPrefix, \"\");\r\n if (elementLevelFlag && attribName === \"id\") {\r\n continue; // skip capturing id if not at the first level.\r\n }\r\n if (!isValueAssigned(elementContent[attribName])) {\r\n elementContent[attribName] = attrib.value;\r\n }\r\n }\r\n // break after current level;\r\n if (parentDataTagFound) {\r\n break;\r\n }\r\n elementLevelFlag = true; // after the initial level set this flag to true.\r\n element = element.parentNode;\r\n }\r\n }\r\n /**\r\n * Capture Element content along with Data Tag attributes and values\r\n */\r\n function _populateElementContent(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {\r\n var elementContent = {};\r\n if (!element) {\r\n return elementContent;\r\n }\r\n var htmlContent = _getHtmlIdAndContentName(element);\r\n elementContent = {\r\n id: htmlContent.id || \"\",\r\n contentName: htmlContent.contentName || \"\"\r\n };\r\n if (isValueAssigned(parentDataTagPrefix)) {\r\n _walkUpDomChainCaptureData(element, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag);\r\n }\r\n // Validate to ensure the minimum required field 'id' or 'contentName' is present.\r\n // The content schema defines id, aN and sN as required fields. However,\r\n // requiring these fields would result in majority of adopter's content from being collected.\r\n // Just throw a warning and continue collection.\r\n if (!elementContent.id && !elementContent.contentName) {\r\n _throwInternal(_traceLogger, 2 /* eLoggingSeverity.WARNING */, 102 /* _eInternalMessageId.InvalidContentBlob */, \"Invalid content blob. Missing required attributes (id, contentName. \" +\r\n \" Content information will still be collected!\");\r\n }\r\n return elementContent;\r\n }\r\n /**\r\n * Capture Element content along with Data Tag attributes and values\r\n */\r\n function _populateElementContentwithDataTag(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {\r\n var dataTags = (_self._config || {}).dataTags;\r\n var elementContent = {};\r\n if (!element) {\r\n return elementContent;\r\n }\r\n var htmlContent = _getHtmlIdAndContentName(element);\r\n if (isValueAssigned(parentDataTagPrefix)) {\r\n _walkUpDomChainCaptureData(element, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag);\r\n }\r\n else {\r\n _captureElementContentWithDataTag(element, elementContent, dataTagPrefix);\r\n }\r\n if (dataTags.useDefaultContentNameOrId) {\r\n if (!isValueAssigned(elementContent.id)) {\r\n elementContent.id = htmlContent.id || \"\";\r\n }\r\n elementContent.contentName = htmlContent.contentName || \"\";\r\n }\r\n // Validate to ensure the minimum required field 'id' or 'contentName' is present.\r\n // The content schema defines id, aN and sN as required fields. However,\r\n // requiring these fields would result in majority of adopter's content from being collected.\r\n // Just throw a warning and continue collection.\r\n if (!elementContent.id && !elementContent.contentName) {\r\n _throwInternal(_traceLogger, 2 /* eLoggingSeverity.WARNING */, 102 /* _eInternalMessageId.InvalidContentBlob */, \"Invalid content blob. Missing required attributes (id, contentName. \" +\r\n \" Content information will still be collected!\");\r\n }\r\n return elementContent;\r\n }\r\n /**\r\n * Retrieve a specified metadata tag value from the DOM.\r\n * @param captureAllMetaDataContent - Flag to capture all metadata content\r\n * @param prefix - Prefix to search the metatags with.\r\n * @param removePrefix - Specifies if the prefix must be excluded from key names in the returned collection.\r\n * @returns Metadata collection/property bag\r\n */\r\n function _getMetaDataFromDOM(captureAllMetaDataContent, prefix, removePrefix) {\r\n var metaElements;\r\n var metaData = {};\r\n if (hasDocument) {\r\n metaElements = document.querySelectorAll(\"meta\");\r\n for (var i = 0; i < metaElements.length; i++) {\r\n var meta = metaElements[i];\r\n if (meta.name) {\r\n if (captureAllMetaDataContent || meta.name.indexOf(prefix) === 0) {\r\n var name_1 = removePrefix ? meta.name.replace(prefix, \"\") : meta.name;\r\n metaData[name_1] = meta.content;\r\n }\r\n }\r\n }\r\n }\r\n return metaData;\r\n }\r\n /**\r\n * Gets the default content name.\r\n * @param element - An html element\r\n * @param useDefaultContentNameOrId -Flag indicating if an element is market PII.\r\n * @returns Content name\r\n */\r\n function _getDefaultContentName(element, useDefaultContentName) {\r\n if (useDefaultContentName === false || !element.tagName) {\r\n return \"\";\r\n }\r\n var doc = getDocument() || {};\r\n var contentName;\r\n switch (element.tagName) {\r\n case \"A\":\r\n contentName = doc.all ? element.innerText || element.innerHTML : element.text || element.innerHTML;\r\n break;\r\n case \"IMG\":\r\n case \"AREA\":\r\n contentName = element.alt;\r\n break;\r\n default:\r\n contentName = element.value || element.name || element.alt || element.innerText || element.id;\r\n }\r\n return contentName.substring(0, MAX_CONTENTNAME_LENGTH);\r\n }\r\n /**\r\n * Check if the user wants to track the element, which means if the element has any tags with data-* or customDataPrefix\r\n * @param element - An html element\r\n * @returns true if any data-* exist, otherwise return false\r\n */\r\n function _isTracked(element, dataTag, aiBlobAttributeTag) {\r\n var attrs = element.attributes;\r\n var dataTagFound = false;\r\n for (var i = 0; i < attrs.length; i++) {\r\n var attributeName = attrs[i].name;\r\n if (attributeName === aiBlobAttributeTag) {\r\n // ignore if the attribute name is equal to aiBlobAttributeTag\r\n return false;\r\n }\r\n else if (attributeName.indexOf(dataTag) === 0) {\r\n dataTagFound = true;\r\n }\r\n }\r\n return dataTagFound;\r\n }\r\n function _getHtmlIdAndContentName(element) {\r\n var dataTags = (_self._config || {}).dataTags;\r\n var callback = (_self._config || {}).callback;\r\n var htmlContent = {};\r\n if (!element) {\r\n return htmlContent;\r\n }\r\n if (dataTags.useDefaultContentNameOrId) {\r\n var customizedContentName = callback.contentName ? callback.contentName(element, dataTags.useDefaultContentNameOrId) : \"\";\r\n var defaultContentName = _getDefaultContentName(element, dataTags.useDefaultContentNameOrId);\r\n htmlContent = {\r\n id: element.id,\r\n contentName: customizedContentName || defaultContentName || element.getAttribute(\"alt\")\r\n };\r\n }\r\n return htmlContent;\r\n }\r\n /**\r\n * Computes the parentId of a given element.\r\n * @param element - An html element\r\n * @returns An object containing the closest parentId , can be empty if nothing was found\r\n */\r\n function _getParentDetails(element, elementContent, dataTagPrefix, aiBlobAttributeTag) {\r\n var parentId = elementContent[\"parentid\"];\r\n var parentName = elementContent[\"parentname\"];\r\n var parentInfo = {};\r\n if (parentId || parentName || !element) {\r\n return parentInfo;\r\n }\r\n return _populateParentInfo(element, dataTagPrefix, aiBlobAttributeTag);\r\n }\r\n /**\r\n * Check if parent info already set up, if so take and put into content, if not walk up the DOM to find correct info\r\n * @param element - An html element that the user wants to track\r\n * @returns An object containing the parent info, can be empty if nothing was found\r\n */\r\n function _populateParentInfo(element, dataTagPrefix, aiBlobAttributeTag) {\r\n var parentInfo = {};\r\n var parentId;\r\n // if the user does not set up parent info, walk to the DOM, find the closest parent element (with tags) and populate the info\r\n var closestParentElement = walkUpDomChainWithElementValidation(element.parentElement, _isTracked, dataTagPrefix);\r\n if (closestParentElement) {\r\n var dataAttr = closestParentElement.getAttribute(aiBlobAttributeTag) || element[aiBlobAttributeTag];\r\n if (dataAttr) {\r\n try {\r\n var telemetryObject = JSON.parse(dataAttr);\r\n }\r\n catch (e) {\r\n _throwInternal(_traceLogger, 1 /* eLoggingSeverity.CRITICAL */, 101 /* _eInternalMessageId.CannotParseAiBlobValue */, \"Can not parse \" + dataAttr);\r\n }\r\n if (telemetryObject) {\r\n parentId = telemetryObject.id;\r\n }\r\n }\r\n else {\r\n parentId = closestParentElement.getAttribute(dataTagPrefix + \"id\");\r\n }\r\n }\r\n if (parentId) {\r\n parentInfo[\"parentid\"] = parentId;\r\n }\r\n else {\r\n var htmlContent = _getHtmlIdAndContentName(element.parentElement);\r\n parentInfo[\"parentid\"] = htmlContent.id;\r\n parentInfo[\"parentname\"] = htmlContent.contentName;\r\n }\r\n return parentInfo;\r\n }\r\n });\r\n }\r\n /**\r\n * Collect metatags from DOM.\r\n * Collect data from meta tags.\r\n * @returns {object} - Metatags collection/property bag\r\n */\r\n DomContentHandler.prototype.getMetadata = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Collect data-* attributes for the given element.\r\n * All attributes with data-* prefix or user provided customDataPrefix are collected.'data-*' prefix is removed from the key name.\r\n * @param element - The element from which attributes need to be collected.\r\n * @returns String representation of the Json array of element attributes\r\n */\r\n DomContentHandler.prototype.getElementContent = function (element) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n return DomContentHandler;\r\n}());\r\nexport { DomContentHandler };\r\n//# sourceMappingURL=DomContentHandler.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;kEAkBM,CAAC;;;;;;6BACsB;AAC7B;AACA;AACA"}
|
|
1
|
+
{"version":3,"file":"DomContentHandler.js.map","sources":["DomContentHandler.js"],"sourcesContent":["/**\r\n* @copyright Microsoft 2020\r\n*/\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { _throwInternal, getDocument, hasDocument, isNullOrUndefined, objExtend } from \"@microsoft/applicationinsights-core-js\";\r\nimport { _DYN_AI_BLOB_ATTRIBUTE_TA2, _DYN_ATTRIBUTES, _DYN_CAPTURE_ALL_META_DAT3, _DYN_CONTENT, _DYN_CONTENT_NAME, _DYN_CUSTOM_DATA_PREFIX, _DYN_DATA_TAGS, _DYN_GET_ATTRIBUTE, _DYN_GET_ELEMENT_CONTENT, _DYN_INDEX_OF, _DYN_LENGTH, _DYN_NAME, _DYN_PARENT_DATA_TAG, _DYN_PARENT_ELEMENT, _DYN_PARENT_NODE, _DYN_TAG_NAME, _DYN_USE_DEFAULT_CONTENT_1, _DYN__CONFIG, _DYN__TRACE_LOGGER } from \"../__DynamicConstants\";\r\nimport { isValueAssigned, removeInvalidElements, walkUpDomChainWithElementValidation } from \"../common/Utils\";\r\nvar MAX_CONTENTNAME_LENGTH = 200;\r\nvar DomContentHandler = /** @class */ (function () {\r\n /**\r\n * @param config - ClickAnalytics configuration object\r\n * @param traceLogger - Trace logger to log to console.\r\n */\r\n function DomContentHandler(_config, _traceLogger) {\r\n this._config = _config;\r\n this._traceLogger = _traceLogger;\r\n dynamicProto(DomContentHandler, this, function (_self) {\r\n _self.getMetadata = function () {\r\n var dataTags = (_self._config || {})[_DYN_DATA_TAGS /* @min:%2edataTags */];\r\n var metaTags = {};\r\n if (hasDocument) {\r\n metaTags = isValueAssigned(dataTags.metaDataPrefix) ? _getMetaDataFromDOM(dataTags[_DYN_CAPTURE_ALL_META_DAT3 /* @min:%2ecaptureAllMetaDataContent */], dataTags.metaDataPrefix, false) :\r\n _getMetaDataFromDOM(dataTags[_DYN_CAPTURE_ALL_META_DAT3 /* @min:%2ecaptureAllMetaDataContent */], \"\", false);\r\n }\r\n return metaTags;\r\n };\r\n _self[_DYN_GET_ELEMENT_CONTENT /* @min:%2egetElementContent */] = function (element) {\r\n if (!element) {\r\n return {};\r\n }\r\n var dataTags = (_self._config || {})[_DYN_DATA_TAGS /* @min:%2edataTags */];\r\n var elementContent = {};\r\n var biBlobValue;\r\n var parentDataTagPrefix;\r\n var dataTagPrefix = dataTags[_DYN_CUSTOM_DATA_PREFIX /* @min:%2ecustomDataPrefix */];\r\n var aiBlobAttributeTag = dataTagPrefix + dataTags[_DYN_AI_BLOB_ATTRIBUTE_TA2 /* @min:%2eaiBlobAttributeTag */];\r\n if (isValueAssigned(dataTags[_DYN_PARENT_DATA_TAG /* @min:%2eparentDataTag */])) {\r\n parentDataTagPrefix = dataTagPrefix + dataTags[_DYN_PARENT_DATA_TAG /* @min:%2eparentDataTag */];\r\n }\r\n if (!_isTracked(element, dataTagPrefix, aiBlobAttributeTag)) {\r\n // capture blob from element or hierarchy\r\n biBlobValue = element[_DYN_GET_ATTRIBUTE /* @min:%2egetAttribute */](aiBlobAttributeTag);\r\n if (biBlobValue) {\r\n try {\r\n elementContent = JSON.parse(biBlobValue);\r\n }\r\n catch (e) {\r\n _throwInternal(_self[_DYN__TRACE_LOGGER /* @min:%2e_traceLogger */], 1 /* eLoggingSeverity.CRITICAL */, 101 /* _eInternalMessageId.CannotParseAiBlobValue */, \"Can not parse \" + biBlobValue);\r\n }\r\n }\r\n else {\r\n // traverse up the DOM to find the closest parent with data-* tag defined\r\n //contentElement = walkUpDomChainWithElementValidation(element, _self._isTracked, dataTagPrefix);\r\n elementContent = objExtend(elementContent, _populateElementContent(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag));\r\n }\r\n }\r\n else {\r\n elementContent = objExtend(elementContent, _populateElementContentwithDataTag(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag));\r\n }\r\n removeInvalidElements(elementContent);\r\n if (parentDataTagPrefix) {\r\n elementContent = objExtend(elementContent, _getParentDetails(element, elementContent, dataTagPrefix, aiBlobAttributeTag));\r\n }\r\n return elementContent;\r\n };\r\n /**\r\n * Capture current level Element content\r\n */\r\n function _captureElementContentWithDataTag(contentElement, elementContent, dataTagPrefix) {\r\n for (var i = 0, attrib; i < contentElement.attributes[_DYN_LENGTH /* @min:%2elength */]; i++) {\r\n attrib = contentElement[_DYN_ATTRIBUTES /* @min:%2eattributes */][i];\r\n if (attrib.name[_DYN_INDEX_OF /* @min:%2eindexOf */](dataTagPrefix) !== 0) {\r\n continue;\r\n }\r\n var attribName = attrib[_DYN_NAME /* @min:%2ename */].replace(dataTagPrefix, \"\");\r\n elementContent[attribName] = attrib.value;\r\n }\r\n }\r\n /**\r\n * Walk Up the DOM to capture Element content\r\n */\r\n function _walkUpDomChainCaptureData(el, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {\r\n var element = el;\r\n var parentDataTagFound = false;\r\n var elementLevelFlag = false; // Use this flag to capture 'id' only at the incoming html element level.\r\n while (!isNullOrUndefined(element) && !isNullOrUndefined(element[_DYN_ATTRIBUTES /* @min:%2eattributes */])) {\r\n var attributes = element[_DYN_ATTRIBUTES /* @min:%2eattributes */];\r\n for (var i = 0; i < attributes[_DYN_LENGTH /* @min:%2elength */]; i++) {\r\n var attrib = attributes[i];\r\n if (attrib.name[_DYN_INDEX_OF /* @min:%2eindexOf */](dataTagPrefix) !== 0) {\r\n continue;\r\n }\r\n if (attrib.name[_DYN_INDEX_OF /* @min:%2eindexOf */](parentDataTagPrefix) === 0) {\r\n parentDataTagFound = true;\r\n }\r\n // Todo handle blob data\r\n if (attrib.name[_DYN_INDEX_OF /* @min:%2eindexOf */](aiBlobAttributeTag) === 0) {\r\n continue;\r\n }\r\n var attribName = attrib[_DYN_NAME /* @min:%2ename */].replace(dataTagPrefix, \"\");\r\n if (elementLevelFlag && attribName === \"id\") {\r\n continue; // skip capturing id if not at the first level.\r\n }\r\n if (!isValueAssigned(elementContent[attribName])) {\r\n elementContent[attribName] = attrib.value;\r\n }\r\n }\r\n // break after current level;\r\n if (parentDataTagFound) {\r\n break;\r\n }\r\n elementLevelFlag = true; // after the initial level set this flag to true.\r\n element = element[_DYN_PARENT_NODE /* @min:%2eparentNode */];\r\n }\r\n }\r\n /**\r\n * Capture Element content along with Data Tag attributes and values\r\n */\r\n function _populateElementContent(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {\r\n var elementContent = {};\r\n if (!element) {\r\n return elementContent;\r\n }\r\n var htmlContent = _getHtmlIdAndContentName(element);\r\n elementContent = {\r\n id: htmlContent.id || \"\",\r\n contentName: htmlContent[_DYN_CONTENT_NAME /* @min:%2econtentName */] || \"\"\r\n };\r\n if (isValueAssigned(parentDataTagPrefix)) {\r\n _walkUpDomChainCaptureData(element, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag);\r\n }\r\n // Validate to ensure the minimum required field 'id' or 'contentName' is present.\r\n // The content schema defines id, aN and sN as required fields. However,\r\n // requiring these fields would result in majority of adopter's content from being collected.\r\n // Just throw a warning and continue collection.\r\n if (!elementContent.id && !elementContent[_DYN_CONTENT_NAME /* @min:%2econtentName */]) {\r\n _throwInternal(_traceLogger, 2 /* eLoggingSeverity.WARNING */, 102 /* _eInternalMessageId.InvalidContentBlob */, \"Invalid content blob. Missing required attributes (id, contentName. \" +\r\n \" Content information will still be collected!\");\r\n }\r\n return elementContent;\r\n }\r\n /**\r\n * Capture Element content along with Data Tag attributes and values\r\n */\r\n function _populateElementContentwithDataTag(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag) {\r\n var dataTags = (_self._config || {})[_DYN_DATA_TAGS /* @min:%2edataTags */];\r\n var elementContent = {};\r\n if (!element) {\r\n return elementContent;\r\n }\r\n var htmlContent = _getHtmlIdAndContentName(element);\r\n if (isValueAssigned(parentDataTagPrefix)) {\r\n _walkUpDomChainCaptureData(element, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag);\r\n }\r\n else {\r\n _captureElementContentWithDataTag(element, elementContent, dataTagPrefix);\r\n }\r\n if (dataTags[_DYN_USE_DEFAULT_CONTENT_1 /* @min:%2euseDefaultContentNameOrId */]) {\r\n if (!isValueAssigned(elementContent.id)) {\r\n elementContent.id = htmlContent.id || \"\";\r\n }\r\n elementContent[_DYN_CONTENT_NAME /* @min:%2econtentName */] = htmlContent[_DYN_CONTENT_NAME /* @min:%2econtentName */] || \"\";\r\n }\r\n // Validate to ensure the minimum required field 'id' or 'contentName' is present.\r\n // The content schema defines id, aN and sN as required fields. However,\r\n // requiring these fields would result in majority of adopter's content from being collected.\r\n // Just throw a warning and continue collection.\r\n if (!elementContent.id && !elementContent[_DYN_CONTENT_NAME /* @min:%2econtentName */]) {\r\n _throwInternal(_traceLogger, 2 /* eLoggingSeverity.WARNING */, 102 /* _eInternalMessageId.InvalidContentBlob */, \"Invalid content blob. Missing required attributes (id, contentName. \" +\r\n \" Content information will still be collected!\");\r\n }\r\n return elementContent;\r\n }\r\n /**\r\n * Retrieve a specified metadata tag value from the DOM.\r\n * @param captureAllMetaDataContent - Flag to capture all metadata content\r\n * @param prefix - Prefix to search the metatags with.\r\n * @param removePrefix - Specifies if the prefix must be excluded from key names in the returned collection.\r\n * @returns Metadata collection/property bag\r\n */\r\n function _getMetaDataFromDOM(captureAllMetaDataContent, prefix, removePrefix) {\r\n var metaElements;\r\n var metaData = {};\r\n if (hasDocument) {\r\n metaElements = document.querySelectorAll(\"meta\");\r\n for (var i = 0; i < metaElements[_DYN_LENGTH /* @min:%2elength */]; i++) {\r\n var meta = metaElements[i];\r\n if (meta[_DYN_NAME /* @min:%2ename */]) {\r\n if (captureAllMetaDataContent || meta.name[_DYN_INDEX_OF /* @min:%2eindexOf */](prefix) === 0) {\r\n var name_1 = removePrefix ? meta[_DYN_NAME /* @min:%2ename */].replace(prefix, \"\") : meta[_DYN_NAME /* @min:%2ename */];\r\n metaData[name_1] = meta[_DYN_CONTENT /* @min:%2econtent */];\r\n }\r\n }\r\n }\r\n }\r\n return metaData;\r\n }\r\n /**\r\n * Gets the default content name.\r\n * @param element - An html element\r\n * @param useDefaultContentNameOrId -Flag indicating if an element is market PII.\r\n * @returns Content name\r\n */\r\n function _getDefaultContentName(element, useDefaultContentName) {\r\n if (useDefaultContentName === false || !element[_DYN_TAG_NAME /* @min:%2etagName */]) {\r\n return \"\";\r\n }\r\n var doc = getDocument() || {};\r\n var contentName;\r\n switch (element[_DYN_TAG_NAME /* @min:%2etagName */]) {\r\n case \"A\":\r\n contentName = doc.all ? element.innerText || element.innerHTML : element.text || element.innerHTML;\r\n break;\r\n case \"IMG\":\r\n case \"AREA\":\r\n contentName = element.alt;\r\n break;\r\n default:\r\n contentName = element.value || element[_DYN_NAME /* @min:%2ename */] || element.alt || element.innerText || element.id;\r\n }\r\n return contentName.substring(0, MAX_CONTENTNAME_LENGTH);\r\n }\r\n /**\r\n * Check if the user wants to track the element, which means if the element has any tags with data-* or customDataPrefix\r\n * @param element - An html element\r\n * @returns true if any data-* exist, otherwise return false\r\n */\r\n function _isTracked(element, dataTag, aiBlobAttributeTag) {\r\n var attrs = element[_DYN_ATTRIBUTES /* @min:%2eattributes */];\r\n var dataTagFound = false;\r\n for (var i = 0; i < attrs[_DYN_LENGTH /* @min:%2elength */]; i++) {\r\n var attributeName = attrs[i][_DYN_NAME /* @min:%2ename */];\r\n if (attributeName === aiBlobAttributeTag) {\r\n // ignore if the attribute name is equal to aiBlobAttributeTag\r\n return false;\r\n }\r\n else if (attributeName[_DYN_INDEX_OF /* @min:%2eindexOf */](dataTag) === 0) {\r\n dataTagFound = true;\r\n }\r\n }\r\n return dataTagFound;\r\n }\r\n function _getHtmlIdAndContentName(element) {\r\n var dataTags = (_self._config || {})[_DYN_DATA_TAGS /* @min:%2edataTags */];\r\n var callback = (_self[_DYN__CONFIG /* @min:%2e_config */] || {}).callback;\r\n var htmlContent = {};\r\n if (!element) {\r\n return htmlContent;\r\n }\r\n if (dataTags[_DYN_USE_DEFAULT_CONTENT_1 /* @min:%2euseDefaultContentNameOrId */]) {\r\n var customizedContentName = callback.contentName ? callback.contentName(element, dataTags[_DYN_USE_DEFAULT_CONTENT_1 /* @min:%2euseDefaultContentNameOrId */]) : \"\";\r\n var defaultContentName = _getDefaultContentName(element, dataTags[_DYN_USE_DEFAULT_CONTENT_1 /* @min:%2euseDefaultContentNameOrId */]);\r\n htmlContent = {\r\n id: element.id,\r\n contentName: customizedContentName || defaultContentName || element[_DYN_GET_ATTRIBUTE /* @min:%2egetAttribute */](\"alt\")\r\n };\r\n }\r\n return htmlContent;\r\n }\r\n /**\r\n * Computes the parentId of a given element.\r\n * @param element - An html element\r\n * @returns An object containing the closest parentId , can be empty if nothing was found\r\n */\r\n function _getParentDetails(element, elementContent, dataTagPrefix, aiBlobAttributeTag) {\r\n var parentId = elementContent[\"parentid\"];\r\n var parentName = elementContent[\"parentname\"];\r\n var parentInfo = {};\r\n if (parentId || parentName || !element) {\r\n return parentInfo;\r\n }\r\n return _populateParentInfo(element, dataTagPrefix, aiBlobAttributeTag);\r\n }\r\n /**\r\n * Check if parent info already set up, if so take and put into content, if not walk up the DOM to find correct info\r\n * @param element - An html element that the user wants to track\r\n * @returns An object containing the parent info, can be empty if nothing was found\r\n */\r\n function _populateParentInfo(element, dataTagPrefix, aiBlobAttributeTag) {\r\n var parentInfo = {};\r\n var parentId;\r\n // if the user does not set up parent info, walk to the DOM, find the closest parent element (with tags) and populate the info\r\n var closestParentElement = walkUpDomChainWithElementValidation(element[_DYN_PARENT_ELEMENT /* @min:%2eparentElement */], _isTracked, dataTagPrefix);\r\n if (closestParentElement) {\r\n var dataAttr = closestParentElement[_DYN_GET_ATTRIBUTE /* @min:%2egetAttribute */](aiBlobAttributeTag) || element[aiBlobAttributeTag];\r\n if (dataAttr) {\r\n try {\r\n var telemetryObject = JSON.parse(dataAttr);\r\n }\r\n catch (e) {\r\n _throwInternal(_traceLogger, 1 /* eLoggingSeverity.CRITICAL */, 101 /* _eInternalMessageId.CannotParseAiBlobValue */, \"Can not parse \" + dataAttr);\r\n }\r\n if (telemetryObject) {\r\n parentId = telemetryObject.id;\r\n }\r\n }\r\n else {\r\n parentId = closestParentElement[_DYN_GET_ATTRIBUTE /* @min:%2egetAttribute */](dataTagPrefix + \"id\");\r\n }\r\n }\r\n if (parentId) {\r\n parentInfo[\"parentid\"] = parentId;\r\n }\r\n else {\r\n var htmlContent = _getHtmlIdAndContentName(element[_DYN_PARENT_ELEMENT /* @min:%2eparentElement */]);\r\n parentInfo[\"parentid\"] = htmlContent.id;\r\n parentInfo[\"parentname\"] = htmlContent[_DYN_CONTENT_NAME /* @min:%2econtentName */];\r\n }\r\n return parentInfo;\r\n }\r\n });\r\n }\r\n /**\r\n * Collect metatags from DOM.\r\n * Collect data from meta tags.\r\n * @returns {object} - Metatags collection/property bag\r\n */\r\n DomContentHandler.prototype.getMetadata = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Collect data-* attributes for the given element.\r\n * All attributes with data-* prefix or user provided customDataPrefix are collected.'data-*' prefix is removed from the key name.\r\n * @param element - The element from which attributes need to be collected.\r\n * @returns String representation of the Json array of element attributes\r\n */\r\n DomContentHandler.prototype.getElementContent = function (element) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n return DomContentHandler;\r\n}());\r\nexport { DomContentHandler };\r\n//# sourceMappingURL=DomContentHandler.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;kEAkBM,CAAC;;;;;;6BACsB;AAC7B;AACA;AACA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/applicationinsights-clickanalytics-js",
|
|
3
|
-
"version": "2.8.5-nightly.
|
|
3
|
+
"version": "2.8.5-nightly.2207-01",
|
|
4
4
|
"description": "Microsoft Application Insights Click Analytics extension",
|
|
5
5
|
"homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
|
|
6
6
|
"author": "Microsoft Application Insights Team",
|
|
@@ -14,9 +14,12 @@
|
|
|
14
14
|
"build:browser": "rollup -c",
|
|
15
15
|
"rebuild": "npm run build",
|
|
16
16
|
"test": "grunt clickanalyticstests",
|
|
17
|
+
"mintest": "grunt clickanalytics-mintests",
|
|
17
18
|
"lint": "tslint -p tsconfig.json",
|
|
18
19
|
"dtsgen": "api-extractor run --local && node ../../scripts/dtsgen.js 'Microsoft.ApplicationInsights'",
|
|
19
|
-
"sri": "node ../../tools/subResourceIntegrity/generateIntegrityFile.js"
|
|
20
|
+
"sri": "node ../../tools/subResourceIntegrity/generateIntegrityFile.js",
|
|
21
|
+
"ai-min": "grunt clickanalytics-min",
|
|
22
|
+
"ai-restore": "grunt clickanalytics-restore"
|
|
20
23
|
},
|
|
21
24
|
"devDependencies": {
|
|
22
25
|
"@microsoft/ai-test-framework": "0.0.1",
|
|
@@ -44,9 +47,9 @@
|
|
|
44
47
|
"dependencies": {
|
|
45
48
|
"@microsoft/dynamicproto-js": "^1.1.6",
|
|
46
49
|
"@microsoft/applicationinsights-shims": "2.0.1",
|
|
47
|
-
"@microsoft/applicationinsights-core-js": "2.8.5-nightly.
|
|
48
|
-
"@microsoft/applicationinsights-common": "2.8.5-nightly.
|
|
49
|
-
"@microsoft/applicationinsights-properties-js": "2.8.5-nightly.
|
|
50
|
+
"@microsoft/applicationinsights-core-js": "2.8.5-nightly.2207-01",
|
|
51
|
+
"@microsoft/applicationinsights-common": "2.8.5-nightly.2207-01",
|
|
52
|
+
"@microsoft/applicationinsights-properties-js": "2.8.5-nightly.2207-01"
|
|
50
53
|
},
|
|
51
54
|
"repository": {
|
|
52
55
|
"type": "git",
|
|
@@ -1,34 +1,27 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
BaseTelemetryPlugin,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from "@microsoft/applicationinsights-
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from "./
|
|
18
|
-
|
|
19
|
-
mergeConfig, BehaviorMapValidator,
|
|
20
|
-
BehaviorValueValidator, BehaviorEnumValidator
|
|
21
|
-
} from "./common/Utils";
|
|
22
|
-
import { PageAction } from "./events/PageAction";
|
|
23
|
-
import { AutoCaptureHandler } from "./handlers/AutoCaptureHandler";
|
|
24
|
-
import { DomContentHandler } from "./handlers/DomContentHandler";
|
|
25
|
-
import { PropertiesPlugin } from "@microsoft/applicationinsights-properties-js";
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Microsoft 2020
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
6
|
+
import { IConfig, IPropertiesPlugin, PropertiesPluginIdentifier } from "@microsoft/applicationinsights-common";
|
|
7
|
+
import {
|
|
8
|
+
BaseTelemetryPlugin, IAppInsightsCore, IConfiguration, ICustomProperties, IPlugin, IProcessTelemetryContext,
|
|
9
|
+
IProcessTelemetryUnloadContext, ITelemetryItem, ITelemetryPluginChain, ITelemetryUnloadState, _eInternalMessageId, _throwInternal,
|
|
10
|
+
arrForEach, dumpObj, eLoggingSeverity, getExceptionName, isNullOrUndefined, throwError, unloadComponents
|
|
11
|
+
} from "@microsoft/applicationinsights-core-js";
|
|
12
|
+
import { PropertiesPlugin } from "@microsoft/applicationinsights-properties-js";
|
|
13
|
+
import { IAutoCaptureHandler, IClickAnalyticsConfiguration, IContentHandler, IPageActionTelemetry } from "./Interfaces/Datamodel";
|
|
14
|
+
import { BehaviorEnumValidator, BehaviorMapValidator, BehaviorValueValidator, mergeConfig } from "./common/Utils";
|
|
15
|
+
import { PageAction } from "./events/PageAction";
|
|
16
|
+
import { AutoCaptureHandler } from "./handlers/AutoCaptureHandler";
|
|
17
|
+
import { DomContentHandler } from "./handlers/DomContentHandler";
|
|
18
|
+
|
|
26
19
|
export { BehaviorMapValidator, BehaviorValueValidator, BehaviorEnumValidator }
|
|
27
20
|
|
|
28
21
|
export class ClickAnalyticsPlugin extends BaseTelemetryPlugin {
|
|
29
22
|
public identifier: string = "ClickAnalyticsPlugin";
|
|
30
23
|
public priority: number = 181;
|
|
31
|
-
public static Version = "
|
|
24
|
+
public static Version = "#version#";
|
|
32
25
|
|
|
33
26
|
constructor() {
|
|
34
27
|
super();
|
|
@@ -132,4 +125,4 @@ export class ClickAnalyticsPlugin extends BaseTelemetryPlugin {
|
|
|
132
125
|
public trackPageAction(pageAction?: IPageActionTelemetry, customProperties?: ICustomProperties) {
|
|
133
126
|
// @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
|
|
134
127
|
}
|
|
135
|
-
}
|
|
128
|
+
}
|
package/src/DataCollector.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
} from "
|
|
8
|
-
|
|
9
|
-
import { IClickAnalyticsConfiguration, IOverrideValues } from "./Interfaces/Datamodel";
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Microsoft 2020
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { getDocument, getLocation, getWindow, hasDocument, isFunction } from "@microsoft/applicationinsights-core-js";
|
|
6
|
+
import { IClickAnalyticsConfiguration, IOverrideValues } from "./Interfaces/Datamodel";
|
|
7
|
+
import { findClosestAnchor, isValueAssigned } from "./common/Utils";
|
|
8
|
+
|
|
12
9
|
var clickCaptureInputTypes = { BUTTON: true, CHECKBOX: true, RADIO: true, RESET: true, SUBMIT: true };
|
|
13
10
|
|
|
14
11
|
|
|
@@ -149,4 +146,4 @@ export function getUri(config: IClickAnalyticsConfiguration, location: any): str
|
|
|
149
146
|
return config.coreData.requestUri;
|
|
150
147
|
}
|
|
151
148
|
return sanitizeUrl(config, location);
|
|
152
|
-
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
// @skip-file-minify
|
|
4
|
+
|
|
5
|
+
// ##############################################################
|
|
6
|
+
// AUTO GENERATED FILE: This file is Auto Generated during build.
|
|
7
|
+
// ##############################################################
|
|
8
|
+
|
|
9
|
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
10
|
+
// Note: DON'T Export these const from the package as we are still targeting ES3 this will export a mutable variables that someone could change!!!
|
|
11
|
+
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
12
|
+
|
|
13
|
+
export const _DYN_EXTENSION_CONFIG = "extensionConfig"; // Count: 5
|
|
14
|
+
export const _DYN_PAGE_ACTION_PAGE_TAG0 = "pageActionPageTags"; // Count: 2
|
|
15
|
+
export const _DYN_TRACK_PAGE_ACTION = "trackPageAction"; // Count: 4
|
|
16
|
+
export const _DYN_LENGTH = "length"; // Count: 5
|
|
17
|
+
export const _DYN_TAG_NAME = "tagName"; // Count: 4
|
|
18
|
+
export const _DYN_TO_UPPER_CASE = "toUpperCase"; // Count: 4
|
|
19
|
+
export const _DYN_PATHNAME = "pathname"; // Count: 3
|
|
20
|
+
export const _DYN_ADD_EVENT_LISTENER = "addEventListener"; // Count: 2
|
|
21
|
+
export const _DYN_PAGE_NAME = "pageName"; // Count: 8
|
|
22
|
+
export const _DYN_CORE_DATA = "coreData"; // Count: 4
|
|
23
|
+
export const _DYN_REQUEST_URI = "requestUri"; // Count: 3
|
|
24
|
+
export const _DYN_GET_ATTRIBUTE = "getAttribute"; // Count: 6
|
|
25
|
+
export const _DYN_PARENT_NODE = "parentNode"; // Count: 3
|
|
26
|
+
export const _DYN_CUSTOM_DATA_PREFIX = "customDataPrefix"; // Count: 6
|
|
27
|
+
export const _DYN_INDEX_OF = "indexOf"; // Count: 8
|
|
28
|
+
export const _DYN_DATA_TAGS = "dataTags"; // Count: 7
|
|
29
|
+
export const _DYN_USE_DEFAULT_CONTENT_1 = "useDefaultContentNameOrId"; // Count: 5
|
|
30
|
+
export const _DYN_AI_BLOB_ATTRIBUTE_TA2 = "aiBlobAttributeTag"; // Count: 2
|
|
31
|
+
export const _DYN_CAPTURE_ALL_META_DAT3 = "captureAllMetaDataContent"; // Count: 3
|
|
32
|
+
export const _DYN_BEHAVIOR_VALIDATOR = "behaviorValidator"; // Count: 2
|
|
33
|
+
export const _DYN_NAME = "name"; // Count: 8
|
|
34
|
+
export const _DYN_DATA = "data"; // Count: 15
|
|
35
|
+
export const _DYN_PAGE_TYPE = "pageType"; // Count: 6
|
|
36
|
+
export const _DYN_PROPERTIES = "properties"; // Count: 4
|
|
37
|
+
export const _DYN_ACTION_TYPE = "actionType"; // Count: 9
|
|
38
|
+
export const _DYN_BEHAVIOR = "behavior"; // Count: 7
|
|
39
|
+
export const _DYN_CLICK_COORDINATES = "clickCoordinates"; // Count: 2
|
|
40
|
+
export const _DYN_CONTENT = "content"; // Count: 4
|
|
41
|
+
export const _DYN_REF_URI = "refUri"; // Count: 4
|
|
42
|
+
export const _DYN_PARENT_ID = "parentId"; // Count: 3
|
|
43
|
+
export const _DYN_CAPTURE_PAGE_ACTION = "capturePageAction"; // Count: 2
|
|
44
|
+
export const _DYN_SET_COMMON_PROPERTIE4 = "setCommonProperties"; // Count: 2
|
|
45
|
+
export const _DYN_GET_ELEMENT_CONTENT = "getElementContent"; // Count: 2
|
|
46
|
+
export const _DYN__GET_VALID_BEHAVIOR = "_getValidBehavior"; // Count: 3
|
|
47
|
+
export const _DYN_CONTENT_NAME = "contentName"; // Count: 12
|
|
48
|
+
export const _DYN__TRACE_LOGGER = "_traceLogger"; // Count: 3
|
|
49
|
+
export const _DYN_CLICK_COORDINATE_X = "clickCoordinateX"; // Count: 3
|
|
50
|
+
export const _DYN_CLICK_COORDINATE_Y = "clickCoordinateY"; // Count: 3
|
|
51
|
+
export const _DYN__CONFIG = "_config"; // Count: 9
|
|
52
|
+
export const _DYN_PARENT_DATA_TAG = "parentDataTag"; // Count: 3
|
|
53
|
+
export const _DYN__PAGE_TAGS = "_pageTags"; // Count: 6
|
|
54
|
+
export const _DYN__PAGE_TAGS_CALLBACK = "_pageTagsCallback"; // Count: 3
|
|
55
|
+
export const _DYN__META_TAGS = "_metaTags"; // Count: 6
|
|
56
|
+
export const _DYN_SET_BASIC_PROPERTIES = "setBasicProperties"; // Count: 2
|
|
57
|
+
export const _DYN__PAGE_TYPE_META_TAG = "_pageTypeMetaTag"; // Count: 3
|
|
58
|
+
export const _DYN__BEHAVIOR_META_TAG = "_behaviorMetaTag"; // Count: 3
|
|
59
|
+
export const _DYN_PARENT_ELEMENT = "parentElement"; // Count: 3
|
|
60
|
+
export const _DYN_ATTRIBUTES = "attributes"; // Count: 4
|