@availity/analytics-core 1.0.0
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/CHANGELOG.md +435 -0
- package/README.md +25 -0
- package/dist/index.d.mts +82 -0
- package/dist/index.d.ts +82 -0
- package/dist/index.js +301 -0
- package/dist/index.mjs +264 -0
- package/jest.config.js +7 -0
- package/package.json +42 -0
- package/project.json +39 -0
- package/src/analytics.d.ts +47 -0
- package/src/analytics.js +197 -0
- package/src/dma.d.ts +13 -0
- package/src/dma.js +45 -0
- package/src/index.d.ts +4 -0
- package/src/index.js +4 -0
- package/src/plugin.d.ts +12 -0
- package/src/plugin.js +13 -0
- package/src/splunk.d.ts +13 -0
- package/src/splunk.js +17 -0
- package/src/tests/analytics.test.ts +187 -0
- package/src/tests/dma.test.ts +31 -0
- package/src/tests/plugin.test.ts +23 -0
- package/src/tests/splunk.test.ts +68 -0
- package/src/tests/util.test.ts +52 -0
- package/src/util.d.ts +14 -0
- package/src/util.js +39 -0
- package/tsconfig.json +5 -0
- package/tsconfig.spec.json +10 -0
package/src/util.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
declare const isLeftClickEvent: (event: any) => boolean;
|
|
3
|
+
|
|
4
|
+
declare const isModifiedEvent: (event: any) => boolean;
|
|
5
|
+
|
|
6
|
+
declare const isValidEventTypeOnTarget: (event: any) => boolean;
|
|
7
|
+
|
|
8
|
+
declare const isPluginEnabled: (plugin: any) => any;
|
|
9
|
+
|
|
10
|
+
declare const camelCase: (str: any) => any;
|
|
11
|
+
|
|
12
|
+
declare const getComposedPath: (node: any) => any;
|
|
13
|
+
|
|
14
|
+
export { isLeftClickEvent, isModifiedEvent, isValidEventTypeOnTarget, isPluginEnabled, camelCase, getComposedPath };
|
package/src/util.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const isLeftClickEvent = (event) => event.button === 0;
|
|
2
|
+
|
|
3
|
+
export const isModifiedEvent = (event) => !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
|
|
4
|
+
|
|
5
|
+
const trackMap = {
|
|
6
|
+
select: ['focus', 'blur'],
|
|
7
|
+
textarea: ['focus', 'blur'],
|
|
8
|
+
input: ['focus', 'blur'],
|
|
9
|
+
default: ['click'],
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const isValidEventTypeOnTarget = (event) =>
|
|
13
|
+
(trackMap[event.target.nodeName.toLowerCase()] || trackMap.default).indexOf(event.type) > -1;
|
|
14
|
+
|
|
15
|
+
export const isPluginEnabled = (plugin) =>
|
|
16
|
+
typeof plugin.isEnabled === 'function' ? plugin.isEnabled() : plugin.isEnabled;
|
|
17
|
+
|
|
18
|
+
export const camelCase = (str) => str.replace(/-([\da-z])/gi, (match, char) => char.toUpperCase());
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Polyfill for [`Event.composedPath()`][1].
|
|
22
|
+
* https://gist.github.com/kleinfreund/e9787d73776c0e3750dcfcdc89f100ec
|
|
23
|
+
*/
|
|
24
|
+
export const getComposedPath = (node) => {
|
|
25
|
+
let parent;
|
|
26
|
+
if (node.parentNode) {
|
|
27
|
+
parent = node.parentNode;
|
|
28
|
+
} else if (node.host) {
|
|
29
|
+
parent = node.host;
|
|
30
|
+
} else if (node.defaultView) {
|
|
31
|
+
parent = node.defaultView;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (parent !== undefined) {
|
|
35
|
+
return [node, ...getComposedPath(parent)];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return [node];
|
|
39
|
+
};
|
package/tsconfig.json
ADDED