@microsoft/applicationinsights-clickanalytics-js 3.0.0-beta.2303-11 → 3.0.0-nightly3.2304-28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/browser/{ai.clck.3.0.0-beta.2303-11.cjs.js → es5/ai.clck.3.0.0-nightly3.2304-28.cjs.js} +810 -786
  2. package/browser/es5/ai.clck.3.0.0-nightly3.2304-28.cjs.js.map +1 -0
  3. package/browser/es5/ai.clck.3.0.0-nightly3.2304-28.cjs.min.js +6 -0
  4. package/browser/es5/ai.clck.3.0.0-nightly3.2304-28.cjs.min.js.map +1 -0
  5. package/browser/{ai.clck.3.0.0-beta.2303-11.gbl.js → es5/ai.clck.3.0.0-nightly3.2304-28.gbl.js} +809 -785
  6. package/browser/es5/ai.clck.3.0.0-nightly3.2304-28.gbl.js.map +1 -0
  7. package/browser/es5/ai.clck.3.0.0-nightly3.2304-28.gbl.min.js +6 -0
  8. package/browser/es5/ai.clck.3.0.0-nightly3.2304-28.gbl.min.js.map +1 -0
  9. package/browser/es5/ai.clck.3.0.0-nightly3.2304-28.integrity.json +66 -0
  10. package/browser/{ai.clck.3.0.0-beta.2303-11.js → es5/ai.clck.3.0.0-nightly3.2304-28.js} +809 -785
  11. package/browser/es5/ai.clck.3.0.0-nightly3.2304-28.js.map +1 -0
  12. package/browser/es5/ai.clck.3.0.0-nightly3.2304-28.min.js +6 -0
  13. package/browser/es5/ai.clck.3.0.0-nightly3.2304-28.min.js.map +1 -0
  14. package/browser/{ai.clck.3.cjs.js → es5/ai.clck.3.cjs.js} +809 -785
  15. package/browser/es5/ai.clck.3.cjs.js.map +1 -0
  16. package/browser/es5/ai.clck.3.cjs.min.js +6 -0
  17. package/browser/es5/ai.clck.3.cjs.min.js.map +1 -0
  18. package/browser/{ai.clck.3.gbl.js → es5/ai.clck.3.gbl.js} +808 -784
  19. package/browser/es5/ai.clck.3.gbl.js.map +1 -0
  20. package/browser/es5/ai.clck.3.gbl.min.js +6 -0
  21. package/browser/es5/ai.clck.3.gbl.min.js.map +1 -0
  22. package/browser/{ai.clck.3.js → es5/ai.clck.3.js} +808 -784
  23. package/browser/es5/ai.clck.3.js.map +1 -0
  24. package/browser/es5/ai.clck.3.min.js +6 -0
  25. package/browser/es5/ai.clck.3.min.js.map +1 -0
  26. package/dist/{applicationinsights-clickanalytics-js.js → es5/applicationinsights-clickanalytics-js.js} +808 -784
  27. package/dist/es5/applicationinsights-clickanalytics-js.js.map +1 -0
  28. package/dist/es5/applicationinsights-clickanalytics-js.min.js +6 -0
  29. package/dist/es5/applicationinsights-clickanalytics-js.min.js.map +1 -0
  30. package/{dist-esm → dist-es5}/Behaviours.js +1 -1
  31. package/{dist-esm → dist-es5}/ClickAnalyticsPlugin.js +2 -2
  32. package/{dist-esm → dist-es5}/ClickAnalyticsPlugin.js.map +1 -1
  33. package/{dist-esm → dist-es5}/DataCollector.js +1 -1
  34. package/{dist-esm → dist-es5}/Enums.js +1 -1
  35. package/{dist-esm → dist-es5}/Interfaces/Datamodel.js +1 -1
  36. package/{dist-esm → dist-es5}/__DynamicConstants.js +1 -1
  37. package/{dist-esm → dist-es5}/applicationinsights-clickanalytics-js.js +1 -1
  38. package/{dist-esm → dist-es5}/common/Utils.js +1 -1
  39. package/{dist-esm → dist-es5}/events/PageAction.js +1 -1
  40. package/{dist-esm → dist-es5}/events/WebEvent.js +1 -1
  41. package/{dist-esm → dist-es5}/handlers/AutoCaptureHandler.js +1 -1
  42. package/{dist-esm → dist-es5}/handlers/DomContentHandler.js +3 -2
  43. package/dist-es5/handlers/DomContentHandler.js.map +1 -0
  44. package/package.json +19 -18
  45. package/tsconfig.json +4 -3
  46. package/types/applicationinsights-clickanalytics-js.d.ts +101 -2
  47. package/{dist/applicationinsights-clickanalytics-js.d.ts → types/applicationinsights-clickanalytics-js.namespaced.d.ts} +1 -1
  48. package/browser/ai.clck.3.0.0-beta.2303-11.cjs.js.map +0 -1
  49. package/browser/ai.clck.3.0.0-beta.2303-11.cjs.min.js +0 -6
  50. package/browser/ai.clck.3.0.0-beta.2303-11.cjs.min.js.map +0 -1
  51. package/browser/ai.clck.3.0.0-beta.2303-11.gbl.js.map +0 -1
  52. package/browser/ai.clck.3.0.0-beta.2303-11.gbl.min.js +0 -6
  53. package/browser/ai.clck.3.0.0-beta.2303-11.gbl.min.js.map +0 -1
  54. package/browser/ai.clck.3.0.0-beta.2303-11.integrity.json +0 -66
  55. package/browser/ai.clck.3.0.0-beta.2303-11.js.map +0 -1
  56. package/browser/ai.clck.3.0.0-beta.2303-11.min.js +0 -6
  57. package/browser/ai.clck.3.0.0-beta.2303-11.min.js.map +0 -1
  58. package/browser/ai.clck.3.cjs.js.map +0 -1
  59. package/browser/ai.clck.3.cjs.min.js +0 -6
  60. package/browser/ai.clck.3.cjs.min.js.map +0 -1
  61. package/browser/ai.clck.3.gbl.js.map +0 -1
  62. package/browser/ai.clck.3.gbl.min.js +0 -6
  63. package/browser/ai.clck.3.gbl.min.js.map +0 -1
  64. package/browser/ai.clck.3.js.map +0 -1
  65. package/browser/ai.clck.3.min.js +0 -6
  66. package/browser/ai.clck.3.min.js.map +0 -1
  67. package/dist/applicationinsights-clickanalytics-js.api.json +0 -695
  68. package/dist/applicationinsights-clickanalytics-js.api.md +0 -46
  69. package/dist/applicationinsights-clickanalytics-js.js.map +0 -1
  70. package/dist/applicationinsights-clickanalytics-js.min.js +0 -6
  71. package/dist/applicationinsights-clickanalytics-js.min.js.map +0 -1
  72. package/dist/applicationinsights-clickanalytics-js.rollup.d.ts +0 -102
  73. package/dist-esm/handlers/DomContentHandler.js.map +0 -1
  74. package/src/Behaviours.ts +0 -165
  75. package/src/ClickAnalyticsPlugin.ts +0 -183
  76. package/src/DataCollector.ts +0 -159
  77. package/src/Enums.ts +0 -15
  78. package/src/Interfaces/Datamodel.ts +0 -300
  79. package/src/__DynamicConstants.ts +0 -61
  80. package/src/applicationinsights-clickanalytics-js.ts +0 -6
  81. package/src/common/Utils.ts +0 -281
  82. package/src/events/PageAction.ts +0 -197
  83. package/src/events/WebEvent.ts +0 -202
  84. package/src/handlers/AutoCaptureHandler.ts +0 -121
  85. package/src/handlers/DomContentHandler.ts +0 -395
  86. package/types/Behaviours.d.ts +0 -99
  87. package/types/ClickAnalyticsPlugin.d.ts +0 -22
  88. package/types/DataCollector.d.ts +0 -39
  89. package/types/Enums.d.ts +0 -14
  90. package/types/Interfaces/Datamodel.d.ts +0 -291
  91. package/types/__DynamicConstants.d.ts +0 -49
  92. package/types/common/Utils.d.ts +0 -123
  93. package/types/events/PageAction.d.ts +0 -28
  94. package/types/events/WebEvent.d.ts +0 -54
  95. package/types/handlers/AutoCaptureHandler.d.ts +0 -20
  96. package/types/handlers/DomContentHandler.d.ts +0 -29
  97. package/types/tsdoc-metadata.json +0 -11
  98. /package/{dist-esm → dist-es5}/Behaviours.js.map +0 -0
  99. /package/{dist-esm → dist-es5}/DataCollector.js.map +0 -0
  100. /package/{dist-esm → dist-es5}/Enums.js.map +0 -0
  101. /package/{dist-esm → dist-es5}/Interfaces/Datamodel.js.map +0 -0
  102. /package/{dist-esm → dist-es5}/__DynamicConstants.js.map +0 -0
  103. /package/{dist-esm → dist-es5}/applicationinsights-clickanalytics-js.js.map +0 -0
  104. /package/{dist-esm → dist-es5}/common/Utils.js.map +0 -0
  105. /package/{dist-esm → dist-es5}/events/PageAction.js.map +0 -0
  106. /package/{dist-esm → dist-es5}/events/WebEvent.js.map +0 -0
  107. /package/{dist-esm → dist-es5}/handlers/AutoCaptureHandler.js.map +0 -0
