@entrolytics/api-client 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs DELETED
@@ -1,1609 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- API_ENDPOINTS: () => import_shared.API_ENDPOINTS,
24
- API_ROUTES: () => import_shared.API_ROUTES,
25
- ApiClient: () => ApiClient,
26
- BILLING_ERRORS: () => import_shared.BILLING_ERRORS,
27
- CLI_CONFIG: () => import_shared.CLI_CONFIG,
28
- CLI_TOKEN_STATUS: () => import_shared.CLI_TOKEN_STATUS,
29
- DEFAULT_API_HOST: () => import_shared.DEFAULT_API_HOST,
30
- DEPLOYMENT_ENV_VARS: () => import_shared.DEPLOYMENT_ENV_VARS,
31
- DEPLOYMENT_SOURCES: () => import_shared.DEPLOYMENT_SOURCES,
32
- ENV_VAR_NAMES: () => import_shared.ENV_VAR_NAMES,
33
- ERROR_MESSAGES: () => import_shared.ERROR_MESSAGES,
34
- EVENT_TYPES: () => import_shared.EVENT_TYPES,
35
- FORM_EVENT_TYPES: () => import_shared.FORM_EVENT_TYPES,
36
- FORM_FIELD_TYPES: () => import_shared.FORM_FIELD_TYPES,
37
- FRAMEWORK_PACKAGES: () => import_shared.FRAMEWORK_PACKAGES,
38
- FRAMEWORK_PATTERNS: () => import_shared.FRAMEWORK_PATTERNS,
39
- HTTP_STATUS: () => import_shared.HTTP_STATUS,
40
- NAVIGATION_TYPES: () => import_shared.NAVIGATION_TYPES,
41
- ONBOARDING_STEPS: () => import_shared.ONBOARDING_STEPS,
42
- PLANS: () => import_shared.PLANS,
43
- PLAN_FEATURES: () => import_shared.PLAN_FEATURES,
44
- RATE_LIMITS: () => import_shared.RATE_LIMITS,
45
- SUCCESS_MESSAGES: () => import_shared.SUCCESS_MESSAGES,
46
- USAGE_THRESHOLDS: () => import_shared.USAGE_THRESHOLDS,
47
- USER_ROLES: () => import_shared.USER_ROLES,
48
- VITAL_RATINGS: () => import_shared.VITAL_RATINGS,
49
- VITAL_THRESHOLDS: () => import_shared.VITAL_THRESHOLDS,
50
- VITAL_TYPES: () => import_shared.VITAL_TYPES,
51
- assertRuntime: () => assertRuntime,
52
- createAdminEndpoints: () => createAdminEndpoints,
53
- createAuthEndpoints: () => createAuthEndpoints,
54
- createBillingEndpoints: () => createBillingEndpoints,
55
- createBoardsEndpoints: () => createBoardsEndpoints,
56
- createConfigEndpoints: () => createConfigEndpoints,
57
- createEdgeFetch: () => createEdgeFetch,
58
- createEventsEndpoints: () => createEventsEndpoints,
59
- createIntegrationsEndpoints: () => createIntegrationsEndpoints,
60
- createLinksEndpoints: () => createLinksEndpoints,
61
- createMeEndpoints: () => createMeEndpoints,
62
- createOrgsEndpoints: () => createOrgsEndpoints,
63
- createPixelsEndpoints: () => createPixelsEndpoints,
64
- createReportsEndpoints: () => createReportsEndpoints,
65
- createSegmentsEndpoints: () => createSegmentsEndpoints,
66
- createSessionsEndpoints: () => createSessionsEndpoints,
67
- createUsersEndpoints: () => createUsersEndpoints,
68
- createWebhooksEndpoints: () => createWebhooksEndpoints,
69
- createWebsitesEndpoints: () => createWebsitesEndpoints,
70
- default: () => index_default,
71
- detectDeploymentContext: () => import_shared.detectDeploymentContext,
72
- detectRuntime: () => detectRuntime,
73
- getApiRoute: () => import_shared.getApiRoute,
74
- getClient: () => getClient,
75
- getClientIp: () => getClientIp,
76
- getEdgeEnv: () => getEdgeEnv,
77
- getEnvVarNames: () => import_shared.getEnvVarNames,
78
- getFrameworkPackage: () => import_shared.getFrameworkPackage,
79
- getGeoFromRequest: () => getGeoFromRequest,
80
- getPlan: () => import_shared.getPlan,
81
- getPlanLimit: () => import_shared.getPlanLimit,
82
- getRegionInfo: () => getRegionInfo,
83
- getRuntimeCapabilities: () => getRuntimeCapabilities,
84
- getVitalRating: () => import_shared.getVitalRating,
85
- isEdgeRuntime: () => isEdgeRuntime,
86
- isNodeRuntime: () => isNodeRuntime,
87
- isPlanFeatureEnabled: () => import_shared.isPlanFeatureEnabled,
88
- isUsageCritical: () => import_shared.isUsageCritical,
89
- isUsageWarning: () => import_shared.isUsageWarning,
90
- isValidFramework: () => import_shared.isValidFramework,
91
- requireEdgeEnv: () => requireEdgeEnv
92
- });
93
- module.exports = __toCommonJS(index_exports);
94
-
95
- // src/client.ts
96
- var ApiClient = class {
97
- endpoint;
98
- bearerToken;
99
- apiKey;
100
- userId;
101
- secret;
102
- fetchFn;
103
- retries;
104
- retryDelay;
105
- constructor(config = {}) {
106
- const getEnv = (key) => {
107
- if (typeof process !== "undefined" && process.env) {
108
- return process.env[key];
109
- }
110
- return void 0;
111
- };
112
- this.endpoint = config.endpoint || getEnv("ENTROLYTICS_API_ENDPOINT") || "";
113
- this.bearerToken = config.bearerToken || getEnv("ENTROLYTICS_BEARER_TOKEN");
114
- this.apiKey = config.apiKey || getEnv("ENTROLYTICS_API_KEY");
115
- this.userId = config.userId || getEnv("ENTROLYTICS_USER_ID");
116
- this.secret = config.secret || getEnv("ENTROLYTICS_SECRET");
117
- this.fetchFn = config.fetch || globalThis.fetch;
118
- this.retries = config.retries ?? 3;
119
- this.retryDelay = config.retryDelay ?? 1e3;
120
- if (!this.endpoint) {
121
- throw new Error(
122
- "Entrolytics API endpoint is required. Set ENTROLYTICS_API_ENDPOINT or pass endpoint in config."
123
- );
124
- }
125
- }
126
- /**
127
- * Update the bearer token (useful for token refresh).
128
- */
129
- setBearerToken(token) {
130
- this.bearerToken = token;
131
- }
132
- /**
133
- * Generate authentication headers.
134
- * Priority: Bearer token > API key > Legacy share token
135
- */
136
- getAuthHeaders() {
137
- const headers = {};
138
- if (this.bearerToken) {
139
- headers.Authorization = `Bearer ${this.bearerToken}`;
140
- } else if (this.apiKey) {
141
- headers["x-entrolytics-api-key"] = this.apiKey;
142
- } else if (this.userId && this.secret) {
143
- headers["x-entrolytics-share-token"] = this.createShareToken();
144
- }
145
- return headers;
146
- }
147
- /**
148
- * Create a share token for self-hosted authentication (legacy).
149
- * @deprecated Use bearerToken or apiKey instead
150
- */
151
- createShareToken() {
152
- if (!this.userId || !this.secret) {
153
- throw new Error("userId and secret are required for self-hosted authentication");
154
- }
155
- const payload = {
156
- userId: this.userId,
157
- timestamp: Date.now()
158
- };
159
- if (typeof Buffer !== "undefined") {
160
- return Buffer.from(JSON.stringify(payload)).toString("base64");
161
- } else {
162
- return btoa(JSON.stringify(payload));
163
- }
164
- }
165
- /**
166
- * Sleep helper for retry delays.
167
- */
168
- sleep(ms) {
169
- return new Promise((resolve) => setTimeout(resolve, ms));
170
- }
171
- /**
172
- * Check if error is retryable.
173
- */
174
- isRetryable(status) {
175
- return status === 0 || status === 429 || status >= 500;
176
- }
177
- /**
178
- * Build URL with query parameters.
179
- */
180
- buildUrl(path, params) {
181
- const url = new URL(path, this.endpoint);
182
- if (params) {
183
- Object.entries(params).forEach(([key, value]) => {
184
- if (value !== void 0) {
185
- url.searchParams.set(key, String(value));
186
- }
187
- });
188
- }
189
- return url.toString();
190
- }
191
- /**
192
- * Make an authenticated API request with automatic retries.
193
- */
194
- async request(path, options = {}) {
195
- const { method = "GET", body, params, headers = {} } = options;
196
- const url = this.buildUrl(path, params);
197
- let lastError = null;
198
- for (let attempt = 0; attempt <= this.retries; attempt++) {
199
- try {
200
- const fetchOptions = {
201
- method,
202
- headers: {
203
- "Content-Type": "application/json",
204
- ...this.getAuthHeaders(),
205
- ...headers
206
- }
207
- };
208
- if (body) {
209
- fetchOptions.body = JSON.stringify(body);
210
- }
211
- const response = await this.fetchFn(url, fetchOptions);
212
- const data = await response.json().catch(() => ({}));
213
- if (!response.ok) {
214
- const errorMessage = typeof data.error === "string" ? data.error : typeof data.message === "string" ? data.message : `HTTP ${response.status}`;
215
- lastError = {
216
- ok: false,
217
- status: response.status,
218
- error: errorMessage
219
- };
220
- if (this.isRetryable(response.status) && attempt < this.retries) {
221
- const delay = this.retryDelay * 2 ** attempt;
222
- await this.sleep(delay);
223
- continue;
224
- }
225
- return lastError;
226
- }
227
- return {
228
- ok: true,
229
- status: response.status,
230
- data
231
- };
232
- } catch (error) {
233
- lastError = {
234
- ok: false,
235
- status: 0,
236
- error: error instanceof Error ? error.message : "Network error"
237
- };
238
- if (attempt < this.retries) {
239
- const delay = this.retryDelay * 2 ** attempt;
240
- await this.sleep(delay);
241
- }
242
- }
243
- }
244
- return lastError ?? {
245
- ok: false,
246
- status: 0,
247
- error: "Request failed after retries"
248
- };
249
- }
250
- /**
251
- * GET request helper.
252
- */
253
- get(path, params) {
254
- return this.request(path, { method: "GET", params });
255
- }
256
- /**
257
- * POST request helper.
258
- */
259
- post(path, body) {
260
- return this.request(path, { method: "POST", body });
261
- }
262
- /**
263
- * PUT request helper.
264
- */
265
- put(path, body) {
266
- return this.request(path, { method: "PUT", body });
267
- }
268
- /**
269
- * DELETE request helper.
270
- */
271
- delete(path) {
272
- return this.request(path, { method: "DELETE" });
273
- }
274
- /**
275
- * PATCH request helper.
276
- */
277
- patch(path, body) {
278
- return this.request(path, { method: "PATCH", body });
279
- }
280
- };
281
-
282
- // src/endpoints/admin.ts
283
- function createAdminEndpoints(client) {
284
- return {
285
- /**
286
- * Get all organizations (admin only)
287
- */
288
- getOrgs: () => client.get("/admin/orgs"),
289
- /**
290
- * Get organization details (admin only)
291
- */
292
- getOrg: ({ orgId }) => client.get(`/admin/orgs/${orgId}`),
293
- /**
294
- * Get all users (admin only)
295
- */
296
- getUsers: () => client.get("/admin/users"),
297
- /**
298
- * Get user details (admin only)
299
- */
300
- getUser: ({ userId }) => client.get(`/admin/users/${userId}`),
301
- /**
302
- * Get all websites (admin only)
303
- */
304
- getWebsites: () => client.get("/admin/websites"),
305
- /**
306
- * Get website details (admin only)
307
- */
308
- getWebsite: ({ websiteId }) => client.get(`/admin/websites/${websiteId}`),
309
- /**
310
- * Run admin setup
311
- */
312
- setup: () => client.post("/admin/setup", {})
313
- };
314
- }
315
-
316
- // src/endpoints/auth.ts
317
- function createAuthEndpoints(client) {
318
- return {
319
- /**
320
- * List all active CLI access tokens for the current user.
321
- */
322
- listCliTokens() {
323
- return client.get("/auth/cli/tokens");
324
- },
325
- /**
326
- * Revoke a specific CLI access token by its JTI.
327
- *
328
- * @param jti - The JWT ID of the token to revoke
329
- */
330
- revokeCliToken(jti) {
331
- return client["request"]("/auth/cli/tokens", {
332
- method: "DELETE",
333
- body: { jti }
334
- });
335
- },
336
- /**
337
- * Revoke all CLI access tokens for the current user.
338
- */
339
- revokeAllCliTokens() {
340
- return client["request"]("/auth/cli/tokens", {
341
- method: "DELETE",
342
- body: { revokeAll: true }
343
- });
344
- }
345
- };
346
- }
347
-
348
- // src/endpoints/billing.ts
349
- function createBillingEndpoints(client) {
350
- return {
351
- /**
352
- * Get current account usage for the billing period.
353
- */
354
- getUsage() {
355
- return client.get("/billing/usage");
356
- },
357
- /**
358
- * Get account entitlements based on current plan.
359
- */
360
- getEntitlements() {
361
- return client.get("/billing/entitlements");
362
- },
363
- /**
364
- * Get current subscription details.
365
- */
366
- getSubscription() {
367
- return client.get("/billing/subscription");
368
- },
369
- /**
370
- * Create a Stripe checkout session for upgrading/changing plan.
371
- */
372
- createCheckoutSession(options) {
373
- return client.post("/billing/checkout", options);
374
- },
375
- /**
376
- * Create a Stripe billing portal session for managing subscription.
377
- */
378
- createPortalSession() {
379
- return client.post("/billing/portal");
380
- }
381
- };
382
- }
383
-
384
- // src/endpoints/boards.ts
385
- function createBoardsEndpoints(client) {
386
- return {
387
- /**
388
- * Get all boards for a website.
389
- */
390
- getBoards(websiteId) {
391
- return client.get(`/websites/${websiteId}/boards`);
392
- },
393
- /**
394
- * Get a specific board by ID.
395
- */
396
- getBoard(boardId) {
397
- return client.get(`/boards/${boardId}`);
398
- },
399
- /**
400
- * Create a new board.
401
- */
402
- createBoard(data) {
403
- return client.post("/boards", data);
404
- },
405
- /**
406
- * Update a board.
407
- */
408
- updateBoard(boardId, data) {
409
- return client.post(`/boards/${boardId}`, data);
410
- },
411
- /**
412
- * Delete a board.
413
- */
414
- deleteBoard(boardId) {
415
- return client.delete(`/boards/${boardId}`);
416
- },
417
- /**
418
- * Get all widgets for a board.
419
- */
420
- getBoardWidgets(boardId) {
421
- return client.get(`/boards/${boardId}/widgets`);
422
- },
423
- /**
424
- * Get a specific widget by ID.
425
- */
426
- getBoardWidget(boardId, widgetId) {
427
- return client.get(`/boards/${boardId}/widgets/${widgetId}`);
428
- },
429
- /**
430
- * Create a new widget on a board.
431
- */
432
- createBoardWidget(boardId, data) {
433
- return client.post(`/boards/${boardId}/widgets`, data);
434
- },
435
- /**
436
- * Update a widget.
437
- */
438
- updateBoardWidget(boardId, widgetId, data) {
439
- return client.post(`/boards/${boardId}/widgets/${widgetId}`, data);
440
- },
441
- /**
442
- * Delete a widget.
443
- */
444
- deleteBoardWidget(boardId, widgetId) {
445
- return client.delete(`/boards/${boardId}/widgets/${widgetId}`);
446
- }
447
- };
448
- }
449
-
450
- // src/endpoints/config.ts
451
- function createConfigEndpoints(client) {
452
- return {
453
- /**
454
- * Get system configuration
455
- */
456
- get: () => client.get("/config")
457
- };
458
- }
459
-
460
- // src/endpoints/events.ts
461
- function createEventsEndpoints(client) {
462
- return {
463
- /**
464
- * Get event data statistics.
465
- */
466
- getEventDataStats(websiteId, params) {
467
- return client.get(`/websites/${websiteId}/event-data/stats`, params);
468
- },
469
- /**
470
- * Get event data events (distinct event names).
471
- */
472
- getEventDataEvents(websiteId, params) {
473
- return client.get(`/websites/${websiteId}/event-data/events`, params);
474
- },
475
- /**
476
- * Get event data fields for a specific event.
477
- */
478
- getEventDataFields(websiteId, params) {
479
- return client.get(`/websites/${websiteId}/event-data/fields`, params);
480
- },
481
- /**
482
- * Get event data values for a specific field.
483
- */
484
- getEventDataValues(websiteId, params) {
485
- return client.get(`/websites/${websiteId}/event-data/values`, params);
486
- },
487
- /**
488
- * Get event data properties breakdown.
489
- */
490
- getEventDataProperties(websiteId, params) {
491
- return client.get(`/websites/${websiteId}/event-data/properties`, params);
492
- },
493
- /**
494
- * Get specific event data by ID.
495
- */
496
- getEventData(websiteId, eventId) {
497
- return client.get(`/websites/${websiteId}/event-data/${eventId}`);
498
- },
499
- /**
500
- * Get session data properties.
501
- */
502
- getSessionDataProperties(websiteId, params) {
503
- return client.get(`/websites/${websiteId}/session-data/properties`, params);
504
- },
505
- getSessionDataValues(websiteId, params) {
506
- return client.get(`/websites/${websiteId}/session-data/values`, params);
507
- },
508
- /**
509
- * Send a test event to verify setup.
510
- */
511
- sendTestEvent(websiteId) {
512
- return client.post("/send", {
513
- type: "event",
514
- payload: {
515
- website: websiteId,
516
- name: "cli_test_event",
517
- data: { source: "entro-cli", timestamp: Date.now() }
518
- }
519
- });
520
- }
521
- };
522
- }
523
-
524
- // src/endpoints/integrations.ts
525
- function createIntegrationsEndpoints(client) {
526
- return {
527
- /**
528
- * Handle WordPress integration
529
- */
530
- wordpress: (params) => client.post("/integrations/wordpress", params.data)
531
- };
532
- }
533
-
534
- // src/endpoints/links.ts
535
- function createLinksEndpoints(client) {
536
- return {
537
- /**
538
- * Get all links.
539
- */
540
- getLinks() {
541
- return client.get("/links");
542
- },
543
- /**
544
- * Get links for an organization.
545
- */
546
- getOrgLinks(orgId) {
547
- return client.get(`/orgs/${orgId}/links`);
548
- },
549
- /**
550
- * Create a new link.
551
- */
552
- createLink(orgId, data) {
553
- return client.post(`/orgs/${orgId}/links`, data);
554
- },
555
- /**
556
- * Get a link by ID.
557
- */
558
- getLink(linkId) {
559
- return client.get(`/links/${linkId}`);
560
- },
561
- /**
562
- * Update a link.
563
- */
564
- updateLink(linkId, data) {
565
- return client.post(`/links/${linkId}`, data);
566
- },
567
- /**
568
- * Delete a link.
569
- */
570
- deleteLink(linkId) {
571
- return client.delete(`/links/${linkId}`);
572
- },
573
- /**
574
- * Get link statistics.
575
- */
576
- getLinkStats(linkId) {
577
- return client.get(`/links/${linkId}/stats`);
578
- }
579
- };
580
- }
581
-
582
- // src/endpoints/me.ts
583
- function createMeEndpoints(client) {
584
- return {
585
- /**
586
- * Get current user profile.
587
- */
588
- getMe() {
589
- return client.get("/me");
590
- },
591
- /**
592
- * Update current user's password.
593
- */
594
- updateMyPassword(data) {
595
- return client.post("/me/password", data);
596
- },
597
- /**
598
- * Get current user's websites.
599
- */
600
- getMyWebsites() {
601
- return client.get("/me/websites");
602
- },
603
- /**
604
- * Get current user's organizations.
605
- */
606
- getMyOrgs() {
607
- return client.get("/me/orgs");
608
- }
609
- };
610
- }
611
-
612
- // src/endpoints/orgs.ts
613
- function createOrgsEndpoints(client) {
614
- return {
615
- /**
616
- * Get all organizations for the current user.
617
- */
618
- getOrgs() {
619
- return client.get("/orgs");
620
- },
621
- /**
622
- * Create a new organization.
623
- */
624
- createOrg(data) {
625
- return client.post("/orgs", data);
626
- },
627
- /**
628
- * Join an organization using access code.
629
- */
630
- joinOrg(data) {
631
- return client.post("/orgs/join", data);
632
- },
633
- /**
634
- * Get an organization by ID.
635
- */
636
- getOrg(orgId) {
637
- return client.get(`/orgs/${orgId}`);
638
- },
639
- /**
640
- * Update an organization.
641
- */
642
- updateOrg(orgId, data) {
643
- return client.post(`/orgs/${orgId}`, data);
644
- },
645
- /**
646
- * Delete an organization.
647
- */
648
- deleteOrg(orgId) {
649
- return client.delete(`/orgs/${orgId}`);
650
- },
651
- /**
652
- * Get organization members.
653
- */
654
- getOrgUsers(orgId) {
655
- return client.get(`/orgs/${orgId}/users`);
656
- },
657
- /**
658
- * Add a user to an organization.
659
- */
660
- addOrgUser(orgId, data) {
661
- return client.post(`/orgs/${orgId}/users`, data);
662
- },
663
- /**
664
- * Update an organization member's role.
665
- */
666
- updateOrgUser(orgId, userId, data) {
667
- return client.post(`/orgs/${orgId}/users/${userId}`, data);
668
- },
669
- /**
670
- * Remove a user from an organization.
671
- */
672
- removeOrgUser(orgId, userId) {
673
- return client.delete(`/orgs/${orgId}/users/${userId}`);
674
- },
675
- /**
676
- * Get organization websites.
677
- */
678
- getOrgWebsites(orgId) {
679
- return client.get(`/orgs/${orgId}/websites`);
680
- },
681
- /**
682
- * Add a website to an organization.
683
- */
684
- addOrgWebsite(orgId, data) {
685
- return client.post(`/orgs/${orgId}/websites`, data);
686
- },
687
- /**
688
- * Remove a website from an organization.
689
- */
690
- removeOrgWebsite(orgId, websiteId) {
691
- return client.delete(`/orgs/${orgId}/websites/${websiteId}`);
692
- }
693
- };
694
- }
695
-
696
- // src/endpoints/pixels.ts
697
- function createPixelsEndpoints(client) {
698
- return {
699
- /**
700
- * Get all pixels.
701
- */
702
- getPixels() {
703
- return client.get("/pixels");
704
- },
705
- /**
706
- * Get pixels for an organization.
707
- */
708
- getOrgPixels(orgId) {
709
- return client.get(`/orgs/${orgId}/pixels`);
710
- },
711
- /**
712
- * Create a new pixel.
713
- */
714
- createPixel(orgId, data) {
715
- return client.post(`/orgs/${orgId}/pixels`, data);
716
- },
717
- /**
718
- * Get a pixel by ID.
719
- */
720
- getPixel(pixelId) {
721
- return client.get(`/pixels/${pixelId}`);
722
- },
723
- /**
724
- * Update a pixel.
725
- */
726
- updatePixel(pixelId, data) {
727
- return client.post(`/pixels/${pixelId}`, data);
728
- },
729
- /**
730
- * Delete a pixel.
731
- */
732
- deletePixel(pixelId) {
733
- return client.delete(`/pixels/${pixelId}`);
734
- }
735
- };
736
- }
737
-
738
- // src/endpoints/reports.ts
739
- function createReportsEndpoints(client) {
740
- return {
741
- /**
742
- * Get all reports for a website.
743
- */
744
- getReports(websiteId) {
745
- return client.get(`/websites/${websiteId}/reports`);
746
- },
747
- /**
748
- * Create a new report.
749
- */
750
- createReport(data) {
751
- return client.post("/reports", data);
752
- },
753
- /**
754
- * Get a report by ID.
755
- */
756
- getReport(reportId) {
757
- return client.get(`/reports/${reportId}`);
758
- },
759
- /**
760
- * Update a report.
761
- */
762
- updateReport(reportId, data) {
763
- return client.post(`/reports/${reportId}`, data);
764
- },
765
- /**
766
- * Delete a report.
767
- */
768
- deleteReport(reportId) {
769
- return client.delete(`/reports/${reportId}`);
770
- },
771
- /**
772
- * Run a funnel report.
773
- */
774
- runFunnelReport(params) {
775
- const { websiteId, steps, window = 30, startAt, endAt, ...rest } = params;
776
- return client.post("/reports/funnel", {
777
- websiteId,
778
- parameters: {
779
- startDate: startAt,
780
- endDate: endAt,
781
- window,
782
- steps
783
- },
784
- filters: rest
785
- });
786
- },
787
- /**
788
- * Run a retention report.
789
- */
790
- runRetentionReport(params) {
791
- const { websiteId, startAt, endAt, timezone, ...rest } = params;
792
- return client.post("/reports/retention", {
793
- websiteId,
794
- parameters: {
795
- startDate: startAt,
796
- endDate: endAt,
797
- timezone
798
- },
799
- filters: rest
800
- });
801
- },
802
- /**
803
- * Run a journey/flow report.
804
- */
805
- runJourneyReport(params) {
806
- const { websiteId, startAt, endAt, steps = 5, startStep, endStep, ...rest } = params;
807
- return client.post("/reports/journey", {
808
- websiteId,
809
- parameters: {
810
- startDate: startAt,
811
- endDate: endAt,
812
- steps,
813
- startStep,
814
- endStep
815
- },
816
- filters: rest
817
- });
818
- },
819
- /**
820
- * Run a goals report.
821
- */
822
- runGoalReport(params) {
823
- const { websiteId, startAt, endAt, type, value, ...rest } = params;
824
- return client.post("/reports/goal", {
825
- websiteId,
826
- parameters: {
827
- startDate: startAt,
828
- endDate: endAt,
829
- type,
830
- value
831
- },
832
- filters: rest
833
- });
834
- },
835
- /**
836
- * Run an attribution report.
837
- */
838
- runAttributionReport(params) {
839
- const { websiteId, startAt, endAt, model, type, step, currency, ...rest } = params;
840
- return client.post("/reports/attribution", {
841
- websiteId,
842
- parameters: {
843
- startDate: startAt,
844
- endDate: endAt,
845
- model,
846
- type,
847
- step,
848
- currency
849
- },
850
- filters: rest
851
- });
852
- },
853
- /**
854
- * Run a revenue report.
855
- */
856
- runRevenueReport(params) {
857
- const { websiteId, startAt, endAt, currency = "USD", ...rest } = params;
858
- return client.post("/reports/revenue", {
859
- websiteId,
860
- parameters: {
861
- startDate: startAt,
862
- endDate: endAt,
863
- currency
864
- },
865
- filters: rest
866
- });
867
- },
868
- /**
869
- * Run a UTM report.
870
- */
871
- runUTMReport(params) {
872
- const { websiteId, startAt, endAt, ...rest } = params;
873
- return client.post("/reports/utm", {
874
- websiteId,
875
- parameters: {
876
- startDate: startAt,
877
- endDate: endAt
878
- },
879
- filters: rest
880
- });
881
- },
882
- /**
883
- * Run a breakdown report.
884
- * @param property - Field to break down by (path, referrer, browser, device, os, country, etc.)
885
- */
886
- runBreakdownReport(params) {
887
- const { websiteId, startAt, endAt, property, ...rest } = params;
888
- return client.post("/reports/breakdown", {
889
- websiteId,
890
- parameters: {
891
- startDate: startAt,
892
- endDate: endAt,
893
- property
894
- },
895
- filters: rest
896
- });
897
- }
898
- };
899
- }
900
-
901
- // src/endpoints/segments.ts
902
- function createSegmentsEndpoints(client) {
903
- return {
904
- /**
905
- * Get all segments for a website.
906
- */
907
- getSegments(websiteId) {
908
- return client.get(`/websites/${websiteId}/segments`);
909
- },
910
- /**
911
- * Create a new segment.
912
- */
913
- createSegment(websiteId, data) {
914
- return client.post(`/websites/${websiteId}/segments`, data);
915
- },
916
- /**
917
- * Get a segment by ID.
918
- */
919
- getSegment(websiteId, segmentId) {
920
- return client.get(`/websites/${websiteId}/segments/${segmentId}`);
921
- },
922
- /**
923
- * Update a segment.
924
- */
925
- updateSegment(websiteId, segmentId, data) {
926
- return client.post(`/websites/${websiteId}/segments/${segmentId}`, data);
927
- },
928
- /**
929
- * Delete a segment.
930
- */
931
- deleteSegment(websiteId, segmentId) {
932
- return client.delete(`/websites/${websiteId}/segments/${segmentId}`);
933
- }
934
- };
935
- }
936
-
937
- // src/endpoints/sessions.ts
938
- function createSessionsEndpoints(client) {
939
- return {
940
- /**
941
- * Get website sessions.
942
- */
943
- getWebsiteSessions(websiteId, params) {
944
- return client.get(`/websites/${websiteId}/sessions`, params);
945
- },
946
- /**
947
- * Get session statistics.
948
- */
949
- getWebsiteSessionStats(websiteId, params) {
950
- return client.get(`/websites/${websiteId}/sessions/stats`, params);
951
- },
952
- /**
953
- * Get weekly session traffic.
954
- */
955
- getWeeklyTraffic(websiteId, params) {
956
- return client.get(`/websites/${websiteId}/sessions/weekly`, params);
957
- },
958
- /**
959
- * Get a specific session.
960
- */
961
- getSession(websiteId, sessionId) {
962
- return client.get(`/websites/${websiteId}/sessions/${sessionId}`);
963
- },
964
- /**
965
- * Get session activity (pageviews and events).
966
- */
967
- getSessionActivity(websiteId, sessionId, params) {
968
- return client.get(
969
- `/websites/${websiteId}/sessions/${sessionId}/activity`,
970
- params
971
- );
972
- },
973
- /**
974
- * Get session properties (custom data).
975
- */
976
- getSessionProperties(websiteId, sessionId) {
977
- return client.get(`/websites/${websiteId}/sessions/${sessionId}/properties`);
978
- }
979
- };
980
- }
981
-
982
- // src/endpoints/users.ts
983
- function createUsersEndpoints(client) {
984
- return {
985
- /**
986
- * Get all users (admin only).
987
- */
988
- getUsers() {
989
- return client.get("/users");
990
- },
991
- /**
992
- * Create a new user (admin only).
993
- */
994
- createUser(data) {
995
- return client.post("/users", data);
996
- },
997
- /**
998
- * Get a user by ID.
999
- */
1000
- getUser(userId) {
1001
- return client.get(`/users/${userId}`);
1002
- },
1003
- /**
1004
- * Update a user.
1005
- */
1006
- updateUser(userId, data) {
1007
- return client.post(`/users/${userId}`, data);
1008
- },
1009
- /**
1010
- * Delete a user (admin only).
1011
- */
1012
- deleteUser(userId) {
1013
- return client.delete(`/users/${userId}`);
1014
- },
1015
- /**
1016
- * Get websites belonging to a user.
1017
- */
1018
- getUserWebsites(userId) {
1019
- return client.get(`/users/${userId}/websites`);
1020
- },
1021
- /**
1022
- * Get user usage statistics.
1023
- */
1024
- getUserUsage(userId, params) {
1025
- return client.get(`/users/${userId}/usage`, params);
1026
- }
1027
- };
1028
- }
1029
-
1030
- // src/endpoints/webhooks.ts
1031
- function createWebhooksEndpoints(client) {
1032
- return {
1033
- /**
1034
- * Handle Clerk webhook
1035
- */
1036
- clerk: (params) => client.post("/webhooks/clerk", params.data)
1037
- };
1038
- }
1039
-
1040
- // src/endpoints/websites.ts
1041
- function createWebsitesEndpoints(client) {
1042
- return {
1043
- /**
1044
- * Get all websites.
1045
- */
1046
- getWebsites() {
1047
- return client.get("/websites").then((response) => {
1048
- if (response.data) {
1049
- response.data = response.data.map((site) => ({
1050
- ...site,
1051
- id: site.id || site.websiteId
1052
- }));
1053
- }
1054
- return response;
1055
- });
1056
- },
1057
- /**
1058
- * Create a new website.
1059
- */
1060
- createWebsite(data) {
1061
- return client.post("/websites", data).then((response) => {
1062
- if (response.data) {
1063
- response.data.id = response.data.id || response.data.websiteId;
1064
- }
1065
- return response;
1066
- });
1067
- },
1068
- /**
1069
- * Get a website by ID.
1070
- */
1071
- getWebsite(websiteId) {
1072
- return client.get(`/websites/${websiteId}`).then((response) => {
1073
- if (response.data) {
1074
- response.data.id = response.data.id || response.data.websiteId;
1075
- }
1076
- return response;
1077
- });
1078
- },
1079
- /**
1080
- * Update a website.
1081
- */
1082
- updateWebsite(websiteId, data) {
1083
- return client.post(`/websites/${websiteId}`, data);
1084
- },
1085
- /**
1086
- * Delete a website.
1087
- */
1088
- deleteWebsite(websiteId) {
1089
- return client.delete(`/websites/${websiteId}`);
1090
- },
1091
- /**
1092
- * Reset a website's data.
1093
- */
1094
- resetWebsite(websiteId) {
1095
- return client.post(`/websites/${websiteId}/reset`);
1096
- },
1097
- /**
1098
- * Transfer website ownership.
1099
- */
1100
- transferWebsite(websiteId, data) {
1101
- return client.post(`/websites/${websiteId}/transfer`, data);
1102
- },
1103
- /**
1104
- * Get website statistics.
1105
- */
1106
- getWebsiteStats(websiteId, params) {
1107
- return client.get(`/websites/${websiteId}/stats`, params);
1108
- },
1109
- /**
1110
- * Get website pageviews data.
1111
- */
1112
- getWebsitePageviews(websiteId, params) {
1113
- return client.get(`/websites/${websiteId}/pageviews`, params);
1114
- },
1115
- /**
1116
- * Get website metrics (URLs, referrers, browsers, etc.).
1117
- */
1118
- getWebsiteMetrics(websiteId, params) {
1119
- return client.get(`/websites/${websiteId}/metrics`, params);
1120
- },
1121
- /**
1122
- * Get expanded metrics (with additional details).
1123
- */
1124
- getWebsiteExpandedMetrics(websiteId, params) {
1125
- return client.get(`/websites/${websiteId}/metrics/expanded`, params);
1126
- },
1127
- /**
1128
- * Get website events.
1129
- */
1130
- getWebsiteEvents(websiteId, params) {
1131
- return client.get(`/websites/${websiteId}/events`, params);
1132
- },
1133
- /**
1134
- * Get events time series.
1135
- */
1136
- getWebsiteEventsSeries(websiteId, params) {
1137
- return client.get(`/websites/${websiteId}/events/series`, params);
1138
- },
1139
- /**
1140
- * Get active visitors count.
1141
- */
1142
- getWebsiteActive(websiteId) {
1143
- return client.get(`/websites/${websiteId}/active`);
1144
- },
1145
- /**
1146
- * Get website date range (first and last event dates).
1147
- */
1148
- getWebsiteDateRange(websiteId) {
1149
- return client.get(`/websites/${websiteId}/daterange`);
1150
- },
1151
- /**
1152
- * Get website values for a specific field.
1153
- */
1154
- getWebsiteValues(websiteId, params) {
1155
- return client.get(`/websites/${websiteId}/values`, params);
1156
- },
1157
- /**
1158
- * Get realtime data.
1159
- */
1160
- getRealtimeData(websiteId) {
1161
- return client.get(`/realtime/${websiteId}`);
1162
- },
1163
- /**
1164
- * Export website data.
1165
- */
1166
- exportWebsiteData(websiteId, params) {
1167
- return client.get(`/websites/${websiteId}/export`, params);
1168
- },
1169
- /**
1170
- * Get website ingest mode configuration.
1171
- */
1172
- getWebsiteMode(websiteId) {
1173
- return client.get(`/websites/${websiteId}/mode`);
1174
- },
1175
- /**
1176
- * Set website ingest mode (auto, node, or edge).
1177
- */
1178
- setWebsiteMode(websiteId, mode) {
1179
- return client.post(`/websites/${websiteId}/mode`, { ingestMode: mode });
1180
- },
1181
- /**
1182
- * Get routing health status.
1183
- */
1184
- getRoutingHealth() {
1185
- return client.get("/health/routing");
1186
- },
1187
- /**
1188
- * Get routing statistics.
1189
- */
1190
- getRoutingStats(params) {
1191
- return client.get("/routing/stats", params);
1192
- },
1193
- // ========================================================================
1194
- // Phase 2: Web Vitals Endpoints (NG only)
1195
- // ========================================================================
1196
- /**
1197
- * Get Web Vitals statistics for a website.
1198
- * Note: Only available in entrolytics.
1199
- */
1200
- getWebsiteVitals(websiteId, params) {
1201
- return client.get(`/websites/${websiteId}/vitals`, params);
1202
- },
1203
- /**
1204
- * Get individual Web Vital events.
1205
- * Note: Only available in entrolytics.
1206
- */
1207
- getWebsiteVitalEvents(websiteId, params) {
1208
- return client.get(`/websites/${websiteId}/vitals/events`, params);
1209
- },
1210
- /**
1211
- * Track a Web Vital metric (send to collection endpoint).
1212
- * Note: Only available in entrolytics.
1213
- */
1214
- trackVital(websiteId, data) {
1215
- return client.post("/collect/vitals", {
1216
- website: websiteId,
1217
- ...data
1218
- });
1219
- },
1220
- /**
1221
- * Track multiple Web Vitals metrics in batch.
1222
- * Note: Only available in entrolytics.
1223
- */
1224
- trackVitalsBatch(websiteId, vitals) {
1225
- return client.post("/collect/vitals", {
1226
- website: websiteId,
1227
- vitals
1228
- });
1229
- },
1230
- // ========================================================================
1231
- // Phase 2: Form Analytics Endpoints (NG only)
1232
- // ========================================================================
1233
- /**
1234
- * Get form analytics for a website.
1235
- * Note: Only available in entrolytics.
1236
- */
1237
- getWebsiteForms(websiteId, params) {
1238
- return client.get(`/websites/${websiteId}/forms`, params);
1239
- },
1240
- /**
1241
- * Get field-level analytics for a specific form.
1242
- * Note: Only available in entrolytics.
1243
- */
1244
- getFormFields(websiteId, formId, params) {
1245
- return client.get(`/websites/${websiteId}/forms/${formId}/fields`, params);
1246
- },
1247
- /**
1248
- * Get individual form events.
1249
- * Note: Only available in entrolytics.
1250
- */
1251
- getFormEvents(websiteId, params) {
1252
- return client.get(`/websites/${websiteId}/forms/events`, params);
1253
- },
1254
- /**
1255
- * Track a form event (send to collection endpoint).
1256
- * Note: Only available in entrolytics.
1257
- */
1258
- trackFormEvent(websiteId, data) {
1259
- return client.post("/collect/forms", {
1260
- website: websiteId,
1261
- ...data
1262
- });
1263
- },
1264
- /**
1265
- * Track multiple form events in batch.
1266
- * Note: Only available in entrolytics.
1267
- */
1268
- trackFormEventsBatch(websiteId, events) {
1269
- return client.post("/collect/forms", {
1270
- website: websiteId,
1271
- events
1272
- });
1273
- },
1274
- // ========================================================================
1275
- // Phase 2: Deployment Tracking Endpoints (NG only)
1276
- // ========================================================================
1277
- /**
1278
- * Get deployments for a website.
1279
- * Note: Only available in entrolytics.
1280
- */
1281
- getWebsiteDeployments(websiteId, params) {
1282
- return client.get(`/websites/${websiteId}/deployments`, params);
1283
- },
1284
- /**
1285
- * Get a specific deployment.
1286
- * Note: Only available in entrolytics.
1287
- */
1288
- getDeployment(websiteId, deployId) {
1289
- return client.get(`/websites/${websiteId}/deployments/${deployId}`);
1290
- },
1291
- /**
1292
- * Compare two deployments.
1293
- * Note: Only available in entrolytics.
1294
- */
1295
- compareDeployments(websiteId, currentDeployId, previousDeployId) {
1296
- return client.get(`/websites/${websiteId}/deployments/${currentDeployId}/compare`, {
1297
- previous: previousDeployId
1298
- });
1299
- },
1300
- /**
1301
- * Set/register a deployment context.
1302
- * Note: Only available in entrolytics.
1303
- */
1304
- setDeployment(websiteId, data) {
1305
- return client.post(`/websites/${websiteId}/deployments`, data);
1306
- }
1307
- };
1308
- }
1309
-
1310
- // src/index.ts
1311
- var import_shared = require("@entrolytics/shared");
1312
-
1313
- // src/runtime.ts
1314
- function detectRuntime() {
1315
- if (
1316
- // @ts-ignore - Edge Runtime global
1317
- typeof EdgeRuntime !== "undefined" || // @ts-ignore - Vercel Edge Runtime
1318
- globalThis.EdgeRuntime !== void 0 || // @ts-ignore - Netlify Edge Functions use Deno
1319
- typeof Deno !== "undefined" || // @ts-ignore - Cloudflare Workers
1320
- typeof WebAssembly !== "undefined" && typeof Response !== "undefined" && !process?.versions?.node
1321
- ) {
1322
- return "edge";
1323
- }
1324
- if (typeof process !== "undefined" && process.versions != null && process.versions.node != null) {
1325
- return "node";
1326
- }
1327
- return "unknown";
1328
- }
1329
- function isNodeRuntime() {
1330
- return detectRuntime() === "node";
1331
- }
1332
- function isEdgeRuntime() {
1333
- return detectRuntime() === "edge";
1334
- }
1335
- function getRuntimeCapabilities() {
1336
- const runtime = detectRuntime();
1337
- return {
1338
- runtime,
1339
- isNode: runtime === "node",
1340
- isEdge: runtime === "edge",
1341
- supportsFileSystem: runtime === "node",
1342
- supportsWebCrypto: typeof crypto !== "undefined" && typeof crypto.subtle !== "undefined",
1343
- supportsFetch: typeof fetch !== "undefined",
1344
- supportsStreams: typeof ReadableStream !== "undefined"
1345
- };
1346
- }
1347
- function assertRuntime(expected) {
1348
- const actual = detectRuntime();
1349
- if (actual !== expected) {
1350
- throw new Error(
1351
- `Expected ${expected} runtime, but detected ${actual}. This code requires ${expected} runtime to function correctly.`
1352
- );
1353
- }
1354
- }
1355
-
1356
- // src/edge-helpers.ts
1357
- function getEdgeEnv(key, defaultValue) {
1358
- if (typeof process !== "undefined" && process.env) {
1359
- const value = process.env[key];
1360
- if (value !== void 0) return value;
1361
- }
1362
- if (typeof Deno !== "undefined" && typeof Deno.env !== "undefined") {
1363
- try {
1364
- return Deno.env.get(key) || defaultValue;
1365
- } catch {
1366
- }
1367
- }
1368
- return defaultValue;
1369
- }
1370
- function requireEdgeEnv(key) {
1371
- const value = getEdgeEnv(key);
1372
- if (!value) {
1373
- throw new Error(`Required environment variable ${key} is not set`);
1374
- }
1375
- return value;
1376
- }
1377
- function createEdgeFetch(defaultOptions = {}) {
1378
- const {
1379
- retries = 3,
1380
- retryDelay = 1e3,
1381
- timeout = 3e4,
1382
- ...fetchDefaults
1383
- } = defaultOptions;
1384
- return async function edgeFetch(input, options) {
1385
- const finalRetries = options?.retries ?? retries;
1386
- const finalDelay = options?.retryDelay ?? retryDelay;
1387
- const finalTimeout = options?.timeout ?? timeout;
1388
- const finalOptions = { ...fetchDefaults, ...options };
1389
- let lastError;
1390
- for (let attempt = 0; attempt <= finalRetries; attempt++) {
1391
- try {
1392
- const controller = new AbortController();
1393
- const timeoutId = setTimeout(() => controller.abort(), finalTimeout);
1394
- const response = await fetch(input, {
1395
- ...finalOptions,
1396
- signal: controller.signal
1397
- });
1398
- clearTimeout(timeoutId);
1399
- if (response.ok || response.status >= 400 && response.status < 500) {
1400
- return response;
1401
- }
1402
- lastError = new Error(`HTTP ${response.status}: ${response.statusText}`);
1403
- } catch (error) {
1404
- lastError = error instanceof Error ? error : new Error(String(error));
1405
- if (lastError.name === "AbortError") {
1406
- throw new Error(`Request timeout after ${finalTimeout}ms`);
1407
- }
1408
- }
1409
- if (attempt < finalRetries) {
1410
- const delay = finalDelay * Math.pow(2, attempt);
1411
- await new Promise((resolve) => setTimeout(resolve, delay));
1412
- }
1413
- }
1414
- throw lastError || new Error("Request failed");
1415
- };
1416
- }
1417
- function getRegionInfo() {
1418
- if (getEdgeEnv("VERCEL")) {
1419
- return {
1420
- provider: "vercel",
1421
- region: getEdgeEnv("VERCEL_REGION"),
1422
- isEdge: getEdgeEnv("VERCEL_EDGE_RUNTIME") === "1"
1423
- };
1424
- }
1425
- if (typeof Deno !== "undefined" && getEdgeEnv("NETLIFY")) {
1426
- return {
1427
- provider: "netlify",
1428
- region: getEdgeEnv("NETLIFY_REGION"),
1429
- isEdge: true
1430
- };
1431
- }
1432
- if (typeof caches !== "undefined" && typeof WebAssembly !== "undefined") {
1433
- return {
1434
- provider: "cloudflare",
1435
- region: void 0,
1436
- // Cloudflare doesn't expose region
1437
- isEdge: true
1438
- };
1439
- }
1440
- return {
1441
- provider: "unknown",
1442
- isEdge: false
1443
- };
1444
- }
1445
- function getGeoFromRequest(request) {
1446
- const headers = request.headers;
1447
- const vercelCountry = headers.get("x-vercel-ip-country");
1448
- if (vercelCountry) {
1449
- return {
1450
- country: vercelCountry,
1451
- region: headers.get("x-vercel-ip-country-region"),
1452
- city: headers.get("x-vercel-ip-city"),
1453
- latitude: headers.get("x-vercel-ip-latitude"),
1454
- longitude: headers.get("x-vercel-ip-longitude")
1455
- };
1456
- }
1457
- const cfCountry = headers.get("cf-ipcountry");
1458
- if (cfCountry) {
1459
- return {
1460
- country: cfCountry,
1461
- region: headers.get("cf-region"),
1462
- city: headers.get("cf-city"),
1463
- latitude: headers.get("cf-latitude"),
1464
- longitude: headers.get("cf-longitude")
1465
- };
1466
- }
1467
- return {
1468
- country: void 0,
1469
- region: void 0,
1470
- city: void 0,
1471
- latitude: void 0,
1472
- longitude: void 0
1473
- };
1474
- }
1475
- function getClientIp(request) {
1476
- const headers = request.headers;
1477
- 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;
1478
- }
1479
-
1480
- // src/index.ts
1481
- function getClient(config) {
1482
- const apiClient = new ApiClient(config);
1483
- const admin = createAdminEndpoints(apiClient);
1484
- const auth = createAuthEndpoints(apiClient);
1485
- const billing = createBillingEndpoints(apiClient);
1486
- const config_endpoints = createConfigEndpoints(apiClient);
1487
- const me = createMeEndpoints(apiClient);
1488
- const users = createUsersEndpoints(apiClient);
1489
- const orgs = createOrgsEndpoints(apiClient);
1490
- const websites = createWebsitesEndpoints(apiClient);
1491
- const sessions = createSessionsEndpoints(apiClient);
1492
- const events = createEventsEndpoints(apiClient);
1493
- const reports = createReportsEndpoints(apiClient);
1494
- const segments = createSegmentsEndpoints(apiClient);
1495
- const links = createLinksEndpoints(apiClient);
1496
- const pixels = createPixelsEndpoints(apiClient);
1497
- const boards = createBoardsEndpoints(apiClient);
1498
- const webhooks = createWebhooksEndpoints(apiClient);
1499
- const integrations = createIntegrationsEndpoints(apiClient);
1500
- return {
1501
- // Auth
1502
- auth,
1503
- // Me
1504
- ...me,
1505
- // Users
1506
- ...users,
1507
- // Organizations
1508
- ...orgs,
1509
- // Websites
1510
- ...websites,
1511
- // Sessions
1512
- ...sessions,
1513
- // Events
1514
- ...events,
1515
- // Reports
1516
- ...reports,
1517
- // Segments
1518
- ...segments,
1519
- // Links
1520
- ...links,
1521
- // Pixels
1522
- ...pixels,
1523
- // Boards
1524
- ...boards,
1525
- // Config
1526
- getConfig: config_endpoints.get,
1527
- // Admin
1528
- admin,
1529
- // Webhooks
1530
- webhooks,
1531
- // Integrations
1532
- integrations,
1533
- // Billing
1534
- billing
1535
- };
1536
- }
1537
- var index_default = getClient;
1538
- // Annotate the CommonJS export names for ESM import in node:
1539
- 0 && (module.exports = {
1540
- API_ENDPOINTS,
1541
- API_ROUTES,
1542
- ApiClient,
1543
- BILLING_ERRORS,
1544
- CLI_CONFIG,
1545
- CLI_TOKEN_STATUS,
1546
- DEFAULT_API_HOST,
1547
- DEPLOYMENT_ENV_VARS,
1548
- DEPLOYMENT_SOURCES,
1549
- ENV_VAR_NAMES,
1550
- ERROR_MESSAGES,
1551
- EVENT_TYPES,
1552
- FORM_EVENT_TYPES,
1553
- FORM_FIELD_TYPES,
1554
- FRAMEWORK_PACKAGES,
1555
- FRAMEWORK_PATTERNS,
1556
- HTTP_STATUS,
1557
- NAVIGATION_TYPES,
1558
- ONBOARDING_STEPS,
1559
- PLANS,
1560
- PLAN_FEATURES,
1561
- RATE_LIMITS,
1562
- SUCCESS_MESSAGES,
1563
- USAGE_THRESHOLDS,
1564
- USER_ROLES,
1565
- VITAL_RATINGS,
1566
- VITAL_THRESHOLDS,
1567
- VITAL_TYPES,
1568
- assertRuntime,
1569
- createAdminEndpoints,
1570
- createAuthEndpoints,
1571
- createBillingEndpoints,
1572
- createBoardsEndpoints,
1573
- createConfigEndpoints,
1574
- createEdgeFetch,
1575
- createEventsEndpoints,
1576
- createIntegrationsEndpoints,
1577
- createLinksEndpoints,
1578
- createMeEndpoints,
1579
- createOrgsEndpoints,
1580
- createPixelsEndpoints,
1581
- createReportsEndpoints,
1582
- createSegmentsEndpoints,
1583
- createSessionsEndpoints,
1584
- createUsersEndpoints,
1585
- createWebhooksEndpoints,
1586
- createWebsitesEndpoints,
1587
- detectDeploymentContext,
1588
- detectRuntime,
1589
- getApiRoute,
1590
- getClient,
1591
- getClientIp,
1592
- getEdgeEnv,
1593
- getEnvVarNames,
1594
- getFrameworkPackage,
1595
- getGeoFromRequest,
1596
- getPlan,
1597
- getPlanLimit,
1598
- getRegionInfo,
1599
- getRuntimeCapabilities,
1600
- getVitalRating,
1601
- isEdgeRuntime,
1602
- isNodeRuntime,
1603
- isPlanFeatureEnabled,
1604
- isUsageCritical,
1605
- isUsageWarning,
1606
- isValidFramework,
1607
- requireEdgeEnv
1608
- });
1609
- //# sourceMappingURL=index.cjs.map