@stacksee/analytics 0.9.5 → 0.9.7
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 +11 -0
- package/dist/providers/server.js +149 -113
- package/package.json +1 -1
|
@@ -28,6 +28,17 @@ export interface EventContext<TTraits extends Record<string, unknown> = Record<s
|
|
|
28
28
|
type?: string;
|
|
29
29
|
os?: string;
|
|
30
30
|
browser?: string;
|
|
31
|
+
userAgent?: string;
|
|
32
|
+
language?: string;
|
|
33
|
+
timezone?: string;
|
|
34
|
+
screen?: {
|
|
35
|
+
width?: number;
|
|
36
|
+
height?: number;
|
|
37
|
+
};
|
|
38
|
+
viewport?: {
|
|
39
|
+
width?: number;
|
|
40
|
+
height?: number;
|
|
41
|
+
};
|
|
31
42
|
};
|
|
32
43
|
utm?: {
|
|
33
44
|
source?: string;
|
package/dist/providers/server.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { B as
|
|
5
|
-
import { P as
|
|
6
|
-
class
|
|
1
|
+
var j = Object.defineProperty;
|
|
2
|
+
var D = (d, h, i) => h in d ? j(d, h, { enumerable: !0, configurable: !0, writable: !0, value: i }) : d[h] = i;
|
|
3
|
+
var g = (d, h, i) => D(d, typeof h != "symbol" ? h + "" : h, i);
|
|
4
|
+
import { B as q } from "../base.provider-AfFL5W_P.js";
|
|
5
|
+
import { P as Q } from "../server-DjEk1fUD.js";
|
|
6
|
+
class N extends q {
|
|
7
7
|
constructor(i) {
|
|
8
8
|
super({ debug: i.debug, enabled: i.enabled });
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
g(this, "name", "Bento-Server");
|
|
10
|
+
g(this, "client");
|
|
11
|
+
g(this, "initialized", !1);
|
|
12
|
+
g(this, "config");
|
|
13
|
+
g(this, "currentUserEmail");
|
|
14
14
|
this.config = i;
|
|
15
15
|
}
|
|
16
16
|
async initialize() {
|
|
@@ -23,8 +23,8 @@ class A extends I {
|
|
|
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: a, enabled: s, ...u } = this.config;
|
|
27
|
+
this.client = new r(u), this.initialized = !0, this.log("Initialized successfully", {
|
|
28
28
|
siteUuid: this.config.siteUuid
|
|
29
29
|
});
|
|
30
30
|
} catch (r) {
|
|
@@ -43,25 +43,25 @@ class A extends I {
|
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
this.currentUserEmail = r;
|
|
46
|
-
const
|
|
47
|
-
delete
|
|
46
|
+
const a = e ? { ...e } : {};
|
|
47
|
+
delete a.email, this.client.V1.addSubscriber({
|
|
48
48
|
email: r,
|
|
49
|
-
fields:
|
|
50
|
-
}).catch((
|
|
51
|
-
console.error("[Bento-Server] Failed to identify user:",
|
|
49
|
+
fields: a
|
|
50
|
+
}).catch((s) => {
|
|
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 u, l, p, n;
|
|
56
56
|
if (!this.isEnabled() || !this.initialized || !this.client) return;
|
|
57
|
-
const r = ((
|
|
57
|
+
const r = ((u = e == null ? void 0 : e.user) == null ? void 0 : u.email) || this.currentUserEmail || ((l = e == null ? void 0 : e.user) == null ? void 0 : l.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 a = {
|
|
65
65
|
...i.properties,
|
|
66
66
|
category: i.category,
|
|
67
67
|
timestamp: i.timestamp || Date.now(),
|
|
@@ -80,30 +80,30 @@ class A extends I {
|
|
|
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
|
-
},
|
|
83
|
+
...((p = e == null ? void 0 : e.user) == null ? void 0 : p.userId) && { visitor: e.user.userId }
|
|
84
|
+
}, s = ((n = e == null ? void 0 : e.user) == null ? void 0 : n.traits) || {};
|
|
85
85
|
try {
|
|
86
86
|
await this.client.V1.track({
|
|
87
87
|
email: r,
|
|
88
88
|
type: `$${i.action}`,
|
|
89
|
-
details:
|
|
90
|
-
fields:
|
|
89
|
+
details: a,
|
|
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 (t) {
|
|
93
|
+
console.error("[Bento-Server] Failed to track event:", t);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
pageView(i, e) {
|
|
97
|
-
var
|
|
97
|
+
var u, l, p;
|
|
98
98
|
if (!this.isEnabled() || !this.initialized || !this.client) return;
|
|
99
|
-
const r = ((
|
|
99
|
+
const r = ((u = e == null ? void 0 : e.user) == null ? void 0 : u.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 a = {
|
|
107
107
|
...i,
|
|
108
108
|
date: (/* @__PURE__ */ new Date()).toISOString(),
|
|
109
109
|
...(e == null ? void 0 : e.page) && {
|
|
@@ -119,14 +119,14 @@ class A extends I {
|
|
|
119
119
|
},
|
|
120
120
|
site: this.config.siteUuid,
|
|
121
121
|
...((l = e == null ? void 0 : e.user) == null ? void 0 : l.userId) && { visitor: e.user.userId }
|
|
122
|
-
},
|
|
122
|
+
}, s = ((p = e == null ? void 0 : e.user) == null ? void 0 : p.traits) || {};
|
|
123
123
|
this.client.V1.track({
|
|
124
124
|
email: r,
|
|
125
125
|
type: "$view",
|
|
126
|
-
details:
|
|
127
|
-
fields:
|
|
128
|
-
}).catch((
|
|
129
|
-
console.error("[Bento-Server] Failed to track page view:",
|
|
126
|
+
details: a,
|
|
127
|
+
fields: s
|
|
128
|
+
}).catch((n) => {
|
|
129
|
+
console.error("[Bento-Server] Failed to track page view:", n);
|
|
130
130
|
}), this.log("Tracked page view", { properties: i, context: e });
|
|
131
131
|
}
|
|
132
132
|
async reset() {
|
|
@@ -136,32 +136,37 @@ class A extends I {
|
|
|
136
136
|
this.client = void 0, this.initialized = !1, this.log("Shutdown complete");
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
class
|
|
139
|
+
class W extends q {
|
|
140
140
|
constructor(i) {
|
|
141
141
|
super({ debug: i.debug, enabled: i.enabled });
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
g(this, "name", "Pirsch-Server");
|
|
143
|
+
g(this, "client");
|
|
144
|
+
g(this, "initialized", !1);
|
|
145
|
+
g(this, "config");
|
|
146
146
|
this.config = i;
|
|
147
147
|
}
|
|
148
148
|
async initialize() {
|
|
149
|
-
if (this.isEnabled()
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
149
|
+
if (!this.isEnabled() || this.initialized) return;
|
|
150
|
+
if (!this.config.hostname || typeof this.config.hostname != "string")
|
|
151
|
+
throw new Error("Pirsch requires a hostname");
|
|
152
|
+
if (!this.config.clientSecret || typeof this.config.clientSecret != "string")
|
|
153
|
+
throw new Error("Pirsch requires a clientSecret (or access key)");
|
|
154
|
+
const i = this.config.clientSecret.startsWith("pa_");
|
|
155
|
+
if (!i && !this.config.clientId)
|
|
156
|
+
throw new Error(
|
|
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
|
+
);
|
|
159
|
+
try {
|
|
160
|
+
const { Pirsch: e } = await import("../index-zS7gy63J.js").then((u) => u.i), { debug: r, enabled: a, ...s } = this.config;
|
|
161
|
+
this.client = new e(s), this.initialized = !0, this.log("Initialized successfully", {
|
|
162
|
+
hostname: this.config.hostname,
|
|
163
|
+
authMode: i ? "access-key" : "oauth"
|
|
164
|
+
});
|
|
165
|
+
} catch (e) {
|
|
166
|
+
throw console.error(
|
|
167
|
+
"[Pirsch-Server] Failed to initialize. Make sure pirsch-sdk is installed:",
|
|
168
|
+
e
|
|
169
|
+
), e;
|
|
165
170
|
}
|
|
166
171
|
}
|
|
167
172
|
identify(i, e) {
|
|
@@ -170,64 +175,95 @@ class K extends I {
|
|
|
170
175
|
url: "https://identify",
|
|
171
176
|
ip: "0.0.0.0",
|
|
172
177
|
user_agent: "analytics-library"
|
|
173
|
-
},
|
|
178
|
+
}, a = {
|
|
174
179
|
userId: i,
|
|
175
180
|
...e && Object.fromEntries(
|
|
176
181
|
Object.entries(e).filter(
|
|
177
|
-
([,
|
|
182
|
+
([, s]) => typeof s == "string" || typeof s == "number" || typeof s == "boolean"
|
|
178
183
|
)
|
|
179
184
|
)
|
|
180
185
|
};
|
|
181
|
-
this.client.event("user_identified", r, 0,
|
|
182
|
-
console.error("[Pirsch-Server] Failed to track identify event:",
|
|
186
|
+
this.client.event("user_identified", r, 0, a).catch((s) => {
|
|
187
|
+
console.error("[Pirsch-Server] Failed to track identify event:", s);
|
|
183
188
|
}), this.log("Identified user via event", { userId: i, traits: e });
|
|
184
189
|
}
|
|
185
190
|
async track(i, e) {
|
|
186
|
-
var
|
|
191
|
+
var t, f, v, y, w, c, m, b, S, k, I, _, E, P, z, B, A, F, o, $, K, O, V;
|
|
187
192
|
if (!this.isEnabled() || !this.initialized || !this.client) return;
|
|
188
|
-
const r = e,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
const r = e, a = ((t = r == null ? void 0 : r.device) == null ? void 0 : t.ip) || ((f = r == null ? void 0 : r.server) == null ? void 0 : f.ip), s = ((v = r == null ? void 0 : r.server) == null ? void 0 : v.userAgent) || ((y = r == null ? void 0 : r.device) == null ? void 0 : y.userAgent);
|
|
194
|
+
if (!a || !s) {
|
|
195
|
+
this.log("Skipping event - missing required IP or user-agent from context", {
|
|
196
|
+
hasIp: !!a,
|
|
197
|
+
hasUserAgent: !!s,
|
|
198
|
+
event: i.action
|
|
199
|
+
});
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const l = {
|
|
203
|
+
url: ((w = e == null ? void 0 : e.page) == null ? void 0 : w.url) || ((c = e == null ? void 0 : e.page) != null && c.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: a,
|
|
205
|
+
user_agent: s,
|
|
206
|
+
...((k = e == null ? void 0 : e.page) == null ? void 0 : k.title) && { title: e.page.title },
|
|
207
|
+
...((I = e == null ? void 0 : e.page) == null ? void 0 : I.referrer) && { referrer: e.page.referrer },
|
|
208
|
+
...((E = (_ = e == null ? void 0 : e.device) == null ? void 0 : _.screen) == null ? void 0 : E.width) && { screen_width: e.device.screen.width },
|
|
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
|
+
...((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
|
+
...((F = e == null ? void 0 : e.device) == null ? void 0 : F.language) && { accept_language: e.device.language },
|
|
212
|
+
...((o = e == null ? void 0 : e.device) == null ? void 0 : o.type) && { sec_ch_ua_mobile: e.device.type === "mobile" || e.device.type === "tablet" ? "?1" : "?0" },
|
|
213
|
+
...(($ = e == null ? void 0 : e.device) == null ? void 0 : $.os) && { sec_ch_ua_platform: e.device.os }
|
|
214
|
+
}, n = {
|
|
195
215
|
...Object.fromEntries(
|
|
196
216
|
Object.entries(i.properties).filter(
|
|
197
|
-
([,
|
|
217
|
+
([, U]) => typeof U == "string" || typeof U == "number" || typeof U == "boolean"
|
|
198
218
|
)
|
|
199
219
|
),
|
|
200
220
|
category: i.category,
|
|
201
221
|
timestamp: String(i.timestamp || Date.now()),
|
|
202
222
|
...i.userId && { userId: i.userId },
|
|
203
223
|
...i.sessionId && { sessionId: i.sessionId },
|
|
204
|
-
...((
|
|
224
|
+
...((K = e == null ? void 0 : e.user) == null ? void 0 : K.email) && { user_email: e.user.email },
|
|
225
|
+
...((O = e == null ? void 0 : e.device) == null ? void 0 : O.timezone) && { timezone: e.device.timezone },
|
|
226
|
+
...((V = e == null ? void 0 : e.device) == null ? void 0 : V.browser) && { browser: e.device.browser }
|
|
205
227
|
};
|
|
206
228
|
try {
|
|
207
|
-
await this.client.event(i.action, l, 0,
|
|
208
|
-
} catch (
|
|
209
|
-
console.error("[Pirsch-Server] Failed to track event:",
|
|
229
|
+
await this.client.event(i.action, l, 0, n), this.log("Tracked event", { event: i, context: e });
|
|
230
|
+
} catch (U) {
|
|
231
|
+
console.error("[Pirsch-Server] Failed to track event:", U);
|
|
210
232
|
}
|
|
211
233
|
}
|
|
212
234
|
pageView(i, e) {
|
|
213
|
-
var
|
|
235
|
+
var p, n, t, f, v, y, w, c, m, b, S, k, I, _, E, P, z, B, A, F;
|
|
214
236
|
if (!this.isEnabled() || !this.initialized || !this.client) return;
|
|
215
|
-
const r = e,
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
237
|
+
const r = e, a = ((p = r == null ? void 0 : r.device) == null ? void 0 : p.ip) || ((n = r == null ? void 0 : r.server) == null ? void 0 : n.ip), s = ((t = r == null ? void 0 : r.server) == null ? void 0 : t.userAgent) || ((f = r == null ? void 0 : r.device) == null ? void 0 : f.userAgent);
|
|
238
|
+
if (!a || !s) {
|
|
239
|
+
this.log("Skipping pageView - missing required IP or user-agent from context", {
|
|
240
|
+
hasIp: !!a,
|
|
241
|
+
hasUserAgent: !!s
|
|
242
|
+
});
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
const l = {
|
|
246
|
+
url: ((v = e == null ? void 0 : e.page) == null ? void 0 : v.url) || ((y = e == null ? void 0 : e.page) != null && y.protocol && ((w = e == null ? void 0 : e.page) != null && w.host) && ((c = e == null ? void 0 : e.page) != null && c.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: a,
|
|
248
|
+
user_agent: s,
|
|
219
249
|
...((b = e == null ? void 0 : e.page) == null ? void 0 : b.title) && { title: e.page.title },
|
|
220
|
-
...((
|
|
250
|
+
...((S = e == null ? void 0 : e.page) == null ? void 0 : S.referrer) && { referrer: e.page.referrer },
|
|
251
|
+
...((I = (k = e == null ? void 0 : e.device) == null ? void 0 : k.screen) == null ? void 0 : I.width) && { screen_width: e.device.screen.width },
|
|
252
|
+
...((E = (_ = e == null ? void 0 : e.device) == null ? void 0 : _.screen) == null ? void 0 : E.height) && { screen_height: e.device.screen.height },
|
|
253
|
+
...((z = (P = e == null ? void 0 : e.device) == null ? void 0 : P.viewport) == null ? void 0 : z.width) && { sec_ch_viewport_width: String(e.device.viewport.width) },
|
|
254
|
+
...((B = e == null ? void 0 : e.device) == null ? void 0 : B.language) && { accept_language: e.device.language },
|
|
255
|
+
...((A = e == null ? void 0 : e.device) == null ? void 0 : A.type) && { sec_ch_ua_mobile: e.device.type === "mobile" || e.device.type === "tablet" ? "?1" : "?0" },
|
|
256
|
+
...((F = e == null ? void 0 : e.device) == null ? void 0 : F.os) && { sec_ch_ua_platform: e.device.os },
|
|
221
257
|
...i && {
|
|
222
258
|
tags: Object.fromEntries(
|
|
223
259
|
Object.entries(i).filter(
|
|
224
|
-
([,
|
|
260
|
+
([, o]) => typeof o == "string" || typeof o == "number" || typeof o == "boolean"
|
|
225
261
|
)
|
|
226
262
|
)
|
|
227
263
|
}
|
|
228
264
|
};
|
|
229
|
-
this.client.hit(l).catch((
|
|
230
|
-
console.error("[Pirsch-Server] Failed to track page view:",
|
|
265
|
+
this.client.hit(l).catch((o) => {
|
|
266
|
+
console.error("[Pirsch-Server] Failed to track page view:", o);
|
|
231
267
|
}), this.log("Tracked page view", { properties: i, context: e });
|
|
232
268
|
}
|
|
233
269
|
async reset() {
|
|
@@ -245,51 +281,51 @@ class K extends I {
|
|
|
245
281
|
this.client = void 0, this.initialized = !1, this.log("Shutdown complete");
|
|
246
282
|
}
|
|
247
283
|
}
|
|
248
|
-
async function
|
|
284
|
+
async function R(d, h, i) {
|
|
249
285
|
var e, r;
|
|
250
286
|
try {
|
|
251
|
-
const
|
|
252
|
-
if (!
|
|
287
|
+
const a = await d.json();
|
|
288
|
+
if (!a.events || !Array.isArray(a.events))
|
|
253
289
|
throw new Error("Invalid payload: missing events array");
|
|
254
|
-
const
|
|
255
|
-
for (const l of
|
|
290
|
+
const s = i != null && i.extractIp ? i.extractIp(d) : T(d), u = i != null && i.enrichContext ? i.enrichContext(d) : {};
|
|
291
|
+
for (const l of a.events)
|
|
256
292
|
try {
|
|
257
293
|
switch (l.type) {
|
|
258
294
|
case "track": {
|
|
259
|
-
const
|
|
295
|
+
const p = {
|
|
260
296
|
...l.context,
|
|
261
|
-
...
|
|
297
|
+
...u,
|
|
262
298
|
device: {
|
|
263
299
|
...(e = l.context) == null ? void 0 : e.device,
|
|
264
300
|
// Add IP (using type assertion for extended fields)
|
|
265
301
|
// biome-ignore lint/suspicious/noExplicitAny: IP field not in base device type
|
|
266
|
-
...
|
|
302
|
+
...s ? { ip: s } : {}
|
|
267
303
|
}
|
|
268
304
|
};
|
|
269
|
-
await
|
|
305
|
+
await h.track(l.event.action, l.event.properties, {
|
|
270
306
|
userId: l.event.userId,
|
|
271
307
|
sessionId: l.event.sessionId,
|
|
272
308
|
// biome-ignore lint/suspicious/noExplicitAny: Generic context forwarding requires type assertion
|
|
273
|
-
context:
|
|
309
|
+
context: p
|
|
274
310
|
});
|
|
275
311
|
break;
|
|
276
312
|
}
|
|
277
313
|
case "identify": {
|
|
278
|
-
|
|
314
|
+
h.identify(l.userId, l.traits);
|
|
279
315
|
break;
|
|
280
316
|
}
|
|
281
317
|
case "pageView": {
|
|
282
|
-
const
|
|
318
|
+
const p = {
|
|
283
319
|
...l.context,
|
|
284
|
-
...
|
|
320
|
+
...u,
|
|
285
321
|
device: {
|
|
286
322
|
...(r = l.context) == null ? void 0 : r.device,
|
|
287
323
|
// biome-ignore lint/suspicious/noExplicitAny: IP field not in base device type
|
|
288
324
|
// Add IP (using type assertion for extended fields)
|
|
289
|
-
...
|
|
325
|
+
...s ? { ip: s } : {}
|
|
290
326
|
}
|
|
291
327
|
};
|
|
292
|
-
|
|
328
|
+
h.pageView(l.properties, p);
|
|
293
329
|
break;
|
|
294
330
|
}
|
|
295
331
|
case "reset":
|
|
@@ -297,16 +333,16 @@ async function B(n, t, i) {
|
|
|
297
333
|
default:
|
|
298
334
|
console.warn("[Proxy] Unknown event type:", l);
|
|
299
335
|
}
|
|
300
|
-
} catch (
|
|
301
|
-
i != null && i.onError ? i.onError(
|
|
336
|
+
} catch (p) {
|
|
337
|
+
i != null && i.onError ? i.onError(p) : console.error("[Proxy] Failed to process event:", p);
|
|
302
338
|
}
|
|
303
|
-
} catch (
|
|
304
|
-
throw i != null && i.onError ? i.onError(
|
|
339
|
+
} catch (a) {
|
|
340
|
+
throw i != null && i.onError ? i.onError(a) : console.error("[Proxy] Failed to ingest events:", a), a;
|
|
305
341
|
}
|
|
306
342
|
}
|
|
307
|
-
function
|
|
343
|
+
function T(d) {
|
|
308
344
|
var i;
|
|
309
|
-
const
|
|
345
|
+
const h = [
|
|
310
346
|
"x-forwarded-for",
|
|
311
347
|
"x-real-ip",
|
|
312
348
|
"cf-connecting-ip",
|
|
@@ -314,26 +350,26 @@ function F(n) {
|
|
|
314
350
|
"x-client-ip",
|
|
315
351
|
"x-cluster-client-ip"
|
|
316
352
|
];
|
|
317
|
-
for (const e of
|
|
318
|
-
const r =
|
|
353
|
+
for (const e of h) {
|
|
354
|
+
const r = d.headers.get(e);
|
|
319
355
|
if (r)
|
|
320
356
|
return (i = r.split(",")[0]) == null ? void 0 : i.trim();
|
|
321
357
|
}
|
|
322
358
|
}
|
|
323
|
-
function
|
|
359
|
+
function G(d, h) {
|
|
324
360
|
return async (i) => {
|
|
325
361
|
try {
|
|
326
|
-
return await
|
|
362
|
+
return await R(i, d, h), new Response("OK", { status: 200 });
|
|
327
363
|
} catch (e) {
|
|
328
364
|
return console.error("[Proxy] Handler error:", e), new Response("Internal Server Error", { status: 500 });
|
|
329
365
|
}
|
|
330
366
|
};
|
|
331
367
|
}
|
|
332
368
|
export {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
369
|
+
q as BaseAnalyticsProvider,
|
|
370
|
+
N as BentoServerProvider,
|
|
371
|
+
W as PirschServerProvider,
|
|
372
|
+
Q as PostHogServerProvider,
|
|
373
|
+
G as createProxyHandler,
|
|
374
|
+
R as ingestProxyEvents
|
|
339
375
|
};
|