aurea-tracking-sdk 1.2.0 → 1.3.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.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +16 -2
- package/dist/index.mjs +16 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -8,6 +8,7 @@ interface EventCategoryConfig {
|
|
|
8
8
|
advanceTo?: string;
|
|
9
9
|
value?: number;
|
|
10
10
|
description?: string;
|
|
11
|
+
trackOnce?: boolean;
|
|
11
12
|
}
|
|
12
13
|
interface AureaConfig {
|
|
13
14
|
apiKey: string;
|
|
@@ -129,6 +130,7 @@ declare class AureaSDK {
|
|
|
129
130
|
private isInCheckout;
|
|
130
131
|
private checkoutStartedAt?;
|
|
131
132
|
private eventCategoryStats;
|
|
133
|
+
private trackedOnceEvents;
|
|
132
134
|
constructor(config: AureaConfig);
|
|
133
135
|
/**
|
|
134
136
|
* Initialize the SDK
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ interface EventCategoryConfig {
|
|
|
8
8
|
advanceTo?: string;
|
|
9
9
|
value?: number;
|
|
10
10
|
description?: string;
|
|
11
|
+
trackOnce?: boolean;
|
|
11
12
|
}
|
|
12
13
|
interface AureaConfig {
|
|
13
14
|
apiKey: string;
|
|
@@ -129,6 +130,7 @@ declare class AureaSDK {
|
|
|
129
130
|
private isInCheckout;
|
|
130
131
|
private checkoutStartedAt?;
|
|
131
132
|
private eventCategoryStats;
|
|
133
|
+
private trackedOnceEvents;
|
|
132
134
|
constructor(config: AureaConfig);
|
|
133
135
|
/**
|
|
134
136
|
* Initialize the SDK
|
package/dist/index.js
CHANGED
|
@@ -53,6 +53,8 @@ var AureaSDK = class {
|
|
|
53
53
|
this.isInCheckout = false;
|
|
54
54
|
// NEW: Event categorization tracking
|
|
55
55
|
this.eventCategoryStats = /* @__PURE__ */ new Map();
|
|
56
|
+
// NEW: Track which events have been fired (for trackOnce behavior)
|
|
57
|
+
this.trackedOnceEvents = /* @__PURE__ */ new Set();
|
|
56
58
|
this.config = {
|
|
57
59
|
apiUrl: "http://localhost:3000/api",
|
|
58
60
|
debug: false,
|
|
@@ -250,6 +252,16 @@ var AureaSDK = class {
|
|
|
250
252
|
const value = options?.value ?? categoryConfig?.value ?? 50;
|
|
251
253
|
const advanceTo = options?.advanceTo || categoryConfig?.advanceTo;
|
|
252
254
|
const description = options?.description || categoryConfig?.description;
|
|
255
|
+
const trackOnce = categoryConfig?.trackOnce ?? false;
|
|
256
|
+
if (trackOnce) {
|
|
257
|
+
if (this.trackedOnceEvents.has(eventName)) {
|
|
258
|
+
if (this.config.debug) {
|
|
259
|
+
console.log(`[Aurea SDK] Event skipped (already tracked once): ${eventName}`);
|
|
260
|
+
}
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
this.trackedOnceEvents.add(eventName);
|
|
264
|
+
}
|
|
253
265
|
this.eventCategoryStats.set(
|
|
254
266
|
category,
|
|
255
267
|
(this.eventCategoryStats.get(category) || 0) + 1
|
|
@@ -265,10 +277,12 @@ var AureaSDK = class {
|
|
|
265
277
|
_value: value,
|
|
266
278
|
_description: description,
|
|
267
279
|
_currentStage: this.currentStage,
|
|
268
|
-
_categoryStats: Object.fromEntries(this.eventCategoryStats)
|
|
280
|
+
_categoryStats: Object.fromEntries(this.eventCategoryStats),
|
|
281
|
+
_trackedOnce: trackOnce
|
|
282
|
+
// Include for backend reference
|
|
269
283
|
});
|
|
270
284
|
if (this.config.debug) {
|
|
271
|
-
console.log(`[Aurea SDK] Event tracked: ${eventName} [${category}] (value: ${value}, stage: ${this.currentStage})`);
|
|
285
|
+
console.log(`[Aurea SDK] Event tracked: ${eventName} [${category}] (value: ${value}, stage: ${this.currentStage}${trackOnce ? ", once-only" : ""})`);
|
|
272
286
|
}
|
|
273
287
|
}
|
|
274
288
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -24,6 +24,8 @@ var AureaSDK = class {
|
|
|
24
24
|
this.isInCheckout = false;
|
|
25
25
|
// NEW: Event categorization tracking
|
|
26
26
|
this.eventCategoryStats = /* @__PURE__ */ new Map();
|
|
27
|
+
// NEW: Track which events have been fired (for trackOnce behavior)
|
|
28
|
+
this.trackedOnceEvents = /* @__PURE__ */ new Set();
|
|
27
29
|
this.config = {
|
|
28
30
|
apiUrl: "http://localhost:3000/api",
|
|
29
31
|
debug: false,
|
|
@@ -221,6 +223,16 @@ var AureaSDK = class {
|
|
|
221
223
|
const value = options?.value ?? categoryConfig?.value ?? 50;
|
|
222
224
|
const advanceTo = options?.advanceTo || categoryConfig?.advanceTo;
|
|
223
225
|
const description = options?.description || categoryConfig?.description;
|
|
226
|
+
const trackOnce = categoryConfig?.trackOnce ?? false;
|
|
227
|
+
if (trackOnce) {
|
|
228
|
+
if (this.trackedOnceEvents.has(eventName)) {
|
|
229
|
+
if (this.config.debug) {
|
|
230
|
+
console.log(`[Aurea SDK] Event skipped (already tracked once): ${eventName}`);
|
|
231
|
+
}
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
this.trackedOnceEvents.add(eventName);
|
|
235
|
+
}
|
|
224
236
|
this.eventCategoryStats.set(
|
|
225
237
|
category,
|
|
226
238
|
(this.eventCategoryStats.get(category) || 0) + 1
|
|
@@ -236,10 +248,12 @@ var AureaSDK = class {
|
|
|
236
248
|
_value: value,
|
|
237
249
|
_description: description,
|
|
238
250
|
_currentStage: this.currentStage,
|
|
239
|
-
_categoryStats: Object.fromEntries(this.eventCategoryStats)
|
|
251
|
+
_categoryStats: Object.fromEntries(this.eventCategoryStats),
|
|
252
|
+
_trackedOnce: trackOnce
|
|
253
|
+
// Include for backend reference
|
|
240
254
|
});
|
|
241
255
|
if (this.config.debug) {
|
|
242
|
-
console.log(`[Aurea SDK] Event tracked: ${eventName} [${category}] (value: ${value}, stage: ${this.currentStage})`);
|
|
256
|
+
console.log(`[Aurea SDK] Event tracked: ${eventName} [${category}] (value: ${value}, stage: ${this.currentStage}${trackOnce ? ", once-only" : ""})`);
|
|
243
257
|
}
|
|
244
258
|
}
|
|
245
259
|
/**
|