@microsoft/applicationinsights-clickanalytics-js 2.7.1-nightly.202110-07 → 2.7.1-nightly.202110-16
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.7.1-nightly.202110-07.cjs.js → ai.clck.2.7.1-nightly.202110-16.cjs.js} +129 -120
- package/browser/ai.clck.2.7.1-nightly.202110-16.cjs.js.map +1 -0
- package/browser/ai.clck.2.7.1-nightly.202110-16.cjs.min.js +6 -0
- package/browser/ai.clck.2.7.1-nightly.202110-16.cjs.min.js.map +1 -0
- package/browser/{ai.clck.2.7.1-nightly.202110-07.gbl.js → ai.clck.2.7.1-nightly.202110-16.gbl.js} +129 -120
- package/browser/ai.clck.2.7.1-nightly.202110-16.gbl.js.map +1 -0
- package/browser/ai.clck.2.7.1-nightly.202110-16.gbl.min.js +6 -0
- package/browser/ai.clck.2.7.1-nightly.202110-16.gbl.min.js.map +1 -0
- package/browser/ai.clck.2.7.1-nightly.202110-16.integrity.json +66 -0
- package/browser/{ai.clck.2.7.1-nightly.202110-07.js → ai.clck.2.7.1-nightly.202110-16.js} +129 -120
- package/browser/ai.clck.2.7.1-nightly.202110-16.js.map +1 -0
- package/browser/ai.clck.2.7.1-nightly.202110-16.min.js +6 -0
- package/browser/ai.clck.2.7.1-nightly.202110-16.min.js.map +1 -0
- package/browser/ai.clck.2.cjs.js +128 -119
- 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 +128 -119
- 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 +128 -119
- 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 +1 -1
- package/dist/applicationinsights-clickanalytics-js.d.ts +1 -1
- package/dist/applicationinsights-clickanalytics-js.js +128 -119
- 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 +5 -5
- package/dist-esm/ClickAnalyticsPlugin.js.map +1 -1
- package/dist-esm/DataCollector.js +16 -16
- package/dist-esm/DataCollector.js.map +1 -1
- package/dist-esm/Enums.js +10 -10
- package/dist-esm/Enums.js.map +1 -1
- package/dist-esm/Interfaces/Datamodel.js +1 -1
- package/dist-esm/applicationinsights-clickanalytics-js.js +1 -1
- package/dist-esm/common/Utils.js +25 -25
- package/dist-esm/common/Utils.js.map +1 -1
- package/dist-esm/events/PageAction.js +24 -24
- package/dist-esm/events/PageAction.js.map +1 -1
- package/dist-esm/events/WebEvent.js +8 -8
- package/dist-esm/events/WebEvent.js.map +1 -1
- package/dist-esm/handlers/AutoCaptureHandler.js +8 -8
- package/dist-esm/handlers/AutoCaptureHandler.js.map +1 -1
- package/dist-esm/handlers/DomContentHandler.js +26 -26
- package/dist-esm/handlers/DomContentHandler.js.map +1 -1
- package/package.json +4 -5
- package/src/ClickAnalyticsPlugin.ts +5 -5
- package/src/DataCollector.ts +16 -16
- package/src/Enums.ts +9 -9
- package/src/common/Utils.ts +25 -25
- package/src/events/PageAction.ts +25 -25
- package/src/events/WebEvent.ts +9 -9
- package/src/handlers/AutoCaptureHandler.ts +9 -9
- package/src/handlers/DomContentHandler.ts +26 -26
- package/types/ClickAnalyticsPlugin.d.ts +2 -2
- package/types/DataCollector.d.ts +1 -1
- package/types/common/Utils.d.ts +1 -1
- package/types/events/PageAction.d.ts +2 -2
- package/types/events/WebEvent.d.ts +3 -3
- package/types/handlers/AutoCaptureHandler.d.ts +2 -2
- package/types/handlers/DomContentHandler.d.ts +1 -1
- package/types/tsdoc-metadata.json +1 -1
- package/browser/ai.clck.2.7.1-nightly.202110-07.cjs.js.map +0 -1
- package/browser/ai.clck.2.7.1-nightly.202110-07.cjs.min.js +0 -6
- package/browser/ai.clck.2.7.1-nightly.202110-07.cjs.min.js.map +0 -1
- package/browser/ai.clck.2.7.1-nightly.202110-07.gbl.js.map +0 -1
- package/browser/ai.clck.2.7.1-nightly.202110-07.gbl.min.js +0 -6
- package/browser/ai.clck.2.7.1-nightly.202110-07.gbl.min.js.map +0 -1
- package/browser/ai.clck.2.7.1-nightly.202110-07.integrity.json +0 -66
- package/browser/ai.clck.2.7.1-nightly.202110-07.js.map +0 -1
- package/browser/ai.clck.2.7.1-nightly.202110-07.min.js +0 -6
- package/browser/ai.clck.2.7.1-nightly.202110-07.min.js.map +0 -1
package/src/common/Utils.ts
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
import { isNullOrUndefined, _InternalMessageId, hasDocument, hasOwnProperty, arrForEach } from "@microsoft/applicationinsights-core-js";
|
|
7
7
|
import {
|
|
8
8
|
IClickAnalyticsConfiguration
|
|
9
|
-
} from
|
|
9
|
+
} from "../Interfaces/Datamodel";
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
const Prototype =
|
|
13
|
-
const DEFAULT_DONOT_TRACK_TAG =
|
|
14
|
-
const DEFAULT_AI_BLOB_ATTRIBUTE_TAG =
|
|
15
|
-
const DEFAULT_DATA_PREFIX =
|
|
12
|
+
const Prototype = "prototype";
|
|
13
|
+
const DEFAULT_DONOT_TRACK_TAG = "ai-dnt";
|
|
14
|
+
const DEFAULT_AI_BLOB_ATTRIBUTE_TAG = "ai-blob";
|
|
15
|
+
const DEFAULT_DATA_PREFIX = "data-";
|
|
16
16
|
|
|
17
17
|
export const _ExtendedInternalMessageId = {
|
|
18
18
|
..._InternalMessageId,
|
|
@@ -32,7 +32,7 @@ export function removeNonObjectsAndInvalidElements(overrideConfig: IClickAnalyti
|
|
|
32
32
|
for (var i in attributeNamesExpectedObjects) {
|
|
33
33
|
if (attributeNamesExpectedObjects.hasOwnProperty(i)) {
|
|
34
34
|
var objectName = attributeNamesExpectedObjects[i];
|
|
35
|
-
if (typeof overrideConfig[objectName] ===
|
|
35
|
+
if (typeof overrideConfig[objectName] === "object") {
|
|
36
36
|
removeInvalidElements(overrideConfig[objectName]);
|
|
37
37
|
} else {
|
|
38
38
|
delete overrideConfig[objectName];
|
|
@@ -52,7 +52,7 @@ export function removeInvalidElements(object: Object): void {
|
|
|
52
52
|
/// the workaround regarding 'callback'
|
|
53
53
|
for (var property in object) {
|
|
54
54
|
if (!isValueAssigned(object[property]) ||
|
|
55
|
-
(JSON.stringify(object[property]) ===
|
|
55
|
+
(JSON.stringify(object[property]) === "{}" && (property !== "callback"))) {
|
|
56
56
|
delete object[property];
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -67,7 +67,7 @@ export function isValueAssigned(value: any) {
|
|
|
67
67
|
/// <summary> takes a value and checks for undefined, null and empty string </summary>
|
|
68
68
|
/// <param type="any"> value to be tested </param>
|
|
69
69
|
/// <returns> true if value is null undefined or emptyString </returns>
|
|
70
|
-
return !(isNullOrUndefined(value) || value ===
|
|
70
|
+
return !(isNullOrUndefined(value) || value === "");
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
@@ -77,9 +77,9 @@ export function isValueAssigned(value: any) {
|
|
|
77
77
|
*/
|
|
78
78
|
export function isRightClick(evt: any): boolean {
|
|
79
79
|
try {
|
|
80
|
-
if (
|
|
80
|
+
if ("which" in evt) { // Chrome, FF, ...
|
|
81
81
|
return (evt.which === 3);
|
|
82
|
-
} else if (
|
|
82
|
+
} else if ("button" in evt) { // IE, ...
|
|
83
83
|
return (evt.button === 2);
|
|
84
84
|
}
|
|
85
85
|
} catch (e) {
|
|
@@ -94,9 +94,9 @@ export function isRightClick(evt: any): boolean {
|
|
|
94
94
|
*/
|
|
95
95
|
export function isLeftClick(evt: any): boolean {
|
|
96
96
|
try {
|
|
97
|
-
if (
|
|
97
|
+
if ("which" in evt) { // Chrome, FF, ...
|
|
98
98
|
return (evt.which === 1);
|
|
99
|
-
} else if (
|
|
99
|
+
} else if ("button" in evt) { // IE, ...
|
|
100
100
|
return (evt.button === 1);
|
|
101
101
|
}
|
|
102
102
|
} catch (e) {
|
|
@@ -111,9 +111,9 @@ export function isLeftClick(evt: any): boolean {
|
|
|
111
111
|
*/
|
|
112
112
|
export function isMiddleClick(evt: any): boolean {
|
|
113
113
|
try {
|
|
114
|
-
if (
|
|
114
|
+
if ("which" in evt) { // Chrome, FF, ...
|
|
115
115
|
return (evt.which === 2);
|
|
116
|
-
} else if (
|
|
116
|
+
} else if ("button" in evt) { // IE, ...
|
|
117
117
|
return (evt.button === 4);
|
|
118
118
|
}
|
|
119
119
|
} catch (e) {
|
|
@@ -128,7 +128,7 @@ export function isMiddleClick(evt: any): boolean {
|
|
|
128
128
|
*/
|
|
129
129
|
export function isKeyboardEnter(evt: KeyboardEvent): boolean {
|
|
130
130
|
try {
|
|
131
|
-
if (
|
|
131
|
+
if ("keyCode" in evt) { // Chrome, FF, ...
|
|
132
132
|
return (evt.keyCode === 13);
|
|
133
133
|
}
|
|
134
134
|
} catch (e) {
|
|
@@ -143,7 +143,7 @@ export function isKeyboardEnter(evt: KeyboardEvent): boolean {
|
|
|
143
143
|
*/
|
|
144
144
|
export function isKeyboardSpace(evt: KeyboardEvent) {
|
|
145
145
|
try {
|
|
146
|
-
if (
|
|
146
|
+
if ("keyCode" in evt) { // Chrome, FF, ...
|
|
147
147
|
return (evt.keyCode === 32);
|
|
148
148
|
}
|
|
149
149
|
} catch (e) {
|
|
@@ -214,7 +214,7 @@ export function walkUpDomChainWithElementValidation(el: Element, validationMetho
|
|
|
214
214
|
* @returns Is element an anchor
|
|
215
215
|
*/
|
|
216
216
|
export function isElementAnAnchor(element: Element): boolean {
|
|
217
|
-
return element.nodeName ===
|
|
217
|
+
return element.nodeName === "A";
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
/**
|
|
@@ -255,7 +255,7 @@ export function bracketIt(str: string): string {
|
|
|
255
255
|
/// <summary>
|
|
256
256
|
/// Adds surrounding square brackets to the passed in text
|
|
257
257
|
/// </summary>
|
|
258
|
-
return
|
|
258
|
+
return "[" + str + "]";
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
/**
|
|
@@ -277,7 +277,7 @@ export function extend(obj?: any, obj2?: any, obj3?: any, obj4?: any, obj5?: any
|
|
|
277
277
|
var theArgs = arguments;
|
|
278
278
|
|
|
279
279
|
// Check if a deep merge
|
|
280
|
-
if (objProto.toString.call(theArgs[0]) ===
|
|
280
|
+
if (objProto.toString.call(theArgs[0]) === "[object Boolean]") {
|
|
281
281
|
deep = theArgs[0];
|
|
282
282
|
i++;
|
|
283
283
|
}
|
|
@@ -287,7 +287,7 @@ export function extend(obj?: any, obj2?: any, obj3?: any, obj4?: any, obj5?: any
|
|
|
287
287
|
for (var prop in obj) {
|
|
288
288
|
if (hasOwnProperty(obj, prop)) {
|
|
289
289
|
// If deep merge and property is an object, merge properties
|
|
290
|
-
if (deep && objProto.toString.call(obj[prop]) ===
|
|
290
|
+
if (deep && objProto.toString.call(obj[prop]) === "[object Object]") {
|
|
291
291
|
extended[prop] = extend(true, extended[prop], obj[prop]);
|
|
292
292
|
} else {
|
|
293
293
|
extended[prop] = obj[prop];
|
|
@@ -324,10 +324,10 @@ export function mergeConfig(overrideConfig: IClickAnalyticsConfiguration): IClic
|
|
|
324
324
|
pageTags: {},
|
|
325
325
|
// overrideValues to use instead of collecting automatically
|
|
326
326
|
coreData: {
|
|
327
|
-
referrerUri: hasDocument ? document.referrer :
|
|
328
|
-
requestUri:
|
|
329
|
-
pageName:
|
|
330
|
-
pageType:
|
|
327
|
+
referrerUri: hasDocument ? document.referrer : "",
|
|
328
|
+
requestUri: "",
|
|
329
|
+
pageName: "",
|
|
330
|
+
pageType: ""
|
|
331
331
|
},
|
|
332
332
|
dataTags: {
|
|
333
333
|
useDefaultContentNameOrId: false,
|
|
@@ -343,7 +343,7 @@ export function mergeConfig(overrideConfig: IClickAnalyticsConfiguration): IClic
|
|
|
343
343
|
|
|
344
344
|
let attributesThatAreObjectsInConfig: any[] = [];
|
|
345
345
|
for (const attribute in defaultConfig) {
|
|
346
|
-
if (typeof defaultConfig[attribute] ===
|
|
346
|
+
if (typeof defaultConfig[attribute] === "object") {
|
|
347
347
|
attributesThatAreObjectsInConfig.push(attribute);
|
|
348
348
|
}
|
|
349
349
|
}
|
package/src/events/PageAction.ts
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* @copyright Microsoft 2020
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { WebEvent } from
|
|
6
|
-
import * as DataCollector from
|
|
5
|
+
import { WebEvent } from "./WebEvent";
|
|
6
|
+
import * as DataCollector from "../DataCollector";
|
|
7
7
|
import { ITelemetryItem, getPerformance, ICustomProperties, LoggingSeverity, objForEachKey } from "@microsoft/applicationinsights-core-js"
|
|
8
|
-
import { IPageActionOverrideValues, IPageActionTelemetry } from
|
|
9
|
-
import { extractFieldFromObject, bracketIt, isValueAssigned, extend, _ExtendedInternalMessageId } from
|
|
10
|
-
import { strNotSpecified } from
|
|
8
|
+
import { IPageActionOverrideValues, IPageActionTelemetry } from "../Interfaces/Datamodel";
|
|
9
|
+
import { extractFieldFromObject, bracketIt, isValueAssigned, extend, _ExtendedInternalMessageId } from "../common/Utils";
|
|
10
|
+
import { strNotSpecified } from "@microsoft/applicationinsights-common";
|
|
11
11
|
|
|
12
12
|
export class PageAction extends WebEvent {
|
|
13
13
|
|
|
@@ -19,29 +19,29 @@ export class PageAction extends WebEvent {
|
|
|
19
19
|
public trackPageAction(pageActionEvent: IPageActionTelemetry, properties?: ICustomProperties): void {
|
|
20
20
|
// Get part A properties
|
|
21
21
|
var ext = {};
|
|
22
|
-
ext[
|
|
22
|
+
ext["web"] = {};
|
|
23
23
|
let event: ITelemetryItem = {
|
|
24
24
|
name: "Microsoft.ApplicationInsights.{0}.Event",
|
|
25
|
-
baseType:
|
|
25
|
+
baseType: "EventData",
|
|
26
26
|
ext,
|
|
27
27
|
data: {},
|
|
28
28
|
baseData: {}
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
this._populateEventDataIfPresent(event.baseData,
|
|
32
|
-
this._populateEventDataIfPresent(event.data,
|
|
33
|
-
this._populateEventDataIfPresent(event.data,
|
|
34
|
-
this._populateEventDataIfPresent(event.data,
|
|
35
|
-
this._populateEventDataIfPresent(event.data,
|
|
36
|
-
this._populateEventDataIfPresent(event.data,
|
|
37
|
-
this._populateEventDataIfPresent(event.data,
|
|
38
|
-
this._populateEventDataIfPresent(event.data,
|
|
39
|
-
this._populateEventDataIfPresent(event.data,
|
|
40
|
-
this._populateEventDataIfPresent(event.data,
|
|
41
|
-
this._populateEventDataIfPresent(event.data,
|
|
42
|
-
this._populateEventDataIfPresent(event.data,
|
|
43
|
-
this._populateEventDataIfPresent(event.data,
|
|
44
|
-
this._populateEventDataIfPresent(event.data,
|
|
31
|
+
this._populateEventDataIfPresent(event.baseData, "name", pageActionEvent.name);
|
|
32
|
+
this._populateEventDataIfPresent(event.data, "baseTypeSource", "ClickEvent");
|
|
33
|
+
this._populateEventDataIfPresent(event.data, "uri", pageActionEvent.uri);
|
|
34
|
+
this._populateEventDataIfPresent(event.data, "pageType", pageActionEvent.pageType);
|
|
35
|
+
this._populateEventDataIfPresent(event.data, "properties", pageActionEvent.properties);
|
|
36
|
+
this._populateEventDataIfPresent(event.data, "actionType", pageActionEvent.actionType);
|
|
37
|
+
this._populateEventDataIfPresent(event.data, "behavior", pageActionEvent.behavior);
|
|
38
|
+
this._populateEventDataIfPresent(event.data, "clickCoordinates", pageActionEvent.clickCoordinates);
|
|
39
|
+
this._populateEventDataIfPresent(event.data, "content", pageActionEvent.content);
|
|
40
|
+
this._populateEventDataIfPresent(event.data, "targetUri", pageActionEvent.targetUri);
|
|
41
|
+
this._populateEventDataIfPresent(event.data, "timeToAction", pageActionEvent.timeToAction);
|
|
42
|
+
this._populateEventDataIfPresent(event.data, "refUri", pageActionEvent.refUri);
|
|
43
|
+
this._populateEventDataIfPresent(event.data, "pageName", pageActionEvent.pageName);
|
|
44
|
+
this._populateEventDataIfPresent(event.data, "parentId", pageActionEvent.parentId);
|
|
45
45
|
|
|
46
46
|
if (properties) {
|
|
47
47
|
objForEachKey(properties, (property, value) => {
|
|
@@ -62,7 +62,7 @@ export class PageAction extends WebEvent {
|
|
|
62
62
|
*/
|
|
63
63
|
public capturePageAction(element: Element, overrideValues?: IPageActionOverrideValues, customProperties?: { [name: string]: string | number | boolean | string[] | number[] | boolean[] | object }, isRightClick?: boolean): void {
|
|
64
64
|
overrideValues = !isValueAssigned(overrideValues) ? {} : overrideValues;
|
|
65
|
-
let pageActionEvent: IPageActionTelemetry = { name :
|
|
65
|
+
let pageActionEvent: IPageActionTelemetry = { name : ""};
|
|
66
66
|
let pageActionProperties: ICustomProperties = isValueAssigned(customProperties) ? customProperties : {};
|
|
67
67
|
this.setCommonProperties(pageActionEvent, overrideValues);
|
|
68
68
|
pageActionEvent.behavior = this._getBehavior(overrideValues);
|
|
@@ -82,7 +82,7 @@ export class PageAction extends WebEvent {
|
|
|
82
82
|
|
|
83
83
|
// if the element has a data-*-bhvr attrib defined, use it.
|
|
84
84
|
if (elementContent.bhvr && !isValueAssigned(overrideValues.behavior)) {
|
|
85
|
-
let currentBehavior: string = extractFieldFromObject(elementContent,
|
|
85
|
+
let currentBehavior: string = extractFieldFromObject(elementContent, "bhvr");
|
|
86
86
|
pageActionEvent.behavior = this._getValidBehavior(currentBehavior);
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -92,7 +92,7 @@ export class PageAction extends WebEvent {
|
|
|
92
92
|
if (!isValueAssigned(elementContent.id) && !isValueAssigned(elementContent.contentName)) {
|
|
93
93
|
this._traceLogger.throwInternal(
|
|
94
94
|
LoggingSeverity.WARNING,
|
|
95
|
-
_ExtendedInternalMessageId.InvalidContentBlob,
|
|
95
|
+
_ExtendedInternalMessageId.InvalidContentBlob, "Missing attributes id or contentName in click event. Click event information will still be collected!"
|
|
96
96
|
)
|
|
97
97
|
}
|
|
98
98
|
}
|
|
@@ -103,7 +103,7 @@ export class PageAction extends WebEvent {
|
|
|
103
103
|
pageActionEvent.actionType = overrideValues.actionType;
|
|
104
104
|
}
|
|
105
105
|
if (isValueAssigned(overrideValues.clickCoordinateX) && isValueAssigned(overrideValues.clickCoordinateY)) {
|
|
106
|
-
pageActionEvent.clickCoordinates = overrideValues.clickCoordinateX +
|
|
106
|
+
pageActionEvent.clickCoordinates = overrideValues.clickCoordinateX + "X" + overrideValues.clickCoordinateY;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
this._sanitizePageActionEventContent(elementContent);
|
package/src/events/WebEvent.ts
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
isValueAssigned, extend
|
|
8
|
-
} from
|
|
9
|
-
import * as DataCollector from
|
|
10
|
-
import { IDiagnosticLogger, getLocation, hasWindow } from
|
|
11
|
-
import { IClickAnalyticsConfiguration, IPageTags, IOverrideValues, IContentHandler, ICoreData, IPageActionTelemetry } from
|
|
12
|
-
import { ClickAnalyticsPlugin } from
|
|
8
|
+
} from "../common/Utils";
|
|
9
|
+
import * as DataCollector from "../DataCollector";
|
|
10
|
+
import { IDiagnosticLogger, getLocation, hasWindow } from "@microsoft/applicationinsights-core-js";
|
|
11
|
+
import { IClickAnalyticsConfiguration, IPageTags, IOverrideValues, IContentHandler, ICoreData, IPageActionTelemetry } from "../Interfaces/Datamodel";
|
|
12
|
+
import { ClickAnalyticsPlugin } from "../ClickAnalyticsPlugin";
|
|
13
13
|
|
|
14
14
|
export class WebEvent {
|
|
15
15
|
|
|
@@ -53,8 +53,8 @@ export class WebEvent {
|
|
|
53
53
|
|
|
54
54
|
// extract specific meta tags out of the pageTags.metaTags collection. These will go into assigned first class fields in the event.
|
|
55
55
|
// the rest will go into pageTags.metaTags collection as is.
|
|
56
|
-
this._pageTypeMetaTag = this._getMetaData(this._metaTags, this._config.coreData,
|
|
57
|
-
this._behaviorMetaTag = this._getMetaData(this._metaTags, this._config.coreData,
|
|
56
|
+
this._pageTypeMetaTag = this._getMetaData(this._metaTags, this._config.coreData, "pageType");
|
|
57
|
+
this._behaviorMetaTag = this._getMetaData(this._metaTags, this._config.coreData, "behavior");
|
|
58
58
|
|
|
59
59
|
if (isValueAssigned(overrideValues.pageType)) {
|
|
60
60
|
event.pageType = overrideValues.pageType;
|
|
@@ -83,14 +83,14 @@ export class WebEvent {
|
|
|
83
83
|
this._pageTags.metaTags = {};
|
|
84
84
|
// Remove not supported meta data in pageTags.metaTags
|
|
85
85
|
for (var metaTag in this._metaTags) {
|
|
86
|
-
if (metaTag !=
|
|
86
|
+
if (metaTag != "behavior" && metaTag != "market" && metaTag != "pageType") {
|
|
87
87
|
this._pageTags.metaTags[metaTag] = this._metaTags[metaTag];
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
// All metadata tags that must be saved as properties have been extracted at this point. Assign pageTags as is.
|
|
92
92
|
event.properties = event.properties || {};
|
|
93
|
-
event.properties[
|
|
93
|
+
event.properties["pageTags"] = this._pageTags;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
protected _getBehavior(overrideValues?: IOverrideValues): string | number {
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { IDiagnosticLogger, _InternalMessageId, getWindow, getDocument, isNullOrUndefined, attachEvent } from "@microsoft/applicationinsights-core-js";
|
|
6
|
-
import { IAutoCaptureHandler, IPageActionOverrideValues, IClickAnalyticsConfiguration } from
|
|
7
|
-
import { isRightClick, isLeftClick, isKeyboardEnter, isKeyboardSpace, isMiddleClick, isElementDnt } from
|
|
8
|
-
import { ActionType } from
|
|
6
|
+
import { IAutoCaptureHandler, IPageActionOverrideValues, IClickAnalyticsConfiguration } from "../Interfaces/Datamodel"
|
|
7
|
+
import { isRightClick, isLeftClick, isKeyboardEnter, isKeyboardSpace, isMiddleClick, isElementDnt } from "../common/Utils";
|
|
8
|
+
import { ActionType } from "../Enums";
|
|
9
9
|
import { ClickAnalyticsPlugin } from "../ClickAnalyticsPlugin";
|
|
10
|
-
import { PageAction } from
|
|
10
|
+
import { PageAction } from "../events/PageAction";
|
|
11
11
|
|
|
12
12
|
const clickCaptureInputTypes = { BUTTON: true, CHECKBOX: true, RADIO: true, RESET: true, SUBMIT: true };
|
|
13
13
|
|
|
@@ -27,14 +27,14 @@ export class AutoCaptureHandler implements IAutoCaptureHandler {
|
|
|
27
27
|
let doc = getDocument();
|
|
28
28
|
if (win) {
|
|
29
29
|
// IE9 onwards addEventListener is available, 'click' event captures mouse click. mousedown works on other browsers
|
|
30
|
-
const event = (navigator.appVersion.indexOf(
|
|
30
|
+
const event = (navigator.appVersion.indexOf("MSIE") !== -1) ? "click" : "mousedown";
|
|
31
31
|
attachEvent(win, event , (evt:any) => { this._processClick(evt); });
|
|
32
|
-
attachEvent(win,
|
|
32
|
+
attachEvent(win, "keyup" , (evt:any) => { this._processClick(evt); });
|
|
33
33
|
} else if (doc) {
|
|
34
34
|
// IE8 and below doesn't have addEventListener so it will use attachEvent
|
|
35
35
|
// attaching to window does not work in IE8
|
|
36
|
-
attachEvent(doc,
|
|
37
|
-
attachEvent(doc,
|
|
36
|
+
attachEvent(doc, "click" , (evt:any) => { this._processClick(evt); });
|
|
37
|
+
attachEvent(doc, "keyup" , (evt:any) => { this._processClick(evt); });
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -95,7 +95,7 @@ export class AutoCaptureHandler implements IAutoCaptureHandler {
|
|
|
95
95
|
continue;
|
|
96
96
|
} else {
|
|
97
97
|
// Check allowed INPUT types
|
|
98
|
-
var sendEvent = tagNameUpperCased ===
|
|
98
|
+
var sendEvent = tagNameUpperCased === "INPUT" ? clickCaptureInputTypes[element.type.toUpperCase()] : true;
|
|
99
99
|
if (sendEvent) {
|
|
100
100
|
this.capturePageAction(element, overrideValues, {}, isRightClickObj);
|
|
101
101
|
}
|
|
@@ -5,9 +5,9 @@ import {
|
|
|
5
5
|
removeInvalidElements,
|
|
6
6
|
walkUpDomChainWithElementValidation,
|
|
7
7
|
extend, _ExtendedInternalMessageId, isValueAssigned
|
|
8
|
-
} from
|
|
8
|
+
} from "../common/Utils";
|
|
9
9
|
import { IDiagnosticLogger, LoggingSeverity, getDocument, isNullOrUndefined, hasDocument} from "@microsoft/applicationinsights-core-js";
|
|
10
|
-
import { IClickAnalyticsConfiguration, IContent, IContentHandler } from
|
|
10
|
+
import { IClickAnalyticsConfiguration, IContent, IContentHandler } from "../Interfaces/Datamodel";
|
|
11
11
|
|
|
12
12
|
const MAX_CONTENTNAME_LENGTH = 200;
|
|
13
13
|
|
|
@@ -30,7 +30,7 @@ export class DomContentHandler implements IContentHandler {
|
|
|
30
30
|
let metaTags = {};
|
|
31
31
|
if (hasDocument) {
|
|
32
32
|
metaTags = isValueAssigned(this._config.dataTags.metaDataPrefix) ? this._getMetaDataFromDOM(this._config.dataTags.captureAllMetaDataContent ,this._config.dataTags.metaDataPrefix, false) :
|
|
33
|
-
this._getMetaDataFromDOM(this._config.dataTags.captureAllMetaDataContent ,
|
|
33
|
+
this._getMetaDataFromDOM(this._config.dataTags.captureAllMetaDataContent ,"", false);
|
|
34
34
|
}
|
|
35
35
|
return metaTags;
|
|
36
36
|
}
|
|
@@ -96,7 +96,7 @@ export class DomContentHandler implements IContentHandler {
|
|
|
96
96
|
continue;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
var attribName = attrib.name.replace(dataTagPrefix,
|
|
99
|
+
var attribName = attrib.name.replace(dataTagPrefix, "");
|
|
100
100
|
elementContent[attribName] = attrib.value;
|
|
101
101
|
}
|
|
102
102
|
}
|
|
@@ -125,8 +125,8 @@ export class DomContentHandler implements IContentHandler {
|
|
|
125
125
|
if( attrib.name.indexOf(aiBlobAttributeTag) === 0) {
|
|
126
126
|
continue;
|
|
127
127
|
}
|
|
128
|
-
const attribName = attrib.name.replace(dataTagPrefix,
|
|
129
|
-
if(elementLevelFlag && attribName ===
|
|
128
|
+
const attribName = attrib.name.replace(dataTagPrefix, "");
|
|
129
|
+
if(elementLevelFlag && attribName ==="id") continue; // skip capturing id if not at the first level.
|
|
130
130
|
if(!isValueAssigned(elementContent[attribName])) {
|
|
131
131
|
elementContent[attribName] = attrib.value;
|
|
132
132
|
}
|
|
@@ -151,8 +151,8 @@ export class DomContentHandler implements IContentHandler {
|
|
|
151
151
|
|
|
152
152
|
let htmlContent = this._getHtmlIdAndContentName(element);
|
|
153
153
|
elementContent = {
|
|
154
|
-
id: htmlContent.id ||
|
|
155
|
-
contentName: htmlContent.contentName ||
|
|
154
|
+
id: htmlContent.id || "",
|
|
155
|
+
contentName: htmlContent.contentName || ""
|
|
156
156
|
};
|
|
157
157
|
|
|
158
158
|
if(isValueAssigned(parentDataTagPrefix)) {
|
|
@@ -166,8 +166,8 @@ export class DomContentHandler implements IContentHandler {
|
|
|
166
166
|
if (!elementContent.id && !elementContent.contentName) {
|
|
167
167
|
this._traceLogger.throwInternal(
|
|
168
168
|
LoggingSeverity.WARNING,
|
|
169
|
-
_ExtendedInternalMessageId.InvalidContentBlob,
|
|
170
|
-
|
|
169
|
+
_ExtendedInternalMessageId.InvalidContentBlob, "Invalid content blob. Missing required attributes (id, contentName. " +
|
|
170
|
+
" Content information will still be collected!"
|
|
171
171
|
)
|
|
172
172
|
}
|
|
173
173
|
|
|
@@ -194,9 +194,9 @@ export class DomContentHandler implements IContentHandler {
|
|
|
194
194
|
|
|
195
195
|
if (this._config.dataTags.useDefaultContentNameOrId) {
|
|
196
196
|
if(!isValueAssigned(elementContent.id)) {
|
|
197
|
-
elementContent.id = htmlContent.id ||
|
|
197
|
+
elementContent.id = htmlContent.id || "";
|
|
198
198
|
}
|
|
199
|
-
elementContent.contentName = htmlContent.contentName ||
|
|
199
|
+
elementContent.contentName = htmlContent.contentName || "";
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
// Validate to ensure the minimum required field 'id' or 'contentName' is present.
|
|
@@ -206,8 +206,8 @@ export class DomContentHandler implements IContentHandler {
|
|
|
206
206
|
if (!elementContent.id && !elementContent.contentName) {
|
|
207
207
|
this._traceLogger.throwInternal(
|
|
208
208
|
LoggingSeverity.WARNING,
|
|
209
|
-
_ExtendedInternalMessageId.InvalidContentBlob,
|
|
210
|
-
|
|
209
|
+
_ExtendedInternalMessageId.InvalidContentBlob, "Invalid content blob. Missing required attributes (id, contentName. " +
|
|
210
|
+
" Content information will still be collected!"
|
|
211
211
|
)
|
|
212
212
|
}
|
|
213
213
|
|
|
@@ -226,12 +226,12 @@ export class DomContentHandler implements IContentHandler {
|
|
|
226
226
|
var metaElements: any;
|
|
227
227
|
var metaData = {};
|
|
228
228
|
if (hasDocument) {
|
|
229
|
-
metaElements = document.querySelectorAll(
|
|
229
|
+
metaElements = document.querySelectorAll("meta");
|
|
230
230
|
for (var i = 0; i < metaElements.length; i++) {
|
|
231
231
|
var meta = metaElements[i];
|
|
232
232
|
if (meta.name) {
|
|
233
233
|
if(captureAllMetaDataContent || meta.name.indexOf(prefix) === 0) {
|
|
234
|
-
const name = removePrefix ? meta.name.replace(prefix,
|
|
234
|
+
const name = removePrefix ? meta.name.replace(prefix, "") : meta.name;
|
|
235
235
|
metaData[name] = meta.content;
|
|
236
236
|
}
|
|
237
237
|
}
|
|
@@ -249,17 +249,17 @@ export class DomContentHandler implements IContentHandler {
|
|
|
249
249
|
*/
|
|
250
250
|
private _getDefaultContentName(element: any, useDefaultContentName: boolean) {
|
|
251
251
|
if (useDefaultContentName === false || !element.tagName) {
|
|
252
|
-
return
|
|
252
|
+
return "";
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
var doc = getDocument() || ({} as Document);
|
|
256
256
|
var contentName;
|
|
257
257
|
switch (element.tagName) {
|
|
258
|
-
case
|
|
258
|
+
case "A":
|
|
259
259
|
contentName = doc.all ? element.innerText || element.innerHTML : element.text || element.innerHTML;
|
|
260
260
|
break;
|
|
261
|
-
case
|
|
262
|
-
case
|
|
261
|
+
case "IMG":
|
|
262
|
+
case "AREA":
|
|
263
263
|
contentName = element.alt;
|
|
264
264
|
break;
|
|
265
265
|
default:
|
|
@@ -299,7 +299,7 @@ export class DomContentHandler implements IContentHandler {
|
|
|
299
299
|
|
|
300
300
|
htmlContent = {
|
|
301
301
|
id: element.id,
|
|
302
|
-
contentName: customizedContentName || defaultContentName || element.getAttribute(
|
|
302
|
+
contentName: customizedContentName || defaultContentName || element.getAttribute("alt")
|
|
303
303
|
};
|
|
304
304
|
}
|
|
305
305
|
|
|
@@ -312,8 +312,8 @@ export class DomContentHandler implements IContentHandler {
|
|
|
312
312
|
* @returns An object containing the closest parentId , can be empty if nothing was found
|
|
313
313
|
*/
|
|
314
314
|
private _getParentDetails(element: Element, elementContent: any, dataTagPrefix: string, aiBlobAttributeTag: string): IContent {
|
|
315
|
-
const parentId = elementContent[
|
|
316
|
-
const parentName = elementContent[
|
|
315
|
+
const parentId = elementContent["parentid"];
|
|
316
|
+
const parentName = elementContent["parentname"];
|
|
317
317
|
let parentInfo = {};
|
|
318
318
|
|
|
319
319
|
if (parentId || parentName || !element) {
|
|
@@ -352,12 +352,12 @@ export class DomContentHandler implements IContentHandler {
|
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
354
|
if (parentId) {
|
|
355
|
-
parentInfo[
|
|
355
|
+
parentInfo["parentid"] = parentId;
|
|
356
356
|
}
|
|
357
357
|
else {
|
|
358
358
|
let htmlContent= this._getHtmlIdAndContentName(element.parentElement);
|
|
359
|
-
parentInfo[
|
|
360
|
-
parentInfo[
|
|
359
|
+
parentInfo["parentid"] = htmlContent.id;
|
|
360
|
+
parentInfo["parentname"] = htmlContent.contentName;
|
|
361
361
|
}
|
|
362
362
|
return parentInfo;
|
|
363
363
|
}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { IPlugin, IConfiguration, IAppInsightsCore, BaseTelemetryPlugin, ITelemetryItem, IProcessTelemetryContext, ITelemetryPluginChain, ICustomProperties } from "@microsoft/applicationinsights-core-js";
|
|
5
5
|
import { IConfig } from "@microsoft/applicationinsights-common";
|
|
6
|
-
import { IPageActionTelemetry } from
|
|
7
|
-
import { BehaviorMapValidator, BehaviorValueValidator, BehaviorEnumValidator } from
|
|
6
|
+
import { IPageActionTelemetry } from "./Interfaces/Datamodel";
|
|
7
|
+
import { BehaviorMapValidator, BehaviorValueValidator, BehaviorEnumValidator } from "./common/Utils";
|
|
8
8
|
export { BehaviorMapValidator, BehaviorValueValidator, BehaviorEnumValidator };
|
|
9
9
|
export declare class ClickAnalyticsPlugin extends BaseTelemetryPlugin {
|
|
10
10
|
identifier: string;
|
package/types/DataCollector.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @copyright Microsoft 2020
|
|
3
3
|
*/
|
|
4
|
-
import { IClickAnalyticsConfiguration, IOverrideValues } from
|
|
4
|
+
import { IClickAnalyticsConfiguration, IOverrideValues } from "./Interfaces/Datamodel";
|
|
5
5
|
/**
|
|
6
6
|
* Get Image href of a given HTMLImageElement
|
|
7
7
|
* @param element - An html image element
|
package/types/common/Utils.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @copyright Microsoft 2020
|
|
3
3
|
* File containing utility functions.
|
|
4
4
|
*/
|
|
5
|
-
import { IClickAnalyticsConfiguration } from
|
|
5
|
+
import { IClickAnalyticsConfiguration } from "../Interfaces/Datamodel";
|
|
6
6
|
export declare const _ExtendedInternalMessageId: {
|
|
7
7
|
CannotParseAiBlobValue: number;
|
|
8
8
|
InvalidContentBlob: number;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @copyright Microsoft 2020
|
|
3
3
|
*/
|
|
4
|
-
import { WebEvent } from
|
|
4
|
+
import { WebEvent } from "./WebEvent";
|
|
5
5
|
import { ICustomProperties } from "@microsoft/applicationinsights-core-js";
|
|
6
|
-
import { IPageActionOverrideValues, IPageActionTelemetry } from
|
|
6
|
+
import { IPageActionOverrideValues, IPageActionTelemetry } from "../Interfaces/Datamodel";
|
|
7
7
|
export declare class PageAction extends WebEvent {
|
|
8
8
|
/**
|
|
9
9
|
* API to send pageAction event
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @copyright Microsoft 2020
|
|
3
3
|
*/
|
|
4
|
-
import { IDiagnosticLogger } from
|
|
5
|
-
import { IClickAnalyticsConfiguration, IPageTags, IOverrideValues, IContentHandler, IPageActionTelemetry } from
|
|
6
|
-
import { ClickAnalyticsPlugin } from
|
|
4
|
+
import { IDiagnosticLogger } from "@microsoft/applicationinsights-core-js";
|
|
5
|
+
import { IClickAnalyticsConfiguration, IPageTags, IOverrideValues, IContentHandler, IPageActionTelemetry } from "../Interfaces/Datamodel";
|
|
6
|
+
import { ClickAnalyticsPlugin } from "../ClickAnalyticsPlugin";
|
|
7
7
|
export declare class WebEvent {
|
|
8
8
|
protected _clickAnalyticsPlugin: ClickAnalyticsPlugin;
|
|
9
9
|
protected _config: IClickAnalyticsConfiguration;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* @copyright Microsoft 2020
|
|
3
3
|
*/
|
|
4
4
|
import { IDiagnosticLogger } from "@microsoft/applicationinsights-core-js";
|
|
5
|
-
import { IAutoCaptureHandler, IClickAnalyticsConfiguration } from
|
|
5
|
+
import { IAutoCaptureHandler, IClickAnalyticsConfiguration } from "../Interfaces/Datamodel";
|
|
6
6
|
import { ClickAnalyticsPlugin } from "../ClickAnalyticsPlugin";
|
|
7
|
-
import { PageAction } from
|
|
7
|
+
import { PageAction } from "../events/PageAction";
|
|
8
8
|
export declare class AutoCaptureHandler implements IAutoCaptureHandler {
|
|
9
9
|
protected _analyticsPlugin: ClickAnalyticsPlugin;
|
|
10
10
|
protected _config: IClickAnalyticsConfiguration;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IDiagnosticLogger } from "@microsoft/applicationinsights-core-js";
|
|
2
|
-
import { IClickAnalyticsConfiguration, IContent, IContentHandler } from
|
|
2
|
+
import { IClickAnalyticsConfiguration, IContent, IContentHandler } from "../Interfaces/Datamodel";
|
|
3
3
|
export declare class DomContentHandler implements IContentHandler {
|
|
4
4
|
protected _config: IClickAnalyticsConfiguration;
|
|
5
5
|
protected _traceLogger: IDiagnosticLogger;
|