@stacksee/analytics 0.9.7 → 0.9.8
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/core/events/types.d.ts +13 -0
- package/dist/providers/server.js +114 -102
- package/package.json +1 -1
|
@@ -13,6 +13,17 @@ export interface UserContext<TTraits extends Record<string, unknown> = Record<st
|
|
|
13
13
|
email?: string;
|
|
14
14
|
traits?: TTraits;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Server-side context enrichment
|
|
18
|
+
* Used by server analytics to add request-specific metadata
|
|
19
|
+
*/
|
|
20
|
+
export interface ServerContext {
|
|
21
|
+
userAgent?: string;
|
|
22
|
+
ip?: string;
|
|
23
|
+
requestId?: string;
|
|
24
|
+
timestamp?: number;
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
16
27
|
export interface EventContext<TTraits extends Record<string, unknown> = Record<string, unknown>> {
|
|
17
28
|
user?: UserContext<TTraits>;
|
|
18
29
|
page?: {
|
|
@@ -31,6 +42,7 @@ export interface EventContext<TTraits extends Record<string, unknown> = Record<s
|
|
|
31
42
|
userAgent?: string;
|
|
32
43
|
language?: string;
|
|
33
44
|
timezone?: string;
|
|
45
|
+
ip?: string;
|
|
34
46
|
screen?: {
|
|
35
47
|
width?: number;
|
|
36
48
|
height?: number;
|
|
@@ -45,6 +57,7 @@ export interface EventContext<TTraits extends Record<string, unknown> = Record<s
|
|
|
45
57
|
medium?: string;
|
|
46
58
|
name?: string;
|
|
47
59
|
};
|
|
60
|
+
server?: ServerContext;
|
|
48
61
|
}
|
|
49
62
|
export interface AnalyticsProvider {
|
|
50
63
|
name: string;
|
package/dist/providers/server.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var D = (
|
|
3
|
-
var
|
|
4
|
-
import { B as
|
|
1
|
+
var q = Object.defineProperty;
|
|
2
|
+
var D = (p, u, i) => u in p ? q(p, u, { enumerable: !0, configurable: !0, writable: !0, value: i }) : p[u] = i;
|
|
3
|
+
var t = (p, u, i) => D(p, typeof u != "symbol" ? u + "" : u, i);
|
|
4
|
+
import { B as V } from "../base.provider-AfFL5W_P.js";
|
|
5
5
|
import { P as Q } from "../server-DjEk1fUD.js";
|
|
6
|
-
class N extends
|
|
6
|
+
class N extends V {
|
|
7
7
|
constructor(i) {
|
|
8
8
|
super({ debug: i.debug, enabled: i.enabled });
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
t(this, "name", "Bento-Server");
|
|
10
|
+
t(this, "client");
|
|
11
|
+
t(this, "initialized", !1);
|
|
12
|
+
t(this, "config");
|
|
13
|
+
t(this, "currentUserEmail");
|
|
14
14
|
this.config = i;
|
|
15
15
|
}
|
|
16
16
|
async initialize() {
|
|
@@ -23,8 +23,8 @@ class N extends q {
|
|
|
23
23
|
if (!((e = this.config.authentication) != null && e.secretKey) || typeof this.config.authentication.secretKey != "string")
|
|
24
24
|
throw new Error("Bento requires authentication.secretKey");
|
|
25
25
|
try {
|
|
26
|
-
const { Analytics: r } = await import("../bento-node-sdk.esm-CWEAoj97.js"), { debug:
|
|
27
|
-
this.client = new r(
|
|
26
|
+
const { Analytics: r } = await import("../bento-node-sdk.esm-CWEAoj97.js"), { debug: h, enabled: s, ...d } = this.config;
|
|
27
|
+
this.client = new r(d), this.initialized = !0, this.log("Initialized successfully", {
|
|
28
28
|
siteUuid: this.config.siteUuid
|
|
29
29
|
});
|
|
30
30
|
} catch (r) {
|
|
@@ -43,25 +43,25 @@ class N extends q {
|
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
this.currentUserEmail = r;
|
|
46
|
-
const
|
|
47
|
-
delete
|
|
46
|
+
const h = e ? { ...e } : {};
|
|
47
|
+
delete h.email, this.client.V1.addSubscriber({
|
|
48
48
|
email: r,
|
|
49
|
-
fields:
|
|
49
|
+
fields: h
|
|
50
50
|
}).catch((s) => {
|
|
51
51
|
console.error("[Bento-Server] Failed to identify user:", s);
|
|
52
52
|
}), this.log("Identified user", { userId: i, email: r, traits: e });
|
|
53
53
|
}
|
|
54
54
|
async track(i, e) {
|
|
55
|
-
var
|
|
55
|
+
var d, g, n, l;
|
|
56
56
|
if (!this.isEnabled() || !this.initialized || !this.client) return;
|
|
57
|
-
const r = ((
|
|
57
|
+
const r = ((d = e == null ? void 0 : e.user) == null ? void 0 : d.email) || this.currentUserEmail || ((g = e == null ? void 0 : e.user) == null ? void 0 : g.userId) || i.userId;
|
|
58
58
|
if (!r || !r.includes("@")) {
|
|
59
59
|
console.warn(
|
|
60
60
|
"[Bento-Server] Skipping event - Bento requires an email address. Anonymous events are not currently supported by the Bento Node SDK. For now, use the Bento client provider for anonymous tracking. If you're using a proxy, use the hybrid pattern as described in the docs. For identified users, call identify() with a valid email before tracking events."
|
|
61
61
|
);
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
|
-
const
|
|
64
|
+
const h = {
|
|
65
65
|
...i.properties,
|
|
66
66
|
category: i.category,
|
|
67
67
|
timestamp: i.timestamp || Date.now(),
|
|
@@ -80,30 +80,30 @@ class N extends q {
|
|
|
80
80
|
...(e == null ? void 0 : e.device) && { device: e.device },
|
|
81
81
|
...(e == null ? void 0 : e.utm) && { utm: e.utm },
|
|
82
82
|
site: this.config.siteUuid,
|
|
83
|
-
...((
|
|
84
|
-
}, s = ((
|
|
83
|
+
...((n = e == null ? void 0 : e.user) == null ? void 0 : n.userId) && { visitor: e.user.userId }
|
|
84
|
+
}, s = ((l = e == null ? void 0 : e.user) == null ? void 0 : l.traits) || {};
|
|
85
85
|
try {
|
|
86
86
|
await this.client.V1.track({
|
|
87
87
|
email: r,
|
|
88
88
|
type: `$${i.action}`,
|
|
89
|
-
details:
|
|
89
|
+
details: h,
|
|
90
90
|
fields: s
|
|
91
91
|
}), this.log("Tracked event", { event: i, context: e });
|
|
92
|
-
} catch (
|
|
93
|
-
console.error("[Bento-Server] Failed to track event:",
|
|
92
|
+
} catch (a) {
|
|
93
|
+
console.error("[Bento-Server] Failed to track event:", a);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
pageView(i, e) {
|
|
97
|
-
var
|
|
97
|
+
var d, g, n;
|
|
98
98
|
if (!this.isEnabled() || !this.initialized || !this.client) return;
|
|
99
|
-
const r = ((
|
|
99
|
+
const r = ((d = e == null ? void 0 : e.user) == null ? void 0 : d.email) || this.currentUserEmail;
|
|
100
100
|
if (!r || !r.includes("@")) {
|
|
101
101
|
console.warn(
|
|
102
102
|
"[Bento-Server] Skipping pageView - Bento requires an email address. Anonymous events are not currently supported by the Bento Node SDK. For now, use the Bento client provider for anonymous tracking. If you're using a proxy, use the hybrid pattern as described in the docs. For identified users, call identify() with a valid email before tracking events."
|
|
103
103
|
);
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
|
-
const
|
|
106
|
+
const h = {
|
|
107
107
|
...i,
|
|
108
108
|
date: (/* @__PURE__ */ new Date()).toISOString(),
|
|
109
109
|
...(e == null ? void 0 : e.page) && {
|
|
@@ -118,15 +118,15 @@ class N extends q {
|
|
|
118
118
|
}
|
|
119
119
|
},
|
|
120
120
|
site: this.config.siteUuid,
|
|
121
|
-
...((
|
|
122
|
-
}, s = ((
|
|
121
|
+
...((g = e == null ? void 0 : e.user) == null ? void 0 : g.userId) && { visitor: e.user.userId }
|
|
122
|
+
}, s = ((n = e == null ? void 0 : e.user) == null ? void 0 : n.traits) || {};
|
|
123
123
|
this.client.V1.track({
|
|
124
124
|
email: r,
|
|
125
125
|
type: "$view",
|
|
126
|
-
details:
|
|
126
|
+
details: h,
|
|
127
127
|
fields: s
|
|
128
|
-
}).catch((
|
|
129
|
-
console.error("[Bento-Server] Failed to track page view:",
|
|
128
|
+
}).catch((l) => {
|
|
129
|
+
console.error("[Bento-Server] Failed to track page view:", l);
|
|
130
130
|
}), this.log("Tracked page view", { properties: i, context: e });
|
|
131
131
|
}
|
|
132
132
|
async reset() {
|
|
@@ -136,13 +136,13 @@ class N extends q {
|
|
|
136
136
|
this.client = void 0, this.initialized = !1, this.log("Shutdown complete");
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
class W extends
|
|
139
|
+
class W extends V {
|
|
140
140
|
constructor(i) {
|
|
141
141
|
super({ debug: i.debug, enabled: i.enabled });
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
t(this, "name", "Pirsch-Server");
|
|
143
|
+
t(this, "client");
|
|
144
|
+
t(this, "initialized", !1);
|
|
145
|
+
t(this, "config");
|
|
146
146
|
this.config = i;
|
|
147
147
|
}
|
|
148
148
|
async initialize() {
|
|
@@ -157,7 +157,7 @@ class W extends q {
|
|
|
157
157
|
"Pirsch requires a clientId when using OAuth authentication (clientSecret doesn't start with 'pa_'). Either provide a clientId or use an access key (starts with 'pa_') as clientSecret."
|
|
158
158
|
);
|
|
159
159
|
try {
|
|
160
|
-
const { Pirsch: e } = await import("../index-zS7gy63J.js").then((
|
|
160
|
+
const { Pirsch: e } = await import("../index-zS7gy63J.js").then((d) => d.i), { debug: r, enabled: h, ...s } = this.config;
|
|
161
161
|
this.client = new e(s), this.initialized = !0, this.log("Initialized successfully", {
|
|
162
162
|
hostname: this.config.hostname,
|
|
163
163
|
authMode: i ? "access-key" : "oauth"
|
|
@@ -175,7 +175,7 @@ class W extends q {
|
|
|
175
175
|
url: "https://identify",
|
|
176
176
|
ip: "0.0.0.0",
|
|
177
177
|
user_agent: "analytics-library"
|
|
178
|
-
},
|
|
178
|
+
}, h = {
|
|
179
179
|
userId: i,
|
|
180
180
|
...e && Object.fromEntries(
|
|
181
181
|
Object.entries(e).filter(
|
|
@@ -183,25 +183,25 @@ class W extends q {
|
|
|
183
183
|
)
|
|
184
184
|
)
|
|
185
185
|
};
|
|
186
|
-
this.client.event("user_identified", r, 0,
|
|
186
|
+
this.client.event("user_identified", r, 0, h).catch((s) => {
|
|
187
187
|
console.error("[Pirsch-Server] Failed to track identify event:", s);
|
|
188
188
|
}), this.log("Identified user via event", { userId: i, traits: e });
|
|
189
189
|
}
|
|
190
190
|
async track(i, e) {
|
|
191
|
-
var
|
|
191
|
+
var a, o, f, y, c, w, m, b, S, k, I, _, E, P, z, B, A, F, v, $, K, j, O;
|
|
192
192
|
if (!this.isEnabled() || !this.initialized || !this.client) return;
|
|
193
|
-
const r = e,
|
|
194
|
-
if (!
|
|
193
|
+
const r = e, h = ((a = r == null ? void 0 : r.device) == null ? void 0 : a.ip) || ((o = r == null ? void 0 : r.server) == null ? void 0 : o.ip), s = ((f = r == null ? void 0 : r.server) == null ? void 0 : f.userAgent) || ((y = r == null ? void 0 : r.device) == null ? void 0 : y.userAgent);
|
|
194
|
+
if (!h || !s) {
|
|
195
195
|
this.log("Skipping event - missing required IP or user-agent from context", {
|
|
196
|
-
hasIp: !!
|
|
196
|
+
hasIp: !!h,
|
|
197
197
|
hasUserAgent: !!s,
|
|
198
198
|
event: i.action
|
|
199
199
|
});
|
|
200
200
|
return;
|
|
201
201
|
}
|
|
202
|
-
const
|
|
203
|
-
url: ((
|
|
204
|
-
ip:
|
|
202
|
+
const g = {
|
|
203
|
+
url: ((c = e == null ? void 0 : e.page) == null ? void 0 : c.url) || ((w = e == null ? void 0 : e.page) != null && w.protocol && ((m = e == null ? void 0 : e.page) != null && m.host) && ((b = e == null ? void 0 : e.page) != null && b.path) ? `${e.page.protocol}://${e.page.host}${e.page.path}` : (S = e == null ? void 0 : e.page) != null && S.path ? `https://${this.config.hostname}${e.page.path}` : "https://event"),
|
|
204
|
+
ip: h,
|
|
205
205
|
user_agent: s,
|
|
206
206
|
...((k = e == null ? void 0 : e.page) == null ? void 0 : k.title) && { title: e.page.title },
|
|
207
207
|
...((I = e == null ? void 0 : e.page) == null ? void 0 : I.referrer) && { referrer: e.page.referrer },
|
|
@@ -209,9 +209,9 @@ class W extends q {
|
|
|
209
209
|
...((z = (P = e == null ? void 0 : e.device) == null ? void 0 : P.screen) == null ? void 0 : z.height) && { screen_height: e.device.screen.height },
|
|
210
210
|
...((A = (B = e == null ? void 0 : e.device) == null ? void 0 : B.viewport) == null ? void 0 : A.width) && { sec_ch_viewport_width: String(e.device.viewport.width) },
|
|
211
211
|
...((F = e == null ? void 0 : e.device) == null ? void 0 : F.language) && { accept_language: e.device.language },
|
|
212
|
-
...((
|
|
212
|
+
...((v = e == null ? void 0 : e.device) == null ? void 0 : v.type) && { sec_ch_ua_mobile: e.device.type === "mobile" || e.device.type === "tablet" ? "?1" : "?0" },
|
|
213
213
|
...(($ = e == null ? void 0 : e.device) == null ? void 0 : $.os) && { sec_ch_ua_platform: e.device.os }
|
|
214
|
-
},
|
|
214
|
+
}, l = {
|
|
215
215
|
...Object.fromEntries(
|
|
216
216
|
Object.entries(i.properties).filter(
|
|
217
217
|
([, U]) => typeof U == "string" || typeof U == "number" || typeof U == "boolean"
|
|
@@ -222,29 +222,29 @@ class W extends q {
|
|
|
222
222
|
...i.userId && { userId: i.userId },
|
|
223
223
|
...i.sessionId && { sessionId: i.sessionId },
|
|
224
224
|
...((K = e == null ? void 0 : e.user) == null ? void 0 : K.email) && { user_email: e.user.email },
|
|
225
|
-
...((
|
|
226
|
-
...((
|
|
225
|
+
...((j = e == null ? void 0 : e.device) == null ? void 0 : j.timezone) && { timezone: e.device.timezone },
|
|
226
|
+
...((O = e == null ? void 0 : e.device) == null ? void 0 : O.browser) && { browser: e.device.browser }
|
|
227
227
|
};
|
|
228
228
|
try {
|
|
229
|
-
await this.client.event(i.action,
|
|
229
|
+
await this.client.event(i.action, g, 0, l), this.log("Tracked event", { event: i, context: e });
|
|
230
230
|
} catch (U) {
|
|
231
231
|
console.error("[Pirsch-Server] Failed to track event:", U);
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
pageView(i, e) {
|
|
235
|
-
var
|
|
235
|
+
var n, l, a, o, f, y, c, w, m, b, S, k, I, _, E, P, z, B, A, F;
|
|
236
236
|
if (!this.isEnabled() || !this.initialized || !this.client) return;
|
|
237
|
-
const r = e,
|
|
238
|
-
if (!
|
|
237
|
+
const r = e, h = ((n = r == null ? void 0 : r.device) == null ? void 0 : n.ip) || ((l = r == null ? void 0 : r.server) == null ? void 0 : l.ip), s = ((a = r == null ? void 0 : r.server) == null ? void 0 : a.userAgent) || ((o = r == null ? void 0 : r.device) == null ? void 0 : o.userAgent);
|
|
238
|
+
if (!h || !s) {
|
|
239
239
|
this.log("Skipping pageView - missing required IP or user-agent from context", {
|
|
240
|
-
hasIp: !!
|
|
240
|
+
hasIp: !!h,
|
|
241
241
|
hasUserAgent: !!s
|
|
242
242
|
});
|
|
243
243
|
return;
|
|
244
244
|
}
|
|
245
|
-
const
|
|
246
|
-
url: ((
|
|
247
|
-
ip:
|
|
245
|
+
const g = {
|
|
246
|
+
url: ((f = e == null ? void 0 : e.page) == null ? void 0 : f.url) || ((y = e == null ? void 0 : e.page) != null && y.protocol && ((c = e == null ? void 0 : e.page) != null && c.host) && ((w = e == null ? void 0 : e.page) != null && w.path) ? `${e.page.protocol}://${e.page.host}${e.page.path}` : (m = e == null ? void 0 : e.page) != null && m.path ? `https://${this.config.hostname}${e.page.path}` : "https://pageview"),
|
|
247
|
+
ip: h,
|
|
248
248
|
user_agent: s,
|
|
249
249
|
...((b = e == null ? void 0 : e.page) == null ? void 0 : b.title) && { title: e.page.title },
|
|
250
250
|
...((S = e == null ? void 0 : e.page) == null ? void 0 : S.referrer) && { referrer: e.page.referrer },
|
|
@@ -257,13 +257,13 @@ class W extends q {
|
|
|
257
257
|
...i && {
|
|
258
258
|
tags: Object.fromEntries(
|
|
259
259
|
Object.entries(i).filter(
|
|
260
|
-
([,
|
|
260
|
+
([, v]) => typeof v == "string" || typeof v == "number" || typeof v == "boolean"
|
|
261
261
|
)
|
|
262
262
|
)
|
|
263
263
|
}
|
|
264
264
|
};
|
|
265
|
-
this.client.hit(
|
|
266
|
-
console.error("[Pirsch-Server] Failed to track page view:",
|
|
265
|
+
this.client.hit(g).catch((v) => {
|
|
266
|
+
console.error("[Pirsch-Server] Failed to track page view:", v);
|
|
267
267
|
}), this.log("Tracked page view", { properties: i, context: e });
|
|
268
268
|
}
|
|
269
269
|
async reset() {
|
|
@@ -281,68 +281,80 @@ class W extends q {
|
|
|
281
281
|
this.client = void 0, this.initialized = !1, this.log("Shutdown complete");
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
|
-
async function R(
|
|
285
|
-
var e, r;
|
|
284
|
+
async function R(p, u, i) {
|
|
285
|
+
var e, r, h, s;
|
|
286
286
|
try {
|
|
287
|
-
const
|
|
288
|
-
if (!
|
|
287
|
+
const d = await p.json();
|
|
288
|
+
if (!d.events || !Array.isArray(d.events))
|
|
289
289
|
throw new Error("Invalid payload: missing events array");
|
|
290
|
-
const
|
|
291
|
-
for (const
|
|
290
|
+
const g = i != null && i.extractIp ? i.extractIp(p) : T(p), n = p.headers.get("user-agent"), l = i != null && i.enrichContext ? i.enrichContext(p) : {};
|
|
291
|
+
for (const a of d.events)
|
|
292
292
|
try {
|
|
293
|
-
switch (
|
|
293
|
+
switch (a.type) {
|
|
294
294
|
case "track": {
|
|
295
|
-
const
|
|
296
|
-
...
|
|
297
|
-
...
|
|
295
|
+
const o = {
|
|
296
|
+
...a.context,
|
|
297
|
+
...l,
|
|
298
|
+
server: {
|
|
299
|
+
...(e = a.context) == null ? void 0 : e.server,
|
|
300
|
+
...typeof (l == null ? void 0 : l.server) == "object" && l.server !== null ? l.server : {},
|
|
301
|
+
...n ? { userAgent: n } : {}
|
|
302
|
+
},
|
|
298
303
|
device: {
|
|
299
|
-
...(
|
|
300
|
-
|
|
301
|
-
// biome-ignore lint/suspicious/noExplicitAny: IP field not in base device type
|
|
302
|
-
...s ? { ip: s } : {}
|
|
304
|
+
...(r = a.context) == null ? void 0 : r.device,
|
|
305
|
+
...g ? { ip: g } : {}
|
|
303
306
|
}
|
|
304
307
|
};
|
|
305
|
-
await
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
308
|
+
await u.track(
|
|
309
|
+
a.event.action,
|
|
310
|
+
// biome-ignore lint/suspicious/noExplicitAny: Properties from JSON cannot be type-checked against TEventMap at compile time
|
|
311
|
+
a.event.properties,
|
|
312
|
+
{
|
|
313
|
+
userId: a.event.userId,
|
|
314
|
+
sessionId: a.event.sessionId,
|
|
315
|
+
context: o
|
|
316
|
+
}
|
|
317
|
+
);
|
|
311
318
|
break;
|
|
312
319
|
}
|
|
313
320
|
case "identify": {
|
|
314
|
-
|
|
321
|
+
u.identify(a.userId, a.traits);
|
|
315
322
|
break;
|
|
316
323
|
}
|
|
317
324
|
case "pageView": {
|
|
318
|
-
const
|
|
319
|
-
...
|
|
320
|
-
...
|
|
325
|
+
const o = {
|
|
326
|
+
...a.context,
|
|
327
|
+
...l,
|
|
328
|
+
server: {
|
|
329
|
+
...(h = a.context) == null ? void 0 : h.server,
|
|
330
|
+
...typeof (l == null ? void 0 : l.server) == "object" && l.server !== null ? l.server : {},
|
|
331
|
+
...n ? { userAgent: n } : {}
|
|
332
|
+
},
|
|
321
333
|
device: {
|
|
322
|
-
...(
|
|
323
|
-
|
|
324
|
-
// Add IP (using type assertion for extended fields)
|
|
325
|
-
...s ? { ip: s } : {}
|
|
334
|
+
...(s = a.context) == null ? void 0 : s.device,
|
|
335
|
+
...g ? { ip: g } : {}
|
|
326
336
|
}
|
|
327
337
|
};
|
|
328
|
-
|
|
338
|
+
u.pageView(a.properties, {
|
|
339
|
+
context: o
|
|
340
|
+
});
|
|
329
341
|
break;
|
|
330
342
|
}
|
|
331
343
|
case "reset":
|
|
332
344
|
break;
|
|
333
345
|
default:
|
|
334
|
-
console.warn("[Proxy] Unknown event type:",
|
|
346
|
+
console.warn("[Proxy] Unknown event type:", a);
|
|
335
347
|
}
|
|
336
|
-
} catch (
|
|
337
|
-
i != null && i.onError ? i.onError(
|
|
348
|
+
} catch (o) {
|
|
349
|
+
i != null && i.onError ? i.onError(o) : console.error("[Proxy] Failed to process event:", o);
|
|
338
350
|
}
|
|
339
|
-
} catch (
|
|
340
|
-
throw i != null && i.onError ? i.onError(
|
|
351
|
+
} catch (d) {
|
|
352
|
+
throw i != null && i.onError ? i.onError(d) : console.error("[Proxy] Failed to ingest events:", d), d;
|
|
341
353
|
}
|
|
342
354
|
}
|
|
343
|
-
function T(
|
|
355
|
+
function T(p) {
|
|
344
356
|
var i;
|
|
345
|
-
const
|
|
357
|
+
const u = [
|
|
346
358
|
"x-forwarded-for",
|
|
347
359
|
"x-real-ip",
|
|
348
360
|
"cf-connecting-ip",
|
|
@@ -350,23 +362,23 @@ function T(d) {
|
|
|
350
362
|
"x-client-ip",
|
|
351
363
|
"x-cluster-client-ip"
|
|
352
364
|
];
|
|
353
|
-
for (const e of
|
|
354
|
-
const r =
|
|
365
|
+
for (const e of u) {
|
|
366
|
+
const r = p.headers.get(e);
|
|
355
367
|
if (r)
|
|
356
368
|
return (i = r.split(",")[0]) == null ? void 0 : i.trim();
|
|
357
369
|
}
|
|
358
370
|
}
|
|
359
|
-
function G(
|
|
371
|
+
function G(p, u) {
|
|
360
372
|
return async (i) => {
|
|
361
373
|
try {
|
|
362
|
-
return await R(i,
|
|
374
|
+
return await R(i, p, u), new Response("OK", { status: 200 });
|
|
363
375
|
} catch (e) {
|
|
364
376
|
return console.error("[Proxy] Handler error:", e), new Response("Internal Server Error", { status: 500 });
|
|
365
377
|
}
|
|
366
378
|
};
|
|
367
379
|
}
|
|
368
380
|
export {
|
|
369
|
-
|
|
381
|
+
V as BaseAnalyticsProvider,
|
|
370
382
|
N as BentoServerProvider,
|
|
371
383
|
W as PirschServerProvider,
|
|
372
384
|
Q as PostHogServerProvider,
|