@stacksee/analytics 0.11.1 → 0.13.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/adapters/client/browser-analytics.d.ts +4 -0
- package/dist/adapters/server/server-analytics.d.ts +4 -0
- package/dist/client.d.ts +2 -2
- package/dist/client.js +122 -100
- package/dist/core/events/types.d.ts +73 -2
- package/dist/providers/emitkit/server.d.ts +28 -1
- package/dist/providers/server.js +130 -108
- package/dist/server.d.ts +2 -2
- package/dist/server.js +96 -74
- package/package.json +1 -1
|
@@ -47,6 +47,10 @@ export declare class BrowserAnalytics<TEventMap extends DefaultEventMap = Defaul
|
|
|
47
47
|
* Checks if a method should be called on a provider based on routing configuration
|
|
48
48
|
*/
|
|
49
49
|
private shouldCallMethod;
|
|
50
|
+
/**
|
|
51
|
+
* Checks if an event should be tracked on a provider based on event filtering configuration
|
|
52
|
+
*/
|
|
53
|
+
private shouldTrackEvent;
|
|
50
54
|
/**
|
|
51
55
|
* Initializes all analytics providers and sets up browser context.
|
|
52
56
|
*
|
|
@@ -43,6 +43,10 @@ export declare class ServerAnalytics<TEventMap extends Record<string, Record<str
|
|
|
43
43
|
* Checks if a method should be called on a provider based on routing configuration
|
|
44
44
|
*/
|
|
45
45
|
private shouldCallMethod;
|
|
46
|
+
/**
|
|
47
|
+
* Checks if an event should be tracked on a provider based on event filtering configuration
|
|
48
|
+
*/
|
|
49
|
+
private shouldTrackEvent;
|
|
46
50
|
/**
|
|
47
51
|
* Initializes all analytics providers.
|
|
48
52
|
*
|
package/dist/client.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BrowserAnalytics } from './adapters/client/browser-analytics.js';
|
|
2
|
-
import {
|
|
2
|
+
import { ProviderConfigOrProvider } from './core/events/types.js';
|
|
3
3
|
import { EventMapFromCollection } from './core/events/index.js';
|
|
4
4
|
export interface ClientAnalyticsConfig {
|
|
5
|
-
providers?:
|
|
5
|
+
providers?: ProviderConfigOrProvider[];
|
|
6
6
|
debug?: boolean;
|
|
7
7
|
enabled?: boolean;
|
|
8
8
|
}
|
package/dist/client.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { i as
|
|
5
|
-
import { P } from "./client-DTHZYkxx.js";
|
|
6
|
-
import { B as
|
|
7
|
-
class
|
|
1
|
+
var f = Object.defineProperty;
|
|
2
|
+
var p = (n, e, t) => e in n ? f(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var a = (n, e, t) => p(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { i as g } from "./client-DTHZYkxx.js";
|
|
5
|
+
import { P as k } from "./client-DTHZYkxx.js";
|
|
6
|
+
import { B as O } from "./base.provider-AfFL5W_P.js";
|
|
7
|
+
class m {
|
|
8
8
|
/**
|
|
9
9
|
* Creates a new BrowserAnalytics instance for client-side event tracking.
|
|
10
10
|
*
|
|
@@ -36,20 +36,20 @@ class p {
|
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
38
|
constructor(e) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
a(this, "providerConfigs", []);
|
|
40
|
+
a(this, "context", {});
|
|
41
|
+
a(this, "userId");
|
|
42
|
+
a(this, "sessionId");
|
|
43
|
+
a(this, "userTraits");
|
|
44
|
+
a(this, "initialized", !1);
|
|
45
|
+
a(this, "initializePromise");
|
|
46
46
|
this.providerConfigs = this.normalizeProviders(e.providers), e.defaultContext && (this.context = { ...e.defaultContext }), this.sessionId = this.generateSessionId();
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Normalizes provider configurations into a consistent internal format
|
|
50
50
|
*/
|
|
51
51
|
normalizeProviders(e) {
|
|
52
|
-
const
|
|
52
|
+
const t = [
|
|
53
53
|
"initialize",
|
|
54
54
|
"identify",
|
|
55
55
|
"track",
|
|
@@ -57,35 +57,55 @@ class p {
|
|
|
57
57
|
"pageLeave",
|
|
58
58
|
"reset"
|
|
59
59
|
];
|
|
60
|
-
return e.map((
|
|
61
|
-
if ("initialize" in
|
|
60
|
+
return e.map((r) => {
|
|
61
|
+
if ("initialize" in r && "track" in r)
|
|
62
62
|
return {
|
|
63
|
-
provider:
|
|
64
|
-
enabledMethods: new Set(
|
|
63
|
+
provider: r,
|
|
64
|
+
enabledMethods: new Set(t)
|
|
65
65
|
};
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
`[Analytics] Provider ${
|
|
66
|
+
const i = r;
|
|
67
|
+
i.methods && i.exclude && console.warn(
|
|
68
|
+
`[Analytics] Provider ${i.provider.name} has both 'methods' and 'exclude' specified. Using 'methods' and ignoring 'exclude'.`
|
|
69
|
+
), i.events && i.excludeEvents && console.warn(
|
|
70
|
+
`[Analytics] Provider ${i.provider.name} has both 'events' and 'excludeEvents' specified. Using 'events' and ignoring 'excludeEvents'.`
|
|
71
|
+
), i.events && i.eventPatterns && console.warn(
|
|
72
|
+
`[Analytics] Provider ${i.provider.name} has both 'events' and 'eventPatterns' specified. Using 'events' and ignoring 'eventPatterns'.`
|
|
73
|
+
), i.excludeEvents && i.eventPatterns && console.warn(
|
|
74
|
+
`[Analytics] Provider ${i.provider.name} has both 'excludeEvents' and 'eventPatterns' specified. Using 'eventPatterns' and ignoring 'excludeEvents'.`
|
|
69
75
|
);
|
|
70
|
-
let
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
(
|
|
74
|
-
var
|
|
75
|
-
return !((
|
|
76
|
+
let d;
|
|
77
|
+
i.methods ? d = new Set(i.methods) : i.exclude ? d = new Set(
|
|
78
|
+
t.filter(
|
|
79
|
+
(u) => {
|
|
80
|
+
var c;
|
|
81
|
+
return !((c = i.exclude) != null && c.includes(u));
|
|
76
82
|
}
|
|
77
83
|
)
|
|
78
|
-
) :
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
) : d = new Set(t);
|
|
85
|
+
let s, h, v;
|
|
86
|
+
return i.events && i.events.length > 0 ? s = new Set(i.events) : i.eventPatterns && i.eventPatterns.length > 0 ? v = i.eventPatterns.map((u) => {
|
|
87
|
+
const c = u.replace(/\*/g, ".*");
|
|
88
|
+
return new RegExp(`^${c}$`);
|
|
89
|
+
}) : i.excludeEvents && i.excludeEvents.length > 0 && (h = new Set(i.excludeEvents)), {
|
|
90
|
+
provider: i.provider,
|
|
91
|
+
enabledMethods: d,
|
|
92
|
+
enabledEvents: s,
|
|
93
|
+
excludedEvents: h,
|
|
94
|
+
eventPatterns: v
|
|
81
95
|
};
|
|
82
96
|
});
|
|
83
97
|
}
|
|
84
98
|
/**
|
|
85
99
|
* Checks if a method should be called on a provider based on routing configuration
|
|
86
100
|
*/
|
|
87
|
-
shouldCallMethod(e,
|
|
88
|
-
return e.enabledMethods.has(
|
|
101
|
+
shouldCallMethod(e, t) {
|
|
102
|
+
return e.enabledMethods.has(t);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Checks if an event should be tracked on a provider based on event filtering configuration
|
|
106
|
+
*/
|
|
107
|
+
shouldTrackEvent(e, t) {
|
|
108
|
+
return !e.enabledEvents && !e.excludedEvents && !e.eventPatterns ? !0 : e.enabledEvents ? e.enabledEvents.has(t) : e.eventPatterns ? e.eventPatterns.some((r) => r.test(t)) : e.excludedEvents ? !e.excludedEvents.has(t) : !0;
|
|
89
109
|
}
|
|
90
110
|
/**
|
|
91
111
|
* Initializes all analytics providers and sets up browser context.
|
|
@@ -118,12 +138,12 @@ class p {
|
|
|
118
138
|
* ```
|
|
119
139
|
*/
|
|
120
140
|
async initialize() {
|
|
121
|
-
if (
|
|
141
|
+
if (g() && !this.initialized)
|
|
122
142
|
return this.initializePromise ? this.initializePromise : (this.initializePromise = this._doInitialize(), this.initializePromise);
|
|
123
143
|
}
|
|
124
144
|
async _doInitialize() {
|
|
125
145
|
const e = this.providerConfigs.map(
|
|
126
|
-
(
|
|
146
|
+
(t) => t.provider.initialize()
|
|
127
147
|
);
|
|
128
148
|
await Promise.all(e), this.initialized = !0, this.updateContext({
|
|
129
149
|
page: {
|
|
@@ -208,12 +228,12 @@ class p {
|
|
|
208
228
|
* }
|
|
209
229
|
* ```
|
|
210
230
|
*/
|
|
211
|
-
identify(e,
|
|
212
|
-
this.userId = e, this.userTraits =
|
|
213
|
-
console.error("[Analytics] Failed to initialize during identify:",
|
|
231
|
+
identify(e, t) {
|
|
232
|
+
this.userId = e, this.userTraits = t, this.ensureInitialized().catch((r) => {
|
|
233
|
+
console.error("[Analytics] Failed to initialize during identify:", r);
|
|
214
234
|
});
|
|
215
|
-
for (const
|
|
216
|
-
this.shouldCallMethod(
|
|
235
|
+
for (const r of this.providerConfigs)
|
|
236
|
+
this.shouldCallMethod(r, "identify") && r.provider.identify(e, t);
|
|
217
237
|
}
|
|
218
238
|
/**
|
|
219
239
|
* Tracks a custom event with properties.
|
|
@@ -290,33 +310,35 @@ class p {
|
|
|
290
310
|
* }
|
|
291
311
|
* ```
|
|
292
312
|
*/
|
|
293
|
-
async track(e,
|
|
313
|
+
async track(e, t) {
|
|
294
314
|
await this.ensureInitialized();
|
|
295
|
-
const
|
|
315
|
+
const r = {
|
|
296
316
|
action: e,
|
|
297
317
|
category: this.getCategoryFromEventName(e),
|
|
298
|
-
properties:
|
|
318
|
+
properties: t,
|
|
299
319
|
timestamp: Date.now(),
|
|
300
320
|
userId: this.userId,
|
|
301
321
|
sessionId: this.sessionId
|
|
302
|
-
},
|
|
322
|
+
}, i = {
|
|
303
323
|
...this.context,
|
|
304
324
|
user: this.userId || this.userTraits ? {
|
|
305
325
|
userId: this.userId,
|
|
306
326
|
email: this.userTraits && "email" in this.userTraits ? this.userTraits.email : void 0,
|
|
307
327
|
traits: this.userTraits
|
|
308
328
|
} : void 0
|
|
309
|
-
},
|
|
329
|
+
}, d = this.providerConfigs.filter(
|
|
330
|
+
(s) => this.shouldCallMethod(s, "track") && this.shouldTrackEvent(s, e)
|
|
331
|
+
).map(async (s) => {
|
|
310
332
|
try {
|
|
311
|
-
await
|
|
333
|
+
await s.provider.track(r, i);
|
|
312
334
|
} catch (h) {
|
|
313
335
|
console.error(
|
|
314
|
-
`[Analytics] Provider ${
|
|
336
|
+
`[Analytics] Provider ${s.provider.name} failed to track event:`,
|
|
315
337
|
h
|
|
316
338
|
);
|
|
317
339
|
}
|
|
318
340
|
});
|
|
319
|
-
await Promise.all(
|
|
341
|
+
await Promise.all(d);
|
|
320
342
|
}
|
|
321
343
|
/**
|
|
322
344
|
* Tracks a page view event.
|
|
@@ -379,8 +401,8 @@ class p {
|
|
|
379
401
|
* ```
|
|
380
402
|
*/
|
|
381
403
|
pageView(e) {
|
|
382
|
-
this.ensureInitialized().catch((
|
|
383
|
-
console.error("[Analytics] Failed to initialize during pageView:",
|
|
404
|
+
this.ensureInitialized().catch((t) => {
|
|
405
|
+
console.error("[Analytics] Failed to initialize during pageView:", t);
|
|
384
406
|
}), this.updateContext({
|
|
385
407
|
page: {
|
|
386
408
|
path: window.location.pathname,
|
|
@@ -388,8 +410,8 @@ class p {
|
|
|
388
410
|
referrer: document.referrer
|
|
389
411
|
}
|
|
390
412
|
});
|
|
391
|
-
for (const
|
|
392
|
-
this.shouldCallMethod(
|
|
413
|
+
for (const t of this.providerConfigs)
|
|
414
|
+
this.shouldCallMethod(t, "pageView") && t.provider.pageView(e, this.context);
|
|
393
415
|
}
|
|
394
416
|
/**
|
|
395
417
|
* Tracks when a user leaves a page.
|
|
@@ -447,14 +469,14 @@ class p {
|
|
|
447
469
|
* ```
|
|
448
470
|
*/
|
|
449
471
|
pageLeave(e) {
|
|
450
|
-
this.ensureInitialized().catch((
|
|
472
|
+
this.ensureInitialized().catch((t) => {
|
|
451
473
|
console.error(
|
|
452
474
|
"[Analytics] Failed to initialize during pageLeave:",
|
|
453
|
-
|
|
475
|
+
t
|
|
454
476
|
);
|
|
455
477
|
});
|
|
456
|
-
for (const
|
|
457
|
-
this.shouldCallMethod(
|
|
478
|
+
for (const t of this.providerConfigs)
|
|
479
|
+
this.shouldCallMethod(t, "pageLeave") && t.provider.pageLeave && t.provider.pageLeave(e, this.context);
|
|
458
480
|
}
|
|
459
481
|
/**
|
|
460
482
|
* Resets the analytics state, clearing user ID and generating a new session.
|
|
@@ -549,18 +571,18 @@ class p {
|
|
|
549
571
|
* ```
|
|
550
572
|
*/
|
|
551
573
|
async flush(e = !1) {
|
|
552
|
-
const
|
|
553
|
-
if (
|
|
574
|
+
const t = this.providerConfigs.map(async (r) => {
|
|
575
|
+
if (r.provider.flush && typeof r.provider.flush == "function")
|
|
554
576
|
try {
|
|
555
|
-
await
|
|
556
|
-
} catch (
|
|
577
|
+
await r.provider.flush(e);
|
|
578
|
+
} catch (i) {
|
|
557
579
|
console.error(
|
|
558
|
-
`[Analytics] Provider ${
|
|
559
|
-
|
|
580
|
+
`[Analytics] Provider ${r.provider.name} failed to flush:`,
|
|
581
|
+
i
|
|
560
582
|
);
|
|
561
583
|
}
|
|
562
584
|
});
|
|
563
|
-
await Promise.all(
|
|
585
|
+
await Promise.all(t);
|
|
564
586
|
}
|
|
565
587
|
/**
|
|
566
588
|
* Updates the analytics context with new information.
|
|
@@ -623,14 +645,14 @@ class p {
|
|
|
623
645
|
* ```
|
|
624
646
|
*/
|
|
625
647
|
updateContext(e) {
|
|
626
|
-
var
|
|
648
|
+
var t, r, i;
|
|
627
649
|
this.context = {
|
|
628
650
|
...this.context,
|
|
629
651
|
...e,
|
|
630
652
|
page: e.page ? {
|
|
631
|
-
path: e.page.path || ((
|
|
632
|
-
title: e.page.title || ((
|
|
633
|
-
referrer: e.page.referrer || ((
|
|
653
|
+
path: e.page.path || ((t = this.context.page) == null ? void 0 : t.path) || window.location.pathname,
|
|
654
|
+
title: e.page.title || ((r = this.context.page) == null ? void 0 : r.title),
|
|
655
|
+
referrer: e.page.referrer || ((i = this.context.page) == null ? void 0 : i.referrer)
|
|
634
656
|
} : this.context.page,
|
|
635
657
|
device: {
|
|
636
658
|
...this.context.device,
|
|
@@ -643,8 +665,8 @@ class p {
|
|
|
643
665
|
};
|
|
644
666
|
}
|
|
645
667
|
getCategoryFromEventName(e) {
|
|
646
|
-
const
|
|
647
|
-
return
|
|
668
|
+
const t = e.split("_");
|
|
669
|
+
return t.length > 1 && t[0] ? t[0] : "engagement";
|
|
648
670
|
}
|
|
649
671
|
generateSessionId() {
|
|
650
672
|
return `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
|
@@ -664,51 +686,51 @@ class p {
|
|
|
664
686
|
return e.indexOf("Chrome") !== -1 ? "Chrome" : e.indexOf("Safari") !== -1 ? "Safari" : e.indexOf("Firefox") !== -1 ? "Firefox" : e.indexOf("Edge") !== -1 ? "Edge" : "Unknown";
|
|
665
687
|
}
|
|
666
688
|
}
|
|
667
|
-
let
|
|
668
|
-
function
|
|
669
|
-
if (
|
|
670
|
-
return console.warn("[Analytics] Already initialized"),
|
|
689
|
+
let o = null;
|
|
690
|
+
function y(n) {
|
|
691
|
+
if (o)
|
|
692
|
+
return console.warn("[Analytics] Already initialized"), o;
|
|
671
693
|
const e = {
|
|
672
|
-
providers:
|
|
673
|
-
debug:
|
|
674
|
-
enabled:
|
|
694
|
+
providers: n.providers || [],
|
|
695
|
+
debug: n.debug,
|
|
696
|
+
enabled: n.enabled
|
|
675
697
|
};
|
|
676
|
-
return
|
|
677
|
-
console.error("[Analytics] Failed to initialize:",
|
|
678
|
-
}),
|
|
698
|
+
return o = new m(e), o.initialize().catch((t) => {
|
|
699
|
+
console.error("[Analytics] Failed to initialize:", t);
|
|
700
|
+
}), o;
|
|
679
701
|
}
|
|
680
702
|
function l() {
|
|
681
|
-
if (!
|
|
703
|
+
if (!o)
|
|
682
704
|
throw new Error(
|
|
683
705
|
"[Analytics] Not initialized. Call createAnalytics() first."
|
|
684
706
|
);
|
|
685
|
-
return
|
|
707
|
+
return o;
|
|
686
708
|
}
|
|
687
|
-
function
|
|
688
|
-
return l().track(
|
|
709
|
+
function P(n, e) {
|
|
710
|
+
return l().track(n, e);
|
|
689
711
|
}
|
|
690
|
-
function
|
|
691
|
-
l().identify(
|
|
712
|
+
function z(n, e) {
|
|
713
|
+
l().identify(n, e);
|
|
692
714
|
}
|
|
693
|
-
function
|
|
694
|
-
l().pageView(
|
|
715
|
+
function C(n) {
|
|
716
|
+
l().pageView(n);
|
|
695
717
|
}
|
|
696
|
-
function
|
|
697
|
-
l().pageLeave(
|
|
718
|
+
function A(n) {
|
|
719
|
+
l().pageLeave(n);
|
|
698
720
|
}
|
|
699
|
-
function
|
|
721
|
+
function b() {
|
|
700
722
|
l().reset();
|
|
701
723
|
}
|
|
702
724
|
export {
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
725
|
+
O as BaseAnalyticsProvider,
|
|
726
|
+
m as BrowserAnalytics,
|
|
727
|
+
k as PostHogClientProvider,
|
|
728
|
+
y as createAnalytics,
|
|
729
|
+
y as createClientAnalytics,
|
|
708
730
|
l as getAnalytics,
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
731
|
+
z as identify,
|
|
732
|
+
A as pageLeave,
|
|
733
|
+
C as pageView,
|
|
734
|
+
b as reset,
|
|
735
|
+
P as track
|
|
714
736
|
};
|
|
@@ -74,8 +74,9 @@ export interface AnalyticsProvider {
|
|
|
74
74
|
*/
|
|
75
75
|
export type ProviderMethod = "initialize" | "identify" | "track" | "pageView" | "pageLeave" | "reset";
|
|
76
76
|
/**
|
|
77
|
-
* Configuration for selective provider method routing.
|
|
78
|
-
* Allows you to control which methods are called on a specific provider
|
|
77
|
+
* Configuration for selective provider method routing and event filtering.
|
|
78
|
+
* Allows you to control which methods are called on a specific provider
|
|
79
|
+
* and which events are tracked.
|
|
79
80
|
*
|
|
80
81
|
* @example
|
|
81
82
|
* ```typescript
|
|
@@ -94,6 +95,33 @@ export type ProviderMethod = "initialize" | "identify" | "track" | "pageView" |
|
|
|
94
95
|
* exclude: ['pageView']
|
|
95
96
|
* }
|
|
96
97
|
* ```
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* // Only track specific events (solves 1-to-50 problem)
|
|
102
|
+
* {
|
|
103
|
+
* provider: new EmitKitServerProvider({...}),
|
|
104
|
+
* events: ['newsletter_signup', 'user_registered']
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* // Track all events except specific ones
|
|
111
|
+
* {
|
|
112
|
+
* provider: new PostHogServerProvider({...}),
|
|
113
|
+
* excludeEvents: ['newsletter_signup']
|
|
114
|
+
* }
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* // Use glob patterns to match multiple events
|
|
120
|
+
* {
|
|
121
|
+
* provider: new EmitKitServerProvider({...}),
|
|
122
|
+
* eventPatterns: ['newsletter_*', 'user_*']
|
|
123
|
+
* }
|
|
124
|
+
* ```
|
|
97
125
|
*/
|
|
98
126
|
export interface ProviderConfig {
|
|
99
127
|
/**
|
|
@@ -112,6 +140,49 @@ export interface ProviderConfig {
|
|
|
112
140
|
* Mutually exclusive with `methods`.
|
|
113
141
|
*/
|
|
114
142
|
exclude?: ProviderMethod[];
|
|
143
|
+
/**
|
|
144
|
+
* Only track these specific event names on this provider.
|
|
145
|
+
* If specified, all other events will be skipped.
|
|
146
|
+
* Mutually exclusive with `excludeEvents`.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```typescript
|
|
150
|
+
* {
|
|
151
|
+
* provider: new EmitKitServerProvider({...}),
|
|
152
|
+
* events: ['newsletter_signup'] // Only this event goes to EmitKit
|
|
153
|
+
* }
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
events?: string[];
|
|
157
|
+
/**
|
|
158
|
+
* Skip these specific event names on this provider.
|
|
159
|
+
* All other events will be tracked normally.
|
|
160
|
+
* Mutually exclusive with `events` and `eventPatterns`.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* {
|
|
165
|
+
* provider: new BentoClientProvider({...}),
|
|
166
|
+
* excludeEvents: ['page_view'] // Everything except page views
|
|
167
|
+
* }
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
excludeEvents?: string[];
|
|
171
|
+
/**
|
|
172
|
+
* Glob-style patterns to match event names.
|
|
173
|
+
* Supports wildcards (*) for flexible event routing.
|
|
174
|
+
* Mutually exclusive with `excludeEvents`.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* {
|
|
179
|
+
* provider: new EmitKitServerProvider({...}),
|
|
180
|
+
* eventPatterns: ['newsletter_*', 'user_registered']
|
|
181
|
+
* // Matches: newsletter_signup, newsletter_unsubscribe, user_registered
|
|
182
|
+
* }
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
eventPatterns?: string[];
|
|
115
186
|
}
|
|
116
187
|
/**
|
|
117
188
|
* Provider configuration - supports both simple provider instances
|
|
@@ -10,9 +10,29 @@ export interface EmitKitServerConfig {
|
|
|
10
10
|
apiKey: string;
|
|
11
11
|
/**
|
|
12
12
|
* Default channel name for events
|
|
13
|
-
* @default '
|
|
13
|
+
* @default 'general'
|
|
14
14
|
*/
|
|
15
15
|
channelName?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Map event categories to specific EmitKit channels.
|
|
18
|
+
* Allows automatic routing of events to appropriate channels based on category.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* {
|
|
23
|
+
* 'user': 'user-activity',
|
|
24
|
+
* 'engagement': 'product-usage',
|
|
25
|
+
* 'error': 'alerts',
|
|
26
|
+
* 'conversion': 'revenue'
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* Channel resolution priority:
|
|
31
|
+
* 1. Event property `__emitkit_channel` (highest priority)
|
|
32
|
+
* 2. Category mapping via `categoryChannelMap`
|
|
33
|
+
* 3. Default `channelName` (fallback, default: 'general')
|
|
34
|
+
*/
|
|
35
|
+
categoryChannelMap?: Record<string, string>;
|
|
16
36
|
/**
|
|
17
37
|
* Send notification for events
|
|
18
38
|
* @default true
|
|
@@ -59,4 +79,11 @@ export declare class EmitKitServerProvider extends BaseAnalyticsProvider {
|
|
|
59
79
|
* Get an appropriate icon for the event category
|
|
60
80
|
*/
|
|
61
81
|
private getEventIcon;
|
|
82
|
+
/**
|
|
83
|
+
* Resolve the channel name for an event based on priority:
|
|
84
|
+
* 1. Event property __emitkit_channel (highest priority)
|
|
85
|
+
* 2. Category mapping via categoryChannelMap
|
|
86
|
+
* 3. Default channelName (fallback, default: 'general')
|
|
87
|
+
*/
|
|
88
|
+
private resolveChannelName;
|
|
62
89
|
}
|