@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/dist/index.js ADDED
@@ -0,0 +1,301 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __export = (target, all) => {
23
+ for (var name in all)
24
+ __defProp(target, name, { get: all[name], enumerable: true });
25
+ };
26
+ var __copyProps = (to, from, except, desc) => {
27
+ if (from && typeof from === "object" || typeof from === "function") {
28
+ for (let key of __getOwnPropNames(from))
29
+ if (!__hasOwnProp.call(to, key) && key !== except)
30
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
31
+ }
32
+ return to;
33
+ };
34
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
35
+ // If the importer is in node compatibility mode or this is not an ESM
36
+ // file that has been converted to a CommonJS file using a Babel-
37
+ // compatible transform (i.e. "__esModule" has not been set), then set
38
+ // "default" to the CommonJS "module.exports" for node compatibility.
39
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
40
+ mod
41
+ ));
42
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
43
+ var __publicField = (obj, key, value) => {
44
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
45
+ return value;
46
+ };
47
+
48
+ // src/index.js
49
+ var src_exports = {};
50
+ __export(src_exports, {
51
+ AvAnalytics: () => AvAnalytics,
52
+ AvAnalyticsPlugin: () => AvAnalyticsPlugin,
53
+ AvDmaAnalytics: () => AvDmaAnalytics,
54
+ AvSplunkAnalytics: () => AvSplunkAnalytics
55
+ });
56
+ module.exports = __toCommonJS(src_exports);
57
+
58
+ // src/util.js
59
+ var isLeftClickEvent = (event) => event.button === 0;
60
+ var isModifiedEvent = (event) => !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
61
+ var trackMap = {
62
+ select: ["focus", "blur"],
63
+ textarea: ["focus", "blur"],
64
+ input: ["focus", "blur"],
65
+ default: ["click"]
66
+ };
67
+ var isValidEventTypeOnTarget = (event) => (trackMap[event.target.nodeName.toLowerCase()] || trackMap.default).indexOf(event.type) > -1;
68
+ var isPluginEnabled = (plugin) => typeof plugin.isEnabled === "function" ? plugin.isEnabled() : plugin.isEnabled;
69
+ var camelCase = (str) => str.replace(/-([\da-z])/gi, (match, char) => char.toUpperCase());
70
+ var getComposedPath = (node) => {
71
+ let parent;
72
+ if (node.parentNode) {
73
+ parent = node.parentNode;
74
+ } else if (node.host) {
75
+ parent = node.host;
76
+ } else if (node.defaultView) {
77
+ parent = node.defaultView;
78
+ }
79
+ if (parent !== void 0) {
80
+ return [node, ...getComposedPath(parent)];
81
+ }
82
+ return [node];
83
+ };
84
+
85
+ // src/analytics.js
86
+ var AvAnalytics = class {
87
+ constructor(plugins, promise = Promise, pageTracking, autoTrack = true, options = {}) {
88
+ __publicField(this, "startAutoTrack", () => {
89
+ document.body.addEventListener("click", this.handleEvent, true);
90
+ document.body.addEventListener("focus", this.handleEvent, true);
91
+ document.body.addEventListener("blur", this.handleEvent, true);
92
+ });
93
+ __publicField(this, "stopAutoTrack", () => {
94
+ document.body.removeEventListener("click", this.handleEvent, true);
95
+ document.body.removeEventListener("focus", this.handleEvent, true);
96
+ document.body.removeEventListener("blur", this.handleEvent, true);
97
+ });
98
+ __publicField(this, "handleEvent", (event) => {
99
+ if (this.invalidEvent(event)) {
100
+ return;
101
+ }
102
+ const target = event.target || event.srcElement;
103
+ const path = getComposedPath(event.target);
104
+ let analyticAttrs = {};
105
+ if (this.recursive) {
106
+ for (const pth of path.reverse()) {
107
+ const attrs = this.getAnalyticAttrs(pth);
108
+ analyticAttrs = __spreadValues(__spreadValues({}, analyticAttrs), attrs);
109
+ if (Object.keys(attrs).length > 0) {
110
+ analyticAttrs.elemId = pth.getAttribute("id") || pth.getAttribute("name") || void 0;
111
+ }
112
+ }
113
+ } else {
114
+ analyticAttrs = this.getAnalyticAttrs(target);
115
+ }
116
+ const actions = analyticAttrs ? this.eventModifiers.filter((mod) => analyticAttrs[mod] === event.type) : [];
117
+ if (Object.keys(analyticAttrs).length === 0 || this.recursive && actions.length === 0 || actions.length === 0) {
118
+ return;
119
+ }
120
+ analyticAttrs.action = analyticAttrs.action || event.type;
121
+ analyticAttrs.event = event.type;
122
+ analyticAttrs.elemId = analyticAttrs.elemId || target.getAttribute("id") || target.getAttribute("name") || void 0;
123
+ if (analyticAttrs.elemId === void 0) {
124
+ delete analyticAttrs.elemId;
125
+ }
126
+ for (const key of actions) {
127
+ if (key !== "action" && key !== "event") {
128
+ delete analyticAttrs[key];
129
+ }
130
+ }
131
+ this.trackEvent(analyticAttrs);
132
+ });
133
+ __publicField(this, "invalidEvent", (event) => isModifiedEvent(event) || event.type === "click" && !isLeftClickEvent(event) || !isValidEventTypeOnTarget(event));
134
+ __publicField(this, "getAnalyticAttrs", (elem) => {
135
+ if (!elem.attributes) {
136
+ return {};
137
+ }
138
+ const attrs = elem.attributes;
139
+ const analyticAttrs = {};
140
+ if (elem.nodeType === 1) {
141
+ for (let i = attrs.length - 1; i >= 0; i--) {
142
+ const { name } = attrs[i];
143
+ if (name.indexOf(`${this.attributePrefix}-`) === 0) {
144
+ const camelName = camelCase(name.slice(this.attributePrefix.length + 1));
145
+ analyticAttrs[camelName] = elem.getAttribute(name);
146
+ }
147
+ }
148
+ }
149
+ return analyticAttrs;
150
+ });
151
+ __publicField(this, "startPageTracking", () => {
152
+ if (!this.pageListener) {
153
+ this.pageListener = this.trackPageView;
154
+ window.addEventListener("hashchange", this.pageListener, false);
155
+ }
156
+ });
157
+ __publicField(this, "stopPageTracking", () => {
158
+ if (this.pageListener) {
159
+ window.removeEventListener("hashchange", this.pageListener, false);
160
+ delete this.pageListener;
161
+ }
162
+ });
163
+ __publicField(this, "init", () => {
164
+ this.setPageTracking();
165
+ for (const plugin of this.plugins) {
166
+ if (isPluginEnabled(plugin) && typeof plugin.init === "function") {
167
+ plugin.init();
168
+ }
169
+ }
170
+ });
171
+ __publicField(this, "setPageTracking", (value) => {
172
+ if (value != void 0) {
173
+ this.pageTracking = !!value;
174
+ }
175
+ const canPageTrack = typeof this.startPageTracking === "function" && typeof this.stopPageTracking === "function";
176
+ if (canPageTrack && this.pageTracking !== this.isPageTracking) {
177
+ if (this.pageTracking) {
178
+ this.startPageTracking();
179
+ } else {
180
+ this.stopPageTracking();
181
+ }
182
+ this.isPageTracking = this.pageTracking;
183
+ }
184
+ });
185
+ __publicField(this, "trackEvent", (properties) => {
186
+ const promises = [];
187
+ properties.url = properties.url || window.location.href || "N/A";
188
+ for (const plugin of this.plugins) {
189
+ const props = __spreadValues({}, properties);
190
+ if (isPluginEnabled(plugin) && typeof plugin.trackEvent === "function") {
191
+ promises.push(plugin.trackEvent(props));
192
+ }
193
+ }
194
+ return this.Promise.all(promises);
195
+ });
196
+ __publicField(this, "trackPageView", (url) => {
197
+ if (typeof url === "object") {
198
+ url = url.newURL;
199
+ }
200
+ url = url || window.location.href;
201
+ const promises = [];
202
+ for (const plugin of this.plugins) {
203
+ if (isPluginEnabled(plugin) && typeof plugin.trackPageView === "function") {
204
+ promises.push(plugin.trackPageView(url));
205
+ }
206
+ }
207
+ return this.Promise.all(promises);
208
+ });
209
+ if (!plugins || !promise) {
210
+ throw new Error("[plugins] and [promise] must be defined");
211
+ }
212
+ this.plugins = Array.isArray(plugins) ? plugins : [plugins];
213
+ this.pageTracking = !!pageTracking;
214
+ if (options.eventModifiers) {
215
+ this.eventModifiers = Array.isArray(options.eventModifiers) ? options.eventModifiers : [options.eventModifiers];
216
+ } else {
217
+ this.eventModifiers = ["action"];
218
+ }
219
+ this.Promise = promise;
220
+ this.recursive = !!options.recursive;
221
+ this.attributePrefix = options.attributePrefix || "data-analytics";
222
+ this.isPageTracking = false;
223
+ this.hasInit = false;
224
+ if (autoTrack) {
225
+ this.startAutoTrack();
226
+ }
227
+ }
228
+ };
229
+
230
+ // src/plugin.js
231
+ var AvAnalyticsPlugin = class {
232
+ constructor(enabled = true) {
233
+ this.enabled = !!enabled;
234
+ }
235
+ trackEvent() {
236
+ }
237
+ trackPageView() {
238
+ }
239
+ isEnabled() {
240
+ return this.enabled;
241
+ }
242
+ };
243
+
244
+ // src/splunk.js
245
+ var AvSplunkAnalytics = class extends AvAnalyticsPlugin {
246
+ constructor(AvLogMessages, enabled) {
247
+ super(enabled);
248
+ this.AvLogMessages = AvLogMessages;
249
+ }
250
+ trackEvent(properties) {
251
+ properties.level = properties.level || "info";
252
+ return this.AvLogMessages[properties.level](properties);
253
+ }
254
+ trackPageView(url) {
255
+ return this.trackEvent({ event: "page", url });
256
+ }
257
+ };
258
+
259
+ // src/dma.js
260
+ var yup = __toESM(require("yup"));
261
+ var schema = yup.object().shape({
262
+ level: yup.string().optional(),
263
+ applicationId: yup.string().optional(),
264
+ payerSpaceId: yup.string().optional(),
265
+ label: yup.string().optional(),
266
+ appName: yup.string().optional(),
267
+ category: yup.string().optional(),
268
+ section: yup.string().optional(),
269
+ url: yup.string().optional(),
270
+ value: yup.string().optional(),
271
+ raw: yup.string().optional(),
272
+ feed: yup.string().optional(),
273
+ feedback: yup.string().optional(),
274
+ feedbackName: yup.string().optional(),
275
+ additionalFeedback: yup.string().optional(),
276
+ smile: yup.string().optional(),
277
+ surveyId: yup.string().optional()
278
+ }).noUnknown(true);
279
+ var AvDmaAnalytics = class extends AvAnalyticsPlugin {
280
+ constructor(AvLogMessages, enabled) {
281
+ super(enabled);
282
+ this.AvLogMessages = AvLogMessages;
283
+ }
284
+ trackEvent(properties) {
285
+ properties.level = properties.level || "info";
286
+ schema.validateSync(properties, {
287
+ strict: true
288
+ });
289
+ return this.AvLogMessages[properties.level](properties);
290
+ }
291
+ trackPageView(url) {
292
+ return this.trackEvent({ event: "page", url });
293
+ }
294
+ };
295
+ // Annotate the CommonJS export names for ESM import in node:
296
+ 0 && (module.exports = {
297
+ AvAnalytics,
298
+ AvAnalyticsPlugin,
299
+ AvDmaAnalytics,
300
+ AvSplunkAnalytics
301
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,264 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __publicField = (obj, key, value) => {
18
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
19
+ return value;
20
+ };
21
+
22
+ // src/util.js
23
+ var isLeftClickEvent = (event) => event.button === 0;
24
+ var isModifiedEvent = (event) => !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
25
+ var trackMap = {
26
+ select: ["focus", "blur"],
27
+ textarea: ["focus", "blur"],
28
+ input: ["focus", "blur"],
29
+ default: ["click"]
30
+ };
31
+ var isValidEventTypeOnTarget = (event) => (trackMap[event.target.nodeName.toLowerCase()] || trackMap.default).indexOf(event.type) > -1;
32
+ var isPluginEnabled = (plugin) => typeof plugin.isEnabled === "function" ? plugin.isEnabled() : plugin.isEnabled;
33
+ var camelCase = (str) => str.replace(/-([\da-z])/gi, (match, char) => char.toUpperCase());
34
+ var getComposedPath = (node) => {
35
+ let parent;
36
+ if (node.parentNode) {
37
+ parent = node.parentNode;
38
+ } else if (node.host) {
39
+ parent = node.host;
40
+ } else if (node.defaultView) {
41
+ parent = node.defaultView;
42
+ }
43
+ if (parent !== void 0) {
44
+ return [node, ...getComposedPath(parent)];
45
+ }
46
+ return [node];
47
+ };
48
+
49
+ // src/analytics.js
50
+ var AvAnalytics = class {
51
+ constructor(plugins, promise = Promise, pageTracking, autoTrack = true, options = {}) {
52
+ __publicField(this, "startAutoTrack", () => {
53
+ document.body.addEventListener("click", this.handleEvent, true);
54
+ document.body.addEventListener("focus", this.handleEvent, true);
55
+ document.body.addEventListener("blur", this.handleEvent, true);
56
+ });
57
+ __publicField(this, "stopAutoTrack", () => {
58
+ document.body.removeEventListener("click", this.handleEvent, true);
59
+ document.body.removeEventListener("focus", this.handleEvent, true);
60
+ document.body.removeEventListener("blur", this.handleEvent, true);
61
+ });
62
+ __publicField(this, "handleEvent", (event) => {
63
+ if (this.invalidEvent(event)) {
64
+ return;
65
+ }
66
+ const target = event.target || event.srcElement;
67
+ const path = getComposedPath(event.target);
68
+ let analyticAttrs = {};
69
+ if (this.recursive) {
70
+ for (const pth of path.reverse()) {
71
+ const attrs = this.getAnalyticAttrs(pth);
72
+ analyticAttrs = __spreadValues(__spreadValues({}, analyticAttrs), attrs);
73
+ if (Object.keys(attrs).length > 0) {
74
+ analyticAttrs.elemId = pth.getAttribute("id") || pth.getAttribute("name") || void 0;
75
+ }
76
+ }
77
+ } else {
78
+ analyticAttrs = this.getAnalyticAttrs(target);
79
+ }
80
+ const actions = analyticAttrs ? this.eventModifiers.filter((mod) => analyticAttrs[mod] === event.type) : [];
81
+ if (Object.keys(analyticAttrs).length === 0 || this.recursive && actions.length === 0 || actions.length === 0) {
82
+ return;
83
+ }
84
+ analyticAttrs.action = analyticAttrs.action || event.type;
85
+ analyticAttrs.event = event.type;
86
+ analyticAttrs.elemId = analyticAttrs.elemId || target.getAttribute("id") || target.getAttribute("name") || void 0;
87
+ if (analyticAttrs.elemId === void 0) {
88
+ delete analyticAttrs.elemId;
89
+ }
90
+ for (const key of actions) {
91
+ if (key !== "action" && key !== "event") {
92
+ delete analyticAttrs[key];
93
+ }
94
+ }
95
+ this.trackEvent(analyticAttrs);
96
+ });
97
+ __publicField(this, "invalidEvent", (event) => isModifiedEvent(event) || event.type === "click" && !isLeftClickEvent(event) || !isValidEventTypeOnTarget(event));
98
+ __publicField(this, "getAnalyticAttrs", (elem) => {
99
+ if (!elem.attributes) {
100
+ return {};
101
+ }
102
+ const attrs = elem.attributes;
103
+ const analyticAttrs = {};
104
+ if (elem.nodeType === 1) {
105
+ for (let i = attrs.length - 1; i >= 0; i--) {
106
+ const { name } = attrs[i];
107
+ if (name.indexOf(`${this.attributePrefix}-`) === 0) {
108
+ const camelName = camelCase(name.slice(this.attributePrefix.length + 1));
109
+ analyticAttrs[camelName] = elem.getAttribute(name);
110
+ }
111
+ }
112
+ }
113
+ return analyticAttrs;
114
+ });
115
+ __publicField(this, "startPageTracking", () => {
116
+ if (!this.pageListener) {
117
+ this.pageListener = this.trackPageView;
118
+ window.addEventListener("hashchange", this.pageListener, false);
119
+ }
120
+ });
121
+ __publicField(this, "stopPageTracking", () => {
122
+ if (this.pageListener) {
123
+ window.removeEventListener("hashchange", this.pageListener, false);
124
+ delete this.pageListener;
125
+ }
126
+ });
127
+ __publicField(this, "init", () => {
128
+ this.setPageTracking();
129
+ for (const plugin of this.plugins) {
130
+ if (isPluginEnabled(plugin) && typeof plugin.init === "function") {
131
+ plugin.init();
132
+ }
133
+ }
134
+ });
135
+ __publicField(this, "setPageTracking", (value) => {
136
+ if (value != void 0) {
137
+ this.pageTracking = !!value;
138
+ }
139
+ const canPageTrack = typeof this.startPageTracking === "function" && typeof this.stopPageTracking === "function";
140
+ if (canPageTrack && this.pageTracking !== this.isPageTracking) {
141
+ if (this.pageTracking) {
142
+ this.startPageTracking();
143
+ } else {
144
+ this.stopPageTracking();
145
+ }
146
+ this.isPageTracking = this.pageTracking;
147
+ }
148
+ });
149
+ __publicField(this, "trackEvent", (properties) => {
150
+ const promises = [];
151
+ properties.url = properties.url || window.location.href || "N/A";
152
+ for (const plugin of this.plugins) {
153
+ const props = __spreadValues({}, properties);
154
+ if (isPluginEnabled(plugin) && typeof plugin.trackEvent === "function") {
155
+ promises.push(plugin.trackEvent(props));
156
+ }
157
+ }
158
+ return this.Promise.all(promises);
159
+ });
160
+ __publicField(this, "trackPageView", (url) => {
161
+ if (typeof url === "object") {
162
+ url = url.newURL;
163
+ }
164
+ url = url || window.location.href;
165
+ const promises = [];
166
+ for (const plugin of this.plugins) {
167
+ if (isPluginEnabled(plugin) && typeof plugin.trackPageView === "function") {
168
+ promises.push(plugin.trackPageView(url));
169
+ }
170
+ }
171
+ return this.Promise.all(promises);
172
+ });
173
+ if (!plugins || !promise) {
174
+ throw new Error("[plugins] and [promise] must be defined");
175
+ }
176
+ this.plugins = Array.isArray(plugins) ? plugins : [plugins];
177
+ this.pageTracking = !!pageTracking;
178
+ if (options.eventModifiers) {
179
+ this.eventModifiers = Array.isArray(options.eventModifiers) ? options.eventModifiers : [options.eventModifiers];
180
+ } else {
181
+ this.eventModifiers = ["action"];
182
+ }
183
+ this.Promise = promise;
184
+ this.recursive = !!options.recursive;
185
+ this.attributePrefix = options.attributePrefix || "data-analytics";
186
+ this.isPageTracking = false;
187
+ this.hasInit = false;
188
+ if (autoTrack) {
189
+ this.startAutoTrack();
190
+ }
191
+ }
192
+ };
193
+
194
+ // src/plugin.js
195
+ var AvAnalyticsPlugin = class {
196
+ constructor(enabled = true) {
197
+ this.enabled = !!enabled;
198
+ }
199
+ trackEvent() {
200
+ }
201
+ trackPageView() {
202
+ }
203
+ isEnabled() {
204
+ return this.enabled;
205
+ }
206
+ };
207
+
208
+ // src/splunk.js
209
+ var AvSplunkAnalytics = class extends AvAnalyticsPlugin {
210
+ constructor(AvLogMessages, enabled) {
211
+ super(enabled);
212
+ this.AvLogMessages = AvLogMessages;
213
+ }
214
+ trackEvent(properties) {
215
+ properties.level = properties.level || "info";
216
+ return this.AvLogMessages[properties.level](properties);
217
+ }
218
+ trackPageView(url) {
219
+ return this.trackEvent({ event: "page", url });
220
+ }
221
+ };
222
+
223
+ // src/dma.js
224
+ import * as yup from "yup";
225
+ var schema = yup.object().shape({
226
+ level: yup.string().optional(),
227
+ applicationId: yup.string().optional(),
228
+ payerSpaceId: yup.string().optional(),
229
+ label: yup.string().optional(),
230
+ appName: yup.string().optional(),
231
+ category: yup.string().optional(),
232
+ section: yup.string().optional(),
233
+ url: yup.string().optional(),
234
+ value: yup.string().optional(),
235
+ raw: yup.string().optional(),
236
+ feed: yup.string().optional(),
237
+ feedback: yup.string().optional(),
238
+ feedbackName: yup.string().optional(),
239
+ additionalFeedback: yup.string().optional(),
240
+ smile: yup.string().optional(),
241
+ surveyId: yup.string().optional()
242
+ }).noUnknown(true);
243
+ var AvDmaAnalytics = class extends AvAnalyticsPlugin {
244
+ constructor(AvLogMessages, enabled) {
245
+ super(enabled);
246
+ this.AvLogMessages = AvLogMessages;
247
+ }
248
+ trackEvent(properties) {
249
+ properties.level = properties.level || "info";
250
+ schema.validateSync(properties, {
251
+ strict: true
252
+ });
253
+ return this.AvLogMessages[properties.level](properties);
254
+ }
255
+ trackPageView(url) {
256
+ return this.trackEvent({ event: "page", url });
257
+ }
258
+ };
259
+ export {
260
+ AvAnalytics,
261
+ AvAnalyticsPlugin,
262
+ AvDmaAnalytics,
263
+ AvSplunkAnalytics
264
+ };
package/jest.config.js ADDED
@@ -0,0 +1,7 @@
1
+ const global = require('../../jest.config');
2
+
3
+ module.exports = {
4
+ ...global,
5
+ displayName: 'analytics-core',
6
+ coverageDirectory: '../../coverage/analytics-core',
7
+ };
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@availity/analytics-core",
3
+ "version": "1.0.0",
4
+ "description": "Analytics base configuration for sdk-js",
5
+ "keywords": [
6
+ "availity",
7
+ "analytics"
8
+ ],
9
+ "homepage": "https://availity.github.io/sdk-js/resources/analytics",
10
+ "bugs": {
11
+ "url": "https://github.com/availity/sdk-js/issues"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/availity/sdk-js.git",
16
+ "directory": "packages/analytics-core"
17
+ },
18
+ "license": "MIT",
19
+ "author": "Kasey Powers <kasey.powers@availity.com>",
20
+ "browser": "./dist/index.js",
21
+ "main": "./dist/index.js",
22
+ "module": "./dist/index.mjs",
23
+ "types": "./dist/index.d.ts",
24
+ "scripts": {
25
+ "build": "tsup src/index.js --format esm,cjs --dts",
26
+ "dev": "tsup src/index.js --format esm,cjs --watch --dts",
27
+ "clean": "rm -rf node_modules && rm -rf dist",
28
+ "bundlesize": "bundlesize",
29
+ "publish": "yarn npm publish --tolerate-republish --access public"
30
+ },
31
+ "dependencies": {
32
+ "yup": "^0.32.11"
33
+ },
34
+ "devDependencies": {
35
+ "@availity/api-axios": "1.0.0",
36
+ "tsup": "^7.2.0",
37
+ "typescript": "^5.1.6"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public"
41
+ }
42
+ }
package/project.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "root": "packages/analytics-core",
3
+ "projectType": "library",
4
+ "targets": {
5
+ "test": {
6
+ "executor": "@nx/jest:jest",
7
+ "outputs": ["coverage/analytics-core"],
8
+ "options": {
9
+ "jestConfig": "packages/analytics-core/jest.config.js",
10
+ "passWithNoTests": true
11
+ }
12
+ },
13
+ "version": {
14
+ "executor": "@jscutlery/semver:version",
15
+ "options": {
16
+ "preset": "angular",
17
+ "commitMessageFormat": "chore(${projectName}): release version ${version} [skip ci]",
18
+ "tagPrefix": "@availity/${projectName}@",
19
+ "baseBranch": "master"
20
+ }
21
+ },
22
+ "lint": {
23
+ "executor": "@nx/linter:eslint",
24
+ "options": {
25
+ "eslintConfig": ".eslintrc.yaml",
26
+ "lintFilePatterns": ["packages/analytics-core/**/*.{js,ts}"],
27
+ "silent": false,
28
+ "fix": false,
29
+ "cache": true,
30
+ "cacheLocation": "./node_modules/.cache/analytics-core/.eslintcache",
31
+ "maxWarnings": -1,
32
+ "quiet": false,
33
+ "noEslintrc": false,
34
+ "hasTypeAwareRules": true,
35
+ "cacheStrategy": "metadata"
36
+ }
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,47 @@
1
+ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ declare class AvAnalytics {
4
+ plugins: any[];
5
+
6
+ attributePrefix: string;
7
+
8
+ recursive: boolean;
9
+
10
+ pageTracking: boolean;
11
+
12
+ isPageTracking: boolean;
13
+
14
+ hasInit: boolean;
15
+
16
+ constructor(
17
+ plugins: any | any[],
18
+ promise?: PromiseConstructor,
19
+ pageTracking?: boolean,
20
+ autoTrack?: boolean,
21
+ options?: Record<string, any>
22
+ );
23
+
24
+ startAutoTrack(): void;
25
+
26
+ stopAutoTrack(): void;
27
+
28
+ handleEvent(event: any): void;
29
+
30
+ invalidEvent(event: any): boolean;
31
+
32
+ getAnalyticAttrs(elem: any): any;
33
+
34
+ startPageTracking(): void;
35
+
36
+ stopPageTracking(): void;
37
+
38
+ init(): void;
39
+
40
+ setPageTracking(value?: any): void;
41
+
42
+ trackEvent(properties: any): Promise<any[]>;
43
+
44
+ trackPageView(url?: string): Promise<any[]>;
45
+ }
46
+
47
+ export default AvAnalytics;