@entrolytics/api-client 2.2.2 → 2.2.3
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.cjs +1973 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1927 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +1927 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1708 -0
- package/dist/index.js.map +1 -0
- package/package.json +6 -6
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1973 @@
|
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
let _entrolytics_shared = require("@entrolytics/shared");
|
|
3
|
+
|
|
4
|
+
//#region src/client.ts
|
|
5
|
+
function isRecord(value) {
|
|
6
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
function unwrapSuccessPayload(payload) {
|
|
9
|
+
if (payload === void 0) return;
|
|
10
|
+
if (isRecord(payload) && "data" in payload) return payload.data;
|
|
11
|
+
return payload;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Core API client for making authenticated requests.
|
|
15
|
+
*/
|
|
16
|
+
var ApiClient = class {
|
|
17
|
+
endpoint;
|
|
18
|
+
bearerToken;
|
|
19
|
+
apiKey;
|
|
20
|
+
fetchFn;
|
|
21
|
+
retries;
|
|
22
|
+
retryDelay;
|
|
23
|
+
constructor(config = {}) {
|
|
24
|
+
const getEnv = (key) => {
|
|
25
|
+
if (typeof process !== "undefined" && process.env) return process.env[key];
|
|
26
|
+
};
|
|
27
|
+
const rawEndpoint = config.endpoint || getEnv("ENTROLYTICS_API_ENDPOINT") || "";
|
|
28
|
+
this.endpoint = rawEndpoint ? rawEndpoint.endsWith("/") ? rawEndpoint : `${rawEndpoint}/` : "";
|
|
29
|
+
this.bearerToken = config.bearerToken || getEnv("ENTROLYTICS_BEARER_TOKEN");
|
|
30
|
+
this.apiKey = config.apiKey || getEnv("ENTROLYTICS_API_KEY");
|
|
31
|
+
this.fetchFn = config.fetch || globalThis.fetch;
|
|
32
|
+
this.retries = config.retries ?? 3;
|
|
33
|
+
this.retryDelay = config.retryDelay ?? 1e3;
|
|
34
|
+
if (!this.endpoint) throw new Error("Entrolytics API endpoint is required. Set ENTROLYTICS_API_ENDPOINT or pass endpoint in config.");
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Update the bearer token (useful for token refresh).
|
|
38
|
+
*/
|
|
39
|
+
setBearerToken(token) {
|
|
40
|
+
this.bearerToken = token;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Generate authentication headers.
|
|
44
|
+
* Priority: Bearer token > API key
|
|
45
|
+
*/
|
|
46
|
+
getAuthHeaders() {
|
|
47
|
+
const headers = {};
|
|
48
|
+
if (this.bearerToken) headers.Authorization = `Bearer ${this.bearerToken}`;
|
|
49
|
+
else if (this.apiKey) headers["x-api-key"] = this.apiKey;
|
|
50
|
+
return headers;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Sleep helper for retry delays.
|
|
54
|
+
*/
|
|
55
|
+
sleep(ms) {
|
|
56
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Check if error is retryable.
|
|
60
|
+
*/
|
|
61
|
+
isRetryable(status) {
|
|
62
|
+
return status === 0 || status === 429 || status >= 500;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Build URL with query parameters.
|
|
66
|
+
*/
|
|
67
|
+
buildUrl(path, params) {
|
|
68
|
+
const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
|
|
69
|
+
const url = new URL(normalizedPath, this.endpoint);
|
|
70
|
+
if (params) Object.entries(params).forEach(([key, value]) => {
|
|
71
|
+
if (value !== void 0) url.searchParams.set(key, String(value));
|
|
72
|
+
});
|
|
73
|
+
return url.toString();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Make an authenticated API request with automatic retries.
|
|
77
|
+
*/
|
|
78
|
+
async request(path, options = {}) {
|
|
79
|
+
const { method = "GET", body, params, headers = {} } = options;
|
|
80
|
+
const url = this.buildUrl(path, params);
|
|
81
|
+
let lastError = null;
|
|
82
|
+
for (let attempt = 0; attempt <= this.retries; attempt++) try {
|
|
83
|
+
const fetchOptions = {
|
|
84
|
+
method,
|
|
85
|
+
headers: {
|
|
86
|
+
"Content-Type": "application/json",
|
|
87
|
+
...this.getAuthHeaders(),
|
|
88
|
+
...headers
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
if (body) fetchOptions.body = JSON.stringify(body);
|
|
92
|
+
const response = await this.fetchFn(url, fetchOptions);
|
|
93
|
+
const data = response.status === 204 ? void 0 : await response.json().catch(() => void 0);
|
|
94
|
+
if (!response.ok) {
|
|
95
|
+
const errorMessage = isRecord(data) && typeof data.error === "string" ? data.error : isRecord(data) && typeof data.message === "string" ? data.message : `HTTP ${response.status}`;
|
|
96
|
+
lastError = {
|
|
97
|
+
ok: false,
|
|
98
|
+
status: response.status,
|
|
99
|
+
error: errorMessage
|
|
100
|
+
};
|
|
101
|
+
if (this.isRetryable(response.status) && attempt < this.retries) {
|
|
102
|
+
const delay = this.retryDelay * 2 ** attempt;
|
|
103
|
+
await this.sleep(delay);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
return lastError;
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
ok: true,
|
|
110
|
+
status: response.status,
|
|
111
|
+
data: unwrapSuccessPayload(data)
|
|
112
|
+
};
|
|
113
|
+
} catch (error) {
|
|
114
|
+
lastError = {
|
|
115
|
+
ok: false,
|
|
116
|
+
status: 0,
|
|
117
|
+
error: error instanceof Error ? error.message : "Network error"
|
|
118
|
+
};
|
|
119
|
+
if (attempt < this.retries) {
|
|
120
|
+
const delay = this.retryDelay * 2 ** attempt;
|
|
121
|
+
await this.sleep(delay);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return lastError ?? {
|
|
125
|
+
ok: false,
|
|
126
|
+
status: 0,
|
|
127
|
+
error: "Request failed after retries"
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* GET request helper.
|
|
132
|
+
*/
|
|
133
|
+
get(path, params) {
|
|
134
|
+
return this.request(path, {
|
|
135
|
+
method: "GET",
|
|
136
|
+
params
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* POST request helper.
|
|
141
|
+
*/
|
|
142
|
+
post(path, body) {
|
|
143
|
+
return this.request(path, {
|
|
144
|
+
method: "POST",
|
|
145
|
+
body
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* PUT request helper.
|
|
150
|
+
*/
|
|
151
|
+
put(path, body) {
|
|
152
|
+
return this.request(path, {
|
|
153
|
+
method: "PUT",
|
|
154
|
+
body
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* DELETE request helper.
|
|
159
|
+
*/
|
|
160
|
+
delete(path) {
|
|
161
|
+
return this.request(path, { method: "DELETE" });
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* PATCH request helper.
|
|
165
|
+
*/
|
|
166
|
+
patch(path, body) {
|
|
167
|
+
return this.request(path, {
|
|
168
|
+
method: "PATCH",
|
|
169
|
+
body
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/endpoints/admin.ts
|
|
176
|
+
function createAdminEndpoints(client) {
|
|
177
|
+
return {
|
|
178
|
+
/**
|
|
179
|
+
* Get all organizations (admin only)
|
|
180
|
+
*/
|
|
181
|
+
getOrgs: () => client.get("/admin/orgs"),
|
|
182
|
+
/**
|
|
183
|
+
* Get organization details (admin only)
|
|
184
|
+
*/
|
|
185
|
+
getOrg: ({ orgId }) => client.get(`/admin/orgs/${orgId}`),
|
|
186
|
+
/**
|
|
187
|
+
* Get all users (admin only)
|
|
188
|
+
*/
|
|
189
|
+
getUsers: () => client.get("/admin/users"),
|
|
190
|
+
/**
|
|
191
|
+
* Get user details (admin only)
|
|
192
|
+
*/
|
|
193
|
+
getUser: ({ userId }) => client.get(`/admin/users/${userId}`),
|
|
194
|
+
/**
|
|
195
|
+
* Get all websites (admin only)
|
|
196
|
+
*/
|
|
197
|
+
getWebsites: () => client.get("/admin/websites"),
|
|
198
|
+
/**
|
|
199
|
+
* Get website details (admin only)
|
|
200
|
+
*/
|
|
201
|
+
getWebsite: ({ websiteId }) => client.get(`/admin/websites/${websiteId}`),
|
|
202
|
+
/**
|
|
203
|
+
* Run admin setup
|
|
204
|
+
*/
|
|
205
|
+
setup: () => client.post("/admin/setup", {})
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
//#endregion
|
|
210
|
+
//#region src/endpoints/auth.ts
|
|
211
|
+
function createAuthEndpoints(client) {
|
|
212
|
+
return {
|
|
213
|
+
/**
|
|
214
|
+
* List all active CLI access tokens for the current user.
|
|
215
|
+
*/
|
|
216
|
+
listCliTokens() {
|
|
217
|
+
return client.get("/auth/cli/tokens");
|
|
218
|
+
},
|
|
219
|
+
/**
|
|
220
|
+
* Revoke a specific CLI access token by its JTI.
|
|
221
|
+
*
|
|
222
|
+
* @param jti - The JWT ID of the token to revoke
|
|
223
|
+
*/
|
|
224
|
+
revokeCliToken(jti) {
|
|
225
|
+
return client["request"]("/auth/cli/tokens", {
|
|
226
|
+
method: "DELETE",
|
|
227
|
+
body: { jti }
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
/**
|
|
231
|
+
* Revoke all CLI access tokens for the current user.
|
|
232
|
+
*/
|
|
233
|
+
revokeAllCliTokens() {
|
|
234
|
+
return client["request"]("/auth/cli/tokens", {
|
|
235
|
+
method: "DELETE",
|
|
236
|
+
body: { revokeAll: true }
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/endpoints/billing.ts
|
|
244
|
+
function createBillingEndpoints(client) {
|
|
245
|
+
return {
|
|
246
|
+
/**
|
|
247
|
+
* Get current account usage for the billing period.
|
|
248
|
+
*/
|
|
249
|
+
getUsage() {
|
|
250
|
+
return client.get("/billing/usage");
|
|
251
|
+
},
|
|
252
|
+
/**
|
|
253
|
+
* Get account entitlements based on current plan.
|
|
254
|
+
*/
|
|
255
|
+
getEntitlements() {
|
|
256
|
+
return client.get("/billing/entitlements");
|
|
257
|
+
},
|
|
258
|
+
/**
|
|
259
|
+
* Get current subscription details.
|
|
260
|
+
*/
|
|
261
|
+
getSubscription() {
|
|
262
|
+
return client.get("/billing/subscription");
|
|
263
|
+
},
|
|
264
|
+
/**
|
|
265
|
+
* Create a Stripe checkout session for upgrading/changing plan.
|
|
266
|
+
*/
|
|
267
|
+
createCheckoutSession(options) {
|
|
268
|
+
return client.post("/billing/checkout", options);
|
|
269
|
+
},
|
|
270
|
+
/**
|
|
271
|
+
* Create a Stripe billing portal session for managing subscription.
|
|
272
|
+
*/
|
|
273
|
+
createPortalSession() {
|
|
274
|
+
return client.post("/billing/portal");
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
//#endregion
|
|
280
|
+
//#region src/endpoints/boards.ts
|
|
281
|
+
function createBoardsEndpoints(client) {
|
|
282
|
+
return {
|
|
283
|
+
/**
|
|
284
|
+
* Get all boards for a website.
|
|
285
|
+
*/
|
|
286
|
+
getBoards(websiteId) {
|
|
287
|
+
return client.get(`/websites/${websiteId}/boards`);
|
|
288
|
+
},
|
|
289
|
+
/**
|
|
290
|
+
* Get a specific board by ID.
|
|
291
|
+
*/
|
|
292
|
+
getBoard(boardId) {
|
|
293
|
+
return client.get(`/boards/${boardId}`);
|
|
294
|
+
},
|
|
295
|
+
/**
|
|
296
|
+
* Create a new board.
|
|
297
|
+
*/
|
|
298
|
+
createBoard(data) {
|
|
299
|
+
return client.post("/boards", data);
|
|
300
|
+
},
|
|
301
|
+
/**
|
|
302
|
+
* Update a board.
|
|
303
|
+
*/
|
|
304
|
+
updateBoard(boardId, data) {
|
|
305
|
+
return client.post(`/boards/${boardId}`, data);
|
|
306
|
+
},
|
|
307
|
+
/**
|
|
308
|
+
* Delete a board.
|
|
309
|
+
*/
|
|
310
|
+
deleteBoard(boardId) {
|
|
311
|
+
return client.delete(`/boards/${boardId}`);
|
|
312
|
+
},
|
|
313
|
+
/**
|
|
314
|
+
* Get all widgets for a board.
|
|
315
|
+
*/
|
|
316
|
+
getBoardWidgets(boardId) {
|
|
317
|
+
return client.get(`/boards/${boardId}/widgets`);
|
|
318
|
+
},
|
|
319
|
+
/**
|
|
320
|
+
* Get a specific widget by ID.
|
|
321
|
+
*/
|
|
322
|
+
getBoardWidget(boardId, widgetId) {
|
|
323
|
+
return client.get(`/boards/${boardId}/widgets/${widgetId}`);
|
|
324
|
+
},
|
|
325
|
+
/**
|
|
326
|
+
* Create a new widget on a board.
|
|
327
|
+
*/
|
|
328
|
+
createBoardWidget(boardId, data) {
|
|
329
|
+
return client.post(`/boards/${boardId}/widgets`, data);
|
|
330
|
+
},
|
|
331
|
+
/**
|
|
332
|
+
* Update a widget.
|
|
333
|
+
*/
|
|
334
|
+
updateBoardWidget(boardId, widgetId, data) {
|
|
335
|
+
return client.post(`/boards/${boardId}/widgets/${widgetId}`, data);
|
|
336
|
+
},
|
|
337
|
+
/**
|
|
338
|
+
* Delete a widget.
|
|
339
|
+
*/
|
|
340
|
+
deleteBoardWidget(boardId, widgetId) {
|
|
341
|
+
return client.delete(`/boards/${boardId}/widgets/${widgetId}`);
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/endpoints/config.ts
|
|
348
|
+
function createConfigEndpoints(client) {
|
|
349
|
+
return {
|
|
350
|
+
/**
|
|
351
|
+
* Get system configuration
|
|
352
|
+
*/
|
|
353
|
+
get: () => client.get("/config") };
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
//#endregion
|
|
357
|
+
//#region src/endpoints/events.ts
|
|
358
|
+
function generateUuid() {
|
|
359
|
+
if (typeof globalThis.crypto !== "undefined" && typeof globalThis.crypto.randomUUID === "function") return globalThis.crypto.randomUUID();
|
|
360
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
361
|
+
const r = Math.floor(Math.random() * 16);
|
|
362
|
+
return (c === "x" ? r : r & 3 | 8).toString(16);
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
function createEventsEndpoints(client) {
|
|
366
|
+
return {
|
|
367
|
+
/**
|
|
368
|
+
* Get event data statistics.
|
|
369
|
+
*/
|
|
370
|
+
getEventDataStats(websiteId, params) {
|
|
371
|
+
return client.get(`/websites/${websiteId}/event-data/stats`, params);
|
|
372
|
+
},
|
|
373
|
+
/**
|
|
374
|
+
* Get event data events (distinct event names).
|
|
375
|
+
*/
|
|
376
|
+
getEventDataEvents(websiteId, params) {
|
|
377
|
+
return client.get(`/websites/${websiteId}/event-data/events`, params);
|
|
378
|
+
},
|
|
379
|
+
/**
|
|
380
|
+
* Get event data fields for a specific event.
|
|
381
|
+
*/
|
|
382
|
+
getEventDataFields(websiteId, params) {
|
|
383
|
+
return client.get(`/websites/${websiteId}/event-data/fields`, params);
|
|
384
|
+
},
|
|
385
|
+
/**
|
|
386
|
+
* Get event data values for a specific field.
|
|
387
|
+
*/
|
|
388
|
+
getEventDataValues(websiteId, params) {
|
|
389
|
+
return client.get(`/websites/${websiteId}/event-data/values`, params);
|
|
390
|
+
},
|
|
391
|
+
/**
|
|
392
|
+
* Get event data properties breakdown.
|
|
393
|
+
*/
|
|
394
|
+
getEventDataProperties(websiteId, params) {
|
|
395
|
+
return client.get(`/websites/${websiteId}/event-data/properties`, params);
|
|
396
|
+
},
|
|
397
|
+
/**
|
|
398
|
+
* Get specific event data by ID.
|
|
399
|
+
*/
|
|
400
|
+
getEventData(websiteId, eventId) {
|
|
401
|
+
return client.get(`/websites/${websiteId}/event-data/${eventId}`);
|
|
402
|
+
},
|
|
403
|
+
/**
|
|
404
|
+
* Get session data properties.
|
|
405
|
+
*/
|
|
406
|
+
getSessionDataProperties(websiteId, params) {
|
|
407
|
+
return client.get(`/websites/${websiteId}/session-data/properties`, params);
|
|
408
|
+
},
|
|
409
|
+
getSessionDataValues(websiteId, params) {
|
|
410
|
+
return client.get(`/websites/${websiteId}/session-data/values`, params);
|
|
411
|
+
},
|
|
412
|
+
/**
|
|
413
|
+
* Send a test event to verify setup.
|
|
414
|
+
*/
|
|
415
|
+
sendTestEvent(websiteId) {
|
|
416
|
+
return client.post("/collect", {
|
|
417
|
+
websiteId,
|
|
418
|
+
eventId: generateUuid(),
|
|
419
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
420
|
+
sessionId: generateUuid(),
|
|
421
|
+
visitorId: generateUuid(),
|
|
422
|
+
url: "https://entrolytics.click/test-event",
|
|
423
|
+
eventType: "custom_event",
|
|
424
|
+
eventName: "cli_test_event",
|
|
425
|
+
properties: {
|
|
426
|
+
source: "entro-cli",
|
|
427
|
+
timestamp: Date.now()
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
//#endregion
|
|
435
|
+
//#region src/endpoints/integrations.ts
|
|
436
|
+
function createIntegrationsEndpoints(client) {
|
|
437
|
+
return {
|
|
438
|
+
/**
|
|
439
|
+
* Handle WordPress integration
|
|
440
|
+
*/
|
|
441
|
+
wordpress: (params) => client.post("/integrations/wordpress", params.data) };
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
//#endregion
|
|
445
|
+
//#region src/endpoints/links.ts
|
|
446
|
+
function createLinksEndpoints(client) {
|
|
447
|
+
return {
|
|
448
|
+
/**
|
|
449
|
+
* Get all links.
|
|
450
|
+
*/
|
|
451
|
+
getLinks() {
|
|
452
|
+
return client.get("/links");
|
|
453
|
+
},
|
|
454
|
+
/**
|
|
455
|
+
* Get links for an organization.
|
|
456
|
+
*/
|
|
457
|
+
getOrgLinks(orgId) {
|
|
458
|
+
return client.get(`/orgs/${orgId}/links`);
|
|
459
|
+
},
|
|
460
|
+
/**
|
|
461
|
+
* Create a new link.
|
|
462
|
+
*/
|
|
463
|
+
createLink(orgId, data) {
|
|
464
|
+
return client.post(`/orgs/${orgId}/links`, data);
|
|
465
|
+
},
|
|
466
|
+
/**
|
|
467
|
+
* Get a link by ID.
|
|
468
|
+
*/
|
|
469
|
+
getLink(linkId) {
|
|
470
|
+
return client.get(`/links/${linkId}`);
|
|
471
|
+
},
|
|
472
|
+
/**
|
|
473
|
+
* Update a link.
|
|
474
|
+
*/
|
|
475
|
+
updateLink(linkId, data) {
|
|
476
|
+
return client.post(`/links/${linkId}`, data);
|
|
477
|
+
},
|
|
478
|
+
/**
|
|
479
|
+
* Delete a link.
|
|
480
|
+
*/
|
|
481
|
+
deleteLink(linkId) {
|
|
482
|
+
return client.delete(`/links/${linkId}`);
|
|
483
|
+
},
|
|
484
|
+
/**
|
|
485
|
+
* Get link statistics.
|
|
486
|
+
*/
|
|
487
|
+
getLinkStats(linkId) {
|
|
488
|
+
return client.get(`/links/${linkId}/stats`);
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
//#endregion
|
|
494
|
+
//#region src/endpoints/me.ts
|
|
495
|
+
function createMeEndpoints(client) {
|
|
496
|
+
return {
|
|
497
|
+
/**
|
|
498
|
+
* Get current user profile.
|
|
499
|
+
*/
|
|
500
|
+
getMe() {
|
|
501
|
+
return client.get("/me");
|
|
502
|
+
},
|
|
503
|
+
/**
|
|
504
|
+
* Update current user's password.
|
|
505
|
+
*/
|
|
506
|
+
updateMyPassword(data) {
|
|
507
|
+
return client.post("/me/password", data);
|
|
508
|
+
},
|
|
509
|
+
/**
|
|
510
|
+
* Get current user's websites.
|
|
511
|
+
*/
|
|
512
|
+
getMyWebsites() {
|
|
513
|
+
return client.get("/me/websites");
|
|
514
|
+
},
|
|
515
|
+
/**
|
|
516
|
+
* Get current user's organizations.
|
|
517
|
+
*/
|
|
518
|
+
getMyOrgs() {
|
|
519
|
+
return client.get("/me/orgs");
|
|
520
|
+
}
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
//#endregion
|
|
525
|
+
//#region src/endpoints/orgs.ts
|
|
526
|
+
function createOrgsEndpoints(client) {
|
|
527
|
+
return {
|
|
528
|
+
/**
|
|
529
|
+
* Get all organizations for the current user.
|
|
530
|
+
*/
|
|
531
|
+
getOrgs() {
|
|
532
|
+
return client.get("/orgs");
|
|
533
|
+
},
|
|
534
|
+
/**
|
|
535
|
+
* Create a new organization.
|
|
536
|
+
*/
|
|
537
|
+
createOrg(data) {
|
|
538
|
+
return client.post("/orgs", data);
|
|
539
|
+
},
|
|
540
|
+
/**
|
|
541
|
+
* Join an organization using access code.
|
|
542
|
+
*/
|
|
543
|
+
joinOrg(data) {
|
|
544
|
+
return client.post("/orgs/join", data);
|
|
545
|
+
},
|
|
546
|
+
/**
|
|
547
|
+
* Get an organization by ID.
|
|
548
|
+
*/
|
|
549
|
+
getOrg(orgId) {
|
|
550
|
+
return client.get(`/orgs/${orgId}`);
|
|
551
|
+
},
|
|
552
|
+
/**
|
|
553
|
+
* Update an organization.
|
|
554
|
+
*/
|
|
555
|
+
updateOrg(orgId, data) {
|
|
556
|
+
return client.patch(`/orgs/${orgId}`, data);
|
|
557
|
+
},
|
|
558
|
+
/**
|
|
559
|
+
* Delete an organization.
|
|
560
|
+
*/
|
|
561
|
+
deleteOrg(orgId) {
|
|
562
|
+
return client.delete(`/orgs/${orgId}`);
|
|
563
|
+
},
|
|
564
|
+
/**
|
|
565
|
+
* Get organization members.
|
|
566
|
+
*/
|
|
567
|
+
getOrgMembers(orgId) {
|
|
568
|
+
return client.get(`/orgs/${orgId}/members`);
|
|
569
|
+
},
|
|
570
|
+
/**
|
|
571
|
+
* Invite a member to an organization.
|
|
572
|
+
*/
|
|
573
|
+
inviteOrgMember(orgId, data) {
|
|
574
|
+
return client.post(`/orgs/${orgId}/members`, data);
|
|
575
|
+
},
|
|
576
|
+
/**
|
|
577
|
+
* Update an organization member's role.
|
|
578
|
+
*/
|
|
579
|
+
updateOrgMember(orgId, memberId, data) {
|
|
580
|
+
return client.patch(`/orgs/${orgId}/members/${memberId}`, data);
|
|
581
|
+
},
|
|
582
|
+
/**
|
|
583
|
+
* Remove a member from an organization.
|
|
584
|
+
*/
|
|
585
|
+
removeOrgMember(orgId, memberId) {
|
|
586
|
+
return client.delete(`/orgs/${orgId}/members/${memberId}`);
|
|
587
|
+
},
|
|
588
|
+
/**
|
|
589
|
+
* Get organization websites.
|
|
590
|
+
*/
|
|
591
|
+
getOrgWebsites(orgId) {
|
|
592
|
+
return client.get(`/orgs/${orgId}/websites`);
|
|
593
|
+
},
|
|
594
|
+
/**
|
|
595
|
+
* Add a website to an organization.
|
|
596
|
+
*/
|
|
597
|
+
addOrgWebsite(orgId, data) {
|
|
598
|
+
return client.post(`/orgs/${orgId}/websites`, data);
|
|
599
|
+
},
|
|
600
|
+
/**
|
|
601
|
+
* Remove a website from an organization.
|
|
602
|
+
*/
|
|
603
|
+
removeOrgWebsite(orgId, websiteId) {
|
|
604
|
+
return client.delete(`/orgs/${orgId}/websites/${websiteId}`);
|
|
605
|
+
}
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
//#endregion
|
|
610
|
+
//#region src/endpoints/pixels.ts
|
|
611
|
+
function createPixelsEndpoints(client) {
|
|
612
|
+
return {
|
|
613
|
+
/**
|
|
614
|
+
* Get all pixels.
|
|
615
|
+
*/
|
|
616
|
+
getPixels() {
|
|
617
|
+
return client.get("/pixels");
|
|
618
|
+
},
|
|
619
|
+
/**
|
|
620
|
+
* Get pixels for an organization.
|
|
621
|
+
*/
|
|
622
|
+
getOrgPixels(orgId) {
|
|
623
|
+
return client.get(`/orgs/${orgId}/pixels`);
|
|
624
|
+
},
|
|
625
|
+
/**
|
|
626
|
+
* Create a new pixel.
|
|
627
|
+
*/
|
|
628
|
+
createPixel(orgId, data) {
|
|
629
|
+
return client.post(`/orgs/${orgId}/pixels`, data);
|
|
630
|
+
},
|
|
631
|
+
/**
|
|
632
|
+
* Get a pixel by ID.
|
|
633
|
+
*/
|
|
634
|
+
getPixel(pixelId) {
|
|
635
|
+
return client.get(`/pixels/${pixelId}`);
|
|
636
|
+
},
|
|
637
|
+
/**
|
|
638
|
+
* Update a pixel.
|
|
639
|
+
*/
|
|
640
|
+
updatePixel(pixelId, data) {
|
|
641
|
+
return client.post(`/pixels/${pixelId}`, data);
|
|
642
|
+
},
|
|
643
|
+
/**
|
|
644
|
+
* Delete a pixel.
|
|
645
|
+
*/
|
|
646
|
+
deletePixel(pixelId) {
|
|
647
|
+
return client.delete(`/pixels/${pixelId}`);
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
//#endregion
|
|
653
|
+
//#region src/endpoints/reports.ts
|
|
654
|
+
function createReportsEndpoints(client) {
|
|
655
|
+
return {
|
|
656
|
+
/**
|
|
657
|
+
* Get all reports for a website.
|
|
658
|
+
*/
|
|
659
|
+
getReports(websiteId) {
|
|
660
|
+
return client.get(`/websites/${websiteId}/reports`);
|
|
661
|
+
},
|
|
662
|
+
/**
|
|
663
|
+
* Create a new report.
|
|
664
|
+
*/
|
|
665
|
+
createReport(data) {
|
|
666
|
+
return client.post("/reports", data);
|
|
667
|
+
},
|
|
668
|
+
/**
|
|
669
|
+
* Get a report by ID.
|
|
670
|
+
*/
|
|
671
|
+
getReport(reportId) {
|
|
672
|
+
return client.get(`/reports/${reportId}`);
|
|
673
|
+
},
|
|
674
|
+
/**
|
|
675
|
+
* Update a report.
|
|
676
|
+
*/
|
|
677
|
+
updateReport(reportId, data) {
|
|
678
|
+
return client.post(`/reports/${reportId}`, data);
|
|
679
|
+
},
|
|
680
|
+
/**
|
|
681
|
+
* Delete a report.
|
|
682
|
+
*/
|
|
683
|
+
deleteReport(reportId) {
|
|
684
|
+
return client.delete(`/reports/${reportId}`);
|
|
685
|
+
},
|
|
686
|
+
/**
|
|
687
|
+
* Run a funnel report.
|
|
688
|
+
*/
|
|
689
|
+
runFunnelReport(params) {
|
|
690
|
+
const { websiteId, steps, window = 30, startAt, endAt, ...rest } = params;
|
|
691
|
+
return client.post("/reports/funnel", {
|
|
692
|
+
websiteId,
|
|
693
|
+
parameters: {
|
|
694
|
+
startDate: startAt,
|
|
695
|
+
endDate: endAt,
|
|
696
|
+
window,
|
|
697
|
+
steps
|
|
698
|
+
},
|
|
699
|
+
filters: rest
|
|
700
|
+
});
|
|
701
|
+
},
|
|
702
|
+
/**
|
|
703
|
+
* Run a retention report.
|
|
704
|
+
*/
|
|
705
|
+
runRetentionReport(params) {
|
|
706
|
+
const { websiteId, startAt, endAt, timezone, ...rest } = params;
|
|
707
|
+
return client.post("/reports/retention", {
|
|
708
|
+
websiteId,
|
|
709
|
+
parameters: {
|
|
710
|
+
startDate: startAt,
|
|
711
|
+
endDate: endAt,
|
|
712
|
+
timezone
|
|
713
|
+
},
|
|
714
|
+
filters: rest
|
|
715
|
+
});
|
|
716
|
+
},
|
|
717
|
+
/**
|
|
718
|
+
* Run a journey/flow report.
|
|
719
|
+
*/
|
|
720
|
+
runJourneyReport(params) {
|
|
721
|
+
const { websiteId, startAt, endAt, steps = 5, startStep, endStep, ...rest } = params;
|
|
722
|
+
return client.post("/reports/journey", {
|
|
723
|
+
websiteId,
|
|
724
|
+
parameters: {
|
|
725
|
+
startDate: startAt,
|
|
726
|
+
endDate: endAt,
|
|
727
|
+
steps,
|
|
728
|
+
startStep,
|
|
729
|
+
endStep
|
|
730
|
+
},
|
|
731
|
+
filters: rest
|
|
732
|
+
});
|
|
733
|
+
},
|
|
734
|
+
/**
|
|
735
|
+
* Run a goals report.
|
|
736
|
+
*/
|
|
737
|
+
runGoalReport(params) {
|
|
738
|
+
const { websiteId, startAt, endAt, type, value, ...rest } = params;
|
|
739
|
+
return client.post("/reports/goal", {
|
|
740
|
+
websiteId,
|
|
741
|
+
parameters: {
|
|
742
|
+
startDate: startAt,
|
|
743
|
+
endDate: endAt,
|
|
744
|
+
type,
|
|
745
|
+
value
|
|
746
|
+
},
|
|
747
|
+
filters: rest
|
|
748
|
+
});
|
|
749
|
+
},
|
|
750
|
+
/**
|
|
751
|
+
* Run an attribution report.
|
|
752
|
+
*/
|
|
753
|
+
runAttributionReport(params) {
|
|
754
|
+
const { websiteId, startAt, endAt, model, type, step, currency, ...rest } = params;
|
|
755
|
+
return client.post("/reports/attribution", {
|
|
756
|
+
websiteId,
|
|
757
|
+
parameters: {
|
|
758
|
+
startDate: startAt,
|
|
759
|
+
endDate: endAt,
|
|
760
|
+
model,
|
|
761
|
+
type,
|
|
762
|
+
step,
|
|
763
|
+
currency
|
|
764
|
+
},
|
|
765
|
+
filters: rest
|
|
766
|
+
});
|
|
767
|
+
},
|
|
768
|
+
/**
|
|
769
|
+
* Run a revenue report.
|
|
770
|
+
*/
|
|
771
|
+
runRevenueReport(params) {
|
|
772
|
+
const { websiteId, startAt, endAt, currency = "USD", ...rest } = params;
|
|
773
|
+
return client.post("/reports/revenue", {
|
|
774
|
+
websiteId,
|
|
775
|
+
parameters: {
|
|
776
|
+
startDate: startAt,
|
|
777
|
+
endDate: endAt,
|
|
778
|
+
currency
|
|
779
|
+
},
|
|
780
|
+
filters: rest
|
|
781
|
+
});
|
|
782
|
+
},
|
|
783
|
+
/**
|
|
784
|
+
* Run a UTM report.
|
|
785
|
+
*/
|
|
786
|
+
runUTMReport(params) {
|
|
787
|
+
const { websiteId, startAt, endAt, ...rest } = params;
|
|
788
|
+
return client.post("/reports/utm", {
|
|
789
|
+
websiteId,
|
|
790
|
+
parameters: {
|
|
791
|
+
startDate: startAt,
|
|
792
|
+
endDate: endAt
|
|
793
|
+
},
|
|
794
|
+
filters: rest
|
|
795
|
+
});
|
|
796
|
+
},
|
|
797
|
+
/**
|
|
798
|
+
* Run a breakdown report.
|
|
799
|
+
* @param property - Field to break down by (path, referrer, browser, device, os, country, etc.)
|
|
800
|
+
*/
|
|
801
|
+
runBreakdownReport(params) {
|
|
802
|
+
const { websiteId, startAt, endAt, property, ...rest } = params;
|
|
803
|
+
return client.post("/reports/breakdown", {
|
|
804
|
+
websiteId,
|
|
805
|
+
parameters: {
|
|
806
|
+
startDate: startAt,
|
|
807
|
+
endDate: endAt,
|
|
808
|
+
property
|
|
809
|
+
},
|
|
810
|
+
filters: rest
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
};
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
//#endregion
|
|
817
|
+
//#region src/endpoints/segments.ts
|
|
818
|
+
function createSegmentsEndpoints(client) {
|
|
819
|
+
return {
|
|
820
|
+
/**
|
|
821
|
+
* Get all segments for a website.
|
|
822
|
+
*/
|
|
823
|
+
getSegments(websiteId) {
|
|
824
|
+
return client.get(`/websites/${websiteId}/segments`);
|
|
825
|
+
},
|
|
826
|
+
/**
|
|
827
|
+
* Create a new segment.
|
|
828
|
+
*/
|
|
829
|
+
createSegment(websiteId, data) {
|
|
830
|
+
return client.post(`/websites/${websiteId}/segments`, data);
|
|
831
|
+
},
|
|
832
|
+
/**
|
|
833
|
+
* Get a segment by ID.
|
|
834
|
+
*/
|
|
835
|
+
getSegment(websiteId, segmentId) {
|
|
836
|
+
return client.get(`/websites/${websiteId}/segments/${segmentId}`);
|
|
837
|
+
},
|
|
838
|
+
/**
|
|
839
|
+
* Update a segment.
|
|
840
|
+
*/
|
|
841
|
+
updateSegment(websiteId, segmentId, data) {
|
|
842
|
+
return client.post(`/websites/${websiteId}/segments/${segmentId}`, data);
|
|
843
|
+
},
|
|
844
|
+
/**
|
|
845
|
+
* Delete a segment.
|
|
846
|
+
*/
|
|
847
|
+
deleteSegment(websiteId, segmentId) {
|
|
848
|
+
return client.delete(`/websites/${websiteId}/segments/${segmentId}`);
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
//#endregion
|
|
854
|
+
//#region src/endpoints/sessions.ts
|
|
855
|
+
function createSessionsEndpoints(client) {
|
|
856
|
+
return {
|
|
857
|
+
/**
|
|
858
|
+
* Get website sessions.
|
|
859
|
+
*/
|
|
860
|
+
getWebsiteSessions(websiteId, params) {
|
|
861
|
+
return client.get(`/websites/${websiteId}/sessions`, params);
|
|
862
|
+
},
|
|
863
|
+
/**
|
|
864
|
+
* Get session statistics.
|
|
865
|
+
*/
|
|
866
|
+
getWebsiteSessionStats(websiteId, params) {
|
|
867
|
+
return client.get(`/websites/${websiteId}/sessions/stats`, params);
|
|
868
|
+
},
|
|
869
|
+
/**
|
|
870
|
+
* Get weekly session traffic.
|
|
871
|
+
*/
|
|
872
|
+
getWeeklyTraffic(websiteId, params) {
|
|
873
|
+
return client.get(`/websites/${websiteId}/sessions/weekly`, params);
|
|
874
|
+
},
|
|
875
|
+
/**
|
|
876
|
+
* Get a specific session.
|
|
877
|
+
*/
|
|
878
|
+
getSession(websiteId, sessionId) {
|
|
879
|
+
return client.get(`/websites/${websiteId}/sessions/${sessionId}`);
|
|
880
|
+
},
|
|
881
|
+
/**
|
|
882
|
+
* Get session activity (pageviews and events).
|
|
883
|
+
*/
|
|
884
|
+
getSessionActivity(websiteId, sessionId, params) {
|
|
885
|
+
return client.get(`/websites/${websiteId}/sessions/${sessionId}/activity`, params);
|
|
886
|
+
},
|
|
887
|
+
/**
|
|
888
|
+
* Get session properties (custom data).
|
|
889
|
+
*/
|
|
890
|
+
getSessionProperties(websiteId, sessionId) {
|
|
891
|
+
return client.get(`/websites/${websiteId}/sessions/${sessionId}/properties`);
|
|
892
|
+
}
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
//#endregion
|
|
897
|
+
//#region src/endpoints/users.ts
|
|
898
|
+
function createUsersEndpoints(client) {
|
|
899
|
+
return {
|
|
900
|
+
/**
|
|
901
|
+
* Get all users (admin only).
|
|
902
|
+
*/
|
|
903
|
+
getUsers() {
|
|
904
|
+
return client.get("/users");
|
|
905
|
+
},
|
|
906
|
+
/**
|
|
907
|
+
* Create a new user (admin only).
|
|
908
|
+
*/
|
|
909
|
+
createUser(data) {
|
|
910
|
+
return client.post("/users", data);
|
|
911
|
+
},
|
|
912
|
+
/**
|
|
913
|
+
* Get a user by ID.
|
|
914
|
+
*/
|
|
915
|
+
getUser(userId) {
|
|
916
|
+
return client.get(`/users/${userId}`);
|
|
917
|
+
},
|
|
918
|
+
/**
|
|
919
|
+
* Update a user.
|
|
920
|
+
*/
|
|
921
|
+
updateUser(userId, data) {
|
|
922
|
+
return client.post(`/users/${userId}`, data);
|
|
923
|
+
},
|
|
924
|
+
/**
|
|
925
|
+
* Delete a user (admin only).
|
|
926
|
+
*/
|
|
927
|
+
deleteUser(userId) {
|
|
928
|
+
return client.delete(`/users/${userId}`);
|
|
929
|
+
},
|
|
930
|
+
/**
|
|
931
|
+
* Get websites belonging to a user.
|
|
932
|
+
*/
|
|
933
|
+
getUserWebsites(userId) {
|
|
934
|
+
return client.get(`/users/${userId}/websites`);
|
|
935
|
+
},
|
|
936
|
+
/**
|
|
937
|
+
* Get user usage statistics.
|
|
938
|
+
*/
|
|
939
|
+
getUserUsage(userId, params) {
|
|
940
|
+
return client.get(`/users/${userId}/usage`, params);
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
//#endregion
|
|
946
|
+
//#region src/endpoints/webhooks.ts
|
|
947
|
+
function createWebhooksEndpoints(client) {
|
|
948
|
+
return {
|
|
949
|
+
/**
|
|
950
|
+
* Handle Clerk webhook
|
|
951
|
+
*/
|
|
952
|
+
clerk: (params) => client.post("/webhooks/clerk", params.data) };
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
//#endregion
|
|
956
|
+
//#region src/endpoints/websites.ts
|
|
957
|
+
function createWebsitesEndpoints(client) {
|
|
958
|
+
const toDateRangeQuery = (params) => ({
|
|
959
|
+
startDate: new Date(params.startAt).toISOString(),
|
|
960
|
+
endDate: new Date(params.endAt).toISOString()
|
|
961
|
+
});
|
|
962
|
+
const toDeploymentDays = (params) => {
|
|
963
|
+
const diffMs = Math.max(params.endAt - params.startAt, 0);
|
|
964
|
+
const days = Math.ceil(diffMs / 864e5);
|
|
965
|
+
return Math.min(Math.max(days, 1), 365);
|
|
966
|
+
};
|
|
967
|
+
const toSuccessResponse = (response) => ({
|
|
968
|
+
...response,
|
|
969
|
+
data: response.data ? {
|
|
970
|
+
success: Boolean(response.data.accepted),
|
|
971
|
+
...typeof response.data.count === "number" ? { count: response.data.count } : {}
|
|
972
|
+
} : void 0
|
|
973
|
+
});
|
|
974
|
+
return {
|
|
975
|
+
/**
|
|
976
|
+
* Get all websites.
|
|
977
|
+
*/
|
|
978
|
+
getWebsites() {
|
|
979
|
+
return client.get("/websites");
|
|
980
|
+
},
|
|
981
|
+
/**
|
|
982
|
+
* Create a new website.
|
|
983
|
+
*/
|
|
984
|
+
createWebsite(data) {
|
|
985
|
+
return client.post("/websites", data);
|
|
986
|
+
},
|
|
987
|
+
/**
|
|
988
|
+
* Get a website by ID.
|
|
989
|
+
*/
|
|
990
|
+
getWebsite(websiteId) {
|
|
991
|
+
return client.get(`/websites/${websiteId}`);
|
|
992
|
+
},
|
|
993
|
+
/**
|
|
994
|
+
* Update a website.
|
|
995
|
+
*/
|
|
996
|
+
updateWebsite(websiteId, data) {
|
|
997
|
+
return client.patch(`/websites/${websiteId}`, data);
|
|
998
|
+
},
|
|
999
|
+
/**
|
|
1000
|
+
* Delete a website.
|
|
1001
|
+
*/
|
|
1002
|
+
deleteWebsite(websiteId) {
|
|
1003
|
+
return client.delete(`/websites/${websiteId}`);
|
|
1004
|
+
},
|
|
1005
|
+
/**
|
|
1006
|
+
* Reset a website's data.
|
|
1007
|
+
*/
|
|
1008
|
+
resetWebsite(websiteId) {
|
|
1009
|
+
return client.post(`/websites/${websiteId}/reset`);
|
|
1010
|
+
},
|
|
1011
|
+
/**
|
|
1012
|
+
* Transfer website ownership.
|
|
1013
|
+
*/
|
|
1014
|
+
transferWebsite(websiteId, data) {
|
|
1015
|
+
return client.post(`/websites/${websiteId}/transfer`, data);
|
|
1016
|
+
},
|
|
1017
|
+
/**
|
|
1018
|
+
* Get website statistics.
|
|
1019
|
+
*/
|
|
1020
|
+
getWebsiteStats(websiteId, params) {
|
|
1021
|
+
return client.get(`/websites/${websiteId}/stats`, toDateRangeQuery(params));
|
|
1022
|
+
},
|
|
1023
|
+
/**
|
|
1024
|
+
* Get website pageviews data.
|
|
1025
|
+
*/
|
|
1026
|
+
getWebsitePageviews(websiteId, params) {
|
|
1027
|
+
return client.get(`/websites/${websiteId}/pageviews`, params);
|
|
1028
|
+
},
|
|
1029
|
+
/**
|
|
1030
|
+
* Get website metrics (URLs, referrers, browsers, etc.).
|
|
1031
|
+
*/
|
|
1032
|
+
getWebsiteMetrics(websiteId, params) {
|
|
1033
|
+
return client.get(`/websites/${websiteId}/metrics`, params);
|
|
1034
|
+
},
|
|
1035
|
+
/**
|
|
1036
|
+
* Get expanded metrics (with additional details).
|
|
1037
|
+
*/
|
|
1038
|
+
getWebsiteExpandedMetrics(websiteId, params) {
|
|
1039
|
+
return client.get(`/websites/${websiteId}/metrics/expanded`, params);
|
|
1040
|
+
},
|
|
1041
|
+
/**
|
|
1042
|
+
* Get website events.
|
|
1043
|
+
*/
|
|
1044
|
+
getWebsiteEvents(websiteId, params) {
|
|
1045
|
+
return client.get(`/websites/${websiteId}/events`, params);
|
|
1046
|
+
},
|
|
1047
|
+
/**
|
|
1048
|
+
* Get events time series.
|
|
1049
|
+
*/
|
|
1050
|
+
getWebsiteEventsSeries(websiteId, params) {
|
|
1051
|
+
return client.get(`/websites/${websiteId}/events/series`, params);
|
|
1052
|
+
},
|
|
1053
|
+
/**
|
|
1054
|
+
* Get active visitors count.
|
|
1055
|
+
*/
|
|
1056
|
+
getWebsiteActive(websiteId) {
|
|
1057
|
+
return client.get(`/websites/${websiteId}/active`);
|
|
1058
|
+
},
|
|
1059
|
+
/**
|
|
1060
|
+
* Get website date range (first and last event dates).
|
|
1061
|
+
*/
|
|
1062
|
+
getWebsiteDateRange(websiteId) {
|
|
1063
|
+
return client.get(`/websites/${websiteId}/daterange`);
|
|
1064
|
+
},
|
|
1065
|
+
/**
|
|
1066
|
+
* Get website values for a specific field.
|
|
1067
|
+
*/
|
|
1068
|
+
getWebsiteValues(websiteId, params) {
|
|
1069
|
+
return client.get(`/websites/${websiteId}/values`, params);
|
|
1070
|
+
},
|
|
1071
|
+
/**
|
|
1072
|
+
* Get realtime data.
|
|
1073
|
+
*/
|
|
1074
|
+
getRealtimeData(websiteId) {
|
|
1075
|
+
return client.get(`/realtime/${websiteId}`);
|
|
1076
|
+
},
|
|
1077
|
+
/**
|
|
1078
|
+
* Export website data.
|
|
1079
|
+
*/
|
|
1080
|
+
exportWebsiteData(websiteId, params) {
|
|
1081
|
+
return client.get(`/websites/${websiteId}/export`, params);
|
|
1082
|
+
},
|
|
1083
|
+
/**
|
|
1084
|
+
* Get website ingest mode configuration.
|
|
1085
|
+
*/
|
|
1086
|
+
getWebsiteMode(websiteId) {
|
|
1087
|
+
return client.get(`/websites/${websiteId}/mode`);
|
|
1088
|
+
},
|
|
1089
|
+
/**
|
|
1090
|
+
* Set website ingest mode (auto, node, or edge).
|
|
1091
|
+
*/
|
|
1092
|
+
setWebsiteMode(websiteId, mode) {
|
|
1093
|
+
return client.post(`/websites/${websiteId}/mode`, { ingestMode: mode });
|
|
1094
|
+
},
|
|
1095
|
+
/**
|
|
1096
|
+
* Get routing health status.
|
|
1097
|
+
*/
|
|
1098
|
+
getRoutingHealth() {
|
|
1099
|
+
return client.get("/health/routing");
|
|
1100
|
+
},
|
|
1101
|
+
/**
|
|
1102
|
+
* Get routing statistics.
|
|
1103
|
+
*/
|
|
1104
|
+
getRoutingStats(params) {
|
|
1105
|
+
return client.get("/routing/stats", params);
|
|
1106
|
+
},
|
|
1107
|
+
/**
|
|
1108
|
+
* Get Web Vitals statistics for a website.
|
|
1109
|
+
* Note: Only available in entrolytics.
|
|
1110
|
+
*/
|
|
1111
|
+
getWebsiteVitals(websiteId, params) {
|
|
1112
|
+
return client.get(_entrolytics_shared.API_ROUTES.vitalsOverview, {
|
|
1113
|
+
websiteId,
|
|
1114
|
+
...toDateRangeQuery(params)
|
|
1115
|
+
});
|
|
1116
|
+
},
|
|
1117
|
+
/**
|
|
1118
|
+
* Get individual Web Vital events.
|
|
1119
|
+
* Note: Only available in entrolytics.
|
|
1120
|
+
*/
|
|
1121
|
+
getWebsiteVitalEvents(websiteId, params) {
|
|
1122
|
+
return client.get(_entrolytics_shared.API_ROUTES.vitalsRecent, {
|
|
1123
|
+
websiteId,
|
|
1124
|
+
...params.limit ? { limit: params.limit } : {}
|
|
1125
|
+
});
|
|
1126
|
+
},
|
|
1127
|
+
/**
|
|
1128
|
+
* Track a Web Vital metric (send to collection endpoint).
|
|
1129
|
+
* Note: Only available in entrolytics.
|
|
1130
|
+
*/
|
|
1131
|
+
trackVital(websiteId, data) {
|
|
1132
|
+
return client.post(_entrolytics_shared.API_ROUTES.collectVitals, {
|
|
1133
|
+
websiteId,
|
|
1134
|
+
visitorId: data.visitorId,
|
|
1135
|
+
sessionId: data.sessionId,
|
|
1136
|
+
url: data.url,
|
|
1137
|
+
path: data.path,
|
|
1138
|
+
metricName: data.metric,
|
|
1139
|
+
metricValue: data.value,
|
|
1140
|
+
deviceType: data.deviceType,
|
|
1141
|
+
browser: data.browser
|
|
1142
|
+
}).then((response) => toSuccessResponse(response));
|
|
1143
|
+
},
|
|
1144
|
+
/**
|
|
1145
|
+
* Track multiple Web Vitals metrics in batch.
|
|
1146
|
+
* Note: Only available in entrolytics.
|
|
1147
|
+
*/
|
|
1148
|
+
trackVitalsBatch(websiteId, vitals) {
|
|
1149
|
+
if (vitals.length === 0) return Promise.resolve({
|
|
1150
|
+
ok: false,
|
|
1151
|
+
status: 400,
|
|
1152
|
+
error: "At least one vital is required"
|
|
1153
|
+
});
|
|
1154
|
+
const [firstVital] = vitals;
|
|
1155
|
+
if (vitals.some((vital) => vital.visitorId !== firstVital?.visitorId || vital.sessionId !== firstVital?.sessionId)) return Promise.resolve({
|
|
1156
|
+
ok: false,
|
|
1157
|
+
status: 400,
|
|
1158
|
+
error: "All batched vitals must share the same visitorId and sessionId"
|
|
1159
|
+
});
|
|
1160
|
+
return client.post(_entrolytics_shared.API_ROUTES.collectVitalsBatch, {
|
|
1161
|
+
websiteId,
|
|
1162
|
+
visitorId: firstVital?.visitorId,
|
|
1163
|
+
sessionId: firstVital?.sessionId,
|
|
1164
|
+
vitals: vitals.map((vital) => ({
|
|
1165
|
+
url: vital.url,
|
|
1166
|
+
path: vital.path,
|
|
1167
|
+
metricName: vital.metric,
|
|
1168
|
+
metricValue: vital.value,
|
|
1169
|
+
deviceType: vital.deviceType,
|
|
1170
|
+
browser: vital.browser
|
|
1171
|
+
}))
|
|
1172
|
+
}).then((response) => toSuccessResponse(response));
|
|
1173
|
+
},
|
|
1174
|
+
/**
|
|
1175
|
+
* Get form analytics for a website.
|
|
1176
|
+
* Note: Only available in entrolytics.
|
|
1177
|
+
*/
|
|
1178
|
+
getWebsiteForms(websiteId, params) {
|
|
1179
|
+
return client.get(_entrolytics_shared.API_ROUTES.formsConversions, {
|
|
1180
|
+
websiteId,
|
|
1181
|
+
...toDateRangeQuery(params)
|
|
1182
|
+
});
|
|
1183
|
+
},
|
|
1184
|
+
/**
|
|
1185
|
+
* Get field-level analytics for a specific form.
|
|
1186
|
+
* Note: Only available in entrolytics.
|
|
1187
|
+
*/
|
|
1188
|
+
getFormFields(websiteId, formId, params) {
|
|
1189
|
+
return client.get(_entrolytics_shared.API_ROUTES.formsFieldMetrics, {
|
|
1190
|
+
websiteId,
|
|
1191
|
+
formId,
|
|
1192
|
+
...toDateRangeQuery(params)
|
|
1193
|
+
});
|
|
1194
|
+
},
|
|
1195
|
+
/**
|
|
1196
|
+
* Get individual form events.
|
|
1197
|
+
* Note: Only available in entrolytics.
|
|
1198
|
+
*/
|
|
1199
|
+
getFormEvents(websiteId, params) {
|
|
1200
|
+
return client.get(_entrolytics_shared.API_ROUTES.formsRecent, {
|
|
1201
|
+
websiteId,
|
|
1202
|
+
...params.limit ? { limit: params.limit } : {}
|
|
1203
|
+
});
|
|
1204
|
+
},
|
|
1205
|
+
/**
|
|
1206
|
+
* Track a form event (send to collection endpoint).
|
|
1207
|
+
* Note: Only available in entrolytics.
|
|
1208
|
+
*/
|
|
1209
|
+
trackFormEvent(websiteId, data) {
|
|
1210
|
+
return client.post(_entrolytics_shared.API_ROUTES.collectForms, {
|
|
1211
|
+
websiteId,
|
|
1212
|
+
visitorId: data.visitorId,
|
|
1213
|
+
sessionId: data.sessionId,
|
|
1214
|
+
formId: data.formId,
|
|
1215
|
+
formName: data.formName,
|
|
1216
|
+
urlPath: data.urlPath,
|
|
1217
|
+
eventType: data.eventType,
|
|
1218
|
+
fieldName: data.fieldName,
|
|
1219
|
+
fieldType: data.fieldType,
|
|
1220
|
+
fieldIndex: data.fieldIndex,
|
|
1221
|
+
timeOnField: data.timeOnField,
|
|
1222
|
+
timeSinceStart: data.timeSinceStart,
|
|
1223
|
+
errorMessage: data.errorMessage,
|
|
1224
|
+
success: data.success
|
|
1225
|
+
}).then((response) => toSuccessResponse(response));
|
|
1226
|
+
},
|
|
1227
|
+
/**
|
|
1228
|
+
* Track multiple form events in batch.
|
|
1229
|
+
* Note: Only available in entrolytics.
|
|
1230
|
+
*/
|
|
1231
|
+
trackFormEventsBatch(websiteId, events) {
|
|
1232
|
+
if (events.length === 0) return Promise.resolve({
|
|
1233
|
+
ok: false,
|
|
1234
|
+
status: 400,
|
|
1235
|
+
error: "At least one event is required"
|
|
1236
|
+
});
|
|
1237
|
+
const [firstEvent] = events;
|
|
1238
|
+
if (events.some((event) => event.visitorId !== firstEvent?.visitorId || event.sessionId !== firstEvent?.sessionId)) return Promise.resolve({
|
|
1239
|
+
ok: false,
|
|
1240
|
+
status: 400,
|
|
1241
|
+
error: "All batched form events must share the same visitorId and sessionId"
|
|
1242
|
+
});
|
|
1243
|
+
return client.post(_entrolytics_shared.API_ROUTES.collectFormsBatch, {
|
|
1244
|
+
websiteId,
|
|
1245
|
+
visitorId: firstEvent?.visitorId,
|
|
1246
|
+
sessionId: firstEvent?.sessionId,
|
|
1247
|
+
events: events.map((event) => ({
|
|
1248
|
+
formId: event.formId,
|
|
1249
|
+
formName: event.formName,
|
|
1250
|
+
urlPath: event.urlPath,
|
|
1251
|
+
eventType: event.eventType,
|
|
1252
|
+
fieldName: event.fieldName,
|
|
1253
|
+
fieldType: event.fieldType,
|
|
1254
|
+
fieldIndex: event.fieldIndex,
|
|
1255
|
+
timeOnField: event.timeOnField,
|
|
1256
|
+
timeSinceStart: event.timeSinceStart,
|
|
1257
|
+
errorMessage: event.errorMessage,
|
|
1258
|
+
success: event.success
|
|
1259
|
+
}))
|
|
1260
|
+
}).then((response) => toSuccessResponse(response));
|
|
1261
|
+
},
|
|
1262
|
+
/**
|
|
1263
|
+
* Get deployments for a website.
|
|
1264
|
+
* Note: Only available in entrolytics.
|
|
1265
|
+
*/
|
|
1266
|
+
getWebsiteDeployments(websiteId, params) {
|
|
1267
|
+
return client.get(_entrolytics_shared.API_ROUTES.deploymentByWebsite(websiteId), {
|
|
1268
|
+
limit: params.limit,
|
|
1269
|
+
days: toDeploymentDays(params)
|
|
1270
|
+
});
|
|
1271
|
+
},
|
|
1272
|
+
/**
|
|
1273
|
+
* Get a specific deployment.
|
|
1274
|
+
* Note: Only available in entrolytics.
|
|
1275
|
+
*/
|
|
1276
|
+
getDeployment(websiteId, deployId) {
|
|
1277
|
+
return client.get(_entrolytics_shared.API_ROUTES.deploymentByWebsite(websiteId), { limit: 100 }).then((response) => {
|
|
1278
|
+
if (!response.data) return {
|
|
1279
|
+
...response,
|
|
1280
|
+
data: void 0
|
|
1281
|
+
};
|
|
1282
|
+
const deployment = response.data.find((item) => item.deployId === deployId);
|
|
1283
|
+
if (!deployment) return {
|
|
1284
|
+
ok: false,
|
|
1285
|
+
status: 404,
|
|
1286
|
+
error: `Deployment not found: ${deployId}`
|
|
1287
|
+
};
|
|
1288
|
+
return {
|
|
1289
|
+
ok: response.ok,
|
|
1290
|
+
status: response.status,
|
|
1291
|
+
data: deployment
|
|
1292
|
+
};
|
|
1293
|
+
});
|
|
1294
|
+
},
|
|
1295
|
+
/**
|
|
1296
|
+
* Compare two deployments.
|
|
1297
|
+
* Note: Only available in entrolytics.
|
|
1298
|
+
*/
|
|
1299
|
+
compareDeployments(websiteId, limit = 10) {
|
|
1300
|
+
return client.get(_entrolytics_shared.API_ROUTES.deploymentCompare(websiteId), { limit });
|
|
1301
|
+
},
|
|
1302
|
+
/**
|
|
1303
|
+
* Set/register a deployment context.
|
|
1304
|
+
* Note: Only available in entrolytics.
|
|
1305
|
+
*/
|
|
1306
|
+
setDeployment(websiteId, data) {
|
|
1307
|
+
return client.post(_entrolytics_shared.API_ROUTES.deployments, {
|
|
1308
|
+
websiteId,
|
|
1309
|
+
...data,
|
|
1310
|
+
source: data.source ?? "custom"
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
//#endregion
|
|
1317
|
+
//#region src/runtime.ts
|
|
1318
|
+
/**
|
|
1319
|
+
* Detect the current JavaScript runtime environment
|
|
1320
|
+
*
|
|
1321
|
+
* @returns {Runtime} The detected runtime ('node', 'edge', or 'unknown')
|
|
1322
|
+
*
|
|
1323
|
+
* @example
|
|
1324
|
+
* ```ts
|
|
1325
|
+
* const runtime = detectRuntime();
|
|
1326
|
+
*
|
|
1327
|
+
* switch (runtime) {
|
|
1328
|
+
* case 'node':
|
|
1329
|
+
* console.log('Running in Node.js');
|
|
1330
|
+
* break;
|
|
1331
|
+
* case 'edge':
|
|
1332
|
+
* console.log('Running in Edge Runtime');
|
|
1333
|
+
* break;
|
|
1334
|
+
* default:
|
|
1335
|
+
* console.log('Unknown runtime');
|
|
1336
|
+
* }
|
|
1337
|
+
* ```
|
|
1338
|
+
*/
|
|
1339
|
+
function detectRuntime() {
|
|
1340
|
+
const globalRef = globalThis;
|
|
1341
|
+
const isNode = typeof globalRef.process?.versions?.node === "string";
|
|
1342
|
+
const hasEdgeRuntime = typeof globalRef.EdgeRuntime !== "undefined";
|
|
1343
|
+
const hasDeno = typeof globalRef.Deno !== "undefined";
|
|
1344
|
+
if (hasEdgeRuntime || hasDeno || typeof WebAssembly !== "undefined" && typeof Response !== "undefined" && !isNode) return "edge";
|
|
1345
|
+
if (typeof process !== "undefined" && process.versions != null && process.versions.node != null) return "node";
|
|
1346
|
+
return "unknown";
|
|
1347
|
+
}
|
|
1348
|
+
/**
|
|
1349
|
+
* Check if code is running in Node.js runtime
|
|
1350
|
+
*
|
|
1351
|
+
* @returns {boolean} True if running in Node.js
|
|
1352
|
+
*
|
|
1353
|
+
* @example
|
|
1354
|
+
* ```ts
|
|
1355
|
+
* if (isNodeRuntime()) {
|
|
1356
|
+
* // Safe to use Node.js-only features
|
|
1357
|
+
* const fs = require('fs');
|
|
1358
|
+
* const data = fs.readFileSync('file.txt');
|
|
1359
|
+
* }
|
|
1360
|
+
* ```
|
|
1361
|
+
*/
|
|
1362
|
+
function isNodeRuntime() {
|
|
1363
|
+
return detectRuntime() === "node";
|
|
1364
|
+
}
|
|
1365
|
+
/**
|
|
1366
|
+
* Check if code is running in Edge runtime
|
|
1367
|
+
*
|
|
1368
|
+
* @returns {boolean} True if running in Edge runtime (Vercel, Netlify, Cloudflare)
|
|
1369
|
+
*
|
|
1370
|
+
* @example
|
|
1371
|
+
* ```ts
|
|
1372
|
+
* if (isEdgeRuntime()) {
|
|
1373
|
+
* // Use only edge-compatible features
|
|
1374
|
+
* const response = await fetch('https://api.example.com');
|
|
1375
|
+
* }
|
|
1376
|
+
* ```
|
|
1377
|
+
*/
|
|
1378
|
+
function isEdgeRuntime() {
|
|
1379
|
+
return detectRuntime() === "edge";
|
|
1380
|
+
}
|
|
1381
|
+
/**
|
|
1382
|
+
* Get runtime capabilities
|
|
1383
|
+
*
|
|
1384
|
+
* @returns Runtime capabilities object
|
|
1385
|
+
*
|
|
1386
|
+
* @example
|
|
1387
|
+
* ```ts
|
|
1388
|
+
* const capabilities = getRuntimeCapabilities();
|
|
1389
|
+
*
|
|
1390
|
+
* if (capabilities.supportsFileSystem) {
|
|
1391
|
+
* // Can use fs module
|
|
1392
|
+
* }
|
|
1393
|
+
*
|
|
1394
|
+
* if (capabilities.supportsWebCrypto) {
|
|
1395
|
+
* // Can use Web Crypto API
|
|
1396
|
+
* }
|
|
1397
|
+
* ```
|
|
1398
|
+
*/
|
|
1399
|
+
function getRuntimeCapabilities() {
|
|
1400
|
+
const runtime = detectRuntime();
|
|
1401
|
+
return {
|
|
1402
|
+
runtime,
|
|
1403
|
+
isNode: runtime === "node",
|
|
1404
|
+
isEdge: runtime === "edge",
|
|
1405
|
+
supportsFileSystem: runtime === "node",
|
|
1406
|
+
supportsWebCrypto: typeof crypto !== "undefined" && typeof crypto.subtle !== "undefined",
|
|
1407
|
+
supportsFetch: typeof fetch !== "undefined",
|
|
1408
|
+
supportsStreams: typeof ReadableStream !== "undefined"
|
|
1409
|
+
};
|
|
1410
|
+
}
|
|
1411
|
+
/**
|
|
1412
|
+
* Assert that code is running in a specific runtime
|
|
1413
|
+
*
|
|
1414
|
+
* @param {Runtime} expected - The expected runtime
|
|
1415
|
+
* @throws {Error} If not running in the expected runtime
|
|
1416
|
+
*
|
|
1417
|
+
* @example
|
|
1418
|
+
* ```ts
|
|
1419
|
+
* // Ensure we're in edge runtime
|
|
1420
|
+
* assertRuntime('edge');
|
|
1421
|
+
*
|
|
1422
|
+
* // Now safe to use edge-only features
|
|
1423
|
+
* export const runtime = 'edge';
|
|
1424
|
+
* ```
|
|
1425
|
+
*/
|
|
1426
|
+
function assertRuntime(expected) {
|
|
1427
|
+
const actual = detectRuntime();
|
|
1428
|
+
if (actual !== expected) throw new Error(`Expected ${expected} runtime, but detected ${actual}. This code requires ${expected} runtime to function correctly.`);
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
//#endregion
|
|
1432
|
+
//#region src/edge-helpers.ts
|
|
1433
|
+
/**
|
|
1434
|
+
* Edge runtime helper utilities
|
|
1435
|
+
*
|
|
1436
|
+
* Provides edge-compatible environment variable access, fetch utilities,
|
|
1437
|
+
* and common patterns for edge deployments (Vercel, Netlify, Cloudflare).
|
|
1438
|
+
*
|
|
1439
|
+
* @module edge-helpers
|
|
1440
|
+
* @example
|
|
1441
|
+
* ```ts
|
|
1442
|
+
* import { getEdgeEnv, createEdgeFetch, getRegionInfo } from 'entro-api/edge-helpers';
|
|
1443
|
+
*
|
|
1444
|
+
* // Access environment variables safely
|
|
1445
|
+
* const apiKey = getEdgeEnv('API_KEY', 'default-key');
|
|
1446
|
+
*
|
|
1447
|
+
* // Create a fetch wrapper with retries
|
|
1448
|
+
* const edgeFetch = createEdgeFetch({ retries: 3 });
|
|
1449
|
+
* const response = await edgeFetch('https://api.example.com');
|
|
1450
|
+
*
|
|
1451
|
+
* // Get deployment region information
|
|
1452
|
+
* const region = getRegionInfo();
|
|
1453
|
+
* console.log(`Running in ${region.provider} region ${region.region}`);
|
|
1454
|
+
* ```
|
|
1455
|
+
*/
|
|
1456
|
+
/**
|
|
1457
|
+
* Safely access environment variables in edge runtime
|
|
1458
|
+
*
|
|
1459
|
+
* @param {string} key - Environment variable name
|
|
1460
|
+
* @param {string} [defaultValue] - Optional default value if variable not found
|
|
1461
|
+
* @returns {string | undefined} The environment variable value or default
|
|
1462
|
+
*
|
|
1463
|
+
* @example
|
|
1464
|
+
* ```ts
|
|
1465
|
+
* // With default value
|
|
1466
|
+
* const apiKey = getEdgeEnv('API_KEY', 'fallback-key');
|
|
1467
|
+
*
|
|
1468
|
+
* // Without default (returns undefined if not found)
|
|
1469
|
+
* const optionalVar = getEdgeEnv('OPTIONAL_VAR');
|
|
1470
|
+
* ```
|
|
1471
|
+
*/
|
|
1472
|
+
function getEdgeEnv(key, defaultValue) {
|
|
1473
|
+
const globals = globalThis;
|
|
1474
|
+
if (typeof process !== "undefined" && process.env) {
|
|
1475
|
+
const value = process.env[key];
|
|
1476
|
+
if (value !== void 0) return value;
|
|
1477
|
+
}
|
|
1478
|
+
if (globals.Deno?.env && typeof globals.Deno.env.get === "function") try {
|
|
1479
|
+
return globals.Deno.env.get(key) || defaultValue;
|
|
1480
|
+
} catch {}
|
|
1481
|
+
return defaultValue;
|
|
1482
|
+
}
|
|
1483
|
+
/**
|
|
1484
|
+
* Check if a required environment variable is set
|
|
1485
|
+
*
|
|
1486
|
+
* @param {string} key - Environment variable name
|
|
1487
|
+
* @throws {Error} If the required variable is not set
|
|
1488
|
+
*
|
|
1489
|
+
* @example
|
|
1490
|
+
* ```ts
|
|
1491
|
+
* // Throws if DATABASE_URL is not set
|
|
1492
|
+
* requireEdgeEnv('DATABASE_URL');
|
|
1493
|
+
* ```
|
|
1494
|
+
*/
|
|
1495
|
+
function requireEdgeEnv(key) {
|
|
1496
|
+
const value = getEdgeEnv(key);
|
|
1497
|
+
if (!value) throw new Error(`Required environment variable ${key} is not set`);
|
|
1498
|
+
return value;
|
|
1499
|
+
}
|
|
1500
|
+
/**
|
|
1501
|
+
* Create an edge-compatible fetch wrapper with retries and timeout
|
|
1502
|
+
*
|
|
1503
|
+
* @param {EdgeFetchOptions} [defaultOptions] - Default options for all requests
|
|
1504
|
+
* @returns {Function} Enhanced fetch function
|
|
1505
|
+
*
|
|
1506
|
+
* @example
|
|
1507
|
+
* ```ts
|
|
1508
|
+
* const edgeFetch = createEdgeFetch({
|
|
1509
|
+
* retries: 3,
|
|
1510
|
+
* retryDelay: 1000,
|
|
1511
|
+
* timeout: 10000,
|
|
1512
|
+
* });
|
|
1513
|
+
*
|
|
1514
|
+
* // Fetch with automatic retries
|
|
1515
|
+
* const response = await edgeFetch('https://api.example.com/data');
|
|
1516
|
+
* ```
|
|
1517
|
+
*/
|
|
1518
|
+
function createEdgeFetch(defaultOptions = {}) {
|
|
1519
|
+
const { retries = 3, retryDelay = 1e3, timeout = 3e4, ...fetchDefaults } = defaultOptions;
|
|
1520
|
+
return async function edgeFetch(input, options) {
|
|
1521
|
+
const finalRetries = options?.retries ?? retries;
|
|
1522
|
+
const finalDelay = options?.retryDelay ?? retryDelay;
|
|
1523
|
+
const finalTimeout = options?.timeout ?? timeout;
|
|
1524
|
+
const finalOptions = {
|
|
1525
|
+
...fetchDefaults,
|
|
1526
|
+
...options
|
|
1527
|
+
};
|
|
1528
|
+
let lastError;
|
|
1529
|
+
for (let attempt = 0; attempt <= finalRetries; attempt++) {
|
|
1530
|
+
try {
|
|
1531
|
+
const controller = new AbortController();
|
|
1532
|
+
const timeoutId = setTimeout(() => controller.abort(), finalTimeout);
|
|
1533
|
+
const response = await fetch(input, {
|
|
1534
|
+
...finalOptions,
|
|
1535
|
+
signal: controller.signal
|
|
1536
|
+
});
|
|
1537
|
+
clearTimeout(timeoutId);
|
|
1538
|
+
if (response.ok || response.status >= 400 && response.status < 500) return response;
|
|
1539
|
+
lastError = /* @__PURE__ */ new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
1540
|
+
} catch (error) {
|
|
1541
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
1542
|
+
if (lastError.name === "AbortError") throw new Error(`Request timeout after ${finalTimeout}ms`);
|
|
1543
|
+
}
|
|
1544
|
+
if (attempt < finalRetries) {
|
|
1545
|
+
const delay = finalDelay * Math.pow(2, attempt);
|
|
1546
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
throw lastError || /* @__PURE__ */ new Error("Request failed");
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1552
|
+
/**
|
|
1553
|
+
* Get information about the current edge deployment region
|
|
1554
|
+
*
|
|
1555
|
+
* @returns {RegionInfo} Information about the deployment region
|
|
1556
|
+
*
|
|
1557
|
+
* @example
|
|
1558
|
+
* ```ts
|
|
1559
|
+
* const region = getRegionInfo();
|
|
1560
|
+
*
|
|
1561
|
+
* if (region.provider === 'vercel') {
|
|
1562
|
+
* console.log(`Running in Vercel region: ${region.region}`);
|
|
1563
|
+
* }
|
|
1564
|
+
* ```
|
|
1565
|
+
*/
|
|
1566
|
+
function getRegionInfo() {
|
|
1567
|
+
const globals = globalThis;
|
|
1568
|
+
if (getEdgeEnv("VERCEL")) return {
|
|
1569
|
+
provider: "vercel",
|
|
1570
|
+
region: getEdgeEnv("VERCEL_REGION"),
|
|
1571
|
+
isEdge: getEdgeEnv("VERCEL_EDGE_RUNTIME") === "1"
|
|
1572
|
+
};
|
|
1573
|
+
if (typeof globals.Deno !== "undefined" && getEdgeEnv("NETLIFY")) return {
|
|
1574
|
+
provider: "netlify",
|
|
1575
|
+
region: getEdgeEnv("NETLIFY_REGION"),
|
|
1576
|
+
isEdge: true
|
|
1577
|
+
};
|
|
1578
|
+
if (typeof globals.caches !== "undefined" && typeof WebAssembly !== "undefined") return {
|
|
1579
|
+
provider: "cloudflare",
|
|
1580
|
+
region: void 0,
|
|
1581
|
+
isEdge: true
|
|
1582
|
+
};
|
|
1583
|
+
return {
|
|
1584
|
+
provider: "unknown",
|
|
1585
|
+
isEdge: false
|
|
1586
|
+
};
|
|
1587
|
+
}
|
|
1588
|
+
/**
|
|
1589
|
+
* Extract geo information from edge request
|
|
1590
|
+
*
|
|
1591
|
+
* @param {Request} request - The incoming Request object
|
|
1592
|
+
* @returns {Object} Geo information extracted from headers
|
|
1593
|
+
*
|
|
1594
|
+
* @example
|
|
1595
|
+
* ```ts
|
|
1596
|
+
* export async function POST(request: Request) {
|
|
1597
|
+
* const geo = getGeoFromRequest(request);
|
|
1598
|
+
* console.log(`Request from: ${geo.country}, ${geo.city}`);
|
|
1599
|
+
* }
|
|
1600
|
+
* ```
|
|
1601
|
+
*/
|
|
1602
|
+
function getGeoFromRequest(request) {
|
|
1603
|
+
const headers = request.headers;
|
|
1604
|
+
const vercelCountry = headers.get("x-vercel-ip-country");
|
|
1605
|
+
if (vercelCountry) return {
|
|
1606
|
+
country: vercelCountry,
|
|
1607
|
+
region: headers.get("x-vercel-ip-country-region"),
|
|
1608
|
+
city: headers.get("x-vercel-ip-city"),
|
|
1609
|
+
latitude: headers.get("x-vercel-ip-latitude"),
|
|
1610
|
+
longitude: headers.get("x-vercel-ip-longitude")
|
|
1611
|
+
};
|
|
1612
|
+
const cfCountry = headers.get("cf-ipcountry");
|
|
1613
|
+
if (cfCountry) return {
|
|
1614
|
+
country: cfCountry,
|
|
1615
|
+
region: headers.get("cf-region"),
|
|
1616
|
+
city: headers.get("cf-city"),
|
|
1617
|
+
latitude: headers.get("cf-latitude"),
|
|
1618
|
+
longitude: headers.get("cf-longitude")
|
|
1619
|
+
};
|
|
1620
|
+
return {
|
|
1621
|
+
country: void 0,
|
|
1622
|
+
region: void 0,
|
|
1623
|
+
city: void 0,
|
|
1624
|
+
latitude: void 0,
|
|
1625
|
+
longitude: void 0
|
|
1626
|
+
};
|
|
1627
|
+
}
|
|
1628
|
+
/**
|
|
1629
|
+
* Get client IP address from edge request
|
|
1630
|
+
*
|
|
1631
|
+
* @param {Request} request - The incoming Request object
|
|
1632
|
+
* @returns {string | undefined} The client IP address
|
|
1633
|
+
*
|
|
1634
|
+
* @example
|
|
1635
|
+
* ```ts
|
|
1636
|
+
* export async function POST(request: Request) {
|
|
1637
|
+
* const clientIp = getClientIp(request);
|
|
1638
|
+
* console.log(`Request from IP: ${clientIp}`);
|
|
1639
|
+
* }
|
|
1640
|
+
* ```
|
|
1641
|
+
*/
|
|
1642
|
+
function getClientIp(request) {
|
|
1643
|
+
const headers = request.headers;
|
|
1644
|
+
return headers.get("x-forwarded-for")?.split(",")[0]?.trim() || headers.get("x-real-ip") || headers.get("cf-connecting-ip") || headers.get("x-vercel-forwarded-for") || void 0;
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
//#endregion
|
|
1648
|
+
//#region src/index.ts
|
|
1649
|
+
/**
|
|
1650
|
+
* Create an Entrolytics API client.
|
|
1651
|
+
*
|
|
1652
|
+
* @example
|
|
1653
|
+
* ```ts
|
|
1654
|
+
* // Using environment variables
|
|
1655
|
+
* const client = getClient();
|
|
1656
|
+
*
|
|
1657
|
+
* // With explicit configuration
|
|
1658
|
+
* const client = getClient({
|
|
1659
|
+
* endpoint: 'https://analytics.example.com/api',
|
|
1660
|
+
* apiKey: 'your-api-key',
|
|
1661
|
+
* });
|
|
1662
|
+
*
|
|
1663
|
+
* // Make API calls
|
|
1664
|
+
* const { ok, data, error } = await client.getWebsites();
|
|
1665
|
+
* ```
|
|
1666
|
+
*/
|
|
1667
|
+
function getClient(config) {
|
|
1668
|
+
const apiClient = new ApiClient(config);
|
|
1669
|
+
const admin = createAdminEndpoints(apiClient);
|
|
1670
|
+
const auth = createAuthEndpoints(apiClient);
|
|
1671
|
+
const billing = createBillingEndpoints(apiClient);
|
|
1672
|
+
const config_endpoints = createConfigEndpoints(apiClient);
|
|
1673
|
+
const me = createMeEndpoints(apiClient);
|
|
1674
|
+
const users = createUsersEndpoints(apiClient);
|
|
1675
|
+
const orgs = createOrgsEndpoints(apiClient);
|
|
1676
|
+
const websites = createWebsitesEndpoints(apiClient);
|
|
1677
|
+
const sessions = createSessionsEndpoints(apiClient);
|
|
1678
|
+
const events = createEventsEndpoints(apiClient);
|
|
1679
|
+
const reports = createReportsEndpoints(apiClient);
|
|
1680
|
+
const segments = createSegmentsEndpoints(apiClient);
|
|
1681
|
+
const links = createLinksEndpoints(apiClient);
|
|
1682
|
+
const pixels = createPixelsEndpoints(apiClient);
|
|
1683
|
+
const boards = createBoardsEndpoints(apiClient);
|
|
1684
|
+
const webhooks = createWebhooksEndpoints(apiClient);
|
|
1685
|
+
const integrations = createIntegrationsEndpoints(apiClient);
|
|
1686
|
+
return {
|
|
1687
|
+
auth,
|
|
1688
|
+
...me,
|
|
1689
|
+
...users,
|
|
1690
|
+
...orgs,
|
|
1691
|
+
...websites,
|
|
1692
|
+
...sessions,
|
|
1693
|
+
...events,
|
|
1694
|
+
...reports,
|
|
1695
|
+
...segments,
|
|
1696
|
+
...links,
|
|
1697
|
+
...pixels,
|
|
1698
|
+
...boards,
|
|
1699
|
+
getConfig: config_endpoints.get,
|
|
1700
|
+
admin,
|
|
1701
|
+
webhooks,
|
|
1702
|
+
integrations,
|
|
1703
|
+
billing
|
|
1704
|
+
};
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
//#endregion
|
|
1708
|
+
Object.defineProperty(exports, 'API_ENDPOINTS', {
|
|
1709
|
+
enumerable: true,
|
|
1710
|
+
get: function () {
|
|
1711
|
+
return _entrolytics_shared.API_ENDPOINTS;
|
|
1712
|
+
}
|
|
1713
|
+
});
|
|
1714
|
+
Object.defineProperty(exports, 'API_ROUTES', {
|
|
1715
|
+
enumerable: true,
|
|
1716
|
+
get: function () {
|
|
1717
|
+
return _entrolytics_shared.API_ROUTES;
|
|
1718
|
+
}
|
|
1719
|
+
});
|
|
1720
|
+
exports.ApiClient = ApiClient;
|
|
1721
|
+
Object.defineProperty(exports, 'BILLING_ERRORS', {
|
|
1722
|
+
enumerable: true,
|
|
1723
|
+
get: function () {
|
|
1724
|
+
return _entrolytics_shared.BILLING_ERRORS;
|
|
1725
|
+
}
|
|
1726
|
+
});
|
|
1727
|
+
Object.defineProperty(exports, 'CLI_CONFIG', {
|
|
1728
|
+
enumerable: true,
|
|
1729
|
+
get: function () {
|
|
1730
|
+
return _entrolytics_shared.CLI_CONFIG;
|
|
1731
|
+
}
|
|
1732
|
+
});
|
|
1733
|
+
Object.defineProperty(exports, 'CLI_TOKEN_STATUS', {
|
|
1734
|
+
enumerable: true,
|
|
1735
|
+
get: function () {
|
|
1736
|
+
return _entrolytics_shared.CLI_TOKEN_STATUS;
|
|
1737
|
+
}
|
|
1738
|
+
});
|
|
1739
|
+
Object.defineProperty(exports, 'DEFAULT_API_HOST', {
|
|
1740
|
+
enumerable: true,
|
|
1741
|
+
get: function () {
|
|
1742
|
+
return _entrolytics_shared.DEFAULT_API_HOST;
|
|
1743
|
+
}
|
|
1744
|
+
});
|
|
1745
|
+
Object.defineProperty(exports, 'DEPLOYMENT_ENV_VARS', {
|
|
1746
|
+
enumerable: true,
|
|
1747
|
+
get: function () {
|
|
1748
|
+
return _entrolytics_shared.DEPLOYMENT_ENV_VARS;
|
|
1749
|
+
}
|
|
1750
|
+
});
|
|
1751
|
+
Object.defineProperty(exports, 'DEPLOYMENT_SOURCES', {
|
|
1752
|
+
enumerable: true,
|
|
1753
|
+
get: function () {
|
|
1754
|
+
return _entrolytics_shared.DEPLOYMENT_SOURCES;
|
|
1755
|
+
}
|
|
1756
|
+
});
|
|
1757
|
+
Object.defineProperty(exports, 'ENV_VAR_NAMES', {
|
|
1758
|
+
enumerable: true,
|
|
1759
|
+
get: function () {
|
|
1760
|
+
return _entrolytics_shared.ENV_VAR_NAMES;
|
|
1761
|
+
}
|
|
1762
|
+
});
|
|
1763
|
+
Object.defineProperty(exports, 'ERROR_MESSAGES', {
|
|
1764
|
+
enumerable: true,
|
|
1765
|
+
get: function () {
|
|
1766
|
+
return _entrolytics_shared.ERROR_MESSAGES;
|
|
1767
|
+
}
|
|
1768
|
+
});
|
|
1769
|
+
Object.defineProperty(exports, 'EVENT_TYPES', {
|
|
1770
|
+
enumerable: true,
|
|
1771
|
+
get: function () {
|
|
1772
|
+
return _entrolytics_shared.EVENT_TYPES;
|
|
1773
|
+
}
|
|
1774
|
+
});
|
|
1775
|
+
Object.defineProperty(exports, 'FORM_EVENT_TYPES', {
|
|
1776
|
+
enumerable: true,
|
|
1777
|
+
get: function () {
|
|
1778
|
+
return _entrolytics_shared.FORM_EVENT_TYPES;
|
|
1779
|
+
}
|
|
1780
|
+
});
|
|
1781
|
+
Object.defineProperty(exports, 'FORM_FIELD_TYPES', {
|
|
1782
|
+
enumerable: true,
|
|
1783
|
+
get: function () {
|
|
1784
|
+
return _entrolytics_shared.FORM_FIELD_TYPES;
|
|
1785
|
+
}
|
|
1786
|
+
});
|
|
1787
|
+
Object.defineProperty(exports, 'FRAMEWORK_PACKAGES', {
|
|
1788
|
+
enumerable: true,
|
|
1789
|
+
get: function () {
|
|
1790
|
+
return _entrolytics_shared.FRAMEWORK_PACKAGES;
|
|
1791
|
+
}
|
|
1792
|
+
});
|
|
1793
|
+
Object.defineProperty(exports, 'FRAMEWORK_PATTERNS', {
|
|
1794
|
+
enumerable: true,
|
|
1795
|
+
get: function () {
|
|
1796
|
+
return _entrolytics_shared.FRAMEWORK_PATTERNS;
|
|
1797
|
+
}
|
|
1798
|
+
});
|
|
1799
|
+
Object.defineProperty(exports, 'HTTP_STATUS', {
|
|
1800
|
+
enumerable: true,
|
|
1801
|
+
get: function () {
|
|
1802
|
+
return _entrolytics_shared.HTTP_STATUS;
|
|
1803
|
+
}
|
|
1804
|
+
});
|
|
1805
|
+
Object.defineProperty(exports, 'NAVIGATION_TYPES', {
|
|
1806
|
+
enumerable: true,
|
|
1807
|
+
get: function () {
|
|
1808
|
+
return _entrolytics_shared.NAVIGATION_TYPES;
|
|
1809
|
+
}
|
|
1810
|
+
});
|
|
1811
|
+
Object.defineProperty(exports, 'ONBOARDING_STEPS', {
|
|
1812
|
+
enumerable: true,
|
|
1813
|
+
get: function () {
|
|
1814
|
+
return _entrolytics_shared.ONBOARDING_STEPS;
|
|
1815
|
+
}
|
|
1816
|
+
});
|
|
1817
|
+
Object.defineProperty(exports, 'PLANS', {
|
|
1818
|
+
enumerable: true,
|
|
1819
|
+
get: function () {
|
|
1820
|
+
return _entrolytics_shared.PLANS;
|
|
1821
|
+
}
|
|
1822
|
+
});
|
|
1823
|
+
Object.defineProperty(exports, 'PLAN_FEATURES', {
|
|
1824
|
+
enumerable: true,
|
|
1825
|
+
get: function () {
|
|
1826
|
+
return _entrolytics_shared.PLAN_FEATURES;
|
|
1827
|
+
}
|
|
1828
|
+
});
|
|
1829
|
+
Object.defineProperty(exports, 'RATE_LIMITS', {
|
|
1830
|
+
enumerable: true,
|
|
1831
|
+
get: function () {
|
|
1832
|
+
return _entrolytics_shared.RATE_LIMITS;
|
|
1833
|
+
}
|
|
1834
|
+
});
|
|
1835
|
+
Object.defineProperty(exports, 'SDK_EVENT_TYPES', {
|
|
1836
|
+
enumerable: true,
|
|
1837
|
+
get: function () {
|
|
1838
|
+
return _entrolytics_shared.SDK_EVENT_TYPES;
|
|
1839
|
+
}
|
|
1840
|
+
});
|
|
1841
|
+
Object.defineProperty(exports, 'SUCCESS_MESSAGES', {
|
|
1842
|
+
enumerable: true,
|
|
1843
|
+
get: function () {
|
|
1844
|
+
return _entrolytics_shared.SUCCESS_MESSAGES;
|
|
1845
|
+
}
|
|
1846
|
+
});
|
|
1847
|
+
Object.defineProperty(exports, 'USAGE_THRESHOLDS', {
|
|
1848
|
+
enumerable: true,
|
|
1849
|
+
get: function () {
|
|
1850
|
+
return _entrolytics_shared.USAGE_THRESHOLDS;
|
|
1851
|
+
}
|
|
1852
|
+
});
|
|
1853
|
+
Object.defineProperty(exports, 'USER_ROLES', {
|
|
1854
|
+
enumerable: true,
|
|
1855
|
+
get: function () {
|
|
1856
|
+
return _entrolytics_shared.USER_ROLES;
|
|
1857
|
+
}
|
|
1858
|
+
});
|
|
1859
|
+
Object.defineProperty(exports, 'VITAL_RATINGS', {
|
|
1860
|
+
enumerable: true,
|
|
1861
|
+
get: function () {
|
|
1862
|
+
return _entrolytics_shared.VITAL_RATINGS;
|
|
1863
|
+
}
|
|
1864
|
+
});
|
|
1865
|
+
Object.defineProperty(exports, 'VITAL_THRESHOLDS', {
|
|
1866
|
+
enumerable: true,
|
|
1867
|
+
get: function () {
|
|
1868
|
+
return _entrolytics_shared.VITAL_THRESHOLDS;
|
|
1869
|
+
}
|
|
1870
|
+
});
|
|
1871
|
+
Object.defineProperty(exports, 'VITAL_TYPES', {
|
|
1872
|
+
enumerable: true,
|
|
1873
|
+
get: function () {
|
|
1874
|
+
return _entrolytics_shared.VITAL_TYPES;
|
|
1875
|
+
}
|
|
1876
|
+
});
|
|
1877
|
+
exports.assertRuntime = assertRuntime;
|
|
1878
|
+
exports.createAdminEndpoints = createAdminEndpoints;
|
|
1879
|
+
exports.createAuthEndpoints = createAuthEndpoints;
|
|
1880
|
+
exports.createBillingEndpoints = createBillingEndpoints;
|
|
1881
|
+
exports.createBoardsEndpoints = createBoardsEndpoints;
|
|
1882
|
+
exports.createConfigEndpoints = createConfigEndpoints;
|
|
1883
|
+
exports.createEdgeFetch = createEdgeFetch;
|
|
1884
|
+
exports.createEventsEndpoints = createEventsEndpoints;
|
|
1885
|
+
exports.createIntegrationsEndpoints = createIntegrationsEndpoints;
|
|
1886
|
+
exports.createLinksEndpoints = createLinksEndpoints;
|
|
1887
|
+
exports.createMeEndpoints = createMeEndpoints;
|
|
1888
|
+
exports.createOrgsEndpoints = createOrgsEndpoints;
|
|
1889
|
+
exports.createPixelsEndpoints = createPixelsEndpoints;
|
|
1890
|
+
exports.createReportsEndpoints = createReportsEndpoints;
|
|
1891
|
+
exports.createSegmentsEndpoints = createSegmentsEndpoints;
|
|
1892
|
+
exports.createSessionsEndpoints = createSessionsEndpoints;
|
|
1893
|
+
exports.createUsersEndpoints = createUsersEndpoints;
|
|
1894
|
+
exports.createWebhooksEndpoints = createWebhooksEndpoints;
|
|
1895
|
+
exports.createWebsitesEndpoints = createWebsitesEndpoints;
|
|
1896
|
+
exports.default = getClient;
|
|
1897
|
+
exports.getClient = getClient;
|
|
1898
|
+
Object.defineProperty(exports, 'detectDeploymentContext', {
|
|
1899
|
+
enumerable: true,
|
|
1900
|
+
get: function () {
|
|
1901
|
+
return _entrolytics_shared.detectDeploymentContext;
|
|
1902
|
+
}
|
|
1903
|
+
});
|
|
1904
|
+
exports.detectRuntime = detectRuntime;
|
|
1905
|
+
Object.defineProperty(exports, 'getApiRoute', {
|
|
1906
|
+
enumerable: true,
|
|
1907
|
+
get: function () {
|
|
1908
|
+
return _entrolytics_shared.getApiRoute;
|
|
1909
|
+
}
|
|
1910
|
+
});
|
|
1911
|
+
exports.getClientIp = getClientIp;
|
|
1912
|
+
exports.getEdgeEnv = getEdgeEnv;
|
|
1913
|
+
Object.defineProperty(exports, 'getEnvVarNames', {
|
|
1914
|
+
enumerable: true,
|
|
1915
|
+
get: function () {
|
|
1916
|
+
return _entrolytics_shared.getEnvVarNames;
|
|
1917
|
+
}
|
|
1918
|
+
});
|
|
1919
|
+
Object.defineProperty(exports, 'getFrameworkPackage', {
|
|
1920
|
+
enumerable: true,
|
|
1921
|
+
get: function () {
|
|
1922
|
+
return _entrolytics_shared.getFrameworkPackage;
|
|
1923
|
+
}
|
|
1924
|
+
});
|
|
1925
|
+
exports.getGeoFromRequest = getGeoFromRequest;
|
|
1926
|
+
Object.defineProperty(exports, 'getPlan', {
|
|
1927
|
+
enumerable: true,
|
|
1928
|
+
get: function () {
|
|
1929
|
+
return _entrolytics_shared.getPlan;
|
|
1930
|
+
}
|
|
1931
|
+
});
|
|
1932
|
+
Object.defineProperty(exports, 'getPlanLimit', {
|
|
1933
|
+
enumerable: true,
|
|
1934
|
+
get: function () {
|
|
1935
|
+
return _entrolytics_shared.getPlanLimit;
|
|
1936
|
+
}
|
|
1937
|
+
});
|
|
1938
|
+
exports.getRegionInfo = getRegionInfo;
|
|
1939
|
+
exports.getRuntimeCapabilities = getRuntimeCapabilities;
|
|
1940
|
+
Object.defineProperty(exports, 'getVitalRating', {
|
|
1941
|
+
enumerable: true,
|
|
1942
|
+
get: function () {
|
|
1943
|
+
return _entrolytics_shared.getVitalRating;
|
|
1944
|
+
}
|
|
1945
|
+
});
|
|
1946
|
+
exports.isEdgeRuntime = isEdgeRuntime;
|
|
1947
|
+
exports.isNodeRuntime = isNodeRuntime;
|
|
1948
|
+
Object.defineProperty(exports, 'isPlanFeatureEnabled', {
|
|
1949
|
+
enumerable: true,
|
|
1950
|
+
get: function () {
|
|
1951
|
+
return _entrolytics_shared.isPlanFeatureEnabled;
|
|
1952
|
+
}
|
|
1953
|
+
});
|
|
1954
|
+
Object.defineProperty(exports, 'isUsageCritical', {
|
|
1955
|
+
enumerable: true,
|
|
1956
|
+
get: function () {
|
|
1957
|
+
return _entrolytics_shared.isUsageCritical;
|
|
1958
|
+
}
|
|
1959
|
+
});
|
|
1960
|
+
Object.defineProperty(exports, 'isUsageWarning', {
|
|
1961
|
+
enumerable: true,
|
|
1962
|
+
get: function () {
|
|
1963
|
+
return _entrolytics_shared.isUsageWarning;
|
|
1964
|
+
}
|
|
1965
|
+
});
|
|
1966
|
+
Object.defineProperty(exports, 'isValidFramework', {
|
|
1967
|
+
enumerable: true,
|
|
1968
|
+
get: function () {
|
|
1969
|
+
return _entrolytics_shared.isValidFramework;
|
|
1970
|
+
}
|
|
1971
|
+
});
|
|
1972
|
+
exports.requireEdgeEnv = requireEdgeEnv;
|
|
1973
|
+
//# sourceMappingURL=index.cjs.map
|