@stacksee/analytics 0.13.0 → 0.13.2
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/_commonjsHelpers-DaMA6jEr.js +8 -0
- package/dist/adapters/server/server-analytics.d.ts +2 -2
- package/dist/{bento-node-sdk.esm-CWEAoj97.js → bento-node-sdk.esm-CT4oS3Kp.js} +1 -1
- package/dist/providers/bento/server.d.ts +2 -2
- package/dist/providers/client.js +8 -7
- package/dist/providers/emitkit/server.d.ts +7 -2
- package/dist/providers/pirsch/client.d.ts +5 -0
- package/dist/providers/pirsch/server.d.ts +40 -6
- package/dist/providers/server.js +372 -295
- package/dist/server.js +41 -38
- package/dist/web-D-ZwlgeQ.js +2034 -0
- package/package.json +5 -2
- package/dist/_commonjsHelpers-B4e78b8K.js +0 -28
- package/dist/axios-0_CwElpL.js +0 -1820
- package/dist/index-zS7gy63J.js +0 -829
- package/dist/web-imCcOhDC.js +0 -220
package/dist/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var u = Object.defineProperty;
|
|
2
|
-
var h = (
|
|
3
|
-
var c = (
|
|
2
|
+
var h = (a, e, t) => e in a ? u(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
3
|
+
var c = (a, e, t) => h(a, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { P as w } from "./server-DjEk1fUD.js";
|
|
5
5
|
import { B as y } from "./base.provider-AfFL5W_P.js";
|
|
6
6
|
class f {
|
|
@@ -68,25 +68,25 @@ class f {
|
|
|
68
68
|
), r.excludeEvents && r.eventPatterns && console.warn(
|
|
69
69
|
`[Analytics] Provider ${r.provider.name} has both 'excludeEvents' and 'eventPatterns' specified. Using 'eventPatterns' and ignoring 'excludeEvents'.`
|
|
70
70
|
);
|
|
71
|
-
let
|
|
72
|
-
r.methods ?
|
|
71
|
+
let i;
|
|
72
|
+
r.methods ? i = new Set(r.methods) : r.exclude ? i = new Set(
|
|
73
73
|
t.filter(
|
|
74
|
-
(
|
|
74
|
+
(o) => {
|
|
75
75
|
var v;
|
|
76
|
-
return !((v = r.exclude) != null && v.includes(
|
|
76
|
+
return !((v = r.exclude) != null && v.includes(o));
|
|
77
77
|
}
|
|
78
78
|
)
|
|
79
|
-
) :
|
|
80
|
-
let
|
|
81
|
-
return r.events && r.events.length > 0 ?
|
|
82
|
-
const v =
|
|
79
|
+
) : i = new Set(t);
|
|
80
|
+
let s, l, d;
|
|
81
|
+
return r.events && r.events.length > 0 ? s = new Set(r.events) : r.eventPatterns && r.eventPatterns.length > 0 ? d = r.eventPatterns.map((o) => {
|
|
82
|
+
const v = o.replace(/\*/g, ".*");
|
|
83
83
|
return new RegExp(`^${v}$`);
|
|
84
|
-
}) : r.excludeEvents && r.excludeEvents.length > 0 && (
|
|
84
|
+
}) : r.excludeEvents && r.excludeEvents.length > 0 && (l = new Set(r.excludeEvents)), {
|
|
85
85
|
provider: r.provider,
|
|
86
|
-
enabledMethods:
|
|
87
|
-
enabledEvents:
|
|
88
|
-
excludedEvents:
|
|
89
|
-
eventPatterns:
|
|
86
|
+
enabledMethods: i,
|
|
87
|
+
enabledEvents: s,
|
|
88
|
+
excludedEvents: l,
|
|
89
|
+
eventPatterns: d
|
|
90
90
|
};
|
|
91
91
|
});
|
|
92
92
|
}
|
|
@@ -191,9 +191,11 @@ class f {
|
|
|
191
191
|
* }
|
|
192
192
|
* ```
|
|
193
193
|
*/
|
|
194
|
-
identify(e, t) {
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
async identify(e, t) {
|
|
195
|
+
const n = this.providerConfigs.filter((i) => this.shouldCallMethod(i, "identify")).map((i) => i.provider.identify(e, t)), r = await Promise.allSettled(n);
|
|
196
|
+
for (const i of r)
|
|
197
|
+
if (i.status === "rejected")
|
|
198
|
+
throw i.reason;
|
|
197
199
|
}
|
|
198
200
|
/**
|
|
199
201
|
* Tracks a custom event with properties and optional context.
|
|
@@ -317,7 +319,7 @@ class f {
|
|
|
317
319
|
* ```
|
|
318
320
|
*/
|
|
319
321
|
async track(e, t, n) {
|
|
320
|
-
var
|
|
322
|
+
var l;
|
|
321
323
|
if (!this.initialized) {
|
|
322
324
|
console.warn("[Analytics] Not initialized. Call initialize() first.");
|
|
323
325
|
return;
|
|
@@ -329,23 +331,23 @@ class f {
|
|
|
329
331
|
timestamp: Date.now(),
|
|
330
332
|
userId: n == null ? void 0 : n.userId,
|
|
331
333
|
sessionId: n == null ? void 0 : n.sessionId
|
|
332
|
-
},
|
|
334
|
+
}, i = {
|
|
333
335
|
...this.config.defaultContext,
|
|
334
336
|
...n == null ? void 0 : n.context,
|
|
335
|
-
user: (n == null ? void 0 : n.user) || ((
|
|
336
|
-
},
|
|
337
|
-
(
|
|
338
|
-
).map(async (
|
|
337
|
+
user: (n == null ? void 0 : n.user) || ((l = n == null ? void 0 : n.context) == null ? void 0 : l.user)
|
|
338
|
+
}, s = this.providerConfigs.filter(
|
|
339
|
+
(d) => this.shouldCallMethod(d, "track") && this.shouldTrackEvent(d, e)
|
|
340
|
+
).map(async (d) => {
|
|
339
341
|
try {
|
|
340
|
-
await
|
|
341
|
-
} catch (
|
|
342
|
+
await d.provider.track(r, i);
|
|
343
|
+
} catch (o) {
|
|
342
344
|
console.error(
|
|
343
|
-
`[Analytics] Provider ${
|
|
344
|
-
|
|
345
|
+
`[Analytics] Provider ${d.provider.name} failed to track event:`,
|
|
346
|
+
o
|
|
345
347
|
);
|
|
346
348
|
}
|
|
347
349
|
});
|
|
348
|
-
await Promise.all(
|
|
350
|
+
await Promise.all(s);
|
|
349
351
|
}
|
|
350
352
|
/**
|
|
351
353
|
* Tracks a page view event from the server side.
|
|
@@ -407,14 +409,15 @@ class f {
|
|
|
407
409
|
* }
|
|
408
410
|
* ```
|
|
409
411
|
*/
|
|
410
|
-
pageView(e, t) {
|
|
412
|
+
async pageView(e, t) {
|
|
411
413
|
if (!this.initialized) return;
|
|
412
414
|
const n = {
|
|
413
415
|
...this.config.defaultContext,
|
|
414
416
|
...t == null ? void 0 : t.context
|
|
415
|
-
};
|
|
416
|
-
for (const
|
|
417
|
-
|
|
417
|
+
}, r = this.providerConfigs.filter((s) => this.shouldCallMethod(s, "pageView")).map((s) => s.provider.pageView(e, n)), i = await Promise.allSettled(r);
|
|
418
|
+
for (const s of i)
|
|
419
|
+
if (s.status === "rejected")
|
|
420
|
+
throw s.reason;
|
|
418
421
|
}
|
|
419
422
|
/**
|
|
420
423
|
* Tracks when a user leaves a page from the server side.
|
|
@@ -577,11 +580,11 @@ class f {
|
|
|
577
580
|
return t.length > 1 && t[0] ? t[0] : "engagement";
|
|
578
581
|
}
|
|
579
582
|
}
|
|
580
|
-
function
|
|
583
|
+
function m(a) {
|
|
581
584
|
const e = {
|
|
582
|
-
providers:
|
|
583
|
-
debug:
|
|
584
|
-
enabled:
|
|
585
|
+
providers: a.providers || [],
|
|
586
|
+
debug: a.debug,
|
|
587
|
+
enabled: a.enabled
|
|
585
588
|
}, t = new f(e);
|
|
586
589
|
return t.initialize(), t;
|
|
587
590
|
}
|
|
@@ -589,5 +592,5 @@ export {
|
|
|
589
592
|
y as BaseAnalyticsProvider,
|
|
590
593
|
w as PostHogServerProvider,
|
|
591
594
|
f as ServerAnalytics,
|
|
592
|
-
|
|
595
|
+
m as createServerAnalytics
|
|
593
596
|
};
|