@@ -1,121 +0,0 @@
1
- /**
2
- * @copyright Microsoft 2020
3
- */
4
-
5
- import dynamicProto from "@microsoft/dynamicproto-js";
6
- import {
7
- IDiagnosticLogger, IProcessTelemetryUnloadContext, ITelemetryUnloadState, createUniqueNamespace, eventOff, eventOn, getDocument,
8
- getWindow, isNullOrUndefined, mergeEvtNamespace
9
- } from "@microsoft/applicationinsights-core-js";
10
- import { ClickAnalyticsPlugin } from "../ClickAnalyticsPlugin";
11
- import { ActionType } from "../Enums";
12
- import { IAutoCaptureHandler, IClickAnalyticsConfiguration, IPageActionOverrideValues } from "../Interfaces/Datamodel";
13
- import { isElementDnt, isKeyboardEnter, isKeyboardSpace, isLeftClick, isMiddleClick, isRightClick } from "../common/Utils";
14
- import { PageAction } from "../events/PageAction";
15
-
16
- const clickCaptureInputTypes = { BUTTON: true, CHECKBOX: true, RADIO: true, RESET: true, SUBMIT: true };
17
-
18
- export class AutoCaptureHandler implements IAutoCaptureHandler {
19
-
20
- /**
21
- * @param analyticsPlugin - WebAnalytics plugin
22
- * @param traceLogger - Trace logger to log to console.
23
- */
24
- constructor(protected _analyticsPlugin: ClickAnalyticsPlugin, protected _config: IClickAnalyticsConfiguration, protected _pageAction: PageAction,
25
- protected _traceLogger: IDiagnosticLogger) {
26
-
27
- let _evtNamespace = mergeEvtNamespace(createUniqueNamespace("AutoCaptureHandler"), (_analyticsPlugin as any)._evtNamespace);
28
-
29
- dynamicProto(AutoCaptureHandler, this, (_self) => {
30
-
31
- _self.click = () => {
32
- let win = getWindow();
33
- let doc = getDocument();
34
- if (win) {
35
- // IE9 onwards addEventListener is available, 'click' event captures mouse click. mousedown works on other browsers
36
- const event = (navigator.appVersion.indexOf("MSIE") !== -1) ? "click" : "mousedown";
37
- eventOn(win, event, _processClick, _evtNamespace);
38
- eventOn(win, "keyup", _processClick, _evtNamespace);
39
- } else if (doc) {
40
- // IE8 and below doesn't have addEventListener so it will use attachEvent
41
- // attaching to window does not work in IE8
42
- eventOn(doc, "click", _processClick, _evtNamespace);
43
- eventOn(doc, "keyup", _processClick, _evtNamespace);
44
- }
45
- };
46
-
47
- _self._doUnload = (unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void): void | boolean => {
48
- eventOff(getWindow(), null, null, _evtNamespace);
49
- eventOff(getDocument(), null, null, _evtNamespace);
50
- };
51
-
52
- function _capturePageAction(element: Element, overrideValues?: IPageActionOverrideValues, customProperties?: { [name: string]: string | number | boolean | string[] | number[] | boolean[] | object }, isRightClick?: boolean): void {
53
- const donotTrackTag = _self._config.dataTags.customDataPrefix + _self._config.dataTags.dntDataTag;
54
- if (!isElementDnt(element, donotTrackTag)) {
55
- _self._pageAction.capturePageAction(element, overrideValues, customProperties, isRightClick);
56
- }
57
- }
58
-
59
- // Process click event
60
- function _processClick(clickEvent: any) {
61
- var clickCaptureElements = { A: true, BUTTON: true, AREA: true, INPUT: true };
62
- let win = getWindow();
63
- if (isNullOrUndefined(clickEvent) && win) {
64
- clickEvent = win.event; // IE 8 does not pass the event
65
- }
66
- if (clickEvent) {
67
- let element = clickEvent.srcElement || clickEvent.target;
68
-
69
- // populate overrideValues
70
- var overrideValues: IPageActionOverrideValues = {
71
- clickCoordinateX: clickEvent.pageX,
72
- clickCoordinateY: clickEvent.pageY
73
- };
74
- var isRightClickObj = isRightClick(clickEvent as MouseEvent);
75
- if (isRightClickObj) {
76
- overrideValues.actionType = ActionType.CLICKRIGHT;
77
- } else if (isLeftClick(clickEvent as MouseEvent)) {
78
- overrideValues.actionType = ActionType.CLICKLEFT;
79
- } else if (isKeyboardEnter(clickEvent as KeyboardEvent)) {
80
- overrideValues.actionType = ActionType.KEYBOARDENTER;
81
- } else if (isKeyboardSpace(clickEvent as KeyboardEvent)) {
82
- overrideValues.actionType = ActionType.KEYBOARDSPACE;
83
- } else if (isMiddleClick(clickEvent as MouseEvent)) {
84
- overrideValues.actionType = ActionType.CLICKMIDDLE;
85
- } else {
86
- return;
87
- }
88
-
89
- while (element && element.tagName) {
90
- // control property will be available for <label> elements with 'for' attribute, only use it when is a
91
- // valid JSLL capture element to avoid infinite loops
92
- if (element.control && clickCaptureElements[element.control.tagName.toUpperCase()]) {
93
- element = element.control;
94
- }
95
- const tagNameUpperCased = element.tagName.toUpperCase();
96
- if (!clickCaptureElements[tagNameUpperCased]) {
97
- element = element.parentElement || element.parentNode;
98
- continue;
99
- } else {
100
- // Check allowed INPUT types
101
- var sendEvent = tagNameUpperCased === "INPUT" ? clickCaptureInputTypes[element.type.toUpperCase()] : true;
102
- if (sendEvent) {
103
- _capturePageAction(element, overrideValues, {}, isRightClickObj);
104
- }
105
- break;
106
- }
107
- }
108
- }
109
- }
110
- });
111
- }
112
-
113
- // handle automatic event firing on user click
114
- public click() {
115
- // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
116
- }
117
-
118
- public _doUnload(unloadCtx?: IProcessTelemetryUnloadContext, unloadState?: ITelemetryUnloadState, asyncCallback?: () => void): void | boolean {
119
- // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
120
- }
121
- }
@@ -1,395 +0,0 @@
1
- /**
2
- * @copyright Microsoft 2020
3
- */
4
-
5
- import dynamicProto from "@microsoft/dynamicproto-js";
6
- import {
7
- IDiagnosticLogger, _eInternalMessageId, _throwInternal, eLoggingSeverity, getDocument, hasDocument, isNullOrUndefined, objExtend
8
- } from "@microsoft/applicationinsights-core-js";
9
- import { IClickAnalyticsConfiguration, IContent, IContentHandler } from "../Interfaces/Datamodel";
10
- import { isValueAssigned, removeInvalidElements, walkUpDomChainWithElementValidation } from "../common/Utils";
11
-
12
- const MAX_CONTENTNAME_LENGTH = 200;
13
-
14
- export class DomContentHandler implements IContentHandler {
15
-
16
- /**
17
- * @param config - ClickAnalytics configuration object
18
- * @param traceLogger - Trace logger to log to console.
19
- */
20
- constructor(protected _config: IClickAnalyticsConfiguration, protected _traceLogger: IDiagnosticLogger) {
21
-
22
- dynamicProto(DomContentHandler, this, (_self) => {
23
-
24
- _self.getMetadata = (): { [name: string]: string } => {
25
- let dataTags = (_self._config || {}).dataTags;
26
- let metaTags = {};
27
- if (hasDocument) {
28
- metaTags = isValueAssigned(dataTags.metaDataPrefix) ? _getMetaDataFromDOM(dataTags.captureAllMetaDataContent, dataTags.metaDataPrefix, false) :
29
- _getMetaDataFromDOM(dataTags.captureAllMetaDataContent ,"", false);
30
- }
31
- return metaTags;
32
- };
33
-
34
- _self.getElementContent = (element: Element): IContent => {
35
-
36
- if (!element) {
37
- return {};
38
- }
39
-
40
- let dataTags = (_self._config || {}).dataTags;
41
- let elementContent: any = {};
42
- let biBlobValue;
43
- let parentDataTagPrefix;
44
- const dataTagPrefix:string = dataTags.customDataPrefix;
45
- const aiBlobAttributeTag:string = dataTagPrefix + dataTags.aiBlobAttributeTag;
46
- if(isValueAssigned(dataTags.parentDataTag)) {
47
- parentDataTagPrefix = dataTagPrefix + dataTags.parentDataTag;
48
- }
49
-
50
- if (!_isTracked(element, dataTagPrefix, aiBlobAttributeTag)) {
51
- // capture blob from element or hierarchy
52
- biBlobValue = element.getAttribute(aiBlobAttributeTag);
53
- if (biBlobValue) {
54
- try {
55
- elementContent = JSON.parse(biBlobValue);
56
- } catch (e) {
57
- _throwInternal(_self._traceLogger,
58
- eLoggingSeverity.CRITICAL,
59
- _eInternalMessageId.CannotParseAiBlobValue, "Can not parse " + biBlobValue
60
- );
61
- }
62
- } else {
63
- // traverse up the DOM to find the closest parent with data-* tag defined
64
- //contentElement = walkUpDomChainWithElementValidation(element, _self._isTracked, dataTagPrefix);
65
- elementContent = objExtend(elementContent, _populateElementContent(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag));
66
- }
67
- } else {
68
- elementContent = objExtend(elementContent, _populateElementContentwithDataTag(element, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag));
69
- }
70
-
71
- removeInvalidElements(elementContent);
72
-
73
- if (parentDataTagPrefix) {
74
- elementContent = objExtend(elementContent, _getParentDetails(element, elementContent, dataTagPrefix, aiBlobAttributeTag ));
75
- }
76
-
77
- return elementContent;
78
- };
79
-
80
- /**
81
- * Capture current level Element content
82
- */
83
- function _captureElementContentWithDataTag(contentElement: Element, elementContent: any, dataTagPrefix: string) {
84
-
85
- for (var i = 0, attrib; i < contentElement.attributes.length; i++) {
86
- attrib = contentElement.attributes[i];
87
-
88
- if ( attrib.name.indexOf(dataTagPrefix) !== 0 ) {
89
- continue;
90
- }
91
-
92
- var attribName = attrib.name.replace(dataTagPrefix, "");
93
- elementContent[attribName] = attrib.value;
94
- }
95
- }
96
-
97
- /**
98
- * Walk Up the DOM to capture Element content
99
- */
100
- function _walkUpDomChainCaptureData(el: Element, elementContent: any, dataTagPrefix: string, parentDataTagPrefix: string, aiBlobAttributeTag: string ): void {
101
- let element = el;
102
- let parentDataTagFound: boolean = false;
103
- let elementLevelFlag: boolean = false; // Use this flag to capture 'id' only at the incoming html element level.
104
-
105
- while(!isNullOrUndefined(element) && !isNullOrUndefined(element.attributes)) {
106
- let attributes=element.attributes;
107
-
108
- for (let i = 0; i < attributes.length; i++) {
109
- const attrib = attributes[i];
110
-
111
- if ( attrib.name.indexOf(dataTagPrefix) !== 0 ) {
112
- continue;
113
- }
114
-
115
- if (attrib.name.indexOf(parentDataTagPrefix) === 0) {
116
- parentDataTagFound = true;
117
- }
118
-
119
- // Todo handle blob data
120
- if (attrib.name.indexOf(aiBlobAttributeTag) === 0) {
121
- continue;
122
- }
123
-
124
- const attribName = attrib.name.replace(dataTagPrefix, "");
125
- if (elementLevelFlag && attribName === "id") {
126
- continue; // skip capturing id if not at the first level.
127
- }
128
-
129
- if (!isValueAssigned(elementContent[attribName])) {
130
- elementContent[attribName] = attrib.value;
131
- }
132
- }
133
-
134
- // break after current level;
135
- if (parentDataTagFound) {
136
- break;
137
- }
138
-
139
- elementLevelFlag = true; // after the initial level set this flag to true.
140
- element = (element.parentNode as Element);
141
- }
142
- }
143
-
144
- /**
145
- * Capture Element content along with Data Tag attributes and values
146
- */
147
- function _populateElementContent(element: Element, dataTagPrefix: string, parentDataTagPrefix: string, aiBlobAttributeTag: string) {
148
-
149
- let elementContent: any = {};
150
- if(!element) {
151
- return elementContent;
152
- }
153
-
154
- let htmlContent = _getHtmlIdAndContentName(element);
155
- elementContent = {
156
- id: htmlContent.id || "",
157
- contentName: htmlContent.contentName || ""
158
- };
159
-
160
- if(isValueAssigned(parentDataTagPrefix)) {
161
- _walkUpDomChainCaptureData(element, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag);
162
- }
163
-
164
- // Validate to ensure the minimum required field 'id' or 'contentName' is present.
165
- // The content schema defines id, aN and sN as required fields. However,
166
- // requiring these fields would result in majority of adopter's content from being collected.
167
- // Just throw a warning and continue collection.
168
- if (!elementContent.id && !elementContent.contentName) {
169
- _throwInternal(_traceLogger,
170
- eLoggingSeverity.WARNING,
171
- _eInternalMessageId.InvalidContentBlob, "Invalid content blob. Missing required attributes (id, contentName. " +
172
- " Content information will still be collected!"
173
- )
174
- }
175
-
176
- return elementContent;
177
- }
178
-
179
- /**
180
- * Capture Element content along with Data Tag attributes and values
181
- */
182
- function _populateElementContentwithDataTag(element: Element, dataTagPrefix: string, parentDataTagPrefix: string, aiBlobAttributeTag: string) {
183
- let dataTags = (_self._config || {}).dataTags;
184
- let elementContent: any = {};
185
- if(!element) {
186
- return elementContent;
187
- }
188
-
189
- let htmlContent = _getHtmlIdAndContentName(element);
190
-
191
- if(isValueAssigned(parentDataTagPrefix)) {
192
- _walkUpDomChainCaptureData(element, elementContent, dataTagPrefix, parentDataTagPrefix, aiBlobAttributeTag);
193
- } else {
194
- _captureElementContentWithDataTag(element, elementContent, dataTagPrefix);
195
- }
196
-
197
-
198
- if (dataTags.useDefaultContentNameOrId) {
199
- if(!isValueAssigned(elementContent.id)) {
200
- elementContent.id = htmlContent.id || "";
201
- }
202
-
203
- elementContent.contentName = htmlContent.contentName || "";
204
- }
205
-
206
- // Validate to ensure the minimum required field 'id' or 'contentName' is present.
207
- // The content schema defines id, aN and sN as required fields. However,
208
- // requiring these fields would result in majority of adopter's content from being collected.
209
- // Just throw a warning and continue collection.
210
- if (!elementContent.id && !elementContent.contentName) {
211
- _throwInternal(_traceLogger,
212
- eLoggingSeverity.WARNING,
213
- _eInternalMessageId.InvalidContentBlob, "Invalid content blob. Missing required attributes (id, contentName. " +
214
- " Content information will still be collected!"
215
- )
216
- }
217
-
218
- return elementContent;
219
- }
220
-
221
-
222
- /**
223
- * Retrieve a specified metadata tag value from the DOM.
224
- * @param captureAllMetaDataContent - Flag to capture all metadata content
225
- * @param prefix - Prefix to search the metatags with.
226
- * @param removePrefix - Specifies if the prefix must be excluded from key names in the returned collection.
227
- * @returns Metadata collection/property bag
228
- */
229
- function _getMetaDataFromDOM(captureAllMetaDataContent:boolean, prefix: string, removePrefix: boolean): { [name: string]: string } {
230
- var metaElements: any;
231
- var metaData = {};
232
- if (hasDocument) {
233
- metaElements = document.querySelectorAll("meta");
234
- for (var i = 0; i < metaElements.length; i++) {
235
- var meta = metaElements[i];
236
- if (meta.name) {
237
- if(captureAllMetaDataContent || meta.name.indexOf(prefix) === 0) {
238
- const name = removePrefix ? meta.name.replace(prefix, "") : meta.name;
239
- metaData[name] = meta.content;
240
- }
241
- }
242
- }
243
- }
244
-
245
- return metaData;
246
- }
247
-
248
- /**
249
- * Gets the default content name.
250
- * @param element - An html element
251
- * @param useDefaultContentNameOrId - Flag indicating if an element is market PII.
252
- * @returns Content name
253
- */
254
- function _getDefaultContentName(element: any, useDefaultContentName: boolean) {
255
- if (useDefaultContentName === false || !element.tagName) {
256
- return "";
257
- }
258
-
259
- var doc = getDocument() || ({} as Document);
260
- var contentName;
261
- switch (element.tagName) {
262
- case "A":
263
- contentName = doc.all ? element.innerText || element.innerHTML : element.text || element.innerHTML;
264
- break;
265
- case "IMG":
266
- case "AREA":
267
- contentName = element.alt;
268
- break;
269
- default:
270
- contentName = element.value || element.name || element.alt || element.innerText || element.id;
271
- }
272
-
273
- return contentName.substring(0, MAX_CONTENTNAME_LENGTH);
274
- }
275
-
276
- /**
277
- * Check if the user wants to track the element, which means if the element has any tags with data-* or customDataPrefix
278
- * @param element - An html element
279
- * @returns true if any data-* exist, otherwise return false
280
- */
281
- function _isTracked(element: Element, dataTag: string, aiBlobAttributeTag: string): boolean {
282
- const attrs = element.attributes;
283
- let dataTagFound = false;
284
- for (let i = 0; i < attrs.length; i++) {
285
- const attributeName = attrs[i].name;
286
- if(attributeName === aiBlobAttributeTag) {
287
- // ignore if the attribute name is equal to aiBlobAttributeTag
288
- return false;
289
- } else if (attributeName.indexOf(dataTag) === 0) {
290
- dataTagFound = true;
291
- }
292
- }
293
- return dataTagFound;
294
- }
295
-
296
- function _getHtmlIdAndContentName(element:Element) {
297
- let dataTags = (_self._config || {}).dataTags;
298
- let callback = (_self._config || {}).callback;
299
- let htmlContent: any = {};
300
- if(!element) {
301
- return htmlContent;
302
- }
303
-
304
- if (dataTags.useDefaultContentNameOrId) {
305
- const customizedContentName = callback.contentName ? callback.contentName(element, dataTags.useDefaultContentNameOrId) : "";
306
- const defaultContentName = _getDefaultContentName(element, dataTags.useDefaultContentNameOrId);
307
-
308
- htmlContent = {
309
- id: element.id,
310
- contentName: customizedContentName || defaultContentName || element.getAttribute("alt")
311
- };
312
- }
313
-
314
- return htmlContent;
315
- }
316
-
317
- /**
318
- * Computes the parentId of a given element.
319
- * @param element - An html element
320
- * @returns An object containing the closest parentId , can be empty if nothing was found
321
- */
322
- function _getParentDetails(element: Element, elementContent: any, dataTagPrefix: string, aiBlobAttributeTag: string): IContent {
323
- const parentId = elementContent["parentid"];
324
- const parentName = elementContent["parentname"];
325
- let parentInfo = {};
326
-
327
- if (parentId || parentName || !element) {
328
- return parentInfo;
329
- }
330
-
331
- return _populateParentInfo(element, dataTagPrefix, aiBlobAttributeTag);
332
- }
333
- /**
334
- * Check if parent info already set up, if so take and put into content, if not walk up the DOM to find correct info
335
- * @param element - An html element that the user wants to track
336
- * @returns An object containing the parent info, can be empty if nothing was found
337
- */
338
- function _populateParentInfo(element: Element, dataTagPrefix: string, aiBlobAttributeTag: string): IContent {
339
- let parentInfo: IContent = {};
340
- let parentId;
341
-
342
- // if the user does not set up parent info, walk to the DOM, find the closest parent element (with tags) and populate the info
343
- const closestParentElement = walkUpDomChainWithElementValidation(element.parentElement, _isTracked, dataTagPrefix);
344
- if (closestParentElement) {
345
- const dataAttr = closestParentElement.getAttribute(aiBlobAttributeTag) || element[aiBlobAttributeTag];
346
- if (dataAttr) {
347
- try {
348
- var telemetryObject = JSON.parse(dataAttr);
349
- } catch (e) {
350
- _throwInternal(_traceLogger,
351
- eLoggingSeverity.CRITICAL,
352
- _eInternalMessageId.CannotParseAiBlobValue, "Can not parse " + dataAttr
353
- );
354
- }
355
- if (telemetryObject) {
356
- parentId = telemetryObject.id;
357
- }
358
- } else {
359
- parentId = closestParentElement.getAttribute(dataTagPrefix+"id");
360
- }
361
- }
362
- if (parentId) {
363
- parentInfo["parentid"] = parentId;
364
- } else {
365
- let htmlContent= _getHtmlIdAndContentName(element.parentElement);
366
- parentInfo["parentid"] = htmlContent.id;
367
- parentInfo["parentname"] = htmlContent.contentName;
368
- }
369
-
370
- return parentInfo;
371
- }
372
- });
373
- }
374
-
375
- /**
376
- * Collect metatags from DOM.
377
- * Collect data from meta tags.
378
- * @returns {object} - Metatags collection/property bag
379
- */
380
- public getMetadata(): { [name: string]: string } {
381
- // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
382
- return null;
383
- }
384
-
385
- /**
386
- * Collect data-* attributes for the given element.
387
- * All attributes with data-* prefix or user provided customDataPrefix are collected.'data-*' prefix is removed from the key name.
388
- * @param element - The element from which attributes need to be collected.
389
- * @returns String representation of the Json array of element attributes
390
- */
391
- public getElementContent(element: Element): IContent {
392
- // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging
393
- return null;
394
- }
395
- }
@@ -1,99 +0,0 @@
1
- /**
2
- * @copyright Microsoft 2020
3
- */
4
- export declare enum Behavior {
5
- UNDEFINED = 0,
6
- NAVIGATIONBACK = 1,
7
- NAVIGATION = 2,
8
- NAVIGATIONFORWARD = 3,
9
- APPLY = 4,
10
- REMOVE = 5,
11
- SORT = 6,
12
- EXPAND = 7,
13
- REDUCE = 8,
14
- CONTEXTMENU = 9,
15
- TAB = 10,
16
- COPY = 11,
17
- EXPERIMENTATION = 12,
18
- PRINT = 13,
19
- SHOW = 14,
20
- HIDE = 15,
21
- MAXIMIZE = 16,
22
- MINIMIZE = 17,
23
- BACKBUTTON = 18,
24
- STARTPROCESS = 20,
25
- PROCESSCHECKPOINT = 21,
26
- COMPLETEPROCESS = 22,
27
- SCENARIOCANCEL = 23,
28
- DOWNLOADCOMMIT = 40,
29
- DOWNLOAD = 41,
30
- SEARCHAUTOCOMPLETE = 60,
31
- SEARCH = 61,
32
- SEARCHINITIATE = 62,
33
- TEXTBOXINPUT = 63,
34
- VIEWCART = 82,
35
- ADDWISHLIST = 83,
36
- FINDSTORE = 84,
37
- CHECKOUT = 85,
38
- REMOVEFROMCART = 86,
39
- PURCHASECOMPLETE = 87,
40
- VIEWCHECKOUTPAGE = 88,
41
- VIEWCARTPAGE = 89,
42
- VIEWPDP = 90,
43
- UPDATEITEMQUANTITY = 91,
44
- INTENTTOBUY = 92,
45
- PUSHTOINSTALL = 93,
46
- SIGNIN = 100,
47
- SIGNOUT = 101,
48
- SOCIALSHARE = 120,
49
- SOCIALLIKE = 121,
50
- SOCIALREPLY = 122,
51
- CALL = 123,
52
- EMAIL = 124,
53
- COMMUNITY = 125,
54
- VOTE = 140,
55
- SURVEYCHECKPOINT = 145,
56
- REGISTRATIONINITIATE = 161,
57
- REGISTRATIONCOMPLETE = 162,
58
- CANCELSUBSCRIPTION = 163,
59
- RENEWSUBSCRIPTION = 164,
60
- CHANGESUBSCRIPTION = 165,
61
- REGISTRATIONCHECKPOINT = 166,
62
- CHATINITIATE = 180,
63
- CHATEND = 181,
64
- TRIALSIGNUP = 200,
65
- TRIALINITIATE = 201,
66
- SIGNUP = 210,
67
- FREESIGNUP = 211,
68
- PARTNERREFERRAL = 220,
69
- LEARNLOWFUNNEL = 230,
70
- LEARNHIGHFUNNEL = 231,
71
- SHOPPINGINTENT = 232,
72
- VIDEOSTART = 240,
73
- VIDEOPAUSE = 241,
74
- VIDEOCONTINUE = 242,
75
- VIDEOCHECKPOINT = 243,
76
- VIDEOJUMP = 244,
77
- VIDEOCOMPLETE = 245,
78
- VIDEOBUFFERING = 246,
79
- VIDEOERROR = 247,
80
- VIDEOMUTE = 248,
81
- VIDEOUNMUTE = 249,
82
- VIDEOFULLSCREEN = 250,
83
- VIDEOUNFULLSCREEN = 251,
84
- VIDEOREPLAY = 252,
85
- VIDEOPLAYERLOAD = 253,
86
- VIDEOPLAYERCLICK = 254,
87
- VIDEOVOLUMECONTROL = 255,
88
- VIDEOAUDIOTRACKCONTROL = 256,
89
- VIDEOCLOSEDCAPTIONCONTROL = 257,
90
- VIDEOCLOSEDCAPTIONSTYLE = 258,
91
- VIDEORESOLUTIONCONTROL = 259,
92
- ADBUFFERING = 283,
93
- ADERROR = 284,
94
- ADSTART = 285,
95
- ADCOMPLETE = 286,
96
- ADSKIP = 287,
97
- ADTIMEOUT = 288,
98
- OTHER = 300
99
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * @copyright Microsoft 2020
3
- */
4
- import { IConfig } from "@microsoft/applicationinsights-common";
5
- import { BaseTelemetryPlugin, IAppInsightsCore, IConfiguration, ICustomProperties, IPlugin, IProcessTelemetryContext, ITelemetryItem, ITelemetryPluginChain } from "@microsoft/applicationinsights-core-js";
6
- import { IPageActionTelemetry } from "./Interfaces/Datamodel";
7
- import { BehaviorEnumValidator, BehaviorMapValidator, BehaviorValueValidator } from "./common/Utils";
8
- export { BehaviorMapValidator, BehaviorValueValidator, BehaviorEnumValidator };
9
- export declare class ClickAnalyticsPlugin extends BaseTelemetryPlugin {
10
- identifier: string;
11
- priority: number;
12
- static Version: string;
13
- constructor();
14
- initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
15
- processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
16
- /**
17
- * Logs a page action event.
18
- * @param IPageActionTelemetry
19
- * @param customProperties - Additional data used to filter events and metrics. Defaults to empty.
20
- */
21
- trackPageAction(pageAction?: IPageActionTelemetry, customProperties?: ICustomProperties): void;
22
- }
@@ -1,39 +0,0 @@
1
- /**
2
- * @copyright Microsoft 2020
3
- */
4
- import { IClickAnalyticsConfiguration, IOverrideValues } from "./Interfaces/Datamodel";
5
- /**
6
- * Get Image href of a given HTMLImageElement
7
- * @param element - An html image element
8
- * @returns Href value.
9
- */
10
- export declare function getImageHref(element: HTMLImageElement): string;
11
- /**
12
- * Get click target
13
- * @returns Click target URI
14
- */
15
- export declare function getClickTarget(element: any): string;
16
- /**
17
- * Execute callback when DOM finish loading
18
- */
19
- export declare function onDomLoaded(callback: () => void): void;
20
- /**
21
- * Gets the pageName from the DOM or by calling a override if set.
22
- * @param config - configuration object
23
- * @returns Page name.
24
- */
25
- export declare function getPageName(config: IClickAnalyticsConfiguration, overrideValues: IOverrideValues): string;
26
- /**
27
- * Sanitize URL values
28
- * @param config - Configuration
29
- * @param location - window.location or document.location
30
- * @returns Flag indicating if an element is market PII.
31
- */
32
- export declare function sanitizeUrl(config: IClickAnalyticsConfiguration, location: Location): string;
33
- /**
34
- * Get URI, sanitize the value if configured on
35
- * @param config - Configuration
36
- * @param location - window.location or document.location
37
- * @returns Flag indicating if an element is market PII.
38
- */
39
- export declare function getUri(config: IClickAnalyticsConfiguration, location: any): string;