@availity/analytics-core 6.0.10 → 6.1.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 CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ # [6.1.0](https://github.com/availity/sdk-js/compare/@availity/analytics-core@6.0.10...@availity/analytics-core@6.1.0) (2026-03-13)
6
+
7
+ ### Dependency Updates
8
+
9
+ * `api-axios` updated to version `6.0.10`
10
+
11
+ ### Features
12
+
13
+ * **analytics-core, api-axios:** add overrides support to /log endpoint ([043e2ae](https://github.com/availity/sdk-js/commit/043e2ae8c04175aeab2740147cf05150468708c8))
14
+
15
+
16
+
5
17
  ## [6.0.10](https://github.com/availity/sdk-js/compare/@availity/analytics-core@6.0.9...@availity/analytics-core@6.0.10) (2026-02-27)
6
18
 
7
19
  ### Dependency Updates
package/dist/index.js CHANGED
@@ -142,9 +142,7 @@ var AvAnalytics = class {
142
142
  });
143
143
  __publicField(this, "invalidEvent", (event) => isModifiedEvent(event) || event.type === "click" && !isLeftClickEvent(event) || !isValidEventTypeOnTarget(event));
144
144
  __publicField(this, "getAnalyticAttrs", (elem) => {
145
- if (!elem.attributes) {
146
- return {};
147
- }
145
+ if (!elem.attributes) return {};
148
146
  const attrs = elem.attributes;
149
147
  const analyticAttrs = {};
150
148
  if (elem.nodeType === 1) {
@@ -155,6 +153,18 @@ var AvAnalytics = class {
155
153
  analyticAttrs[camelName] = elem.getAttribute(name);
156
154
  }
157
155
  }
156
+ if (this.hasLogPlugin) {
157
+ const overridesKeys = Object.keys(analyticAttrs).filter((key) => key.startsWith("overrides"));
158
+ if (overridesKeys.length > 0) {
159
+ analyticAttrs.overrides = {};
160
+ for (const key of overridesKeys) {
161
+ const nestedKey = key.slice(9);
162
+ const finalKey = nestedKey.charAt(0).toLowerCase() + nestedKey.slice(1);
163
+ analyticAttrs.overrides[finalKey] = analyticAttrs[key];
164
+ delete analyticAttrs[key];
165
+ }
166
+ }
167
+ }
158
168
  }
159
169
  return analyticAttrs;
160
170
  });
@@ -231,6 +241,11 @@ var AvAnalytics = class {
231
241
  this.attributePrefix = options.attributePrefix || "data-analytics";
232
242
  this.isPageTracking = false;
233
243
  this.hasInit = false;
244
+ this.hasLogPlugin = this.plugins.some((plugin) => {
245
+ var _a, _b;
246
+ const apiName = (_b = (_a = plugin.AvLogMessages) == null ? void 0 : _a.defaultConfig) == null ? void 0 : _b.name;
247
+ return apiName === "appl/analytics/log" || apiName === "spc/analytics/log";
248
+ });
234
249
  if (autoTrack) {
235
250
  this.startAutoTrack();
236
251
  }
package/dist/index.mjs CHANGED
@@ -105,9 +105,7 @@ var AvAnalytics = class {
105
105
  });
106
106
  __publicField(this, "invalidEvent", (event) => isModifiedEvent(event) || event.type === "click" && !isLeftClickEvent(event) || !isValidEventTypeOnTarget(event));
107
107
  __publicField(this, "getAnalyticAttrs", (elem) => {
108
- if (!elem.attributes) {
109
- return {};
110
- }
108
+ if (!elem.attributes) return {};
111
109
  const attrs = elem.attributes;
112
110
  const analyticAttrs = {};
113
111
  if (elem.nodeType === 1) {
@@ -118,6 +116,18 @@ var AvAnalytics = class {
118
116
  analyticAttrs[camelName] = elem.getAttribute(name);
119
117
  }
120
118
  }
119
+ if (this.hasLogPlugin) {
120
+ const overridesKeys = Object.keys(analyticAttrs).filter((key) => key.startsWith("overrides"));
121
+ if (overridesKeys.length > 0) {
122
+ analyticAttrs.overrides = {};
123
+ for (const key of overridesKeys) {
124
+ const nestedKey = key.slice(9);
125
+ const finalKey = nestedKey.charAt(0).toLowerCase() + nestedKey.slice(1);
126
+ analyticAttrs.overrides[finalKey] = analyticAttrs[key];
127
+ delete analyticAttrs[key];
128
+ }
129
+ }
130
+ }
121
131
  }
122
132
  return analyticAttrs;
123
133
  });
