@microsoft/applicationinsights-clickanalytics-js 2.8.0-beta.2203-10 → 2.8.0-beta.2203-11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/{ai.clck.2.8.0-beta.2203-10.cjs.js → ai.clck.2.8.0-beta.2203-11.cjs.js} +688 -514
- package/browser/ai.clck.2.8.0-beta.2203-11.cjs.js.map +1 -0
- package/browser/ai.clck.2.8.0-beta.2203-11.cjs.min.js +6 -0
- package/browser/ai.clck.2.8.0-beta.2203-11.cjs.min.js.map +1 -0
- package/browser/{ai.clck.2.8.0-beta.2203-10.gbl.js → ai.clck.2.8.0-beta.2203-11.gbl.js} +688 -514
- package/browser/ai.clck.2.8.0-beta.2203-11.gbl.js.map +1 -0
- package/browser/ai.clck.2.8.0-beta.2203-11.gbl.min.js +6 -0
- package/browser/ai.clck.2.8.0-beta.2203-11.gbl.min.js.map +1 -0
- package/browser/ai.clck.2.8.0-beta.2203-11.integrity.json +66 -0
- package/browser/{ai.clck.2.8.0-beta.2203-10.js → ai.clck.2.8.0-beta.2203-11.js} +688 -514
- package/browser/ai.clck.2.8.0-beta.2203-11.js.map +1 -0
- package/browser/ai.clck.2.8.0-beta.2203-11.min.js +6 -0
- package/browser/ai.clck.2.8.0-beta.2203-11.min.js.map +1 -0
- package/browser/ai.clck.2.cjs.js +687 -513
- 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 +687 -513
- 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 +687 -513
- package/browser/ai.clck.2.js.map +1 -1
- package/browser/ai.clck.2.min.js +2 -2
- package/browser/ai.clck.2.min.js.map +1 -1
- package/dist/applicationinsights-clickanalytics-js.api.json +15 -1
- package/dist/applicationinsights-clickanalytics-js.api.md +1 -0
- package/dist/applicationinsights-clickanalytics-js.d.ts +2 -5
- package/dist/applicationinsights-clickanalytics-js.js +687 -513
- package/dist/applicationinsights-clickanalytics-js.js.map +1 -1
- package/dist/applicationinsights-clickanalytics-js.min.js +2 -2
- package/dist/applicationinsights-clickanalytics-js.min.js.map +1 -1
- package/dist/applicationinsights-clickanalytics-js.rollup.d.ts +2 -5
- package/dist-esm/Behaviours.js +1 -1
- package/dist-esm/ClickAnalyticsPlugin.js +74 -50
- package/dist-esm/ClickAnalyticsPlugin.js.map +1 -1
- package/dist-esm/DataCollector.js +1 -1
- package/dist-esm/Enums.js +1 -1
- package/dist-esm/Interfaces/Datamodel.js +1 -1
- package/dist-esm/applicationinsights-clickanalytics-js.js +1 -1
- package/dist-esm/common/Utils.js +1 -1
- package/dist-esm/events/PageAction.js +128 -128
- package/dist-esm/events/PageAction.js.map +1 -1
- package/dist-esm/events/WebEvent.js +109 -94
- package/dist-esm/events/WebEvent.js.map +1 -1
- package/dist-esm/handlers/AutoCaptureHandler.js +85 -91
- package/dist-esm/handlers/AutoCaptureHandler.js.map +1 -1
- package/dist-esm/handlers/DomContentHandler.js +279 -280
- package/dist-esm/handlers/DomContentHandler.js.map +1 -1
- package/package.json +5 -5
- package/src/ClickAnalyticsPlugin.ts +91 -46
- package/src/Interfaces/Datamodel.ts +17 -18
- package/src/events/PageAction.ts +165 -134
- package/src/events/WebEvent.ts +147 -77
- package/src/handlers/AutoCaptureHandler.ts +88 -86
- package/src/handlers/DomContentHandler.ts +336 -310
- package/types/ClickAnalyticsPlugin.d.ts +1 -4
- package/types/Interfaces/Datamodel.d.ts +7 -6
- package/types/events/PageAction.d.ts +6 -6
- package/types/events/WebEvent.d.ts +17 -17
- package/types/handlers/AutoCaptureHandler.d.ts +2 -10
- package/types/handlers/DomContentHandler.d.ts +3 -50
- package/types/tsdoc-metadata.json +1 -1
- package/browser/ai.clck.2.8.0-beta.2203-10.cjs.js.map +0 -1
- package/browser/ai.clck.2.8.0-beta.2203-10.cjs.min.js +0 -6
- package/browser/ai.clck.2.8.0-beta.2203-10.cjs.min.js.map +0 -1
- package/browser/ai.clck.2.8.0-beta.2203-10.gbl.js.map +0 -1
- package/browser/ai.clck.2.8.0-beta.2203-10.gbl.min.js +0 -6
- package/browser/ai.clck.2.8.0-beta.2203-10.gbl.min.js.map +0 -1
- package/browser/ai.clck.2.8.0-beta.2203-10.integrity.json +0 -66
- package/browser/ai.clck.2.8.0-beta.2203-10.js.map +0 -1
- package/browser/ai.clck.2.8.0-beta.2203-10.min.js +0 -6
- package/browser/ai.clck.2.8.0-beta.2203-10.min.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Microsoft.ApplicationInsights, 2.8.0-beta.2203-
|
|
2
|
+
* Microsoft.ApplicationInsights, 2.8.0-beta.2203-11
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* Microsoft Application Insights Team
|
|
@@ -34,10 +34,7 @@ export declare class ClickAnalyticsPlugin extends BaseTelemetryPlugin {
|
|
|
34
34
|
identifier: string;
|
|
35
35
|
priority: number;
|
|
36
36
|
static Version: string;
|
|
37
|
-
|
|
38
|
-
private pageAction;
|
|
39
|
-
private _autoCaptureHandler;
|
|
40
|
-
private _contentHandler;
|
|
37
|
+
constructor();
|
|
41
38
|
initialize(config: IConfiguration & IConfig, core: IAppInsightsCore, extensions: IPlugin[], pluginChain?: ITelemetryPluginChain): void;
|
|
42
39
|
processTelemetry(env: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
|
|
43
40
|
/**
|
package/dist-esm/Behaviours.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Click Analytics, 2.8.0-beta.2203-
|
|
2
|
+
* Application Insights JavaScript SDK - Click Analytics, 2.8.0-beta.2203-11
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @copyright Microsoft 2020
|
|
7
7
|
*/
|
|
8
8
|
import { __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
|
|
9
|
-
import
|
|
9
|
+
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
10
|
+
import { BaseTelemetryPlugin, isNullOrUndefined, LoggingSeverity, arrForEach, dumpObj, getExceptionName, throwError, _throwInternal, unloadComponents } from "@microsoft/applicationinsights-core-js";
|
|
10
11
|
import { PropertiesPluginIdentifier } from "@microsoft/applicationinsights-common";
|
|
11
12
|
import { mergeConfig, BehaviorMapValidator, BehaviorValueValidator, BehaviorEnumValidator, _ExtendedInternalMessageId } from "./common/Utils";
|
|
12
13
|
import { PageAction } from "./events/PageAction";
|
|
@@ -16,58 +17,81 @@ export { BehaviorMapValidator, BehaviorValueValidator, BehaviorEnumValidator };
|
|
|
16
17
|
var ClickAnalyticsPlugin = /** @class */ (function (_super) {
|
|
17
18
|
__extends(ClickAnalyticsPlugin, _super);
|
|
18
19
|
function ClickAnalyticsPlugin() {
|
|
19
|
-
var _this = _super
|
|
20
|
+
var _this = _super.call(this) || this;
|
|
20
21
|
_this.identifier = "ClickAnalyticsPlugin";
|
|
21
22
|
_this.priority = 181;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
23
|
+
var _config;
|
|
24
|
+
var _pageAction;
|
|
25
|
+
var _autoCaptureHandler;
|
|
26
|
+
var _contentHandler;
|
|
27
|
+
dynamicProto(ClickAnalyticsPlugin, _this, function (_self, _base) {
|
|
28
|
+
var _identifier = _self.identifier;
|
|
29
|
+
_initDefaults();
|
|
30
|
+
_self.initialize = function (config, core, extensions, pluginChain) {
|
|
31
|
+
if (isNullOrUndefined(core)) {
|
|
32
|
+
throwError("Error initializing");
|
|
33
|
+
}
|
|
34
|
+
config.extensionConfig = config.extensionConfig || [];
|
|
35
|
+
config.extensionConfig[_identifier] = config.extensionConfig[_identifier] || {};
|
|
36
|
+
_config = mergeConfig(config.extensionConfig[_identifier]);
|
|
37
|
+
_super.prototype.initialize.call(_this, config, core, extensions, pluginChain);
|
|
38
|
+
var logger = _self.diagLog();
|
|
39
|
+
// Default to DOM content handler
|
|
40
|
+
_contentHandler = _contentHandler ? _contentHandler : new DomContentHandler(_config, logger);
|
|
41
|
+
var metaTags = _contentHandler.getMetadata();
|
|
42
|
+
_pageAction = new PageAction(_this, _config, _contentHandler, _config.callback.pageActionPageTags, metaTags, logger);
|
|
43
|
+
// Default to DOM autoCapture handler
|
|
44
|
+
_autoCaptureHandler = _autoCaptureHandler ? _autoCaptureHandler : new AutoCaptureHandler(_self, _config, _pageAction, logger);
|
|
45
|
+
if (_config.autoCapture) {
|
|
46
|
+
_autoCaptureHandler.click();
|
|
47
|
+
}
|
|
48
|
+
// Find the properties plugin.
|
|
49
|
+
var _propertiesExtension;
|
|
50
|
+
arrForEach(extensions, function (extension) {
|
|
51
|
+
if (extension.identifier === PropertiesPluginIdentifier) {
|
|
52
|
+
_propertiesExtension = extension;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
// Append Click Analytics Plugin Version to SDK version.
|
|
56
|
+
if (_propertiesExtension && _propertiesExtension.context &&
|
|
57
|
+
_propertiesExtension.context.internal && _propertiesExtension.context.internal.sdkVersion) {
|
|
58
|
+
_propertiesExtension.context.internal.sdkVersion += "_ClickPlugin" + ClickAnalyticsPlugin.Version;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
_self.processTelemetry = function (env, itemCtx) {
|
|
62
|
+
_self.processNext(env, itemCtx);
|
|
63
|
+
};
|
|
64
|
+
_self.trackPageAction = function (pageAction, customProperties) {
|
|
65
|
+
try {
|
|
66
|
+
_pageAction.trackPageAction(pageAction, customProperties);
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
_throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.TrackPageActionEventFailed, "trackPageAction failed, page action event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
_self._doTeardown = function (unloadCtx, unloadState, asyncCallback) {
|
|
73
|
+
return unloadComponents([
|
|
74
|
+
_autoCaptureHandler,
|
|
75
|
+
_contentHandler,
|
|
76
|
+
_pageAction
|
|
77
|
+
], unloadCtx, unloadState, function () {
|
|
78
|
+
_initDefaults();
|
|
79
|
+
asyncCallback && asyncCallback();
|
|
80
|
+
});
|
|
81
|
+
};
|
|
47
82
|
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
83
|
+
function _initDefaults() {
|
|
84
|
+
_config = null;
|
|
85
|
+
_pageAction = null;
|
|
86
|
+
_autoCaptureHandler = null;
|
|
87
|
+
_contentHandler = null;
|
|
52
88
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
* @param IPageActionTelemetry
|
|
60
|
-
* @param customProperties Additional data used to filter events and metrics. Defaults to empty.
|
|
61
|
-
*/
|
|
62
|
-
ClickAnalyticsPlugin.prototype.trackPageAction = function (pageAction, customProperties) {
|
|
63
|
-
try {
|
|
64
|
-
this.pageAction.trackPageAction(pageAction, customProperties);
|
|
65
|
-
}
|
|
66
|
-
catch (e) {
|
|
67
|
-
this.diagLog().throwInternal(LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.TrackPageActionEventFailed, "trackPageAction failed, page action event will not be collected: " + getExceptionName(e), { exception: dumpObj(e) });
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
ClickAnalyticsPlugin.Version = "2.8.0-beta.2203-10";
|
|
89
|
+
return _this;
|
|
90
|
+
}
|
|
91
|
+
// Removed Stub for ClickAnalyticsPlugin.prototype.initialize.
|
|
92
|
+
// Removed Stub for ClickAnalyticsPlugin.prototype.processTelemetry.
|
|
93
|
+
// Removed Stub for ClickAnalyticsPlugin.prototype.trackPageAction.
|
|
94
|
+
ClickAnalyticsPlugin.Version = "2.8.0-beta.2203-11";
|
|
71
95
|
return ClickAnalyticsPlugin;
|
|
72
96
|
}(BaseTelemetryPlugin));
|
|
73
97
|
export { ClickAnalyticsPlugin };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClickAnalyticsPlugin.js.map","sources":["ClickAnalyticsPlugin.js"],"sourcesContent":["/**\r\n * @copyright Microsoft 2020\r\n */\r\nimport { __extends } from \"tslib\";\r\nimport { BaseTelemetryPlugin, isNullOrUndefined, LoggingSeverity, arrForEach, dumpObj, getExceptionName } from \"@microsoft/applicationinsights-core-js\";\r\nimport { PropertiesPluginIdentifier } from \"@microsoft/applicationinsights-common\";\r\nimport { mergeConfig, BehaviorMapValidator, BehaviorValueValidator, BehaviorEnumValidator, _ExtendedInternalMessageId } from \"./common/Utils\";\r\nimport { PageAction } from \"./events/PageAction\";\r\nimport { AutoCaptureHandler } from \"./handlers/AutoCaptureHandler\";\r\nimport { DomContentHandler } from \"./handlers/DomContentHandler\";\r\nexport { BehaviorMapValidator, BehaviorValueValidator, BehaviorEnumValidator };\r\nvar ClickAnalyticsPlugin = /** @class */ (function (_super) {\r\n __extends(ClickAnalyticsPlugin, _super);\r\n function ClickAnalyticsPlugin() {\r\n var _this = _super
|
|
1
|
+
{"version":3,"file":"ClickAnalyticsPlugin.js.map","sources":["ClickAnalyticsPlugin.js"],"sourcesContent":["/**\r\n * @copyright Microsoft 2020\r\n */\r\nimport { __extends } from \"tslib\";\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { BaseTelemetryPlugin, isNullOrUndefined, LoggingSeverity, arrForEach, dumpObj, getExceptionName, throwError, _throwInternal, unloadComponents } from \"@microsoft/applicationinsights-core-js\";\r\nimport { PropertiesPluginIdentifier } from \"@microsoft/applicationinsights-common\";\r\nimport { mergeConfig, BehaviorMapValidator, BehaviorValueValidator, BehaviorEnumValidator, _ExtendedInternalMessageId } from \"./common/Utils\";\r\nimport { PageAction } from \"./events/PageAction\";\r\nimport { AutoCaptureHandler } from \"./handlers/AutoCaptureHandler\";\r\nimport { DomContentHandler } from \"./handlers/DomContentHandler\";\r\nexport { BehaviorMapValidator, BehaviorValueValidator, BehaviorEnumValidator };\r\nvar ClickAnalyticsPlugin = /** @class */ (function (_super) {\r\n __extends(ClickAnalyticsPlugin, _super);\r\n function ClickAnalyticsPlugin() {\r\n var _this = _super.call(this) || this;\r\n _this.identifier = \"ClickAnalyticsPlugin\";\r\n _this.priority = 181;\r\n var _config;\r\n var _pageAction;\r\n var _autoCaptureHandler;\r\n var _contentHandler;\r\n dynamicProto(ClickAnalyticsPlugin, _this, function (_self, _base) {\r\n var _identifier = _self.identifier;\r\n _initDefaults();\r\n _self.initialize = function (config, core, extensions, pluginChain) {\r\n if (isNullOrUndefined(core)) {\r\n throwError(\"Error initializing\");\r\n }\r\n config.extensionConfig = config.extensionConfig || [];\r\n config.extensionConfig[_identifier] = config.extensionConfig[_identifier] || {};\r\n _config = mergeConfig(config.extensionConfig[_identifier]);\r\n _super.prototype.initialize.call(_this, config, core, extensions, pluginChain);\r\n var logger = _self.diagLog();\r\n // Default to DOM content handler\r\n _contentHandler = _contentHandler ? _contentHandler : new DomContentHandler(_config, logger);\r\n var metaTags = _contentHandler.getMetadata();\r\n _pageAction = new PageAction(_this, _config, _contentHandler, _config.callback.pageActionPageTags, metaTags, logger);\r\n // Default to DOM autoCapture handler\r\n _autoCaptureHandler = _autoCaptureHandler ? _autoCaptureHandler : new AutoCaptureHandler(_self, _config, _pageAction, logger);\r\n if (_config.autoCapture) {\r\n _autoCaptureHandler.click();\r\n }\r\n // Find the properties plugin.\r\n var _propertiesExtension;\r\n arrForEach(extensions, function (extension) {\r\n if (extension.identifier === PropertiesPluginIdentifier) {\r\n _propertiesExtension = extension;\r\n }\r\n });\r\n // Append Click Analytics Plugin Version to SDK version.\r\n if (_propertiesExtension && _propertiesExtension.context &&\r\n _propertiesExtension.context.internal && _propertiesExtension.context.internal.sdkVersion) {\r\n _propertiesExtension.context.internal.sdkVersion += \"_ClickPlugin\" + ClickAnalyticsPlugin.Version;\r\n }\r\n };\r\n _self.processTelemetry = function (env, itemCtx) {\r\n _self.processNext(env, itemCtx);\r\n };\r\n _self.trackPageAction = function (pageAction, customProperties) {\r\n try {\r\n _pageAction.trackPageAction(pageAction, customProperties);\r\n }\r\n catch (e) {\r\n _throwInternal(_self.diagLog(), LoggingSeverity.CRITICAL, _ExtendedInternalMessageId.TrackPageActionEventFailed, \"trackPageAction failed, page action event will not be collected: \" + getExceptionName(e), { exception: dumpObj(e) });\r\n }\r\n };\r\n _self._doTeardown = function (unloadCtx, unloadState, asyncCallback) {\r\n return unloadComponents([\r\n _autoCaptureHandler,\r\n _contentHandler,\r\n _pageAction\r\n ], unloadCtx, unloadState, function () {\r\n _initDefaults();\r\n asyncCallback && asyncCallback();\r\n });\r\n };\r\n });\r\n function _initDefaults() {\r\n _config = null;\r\n _pageAction = null;\r\n _autoCaptureHandler = null;\r\n _contentHandler = null;\r\n }\r\n return _this;\r\n }\r\n ClickAnalyticsPlugin.prototype.initialize = function (config, core, extensions, pluginChain) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n ClickAnalyticsPlugin.prototype.processTelemetry = function (env, itemCtx) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * Logs a page action event.\r\n * @param IPageActionTelemetry\r\n * @param customProperties Additional data used to filter events and metrics. Defaults to empty.\r\n */\r\n ClickAnalyticsPlugin.prototype.trackPageAction = function (pageAction, customProperties) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n ClickAnalyticsPlugin.Version = \"2.8.0-beta.2203-11\";\r\n return ClickAnalyticsPlugin;\r\n}(BaseTelemetryPlugin));\r\nexport { ClickAnalyticsPlugin };\r\n//# sourceMappingURL=ClickAnalyticsPlugin.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA,gFAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;mEAaM;AACN;AACA;AACA;AACA;AACA"}
|
package/dist-esm/Enums.js
CHANGED
package/dist-esm/common/Utils.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Click Analytics, 2.8.0-beta.2203-
|
|
2
|
+
* Application Insights JavaScript SDK - Click Analytics, 2.8.0-beta.2203-11
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* @copyright Microsoft 2020
|
|
7
7
|
*/
|
|
8
8
|
import { __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
|
|
9
|
+
import dynamicProto from "@microsoft/dynamicproto-js";
|
|
9
10
|
import { WebEvent } from "./WebEvent";
|
|
10
11
|
import * as DataCollector from "../DataCollector";
|
|
11
12
|
import { getPerformance, LoggingSeverity, objForEachKey } from "@microsoft/applicationinsights-core-js";
|
|
@@ -13,138 +14,137 @@ import { extractFieldFromObject, bracketIt, isValueAssigned, extend, _ExtendedIn
|
|
|
13
14
|
import { strNotSpecified } from "@microsoft/applicationinsights-common";
|
|
14
15
|
var PageAction = /** @class */ (function (_super) {
|
|
15
16
|
__extends(PageAction, _super);
|
|
16
|
-
function PageAction() {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (properties) {
|
|
51
|
-
objForEachKey(properties, function (property, value) {
|
|
52
|
-
if (!event.data[property]) {
|
|
53
|
-
_this._populateEventDataIfPresent(event.data, property, value);
|
|
17
|
+
function PageAction(clickAnalyticsPlugin, config, contentHandler, pageTagsCallback, metaTags, traceLogger) {
|
|
18
|
+
var _this = _super.call(this, clickAnalyticsPlugin, config, contentHandler, pageTagsCallback, metaTags, traceLogger) || this;
|
|
19
|
+
dynamicProto(PageAction, _this, function (_self, _base) {
|
|
20
|
+
_self.trackPageAction = function (pageActionEvent, properties) {
|
|
21
|
+
// Get part A properties
|
|
22
|
+
var ext = {};
|
|
23
|
+
ext["web"] = {};
|
|
24
|
+
var event = {
|
|
25
|
+
name: "Microsoft.ApplicationInsights.{0}.Event",
|
|
26
|
+
baseType: "EventData",
|
|
27
|
+
ext: ext,
|
|
28
|
+
data: {},
|
|
29
|
+
baseData: {}
|
|
30
|
+
};
|
|
31
|
+
_populateEventDataIfPresent(event.baseData, "name", pageActionEvent.name);
|
|
32
|
+
_populateEventDataIfPresent(event.data, "baseTypeSource", "ClickEvent");
|
|
33
|
+
_populateEventDataIfPresent(event.data, "uri", pageActionEvent.uri);
|
|
34
|
+
_populateEventDataIfPresent(event.data, "pageType", pageActionEvent.pageType);
|
|
35
|
+
_populateEventDataIfPresent(event.data, "properties", pageActionEvent.properties);
|
|
36
|
+
_populateEventDataIfPresent(event.data, "actionType", pageActionEvent.actionType);
|
|
37
|
+
_populateEventDataIfPresent(event.data, "behavior", pageActionEvent.behavior);
|
|
38
|
+
_populateEventDataIfPresent(event.data, "clickCoordinates", pageActionEvent.clickCoordinates);
|
|
39
|
+
_populateEventDataIfPresent(event.data, "content", pageActionEvent.content);
|
|
40
|
+
_populateEventDataIfPresent(event.data, "targetUri", pageActionEvent.targetUri);
|
|
41
|
+
_populateEventDataIfPresent(event.data, "timeToAction", pageActionEvent.timeToAction);
|
|
42
|
+
_populateEventDataIfPresent(event.data, "refUri", pageActionEvent.refUri);
|
|
43
|
+
_populateEventDataIfPresent(event.data, "pageName", pageActionEvent.pageName);
|
|
44
|
+
_populateEventDataIfPresent(event.data, "parentId", pageActionEvent.parentId);
|
|
45
|
+
if (properties) {
|
|
46
|
+
objForEachKey(properties, function (property, value) {
|
|
47
|
+
if (!event.data[property]) {
|
|
48
|
+
_populateEventDataIfPresent(event.data, property, value);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
54
51
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
52
|
+
_self._clickAnalyticsPlugin.core.track(event);
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* API to create and send a populated PageAction event
|
|
56
|
+
* @param element - DOM element
|
|
57
|
+
* @param overrideValues - PageAction overrides
|
|
58
|
+
* @param customProperties - Custom properties(Part C)
|
|
59
|
+
* @param isRightClick - Flag for mouse right clicks
|
|
60
|
+
*/
|
|
61
|
+
_self.capturePageAction = function (element, overrideValues, customProperties, isRightClick) {
|
|
62
|
+
overrideValues = !isValueAssigned(overrideValues) ? {} : overrideValues;
|
|
63
|
+
var pageActionEvent = { name: "" };
|
|
64
|
+
var pageActionProperties = isValueAssigned(customProperties) ? customProperties : {};
|
|
65
|
+
_self.setCommonProperties(pageActionEvent, overrideValues);
|
|
66
|
+
pageActionEvent.behavior = _self._getBehavior(overrideValues);
|
|
67
|
+
// element in scope is needed for below properties. We cannot pass element into the plugin call chain.
|
|
68
|
+
// process them here.
|
|
69
|
+
var elementContent = {};
|
|
70
|
+
if (isRightClick) {
|
|
71
|
+
// Default behavior for righ click
|
|
72
|
+
pageActionEvent.behavior = _self._config.defaultRightClickBhvr;
|
|
73
|
+
}
|
|
74
|
+
// Fill PartB
|
|
75
|
+
if (element) {
|
|
76
|
+
pageActionEvent.targetUri = DataCollector.getClickTarget(element);
|
|
77
|
+
elementContent = _self._contentHandler.getElementContent(element); // collect id,cn tags
|
|
78
|
+
// if the element has a data-*-bhvr attrib defined, use it.
|
|
79
|
+
if (elementContent.bhvr && !isValueAssigned(overrideValues.behavior)) {
|
|
80
|
+
var currentBehavior = extractFieldFromObject(elementContent, "bhvr");
|
|
81
|
+
pageActionEvent.behavior = _self._getValidBehavior(currentBehavior);
|
|
82
|
+
}
|
|
83
|
+
// Validate to ensure the minimum required field 'contentName' or 'id' is present. However,
|
|
84
|
+
// requiring these fields would result in majority of adopter's content from being collected.
|
|
85
|
+
// Just throw a warning and continue collection.
|
|
86
|
+
if (!isValueAssigned(elementContent.id) && !isValueAssigned(elementContent.contentName)) {
|
|
87
|
+
_self._traceLogger.throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.InvalidContentBlob, "Missing attributes id or contentName in click event. Click event information will still be collected!");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
pageActionEvent.name = elementContent.id || elementContent.contentName || strNotSpecified;
|
|
91
|
+
pageActionEvent.parentId = elementContent.parentid || elementContent.parentName || strNotSpecified;
|
|
92
|
+
if (isValueAssigned(overrideValues.actionType)) {
|
|
93
|
+
pageActionEvent.actionType = overrideValues.actionType;
|
|
94
|
+
}
|
|
95
|
+
if (isValueAssigned(overrideValues.clickCoordinateX) && isValueAssigned(overrideValues.clickCoordinateY)) {
|
|
96
|
+
pageActionEvent.clickCoordinates = overrideValues.clickCoordinateX + "X" + overrideValues.clickCoordinateY;
|
|
97
|
+
}
|
|
98
|
+
_sanitizePageActionEventContent(elementContent);
|
|
99
|
+
pageActionEvent.content = bracketIt(JSON.stringify(extend(elementContent, overrideValues && overrideValues.contentTags ? overrideValues.contentTags : {})));
|
|
100
|
+
pageActionEvent.timeToAction = _getTimeToClick();
|
|
101
|
+
pageActionEvent.refUri = isValueAssigned(overrideValues.refUri) ? overrideValues.refUri : _self._config.coreData.referrerUri;
|
|
102
|
+
if (_isUndefinedEvent(pageActionEvent)) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
_self.trackPageAction(pageActionEvent, pageActionProperties);
|
|
106
|
+
};
|
|
107
|
+
// capture performance data into PageTags
|
|
108
|
+
function _getTimeToClick() {
|
|
109
|
+
var perf = getPerformance();
|
|
110
|
+
if (perf && perf.timing) {
|
|
111
|
+
var isNavigationStart = perf.timing.navigationStart;
|
|
112
|
+
if (isNavigationStart && isNavigationStart !== 0) {
|
|
113
|
+
return new Date().getTime() - isNavigationStart;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return -1;
|
|
93
117
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
pageActionEvent.actionType = overrideValues.actionType;
|
|
99
|
-
}
|
|
100
|
-
if (isValueAssigned(overrideValues.clickCoordinateX) && isValueAssigned(overrideValues.clickCoordinateY)) {
|
|
101
|
-
pageActionEvent.clickCoordinates = overrideValues.clickCoordinateX + "X" + overrideValues.clickCoordinateY;
|
|
102
|
-
}
|
|
103
|
-
this._sanitizePageActionEventContent(elementContent);
|
|
104
|
-
pageActionEvent.content = bracketIt(JSON.stringify(extend(elementContent, overrideValues && overrideValues.contentTags ? overrideValues.contentTags : {})));
|
|
105
|
-
pageActionEvent.timeToAction = this._getTimeToClick();
|
|
106
|
-
pageActionEvent.refUri = isValueAssigned(overrideValues.refUri) ? overrideValues.refUri : this._config.coreData.referrerUri;
|
|
107
|
-
if (this._isUndefinedEvent(pageActionEvent)) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
this.trackPageAction(pageActionEvent, pageActionProperties);
|
|
111
|
-
};
|
|
112
|
-
// capture performance data into PageTags
|
|
113
|
-
PageAction.prototype._getTimeToClick = function () {
|
|
114
|
-
var perf = getPerformance();
|
|
115
|
-
if (perf && perf.timing) {
|
|
116
|
-
var isNavigationStart = perf.timing.navigationStart;
|
|
117
|
-
if (isNavigationStart && isNavigationStart !== 0) {
|
|
118
|
-
return new Date().getTime() - isNavigationStart;
|
|
118
|
+
function _populateEventDataIfPresent(obj, property, value) {
|
|
119
|
+
if (isValueAssigned(value)) {
|
|
120
|
+
obj[property] = value;
|
|
121
|
+
}
|
|
119
122
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if (pageActionContent) {
|
|
130
|
-
delete pageActionContent.id;
|
|
131
|
-
delete pageActionContent.parentid;
|
|
132
|
-
delete pageActionContent.parentname;
|
|
133
|
-
if (this._config && this._config.dataTags && isValueAssigned(this._config.dataTags.parentDataTag)) {
|
|
134
|
-
delete pageActionContent[this._config.dataTags.parentDataTag];
|
|
123
|
+
function _sanitizePageActionEventContent(pageActionContent) {
|
|
124
|
+
if (pageActionContent) {
|
|
125
|
+
delete pageActionContent.id;
|
|
126
|
+
delete pageActionContent.parentid;
|
|
127
|
+
delete pageActionContent.parentname;
|
|
128
|
+
if (_self._config && _self._config.dataTags && isValueAssigned(_self._config.dataTags.parentDataTag)) {
|
|
129
|
+
delete pageActionContent[_self._config.dataTags.parentDataTag];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
135
132
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
133
|
+
function _isUndefinedEvent(pageActionEvent) {
|
|
134
|
+
if (_self._config.dropInvalidEvents) {
|
|
135
|
+
if (pageActionEvent.name === strNotSpecified
|
|
136
|
+
&& pageActionEvent.parentId === strNotSpecified
|
|
137
|
+
&& pageActionEvent.content === "[{}]") {
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return false;
|
|
144
142
|
}
|
|
145
|
-
}
|
|
146
|
-
return
|
|
147
|
-
}
|
|
143
|
+
});
|
|
144
|
+
return _this;
|
|
145
|
+
}
|
|
146
|
+
// Removed Stub for PageAction.prototype.trackPageAction.
|
|
147
|
+
// Removed Stub for PageAction.prototype.capturePageAction.
|
|
148
148
|
return PageAction;
|
|
149
149
|
}(WebEvent));
|
|
150
150
|
export { PageAction };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PageAction.js.map","sources":["PageAction.js"],"sourcesContent":["/**\r\n * @copyright Microsoft 2020\r\n */\r\nimport { __extends } from \"tslib\";\r\nimport { WebEvent } from \"./WebEvent\";\r\nimport * as DataCollector from \"../DataCollector\";\r\nimport { getPerformance, LoggingSeverity, objForEachKey } from \"@microsoft/applicationinsights-core-js\";\r\nimport { extractFieldFromObject, bracketIt, isValueAssigned, extend, _ExtendedInternalMessageId } from \"../common/Utils\";\r\nimport { strNotSpecified } from \"@microsoft/applicationinsights-common\";\r\nvar PageAction = /** @class */ (function (_super) {\r\n __extends(PageAction, _super);\r\n function PageAction() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n /**\r\n * API to send pageAction event\r\n * @param pageActionEvent - PageAction event\r\n * @param properties - PageAction properties(Part C)\r\n */\r\n PageAction.prototype.trackPageAction = function (pageActionEvent, properties) {\r\n var _this = this;\r\n // Get part A properties\r\n var ext = {};\r\n ext[\"web\"] = {};\r\n var event = {\r\n name: \"Microsoft.ApplicationInsights.{0}.Event\",\r\n baseType: \"EventData\",\r\n ext: ext,\r\n data: {},\r\n baseData: {}\r\n };\r\n this._populateEventDataIfPresent(event.baseData, \"name\", pageActionEvent.name);\r\n this._populateEventDataIfPresent(event.data, \"baseTypeSource\", \"ClickEvent\");\r\n this._populateEventDataIfPresent(event.data, \"uri\", pageActionEvent.uri);\r\n this._populateEventDataIfPresent(event.data, \"pageType\", pageActionEvent.pageType);\r\n this._populateEventDataIfPresent(event.data, \"properties\", pageActionEvent.properties);\r\n this._populateEventDataIfPresent(event.data, \"actionType\", pageActionEvent.actionType);\r\n this._populateEventDataIfPresent(event.data, \"behavior\", pageActionEvent.behavior);\r\n this._populateEventDataIfPresent(event.data, \"clickCoordinates\", pageActionEvent.clickCoordinates);\r\n this._populateEventDataIfPresent(event.data, \"content\", pageActionEvent.content);\r\n this._populateEventDataIfPresent(event.data, \"targetUri\", pageActionEvent.targetUri);\r\n this._populateEventDataIfPresent(event.data, \"timeToAction\", pageActionEvent.timeToAction);\r\n this._populateEventDataIfPresent(event.data, \"refUri\", pageActionEvent.refUri);\r\n this._populateEventDataIfPresent(event.data, \"pageName\", pageActionEvent.pageName);\r\n this._populateEventDataIfPresent(event.data, \"parentId\", pageActionEvent.parentId);\r\n if (properties) {\r\n objForEachKey(properties, function (property, value) {\r\n if (!event.data[property]) {\r\n _this._populateEventDataIfPresent(event.data, property, value);\r\n }\r\n });\r\n }\r\n this._clickAnalyticsPlugin.core.track(event);\r\n };\r\n /**\r\n * API to create and send a populated PageAction event\r\n * @param element - DOM element\r\n * @param overrideValues - PageAction overrides\r\n * @param customProperties - Custom properties(Part C)\r\n * @param isRightClick - Flag for mouse right clicks\r\n */\r\n PageAction.prototype.capturePageAction = function (element, overrideValues, customProperties, isRightClick) {\r\n overrideValues = !isValueAssigned(overrideValues) ? {} : overrideValues;\r\n var pageActionEvent = { name: \"\" };\r\n var pageActionProperties = isValueAssigned(customProperties) ? customProperties : {};\r\n this.setCommonProperties(pageActionEvent, overrideValues);\r\n pageActionEvent.behavior = this._getBehavior(overrideValues);\r\n // element in scope is needed for below properties. We cannot pass element into the plugin call chain.\r\n // process them here.\r\n var elementContent = {};\r\n if (isRightClick) {\r\n // Default behavior for righ click\r\n pageActionEvent.behavior = this._config.defaultRightClickBhvr;\r\n }\r\n // Fill PartB\r\n if (element) {\r\n pageActionEvent.targetUri = DataCollector.getClickTarget(element);\r\n elementContent = this._contentHandler.getElementContent(element); // collect id,cn tags\r\n // if the element has a data-*-bhvr attrib defined, use it.\r\n if (elementContent.bhvr && !isValueAssigned(overrideValues.behavior)) {\r\n var currentBehavior = extractFieldFromObject(elementContent, \"bhvr\");\r\n pageActionEvent.behavior = this._getValidBehavior(currentBehavior);\r\n }\r\n // Validate to ensure the minimum required field 'contentName' or 'id' is present. 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 (!isValueAssigned(elementContent.id) && !isValueAssigned(elementContent.contentName)) {\r\n this._traceLogger.throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.InvalidContentBlob, \"Missing attributes id or contentName in click event. Click event information will still be collected!\");\r\n }\r\n }\r\n pageActionEvent.name = elementContent.id || elementContent.contentName || strNotSpecified;\r\n pageActionEvent.parentId = elementContent.parentid || elementContent.parentName || strNotSpecified;\r\n if (isValueAssigned(overrideValues.actionType)) {\r\n pageActionEvent.actionType = overrideValues.actionType;\r\n }\r\n if (isValueAssigned(overrideValues.clickCoordinateX) && isValueAssigned(overrideValues.clickCoordinateY)) {\r\n pageActionEvent.clickCoordinates = overrideValues.clickCoordinateX + \"X\" + overrideValues.clickCoordinateY;\r\n }\r\n this._sanitizePageActionEventContent(elementContent);\r\n pageActionEvent.content = bracketIt(JSON.stringify(extend(elementContent, overrideValues && overrideValues.contentTags ? overrideValues.contentTags : {})));\r\n pageActionEvent.timeToAction = this._getTimeToClick();\r\n pageActionEvent.refUri = isValueAssigned(overrideValues.refUri) ? overrideValues.refUri : this._config.coreData.referrerUri;\r\n if (this._isUndefinedEvent(pageActionEvent)) {\r\n return;\r\n }\r\n this.trackPageAction(pageActionEvent, pageActionProperties);\r\n };\r\n // capture performance data into PageTags\r\n PageAction.prototype._getTimeToClick = function () {\r\n var perf = getPerformance();\r\n if (perf && perf.timing) {\r\n var isNavigationStart = perf.timing.navigationStart;\r\n if (isNavigationStart && isNavigationStart !== 0) {\r\n return new Date().getTime() - isNavigationStart;\r\n }\r\n }\r\n return -1;\r\n };\r\n PageAction.prototype._populateEventDataIfPresent = function (obj, property, value) {\r\n if (isValueAssigned(value)) {\r\n obj[property] = value;\r\n }\r\n };\r\n PageAction.prototype._sanitizePageActionEventContent = function (pageActionContent) {\r\n if (pageActionContent) {\r\n delete pageActionContent.id;\r\n delete pageActionContent.parentid;\r\n delete pageActionContent.parentname;\r\n if (this._config && this._config.dataTags && isValueAssigned(this._config.dataTags.parentDataTag)) {\r\n delete pageActionContent[this._config.dataTags.parentDataTag];\r\n }\r\n }\r\n };\r\n PageAction.prototype._isUndefinedEvent = function (pageActionEvent) {\r\n if (this._config.dropInvalidEvents) {\r\n if (pageActionEvent.name === strNotSpecified\r\n && pageActionEvent.parentId === strNotSpecified\r\n && pageActionEvent.content === \"[{}]\") {\r\n return true;\r\n }\r\n }\r\n return false;\r\n };\r\n return PageAction;\r\n}(WebEvent));\r\nexport { PageAction };\r\n//# sourceMappingURL=PageAction.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA,gFAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
1
|
+
{"version":3,"file":"PageAction.js.map","sources":["PageAction.js"],"sourcesContent":["/**\r\n * @copyright Microsoft 2020\r\n */\r\nimport { __extends } from \"tslib\";\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { WebEvent } from \"./WebEvent\";\r\nimport * as DataCollector from \"../DataCollector\";\r\nimport { getPerformance, LoggingSeverity, objForEachKey } from \"@microsoft/applicationinsights-core-js\";\r\nimport { extractFieldFromObject, bracketIt, isValueAssigned, extend, _ExtendedInternalMessageId } from \"../common/Utils\";\r\nimport { strNotSpecified } from \"@microsoft/applicationinsights-common\";\r\nvar PageAction = /** @class */ (function (_super) {\r\n __extends(PageAction, _super);\r\n function PageAction(clickAnalyticsPlugin, config, contentHandler, pageTagsCallback, metaTags, traceLogger) {\r\n var _this = _super.call(this, clickAnalyticsPlugin, config, contentHandler, pageTagsCallback, metaTags, traceLogger) || this;\r\n dynamicProto(PageAction, _this, function (_self, _base) {\r\n _self.trackPageAction = function (pageActionEvent, properties) {\r\n // Get part A properties\r\n var ext = {};\r\n ext[\"web\"] = {};\r\n var event = {\r\n name: \"Microsoft.ApplicationInsights.{0}.Event\",\r\n baseType: \"EventData\",\r\n ext: ext,\r\n data: {},\r\n baseData: {}\r\n };\r\n _populateEventDataIfPresent(event.baseData, \"name\", pageActionEvent.name);\r\n _populateEventDataIfPresent(event.data, \"baseTypeSource\", \"ClickEvent\");\r\n _populateEventDataIfPresent(event.data, \"uri\", pageActionEvent.uri);\r\n _populateEventDataIfPresent(event.data, \"pageType\", pageActionEvent.pageType);\r\n _populateEventDataIfPresent(event.data, \"properties\", pageActionEvent.properties);\r\n _populateEventDataIfPresent(event.data, \"actionType\", pageActionEvent.actionType);\r\n _populateEventDataIfPresent(event.data, \"behavior\", pageActionEvent.behavior);\r\n _populateEventDataIfPresent(event.data, \"clickCoordinates\", pageActionEvent.clickCoordinates);\r\n _populateEventDataIfPresent(event.data, \"content\", pageActionEvent.content);\r\n _populateEventDataIfPresent(event.data, \"targetUri\", pageActionEvent.targetUri);\r\n _populateEventDataIfPresent(event.data, \"timeToAction\", pageActionEvent.timeToAction);\r\n _populateEventDataIfPresent(event.data, \"refUri\", pageActionEvent.refUri);\r\n _populateEventDataIfPresent(event.data, \"pageName\", pageActionEvent.pageName);\r\n _populateEventDataIfPresent(event.data, \"parentId\", pageActionEvent.parentId);\r\n if (properties) {\r\n objForEachKey(properties, function (property, value) {\r\n if (!event.data[property]) {\r\n _populateEventDataIfPresent(event.data, property, value);\r\n }\r\n });\r\n }\r\n _self._clickAnalyticsPlugin.core.track(event);\r\n };\r\n /**\r\n * API to create and send a populated PageAction event\r\n * @param element - DOM element\r\n * @param overrideValues - PageAction overrides\r\n * @param customProperties - Custom properties(Part C)\r\n * @param isRightClick - Flag for mouse right clicks\r\n */\r\n _self.capturePageAction = function (element, overrideValues, customProperties, isRightClick) {\r\n overrideValues = !isValueAssigned(overrideValues) ? {} : overrideValues;\r\n var pageActionEvent = { name: \"\" };\r\n var pageActionProperties = isValueAssigned(customProperties) ? customProperties : {};\r\n _self.setCommonProperties(pageActionEvent, overrideValues);\r\n pageActionEvent.behavior = _self._getBehavior(overrideValues);\r\n // element in scope is needed for below properties. We cannot pass element into the plugin call chain.\r\n // process them here.\r\n var elementContent = {};\r\n if (isRightClick) {\r\n // Default behavior for righ click\r\n pageActionEvent.behavior = _self._config.defaultRightClickBhvr;\r\n }\r\n // Fill PartB\r\n if (element) {\r\n pageActionEvent.targetUri = DataCollector.getClickTarget(element);\r\n elementContent = _self._contentHandler.getElementContent(element); // collect id,cn tags\r\n // if the element has a data-*-bhvr attrib defined, use it.\r\n if (elementContent.bhvr && !isValueAssigned(overrideValues.behavior)) {\r\n var currentBehavior = extractFieldFromObject(elementContent, \"bhvr\");\r\n pageActionEvent.behavior = _self._getValidBehavior(currentBehavior);\r\n }\r\n // Validate to ensure the minimum required field 'contentName' or 'id' is present. 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 (!isValueAssigned(elementContent.id) && !isValueAssigned(elementContent.contentName)) {\r\n _self._traceLogger.throwInternal(LoggingSeverity.WARNING, _ExtendedInternalMessageId.InvalidContentBlob, \"Missing attributes id or contentName in click event. Click event information will still be collected!\");\r\n }\r\n }\r\n pageActionEvent.name = elementContent.id || elementContent.contentName || strNotSpecified;\r\n pageActionEvent.parentId = elementContent.parentid || elementContent.parentName || strNotSpecified;\r\n if (isValueAssigned(overrideValues.actionType)) {\r\n pageActionEvent.actionType = overrideValues.actionType;\r\n }\r\n if (isValueAssigned(overrideValues.clickCoordinateX) && isValueAssigned(overrideValues.clickCoordinateY)) {\r\n pageActionEvent.clickCoordinates = overrideValues.clickCoordinateX + \"X\" + overrideValues.clickCoordinateY;\r\n }\r\n _sanitizePageActionEventContent(elementContent);\r\n pageActionEvent.content = bracketIt(JSON.stringify(extend(elementContent, overrideValues && overrideValues.contentTags ? overrideValues.contentTags : {})));\r\n pageActionEvent.timeToAction = _getTimeToClick();\r\n pageActionEvent.refUri = isValueAssigned(overrideValues.refUri) ? overrideValues.refUri : _self._config.coreData.referrerUri;\r\n if (_isUndefinedEvent(pageActionEvent)) {\r\n return;\r\n }\r\n _self.trackPageAction(pageActionEvent, pageActionProperties);\r\n };\r\n // capture performance data into PageTags\r\n function _getTimeToClick() {\r\n var perf = getPerformance();\r\n if (perf && perf.timing) {\r\n var isNavigationStart = perf.timing.navigationStart;\r\n if (isNavigationStart && isNavigationStart !== 0) {\r\n return new Date().getTime() - isNavigationStart;\r\n }\r\n }\r\n return -1;\r\n }\r\n function _populateEventDataIfPresent(obj, property, value) {\r\n if (isValueAssigned(value)) {\r\n obj[property] = value;\r\n }\r\n }\r\n function _sanitizePageActionEventContent(pageActionContent) {\r\n if (pageActionContent) {\r\n delete pageActionContent.id;\r\n delete pageActionContent.parentid;\r\n delete pageActionContent.parentname;\r\n if (_self._config && _self._config.dataTags && isValueAssigned(_self._config.dataTags.parentDataTag)) {\r\n delete pageActionContent[_self._config.dataTags.parentDataTag];\r\n }\r\n }\r\n }\r\n function _isUndefinedEvent(pageActionEvent) {\r\n if (_self._config.dropInvalidEvents) {\r\n if (pageActionEvent.name === strNotSpecified\r\n && pageActionEvent.parentId === strNotSpecified\r\n && pageActionEvent.content === \"[{}]\") {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n });\r\n return _this;\r\n }\r\n /**\r\n * API to send pageAction event\r\n * @param pageActionEvent - PageAction event\r\n * @param properties - PageAction properties(Part C)\r\n */\r\n PageAction.prototype.trackPageAction = function (pageActionEvent, properties) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n /**\r\n * API to create and send a populated PageAction event\r\n * @param element - DOM element\r\n * @param overrideValues - PageAction overrides\r\n * @param customProperties - Custom properties(Part C)\r\n * @param isRightClick - Flag for mouse right clicks\r\n */\r\n PageAction.prototype.capturePageAction = function (element, overrideValues, customProperties, isRightClick) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return PageAction;\r\n}(WebEvent));\r\nexport { PageAction };\r\n//# sourceMappingURL=PageAction.js.map"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA,gFAAkC;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;2DAiBM;AACN;AACA;AACA;AACA"}
|