@@ -194,6 +204,11 @@ var AvAnalytics = class {
194
204
  this.attributePrefix = options.attributePrefix || "data-analytics";
195
205
  this.isPageTracking = false;
196
206
  this.hasInit = false;
207
+ this.hasLogPlugin = this.plugins.some((plugin) => {
208
+ var _a, _b;
209
+ const apiName = (_b = (_a = plugin.AvLogMessages) == null ? void 0 : _a.defaultConfig) == null ? void 0 : _b.name;
210
+ return apiName === "appl/analytics/log" || apiName === "spc/analytics/log";
211
+ });
197
212
  if (autoTrack) {
198
213
  this.startAutoTrack();
199
214
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@availity/analytics-core",
3
- "version": "6.0.10",
3
+ "version": "6.1.0",
4
4
  "description": "Analytics base configuration for sdk-js",
5
5
  "keywords": [
6
6
  "availity",
@@ -43,7 +43,7 @@
43
43
  "yup": "^0.32.11"
44
44
  },
45
45
  "devDependencies": {
46
- "@availity/api-axios": "12.0.4",
46
+ "@availity/api-axios": "12.1.0",
47
47
  "tsup": "^8.4.0",
48
48
  "typescript": "^5.5.4"
49
49
  },
package/src/analytics.js CHANGED
@@ -31,6 +31,11 @@ export default class AvAnalytics {
31
31
  this.isPageTracking = false;
32
32
  this.hasInit = false;
33
33
 
34
+ this.hasLogPlugin = this.plugins.some((plugin) => {
35
+ const apiName = plugin.AvLogMessages?.defaultConfig?.name;
36
+ return apiName === 'appl/analytics/log' || apiName === 'spc/analytics/log';
37
+ });
38
+
34
39
  if (autoTrack) {
35
40
  this.startAutoTrack();
36
41
  }
@@ -102,9 +107,7 @@ export default class AvAnalytics {
102
107
  isModifiedEvent(event) || (event.type === 'click' && !isLeftClickEvent(event)) || !isValidEventTypeOnTarget(event);
103
108
 
104
109
  getAnalyticAttrs = (elem) => {
105
- if (!elem.attributes) {
106
- return {};
107
- }
110
+ if (!elem.attributes) return {};
108
111
 
109
112
  const attrs = elem.attributes;
110
113
  const analyticAttrs = {};
@@ -117,6 +120,19 @@ export default class AvAnalytics {
117
120
  analyticAttrs[camelName] = elem.getAttribute(name);
118
121
  }
119
122
  }
123
+
124
+ if (this.hasLogPlugin) {
125
+ const overridesKeys = Object.keys(analyticAttrs).filter(key => key.startsWith('overrides'));
126
+ if (overridesKeys.length > 0) {
127
+ analyticAttrs.overrides = {};
128
+ for (const key of overridesKeys) {
129
+ const nestedKey = key.slice(9); // Remove 'overrides'
130
+ const finalKey = nestedKey.charAt(0).toLowerCase() + nestedKey.slice(1);
131
+ analyticAttrs.overrides[finalKey] = analyticAttrs[key];
132
+ delete analyticAttrs[key];
133
+ }
134
+ }
135
+ }
120
136
  }
121
137
  return analyticAttrs;
122
138
  };
@@ -1,3 +1,4 @@
1
+ /* eslint-disable unicorn/prefer-dom-node-dataset */
1
2
  import { AvAnalytics } from '..';
2
3
 
3
4
  type MockPlugin = {
@@ -184,4 +185,135 @@ describe('AvAnalytics', () => {
184
185
  expect(plugins[1].trackPageView).toHaveBeenCalledWith(mockUrl);
185
186
  });
186
187
  });
188
+
189
+ describe('getAnalyticAttrs with nested overrides', () => {
190
+ let logPlugin: MockPlugin & { AvLogMessages?: { defaultConfig: { name: string } } };
191
+ let mockApiV2: { defaultConfig: { name: string } };
192
+ let mockApiV3: { defaultConfig: { name: string } };
193
+
194
+ beforeEach(() => {
195
+ logPlugin = makePlugin();
196
+ mockApiV2 = { defaultConfig: { name: 'spc/analytics/log' } };
197
+ mockApiV3 = { defaultConfig: { name: 'appl/analytics/log' } };
198
+ });
199
+
200
+ test('should extract nested overrides when AvLogMessagesApiV3 plugin is registered', () => {
201
+ logPlugin.AvLogMessages = mockApiV3;
202
+ mockAvAnalytics = new AvAnalytics([logPlugin], Promise, false, false);
203
+
204
+ const elem = document.createElement('button');
205
+ elem.setAttribute('data-analytics-category', 'error');
206
+ elem.setAttribute('data-analytics-overrides-endpoint', '/custom/log');
207
+ elem.setAttribute('data-analytics-overrides-timeout', '5000');
208
+
209
+ const attrs = mockAvAnalytics.getAnalyticAttrs(elem);
210
+
211
+ expect(attrs).toEqual({
212
+ category: 'error',
213
+ overrides: {
214
+ endpoint: '/custom/log',
215
+ timeout: '5000',
216
+ },
217
+ });
218
+ });
219
+
220
+ test('should extract nested overrides when AvLogMessagesApiV2 plugin is registered', () => {
221
+ logPlugin.AvLogMessages = mockApiV2;
222
+ mockAvAnalytics = new AvAnalytics([logPlugin], Promise, false, false);
223
+
224
+ const elem = document.createElement('button');
225
+ elem.setAttribute('data-analytics-overrides-retry', 'true');
226
+
227
+ const attrs = mockAvAnalytics.getAnalyticAttrs(elem);
228
+
229
+ expect(attrs).toEqual({
230
+ overrides: {
231
+ retry: 'true',
232
+ },
233
+ });
234
+ });
235
+
236
+ test('should NOT extract nested overrides when no log plugin is registered', () => {
237
+ const googlePlugin = makePlugin();
238
+ mockAvAnalytics = new AvAnalytics([googlePlugin], Promise, false, false);
239
+
240
+ const elem = document.createElement('button');
241
+ elem.setAttribute('data-analytics-category', 'button');
242
+ elem.setAttribute('data-analytics-overrides-endpoint', '/custom/log');
243
+
244
+ const attrs = mockAvAnalytics.getAnalyticAttrs(elem);
245
+
246
+ expect(attrs).toEqual({
247
+ category: 'button',
248
+ overridesEndpoint: '/custom/log',
249
+ });
250
+ });
251
+
252
+ test('should NOT extract nested overrides when plugin has no AvLogMessages', () => {
253
+ const plugin = makePlugin();
254
+ mockAvAnalytics = new AvAnalytics([plugin], Promise, false, false);
255
+
256
+ const elem = document.createElement('button');
257
+ elem.setAttribute('data-analytics-category', 'button');
258
+ elem.setAttribute('data-analytics-overrides-endpoint', '/custom/log');
259
+
260
+ const attrs = mockAvAnalytics.getAnalyticAttrs(elem);
261
+
262
+ expect(attrs).toEqual({
263
+ category: 'button',
264
+ overridesEndpoint: '/custom/log',
265
+ });
266
+ });
267
+
268
+ test('should handle log plugin without overrides attributes', () => {
269
+ logPlugin.AvLogMessages = mockApiV3;
270
+ mockAvAnalytics = new AvAnalytics([logPlugin], Promise, false, false);
271
+
272
+ const elem = document.createElement('button');
273
+ elem.setAttribute('data-analytics-category', 'error');
274
+
275
+ const attrs = mockAvAnalytics.getAnalyticAttrs(elem);
276
+
277
+ expect(attrs).toEqual({
278
+ category: 'error',
279
+ });
280
+ });
281
+
282
+ test('should use custom attributePrefix with log plugin', () => {
283
+ logPlugin.AvLogMessages = mockApiV3;
284
+ mockAvAnalytics = new AvAnalytics([logPlugin], Promise, false, false, {
285
+ attributePrefix: 'custom-attr',
286
+ });
287
+
288
+ const elem = document.createElement('button');
289
+ elem.setAttribute('custom-attr-overrides-endpoint', '/test');
290
+
291
+ const attrs = mockAvAnalytics.getAnalyticAttrs(elem);
292
+
293
+ expect(attrs).toEqual({
294
+ overrides: {
295
+ endpoint: '/test',
296
+ },
297
+ });
298
+ });
299
+
300
+ test('should extract nested overrides when multiple plugins including log plugin', () => {
301
+ logPlugin.AvLogMessages = mockApiV3;
302
+ const googlePlugin = makePlugin();
303
+ mockAvAnalytics = new AvAnalytics([googlePlugin, logPlugin], Promise, false, false);
304
+
305
+ const elem = document.createElement('button');
306
+ elem.setAttribute('data-analytics-category', 'error');
307
+ elem.setAttribute('data-analytics-overrides-endpoint', '/custom/log');
308
+
309
+ const attrs = mockAvAnalytics.getAnalyticAttrs(elem);
310
+
311
+ expect(attrs).toEqual({
312
+ category: 'error',
313
+ overrides: {
314
+ endpoint: '/custom/log',
315
+ },
316
+ });
317
+ });
318
+ });
187
319
  });