@entrolytics/shared 2.3.3 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,685 +1,740 @@
1
- //#region src/event-protocol.ts
2
- /**
3
- * Event Protocol Types
4
- *
5
- * These types define the canonical event structures used across the Entrolytics ecosystem.
6
- * Used by: API Server, SDKs, CLI, worker processes.
7
- *
8
- * This file was extracted from the internal @entrolytics/protocol package to enable
9
- * sharing with external packages.
10
- */
11
- /**
12
- * Core event types supported by the analytics platform
13
- */
14
- const EventType = {
15
- PageView: "pageview",
16
- Custom: "custom_event",
17
- Click: "click"
18
- };
19
-
20
- //#endregion
21
- //#region src/index.ts
22
- /**
23
- * Shared constants across Entrolytics ecosystem
24
- * Used by: CLI, SDKs, Dashboard, Integrations
25
- */
26
- /**
27
- * Plan definitions and limits
28
- */
29
- const PLANS = {
30
- starter: {
31
- id: "starter",
32
- name: "Starter",
33
- price: 0,
34
- limits: {
35
- pageviewsPerMonth: 25e3,
36
- websites: 2,
37
- retentionDays: 30,
38
- seats: 1
39
- },
40
- features: {
41
- funnels: false,
42
- attribution: false,
43
- revenue: false,
44
- customDashboards: false,
45
- apiAccess: false,
46
- weeklyReports: true,
47
- support: "community"
48
- }
49
- },
50
- pro: {
51
- id: "pro",
52
- name: "Pro",
53
- price: 29,
54
- limits: {
55
- pageviewsPerMonth: 25e4,
56
- websites: 10,
57
- retentionDays: 365,
58
- seats: 5
59
- },
60
- features: {
61
- funnels: true,
62
- attribution: true,
63
- revenue: true,
64
- customDashboards: false,
65
- apiAccess: true,
66
- weeklyReports: true,
67
- support: "email"
68
- }
69
- },
70
- business: {
71
- id: "business",
72
- name: "Business",
73
- price: 99,
74
- limits: {
75
- pageviewsPerMonth: 1e6,
76
- websites: -1,
77
- retentionDays: 730,
78
- seats: -1
79
- },
80
- features: {
81
- funnels: true,
82
- attribution: true,
83
- revenue: true,
84
- customDashboards: true,
85
- apiAccess: true,
86
- weeklyReports: true,
87
- support: "priority"
88
- }
89
- },
90
- enterprise: {
91
- id: "enterprise",
92
- name: "Enterprise",
93
- price: -1,
94
- limits: {
95
- pageviewsPerMonth: -1,
96
- websites: -1,
97
- retentionDays: -1,
98
- seats: -1
99
- },
100
- features: {
101
- funnels: true,
102
- attribution: true,
103
- revenue: true,
104
- customDashboards: true,
105
- apiAccess: true,
106
- weeklyReports: true,
107
- support: "dedicated",
108
- sso: true,
109
- auditLogs: true,
110
- customRetention: true
111
- }
112
- }
1
+ /**
2
+ * Shared constants across Entrolytics ecosystem
3
+ * Used by: CLI, SDKs, Dashboard, Integrations
4
+ */
5
+ /**
6
+ * Plan definitions and limits
7
+ */
8
+ export const PLANS = {
9
+ starter: {
10
+ id: "starter",
11
+ name: "Starter",
12
+ price: 0,
13
+ limits: {
14
+ pageviewsPerMonth: 25_000,
15
+ websites: 2,
16
+ retentionDays: 30,
17
+ seats: 1,
18
+ },
19
+ features: {
20
+ funnels: false,
21
+ attribution: false,
22
+ revenue: false,
23
+ customDashboards: false,
24
+ apiAccess: false,
25
+ weeklyReports: true,
26
+ support: "community",
27
+ },
28
+ },
29
+ pro: {
30
+ id: "pro",
31
+ name: "Pro",
32
+ price: 29,
33
+ limits: {
34
+ pageviewsPerMonth: 250_000,
35
+ websites: 10,
36
+ retentionDays: 365,
37
+ seats: 5,
38
+ },
39
+ features: {
40
+ funnels: true,
41
+ attribution: true,
42
+ revenue: true,
43
+ customDashboards: false,
44
+ apiAccess: true,
45
+ weeklyReports: true,
46
+ support: "email",
47
+ },
48
+ },
49
+ business: {
50
+ id: "business",
51
+ name: "Business",
52
+ price: 99,
53
+ limits: {
54
+ pageviewsPerMonth: 1_000_000,
55
+ websites: -1, // unlimited
56
+ retentionDays: 730, // 2 years
57
+ seats: -1, // unlimited
58
+ },
59
+ features: {
60
+ funnels: true,
61
+ attribution: true,
62
+ revenue: true,
63
+ customDashboards: true,
64
+ apiAccess: true,
65
+ weeklyReports: true,
66
+ support: "priority",
67
+ },
68
+ },
69
+ enterprise: {
70
+ id: "enterprise",
71
+ name: "Enterprise",
72
+ price: -1, // custom
73
+ limits: {
74
+ pageviewsPerMonth: -1, // custom
75
+ websites: -1,
76
+ retentionDays: -1, // custom
77
+ seats: -1,
78
+ },
79
+ features: {
80
+ funnels: true,
81
+ attribution: true,
82
+ revenue: true,
83
+ customDashboards: true,
84
+ apiAccess: true,
85
+ weeklyReports: true,
86
+ support: "dedicated",
87
+ sso: true,
88
+ auditLogs: true,
89
+ customRetention: true,
90
+ },
91
+ },
113
92
  };
114
93
  /**
115
- * Plan feature names for display
116
- */
117
- const PLAN_FEATURES = {
118
- funnels: "Funnel Analytics",
119
- attribution: "Attribution Reports",
120
- revenue: "Revenue Tracking",
121
- customDashboards: "Custom Dashboards",
122
- apiAccess: "API Access",
123
- weeklyReports: "Weekly Email Reports",
124
- sso: "SSO/SAML",
125
- auditLogs: "Audit Logs",
126
- customRetention: "Custom Data Retention"
94
+ * Plan feature names for display
95
+ */
96
+ export const PLAN_FEATURES = {
97
+ funnels: "Funnel Analytics",
98
+ attribution: "Attribution Reports",
99
+ revenue: "Revenue Tracking",
100
+ customDashboards: "Custom Dashboards",
101
+ apiAccess: "API Access",
102
+ weeklyReports: "Weekly Email Reports",
103
+ sso: "SSO/SAML",
104
+ auditLogs: "Audit Logs",
105
+ customRetention: "Custom Data Retention",
127
106
  };
128
107
  /**
129
- * Usage warning thresholds (percentages)
130
- */
131
- const USAGE_THRESHOLDS = {
132
- warning: 90,
133
- critical: 95
108
+ * Usage warning thresholds (percentages)
109
+ */
110
+ export const USAGE_THRESHOLDS = {
111
+ warning: 90,
112
+ critical: 95,
134
113
  };
135
114
  /**
136
- * Billing-related error codes
137
- */
138
- const BILLING_ERRORS = {
139
- quotaExceeded: "QUOTA_EXCEEDED",
140
- planRequired: "PLAN_REQUIRED",
141
- featureNotAvailable: "FEATURE_NOT_AVAILABLE",
142
- subscriptionInactive: "SUBSCRIPTION_INACTIVE",
143
- paymentFailed: "PAYMENT_FAILED"
115
+ * Billing-related error codes
116
+ */
117
+ export const BILLING_ERRORS = {
118
+ quotaExceeded: "QUOTA_EXCEEDED",
119
+ planRequired: "PLAN_REQUIRED",
120
+ featureNotAvailable: "FEATURE_NOT_AVAILABLE",
121
+ subscriptionInactive: "SUBSCRIPTION_INACTIVE",
122
+ paymentFailed: "PAYMENT_FAILED",
144
123
  };
145
124
  /**
146
- * API endpoint configuration
147
- */
148
- const API_ENDPOINTS = {
149
- production: "https://api.entrolytics.com",
150
- development: "http://localhost:3001"
125
+ * API endpoint configuration
126
+ */
127
+ export const API_ENDPOINTS = {
128
+ production: "https://api.entrolytics.click",
129
+ development: "http://localhost:3001",
151
130
  };
152
131
  /**
153
- * Default API host
154
- */
155
- const DEFAULT_API_HOST = process.env.NODE_ENV === "production" ? API_ENDPOINTS.production : API_ENDPOINTS.development;
156
- /**
157
- * Environment variable naming conventions by framework
158
- */
159
- const ENV_VAR_NAMES = {
160
- nextjs: {
161
- websiteId: "NEXT_PUBLIC_ENTROLYTICS_WEBSITE_ID",
162
- host: "NEXT_PUBLIC_ENTROLYTICS_HOST",
163
- envFile: ".env.local"
164
- },
165
- react: {
166
- websiteId: "VITE_ENTROLYTICS_WEBSITE_ID",
167
- host: "VITE_ENTROLYTICS_HOST",
168
- envFile: ".env",
169
- fallback: {
170
- websiteId: "REACT_APP_ENTROLYTICS_WEBSITE_ID",
171
- host: "REACT_APP_ENTROLYTICS_HOST"
172
- }
173
- },
174
- vue: {
175
- websiteId: "VITE_ENTROLYTICS_WEBSITE_ID",
176
- host: "VITE_ENTROLYTICS_HOST",
177
- envFile: ".env"
178
- },
179
- svelte: {
180
- websiteId: "PUBLIC_ENTROLYTICS_WEBSITE_ID",
181
- host: "PUBLIC_ENTROLYTICS_HOST",
182
- envFile: ".env"
183
- },
184
- astro: {
185
- websiteId: "PUBLIC_ENTROLYTICS_WEBSITE_ID",
186
- host: "PUBLIC_ENTROLYTICS_HOST",
187
- envFile: ".env"
188
- },
189
- html: {
190
- websiteId: "ENTROLYTICS_WEBSITE_ID",
191
- host: "ENTROLYTICS_HOST",
192
- envFile: ".env"
193
- },
194
- node: {
195
- websiteId: "ENTROLYTICS_WEBSITE_ID",
196
- host: "ENTROLYTICS_HOST",
197
- envFile: ".env"
198
- },
199
- php: {
200
- websiteId: "ENTROLYTICS_WEBSITE_ID",
201
- host: "ENTROLYTICS_HOST",
202
- envFile: ".env"
203
- },
204
- python: {
205
- websiteId: "ENTROLYTICS_WEBSITE_ID",
206
- host: "ENTROLYTICS_HOST",
207
- envFile: ".env"
208
- },
209
- go: {
210
- websiteId: "ENTROLYTICS_WEBSITE_ID",
211
- host: "ENTROLYTICS_HOST",
212
- envFile: ".env"
213
- }
132
+ * Default API host
133
+ */
134
+ export const DEFAULT_API_HOST = getEnv()?.NODE_ENV === "production" ? API_ENDPOINTS.production : API_ENDPOINTS.development;
135
+ /**
136
+ * Environment variable naming conventions by framework
137
+ */
138
+ export const ENV_VAR_NAMES = {
139
+ nextjs: {
140
+ websiteId: "NEXT_PUBLIC_ENTROLYTICS_WEBSITE_ID",
141
+ host: "NEXT_PUBLIC_ENTROLYTICS_HOST",
142
+ envFile: ".env.local",
143
+ },
144
+ react: {
145
+ websiteId: "VITE_ENTROLYTICS_WEBSITE_ID",
146
+ host: "VITE_ENTROLYTICS_HOST",
147
+ envFile: ".env",
148
+ fallback: {
149
+ // CRA fallback
150
+ websiteId: "REACT_APP_ENTROLYTICS_WEBSITE_ID",
151
+ host: "REACT_APP_ENTROLYTICS_HOST",
152
+ },
153
+ },
154
+ vue: {
155
+ websiteId: "VITE_ENTROLYTICS_WEBSITE_ID",
156
+ host: "VITE_ENTROLYTICS_HOST",
157
+ envFile: ".env",
158
+ },
159
+ svelte: {
160
+ websiteId: "PUBLIC_ENTROLYTICS_WEBSITE_ID",
161
+ host: "PUBLIC_ENTROLYTICS_HOST",
162
+ envFile: ".env",
163
+ },
164
+ astro: {
165
+ websiteId: "PUBLIC_ENTROLYTICS_WEBSITE_ID",
166
+ host: "PUBLIC_ENTROLYTICS_HOST",
167
+ envFile: ".env",
168
+ },
169
+ html: {
170
+ websiteId: "ENTROLYTICS_WEBSITE_ID",
171
+ host: "ENTROLYTICS_HOST",
172
+ envFile: ".env",
173
+ },
174
+ node: {
175
+ websiteId: "ENTROLYTICS_WEBSITE_ID",
176
+ host: "ENTROLYTICS_HOST",
177
+ envFile: ".env",
178
+ },
179
+ php: {
180
+ websiteId: "ENTROLYTICS_WEBSITE_ID",
181
+ host: "ENTROLYTICS_HOST",
182
+ envFile: ".env",
183
+ },
184
+ python: {
185
+ websiteId: "ENTROLYTICS_WEBSITE_ID",
186
+ host: "ENTROLYTICS_HOST",
187
+ envFile: ".env",
188
+ },
189
+ go: {
190
+ websiteId: "ENTROLYTICS_WEBSITE_ID",
191
+ host: "ENTROLYTICS_HOST",
192
+ envFile: ".env",
193
+ },
214
194
  };
215
195
  /**
216
- * CLI configuration constants
217
- */
218
- const CLI_CONFIG = {
219
- tokenExpiryMinutes: 15,
220
- maxTokensPerUser: 10,
221
- pollIntervalMs: 2e3,
222
- setupTimeoutMs: 3e5,
223
- minCliVersion: "1.0.0"
196
+ * CLI configuration constants
197
+ */
198
+ export const CLI_CONFIG = {
199
+ tokenExpiryMinutes: 15,
200
+ maxTokensPerUser: 10,
201
+ pollIntervalMs: 2000,
202
+ setupTimeoutMs: 300000, // 5 minutes
203
+ minCliVersion: "1.0.0",
224
204
  };
225
205
  /**
226
- * Core event types - matches backend protocol values exactly
227
- * Used by: API Server, SDKs, CLI, worker processes
228
- * See: entrolytics/packages/protocol/src/events.ts
229
- */
230
- const EVENT_TYPES = {
231
- pageView: "pageview",
232
- custom: "custom_event",
233
- click: "click"
206
+ * Core event types - matches backend protocol values exactly
207
+ * Used by: API Server, SDKs, CLI, worker processes
208
+ * See: entrolytics/packages/protocol/src/events.ts
209
+ */
210
+ export const EVENT_TYPES = {
211
+ pageView: "pageview",
212
+ custom: "custom_event",
213
+ click: "click",
234
214
  };
235
215
  /**
236
- * Extended event types for SDK-level semantics
237
- * These are higher-level event categories used by SDKs
238
- * They map to the core EVENT_TYPES when sent to the backend
239
- */
240
- const SDK_EVENT_TYPES = {
241
- pageView: "pageview",
242
- click: "click",
243
- formSubmit: "form_submit",
244
- custom: "custom_event",
245
- error: "error",
246
- performance: "performance"
216
+ * Extended event types for SDK-level semantics
217
+ * These are higher-level event categories used by SDKs
218
+ * They map to the core EVENT_TYPES when sent to the backend
219
+ */
220
+ export const SDK_EVENT_TYPES = {
221
+ pageView: "pageview",
222
+ click: "click",
223
+ formSubmit: "form_submit",
224
+ custom: "custom_event",
225
+ error: "error",
226
+ performance: "performance",
247
227
  };
248
228
  /**
249
- * Web Vitals metric types (Phase 2)
250
- * Core Web Vitals: LCP, INP, CLS
251
- * Additional: TTFB, FCP
252
- */
253
- const VITAL_TYPES = {
254
- LCP: "LCP",
255
- INP: "INP",
256
- CLS: "CLS",
257
- TTFB: "TTFB",
258
- FCP: "FCP"
229
+ * Web Vitals metric types (Phase 2)
230
+ * Core Web Vitals: LCP, INP, CLS
231
+ * Additional: TTFB, FCP
232
+ */
233
+ export const VITAL_TYPES = {
234
+ LCP: "LCP", // Largest Contentful Paint
235
+ INP: "INP", // Interaction to Next Paint (replaced FID)
236
+ CLS: "CLS", // Cumulative Layout Shift
237
+ TTFB: "TTFB", // Time to First Byte
238
+ FCP: "FCP", // First Contentful Paint
259
239
  };
260
240
  /**
261
- * Web Vitals rating thresholds
262
- */
263
- const VITAL_RATINGS = {
264
- good: "good",
265
- needsImprovement: "needs-improvement",
266
- poor: "poor"
241
+ * Web Vitals rating thresholds
242
+ */
243
+ export const VITAL_RATINGS = {
244
+ good: "good",
245
+ needsImprovement: "needs-improvement",
246
+ poor: "poor",
267
247
  };
268
248
  /**
269
- * Web Vitals thresholds by metric (in milliseconds, except CLS which is unitless)
270
- */
271
- const VITAL_THRESHOLDS = {
272
- LCP: {
273
- good: 2500,
274
- poor: 4e3
275
- },
276
- INP: {
277
- good: 200,
278
- poor: 500
279
- },
280
- CLS: {
281
- good: .1,
282
- poor: .25
283
- },
284
- TTFB: {
285
- good: 800,
286
- poor: 1800
287
- },
288
- FCP: {
289
- good: 1800,
290
- poor: 3e3
291
- }
249
+ * Web Vitals thresholds by metric (in milliseconds, except CLS which is unitless)
250
+ */
251
+ export const VITAL_THRESHOLDS = {
252
+ LCP: { good: 2500, poor: 4000 },
253
+ INP: { good: 200, poor: 500 },
254
+ CLS: { good: 0.1, poor: 0.25 },
255
+ TTFB: { good: 800, poor: 1800 },
256
+ FCP: { good: 1800, poor: 3000 },
292
257
  };
293
258
  /**
294
- * Navigation types for Web Vitals context
295
- */
296
- const NAVIGATION_TYPES = {
297
- navigate: "navigate",
298
- reload: "reload",
299
- backForward: "back-forward",
300
- backForwardCache: "back-forward-cache",
301
- prerender: "prerender",
302
- restore: "restore"
259
+ * Navigation types for Web Vitals context
260
+ */
261
+ export const NAVIGATION_TYPES = {
262
+ navigate: "navigate",
263
+ reload: "reload",
264
+ backForward: "back-forward",
265
+ backForwardCache: "back-forward-cache",
266
+ prerender: "prerender",
267
+ restore: "restore",
303
268
  };
304
269
  /**
305
- * Form event types (Phase 2)
306
- */
307
- const FORM_EVENT_TYPES = {
308
- start: "start",
309
- fieldFocus: "field_focus",
310
- fieldBlur: "field_blur",
311
- fieldError: "field_error",
312
- submit: "submit",
313
- abandon: "abandon"
270
+ * Form event types (Phase 2)
271
+ */
272
+ export const FORM_EVENT_TYPES = {
273
+ start: "start", // Form interaction started
274
+ fieldFocus: "field_focus", // Field received focus
275
+ fieldBlur: "field_blur", // Field lost focus
276
+ fieldError: "field_error", // Field validation error
277
+ submit: "submit", // Form submitted
278
+ abandon: "abandon", // Form abandoned (left page)
314
279
  };
315
280
  /**
316
- * Form field types
317
- */
318
- const FORM_FIELD_TYPES = {
319
- text: "text",
320
- email: "email",
321
- password: "password",
322
- tel: "tel",
323
- number: "number",
324
- url: "url",
325
- textarea: "textarea",
326
- select: "select",
327
- checkbox: "checkbox",
328
- radio: "radio",
329
- date: "date",
330
- file: "file",
331
- hidden: "hidden",
332
- submit: "submit",
333
- other: "other"
281
+ * Form field types
282
+ */
283
+ export const FORM_FIELD_TYPES = {
284
+ text: "text",
285
+ email: "email",
286
+ password: "password",
287
+ tel: "tel",
288
+ number: "number",
289
+ url: "url",
290
+ textarea: "textarea",
291
+ select: "select",
292
+ checkbox: "checkbox",
293
+ radio: "radio",
294
+ date: "date",
295
+ file: "file",
296
+ hidden: "hidden",
297
+ submit: "submit",
298
+ other: "other",
334
299
  };
335
300
  /**
336
- * Deployment platform sources (Phase 2)
337
- */
338
- const DEPLOYMENT_SOURCES = {
339
- vercel: "vercel",
340
- netlify: "netlify",
341
- cloudflare: "cloudflare",
342
- railway: "railway",
343
- render: "render",
344
- fly: "fly",
345
- heroku: "heroku",
346
- aws: "aws",
347
- gcp: "gcp",
348
- azure: "azure",
349
- custom: "custom"
301
+ * Deployment platform sources (Phase 2)
302
+ */
303
+ export const DEPLOYMENT_SOURCES = {
304
+ vercel: "vercel",
305
+ netlify: "netlify",
306
+ cloudflare: "cloudflare",
307
+ railway: "railway",
308
+ render: "render",
309
+ fly: "fly",
310
+ heroku: "heroku",
311
+ aws: "aws",
312
+ gcp: "gcp",
313
+ azure: "azure",
314
+ custom: "custom",
350
315
  };
351
316
  /**
352
- * Deployment environment variables by platform
353
- */
354
- const DEPLOYMENT_ENV_VARS = {
355
- vercel: {
356
- deployId: "VERCEL_DEPLOYMENT_ID",
357
- gitSha: "VERCEL_GIT_COMMIT_SHA",
358
- gitBranch: "VERCEL_GIT_COMMIT_REF",
359
- url: "VERCEL_URL"
360
- },
361
- netlify: {
362
- deployId: "DEPLOY_ID",
363
- gitSha: "COMMIT_REF",
364
- gitBranch: "BRANCH",
365
- url: "DEPLOY_URL"
366
- },
367
- cloudflare: {
368
- deployId: "CF_PAGES_COMMIT_SHA",
369
- gitSha: "CF_PAGES_COMMIT_SHA",
370
- gitBranch: "CF_PAGES_BRANCH",
371
- url: "CF_PAGES_URL"
372
- }
317
+ * Deployment environment variables by platform
318
+ */
319
+ export const DEPLOYMENT_ENV_VARS = {
320
+ vercel: {
321
+ deployId: "VERCEL_DEPLOYMENT_ID",
322
+ gitSha: "VERCEL_GIT_COMMIT_SHA",
323
+ gitBranch: "VERCEL_GIT_COMMIT_REF",
324
+ url: "VERCEL_URL",
325
+ },
326
+ netlify: {
327
+ deployId: "DEPLOY_ID",
328
+ gitSha: "COMMIT_REF",
329
+ gitBranch: "BRANCH",
330
+ url: "DEPLOY_URL",
331
+ },
332
+ cloudflare: {
333
+ deployId: "CF_PAGES_COMMIT_SHA",
334
+ gitSha: "CF_PAGES_COMMIT_SHA",
335
+ gitBranch: "CF_PAGES_BRANCH",
336
+ url: "CF_PAGES_URL",
337
+ },
373
338
  };
374
339
  /**
375
- * HTTP status codes
376
- */
377
- const HTTP_STATUS = {
378
- ok: 200,
379
- created: 201,
380
- accepted: 202,
381
- noContent: 204,
382
- badRequest: 400,
383
- unauthorized: 401,
384
- forbidden: 403,
385
- notFound: 404,
386
- conflict: 409,
387
- tooManyRequests: 429,
388
- internalServerError: 500,
389
- serviceUnavailable: 503
340
+ * HTTP status codes
341
+ */
342
+ export const HTTP_STATUS = {
343
+ ok: 200,
344
+ created: 201,
345
+ accepted: 202,
346
+ noContent: 204,
347
+ badRequest: 400,
348
+ unauthorized: 401,
349
+ forbidden: 403,
350
+ notFound: 404,
351
+ conflict: 409,
352
+ tooManyRequests: 429,
353
+ internalServerError: 500,
354
+ serviceUnavailable: 503,
390
355
  };
391
356
  /**
392
- * API route paths
393
- */
394
- const API_ROUTES = {
395
- cliAuthToken: "/api/auth/cli/token",
396
- cliAuthTokens: "/api/auth/cli/tokens",
397
- cliValidate: "/api/auth/cli/validate",
398
- cliToken: "/api/cli/token",
399
- shareToken: (shareId) => `/api/share/${shareId}`,
400
- links: "/api/links",
401
- linkRedirect: (slug) => `/q/${slug}`,
402
- websites: "/api/websites",
403
- websiteById: (id) => `/api/websites/${id}`,
404
- websiteEvents: (id) => `/api/websites/${id}/events`,
405
- websiteRecentEvents: (id) => `/api/websites/${id}/recent-events`,
406
- userOnboarding: "/api/user/onboarding",
407
- userProfile: "/api/user/profile",
408
- userEmailPreferences: "/api/me/email-preferences",
409
- billingUsage: "/api/billing/usage",
410
- billingCheckout: "/api/billing/checkout",
411
- billingPortal: "/api/billing/portal",
412
- billingWebhook: "/api/billing/webhook",
413
- analyticsOverview: (websiteId) => `/api/analytics/${websiteId}/overview`,
414
- analyticsTimeseries: (websiteId) => `/api/analytics/${websiteId}/timeseries`,
415
- analyticsTopPages: (websiteId) => `/api/analytics/${websiteId}/top-pages`,
416
- analyticsTopReferrers: (websiteId) => `/api/analytics/${websiteId}/top-referrers`,
417
- analyticsGeography: (websiteId) => `/api/analytics/${websiteId}/geography`,
418
- analyticsDevices: (websiteId) => `/api/analytics/${websiteId}/devices`,
419
- collect: "/collect",
420
- collectBatch: "/collect/batch",
421
- send: "/collect",
422
- collectVitals: "/api/collect/vitals",
423
- collectVitalsBatch: "/api/collect/vitals/batch",
424
- collectForms: "/api/collect/forms",
425
- websiteVitals: (id) => `/api/websites/${id}/vitals`,
426
- websiteForms: (id) => `/api/websites/${id}/forms`,
427
- websiteDeployments: (id) => `/api/websites/${id}/deployments`,
428
- health: "/api/health",
429
- healthIntegrations: "/api/health/integrations"
357
+ * API route paths
358
+ */
359
+ export const API_ROUTES = {
360
+ // CLI Auth routes
361
+ cliAuthToken: "/api/auth/cli/token",
362
+ cliAuthTokens: "/api/auth/cli/tokens",
363
+ cliValidate: "/api/auth/cli/validate",
364
+ cliToken: "/api/cli/token", // Legacy - deprecated
365
+ // Share routes
366
+ shareToken: (shareId) => `/api/share/${shareId}`,
367
+ // Links routes
368
+ links: "/api/links",
369
+ linkRedirect: (slug) => `/q/${slug}`,
370
+ // Website routes
371
+ websites: "/api/websites",
372
+ websiteById: (id) => `/api/websites/${id}`,
373
+ websiteEvents: (id) => `/api/websites/${id}/events`,
374
+ websiteRecentEvents: (id) => `/api/websites/${id}/recent-events`,
375
+ // User routes
376
+ userOnboarding: "/api/user/onboarding",
377
+ userProfile: "/api/user/profile",
378
+ userEmailPreferences: "/api/me/email-preferences",
379
+ // Billing routes
380
+ billingUsage: "/api/billing/usage",
381
+ billingCheckout: "/api/billing/checkout",
382
+ billingPortal: "/api/billing/portal",
383
+ billingWebhook: "/api/billing/webhook",
384
+ // Analytics routes (REST)
385
+ analyticsOverview: (websiteId) => `/api/analytics/${websiteId}/overview`,
386
+ analyticsTimeseries: (websiteId) => `/api/analytics/${websiteId}/timeseries`,
387
+ analyticsTopPages: (websiteId) => `/api/analytics/${websiteId}/top-pages`,
388
+ analyticsTopReferrers: (websiteId) => `/api/analytics/${websiteId}/top-referrers`,
389
+ analyticsGeography: (websiteId) => `/api/analytics/${websiteId}/geography`,
390
+ analyticsDevices: (websiteId) => `/api/analytics/${websiteId}/devices`,
391
+ // Event collection
392
+ collect: "/collect",
393
+ collectBatch: "/collect/batch",
394
+ send: "/collect",
395
+ // Phase 2: Web Vitals, Forms, Deployments
396
+ collectVitals: "/api/collect/vitals",
397
+ collectVitalsBatch: "/api/collect/vitals/batch",
398
+ collectForms: "/api/collect/forms",
399
+ collectFormsBatch: "/api/collect/forms/batch",
400
+ vitalsOverview: "/api/vitals/overview",
401
+ vitalsByPage: "/api/vitals/by-page",
402
+ vitalsTrend: "/api/vitals/trend",
403
+ vitalsRecent: "/api/vitals/recent",
404
+ vitalsPageBreakdown: "/api/vitals/page-breakdown",
405
+ formsConversions: "/api/forms/conversions",
406
+ formsFieldMetrics: "/api/forms/field-metrics",
407
+ formsFunnel: "/api/forms/funnel",
408
+ formsRecent: "/api/forms/recent",
409
+ deployments: "/api/deployments",
410
+ deploymentByWebsite: (id) => `/api/deployments/${id}`,
411
+ deploymentLatest: (id) => `/api/deployments/${id}/latest`,
412
+ // Backwards-compatible aliases for legacy website-scoped helpers
413
+ websiteVitals: (id) => `/api/vitals/overview?websiteId=${encodeURIComponent(id)}`,
414
+ websiteForms: (id) => `/api/forms/conversions?websiteId=${encodeURIComponent(id)}`,
415
+ websiteDeployments: (id) => `/api/deployments/${encodeURIComponent(id)}`,
416
+ // Health checks
417
+ health: "/api/health",
418
+ healthIntegrations: "/api/health/integrations",
430
419
  };
431
420
  /**
432
- * Onboarding step identifiers
433
- */
434
- const ONBOARDING_STEPS = {
435
- welcome: "welcome",
436
- createWebsite: "create-website",
437
- installTracking: "install-tracking",
438
- verify: "verify",
439
- complete: "complete",
440
- skipped: "skipped"
421
+ * Onboarding step identifiers
422
+ */
423
+ export const ONBOARDING_STEPS = {
424
+ welcome: "welcome",
425
+ createWebsite: "create-website",
426
+ installTracking: "install-tracking",
427
+ verify: "verify",
428
+ complete: "complete",
429
+ skipped: "skipped",
441
430
  };
442
431
  /**
443
- * CLI token statuses
444
- */
445
- const CLI_TOKEN_STATUS = {
446
- pending: "pending",
447
- used: "used",
448
- expired: "expired",
449
- revoked: "revoked"
432
+ * CLI token statuses
433
+ */
434
+ export const CLI_TOKEN_STATUS = {
435
+ pending: "pending",
436
+ used: "used",
437
+ expired: "expired",
438
+ revoked: "revoked",
450
439
  };
451
440
  /**
452
- * User roles
453
- */
454
- const USER_ROLES = {
455
- admin: "admin",
456
- user: "user",
457
- viewer: "viewer"
441
+ * User roles
442
+ */
443
+ export const USER_ROLES = {
444
+ admin: "admin",
445
+ user: "user",
446
+ viewer: "viewer",
458
447
  };
459
448
  /**
460
- * Framework package names
461
- */
462
- const FRAMEWORK_PACKAGES = {
463
- nextjs: "@entrolytics/nextjs-sdk",
464
- react: "@entrolytics/react-sdk",
465
- vue: "@entrolytics/vue-sdk",
466
- svelte: "@entrolytics/svelte-sdk",
467
- astro: "@entrolytics/astro-sdk",
468
- node: "@entrolytics/node-sdk"
449
+ * Framework package names
450
+ */
451
+ export const FRAMEWORK_PACKAGES = {
452
+ nextjs: "@entrolytics/nextjs-sdk",
453
+ react: "@entrolytics/react-sdk",
454
+ vue: "@entrolytics/vue-sdk",
455
+ svelte: "@entrolytics/svelte-sdk",
456
+ astro: "@entrolytics/astro-sdk",
457
+ node: "@entrolytics/node-sdk",
469
458
  };
470
459
  /**
471
- * Framework detection patterns
472
- */
473
- const FRAMEWORK_PATTERNS = {
474
- nextjs: {
475
- files: [
476
- "next.config.js",
477
- "next.config.mjs",
478
- "next.config.ts"
479
- ],
480
- dependencies: ["next"]
481
- },
482
- react: {
483
- files: ["vite.config.js", "vite.config.ts"],
484
- dependencies: ["react", "vite"]
485
- },
486
- vue: {
487
- files: ["vite.config.js", "vite.config.ts"],
488
- dependencies: ["vue", "vite"]
489
- },
490
- svelte: {
491
- files: ["svelte.config.js", "svelte.config.ts"],
492
- dependencies: ["svelte"]
493
- },
494
- astro: {
495
- files: ["astro.config.mjs", "astro.config.ts"],
496
- dependencies: ["astro"]
497
- }
460
+ * Framework detection patterns
461
+ */
462
+ export const FRAMEWORK_PATTERNS = {
463
+ nextjs: {
464
+ files: ["next.config.js", "next.config.mjs", "next.config.ts"],
465
+ dependencies: ["next"],
466
+ },
467
+ react: {
468
+ files: ["vite.config.js", "vite.config.ts"],
469
+ dependencies: ["react", "vite"],
470
+ },
471
+ vue: {
472
+ files: ["vite.config.js", "vite.config.ts"],
473
+ dependencies: ["vue", "vite"],
474
+ },
475
+ svelte: {
476
+ files: ["svelte.config.js", "svelte.config.ts"],
477
+ dependencies: ["svelte"],
478
+ },
479
+ astro: {
480
+ files: ["astro.config.mjs", "astro.config.ts"],
481
+ dependencies: ["astro"],
482
+ },
498
483
  };
499
484
  /**
500
- * Rate limiting configuration
501
- * Updated to match server-side implementation
502
- */
503
- const RATE_LIMITS = {
504
- cliTokenExchange: {
505
- windowSeconds: 60,
506
- maxRequests: 5
507
- },
508
- shareTokenGeneration: {
509
- windowSeconds: 60,
510
- maxRequests: 10
511
- },
512
- linkCreation: {
513
- windowSeconds: 60,
514
- maxRequests: 20
515
- },
516
- linkRedirect: {
517
- windowSeconds: 60,
518
- maxRequests: 100
519
- },
520
- apiGeneral: {
521
- windowSeconds: 60,
522
- maxRequests: 100
523
- },
524
- cliTokenGeneration: {
525
- windowMs: 36e5,
526
- maxRequests: 10
527
- },
528
- cliValidation: {
529
- windowMs: 36e5,
530
- maxRequests: 100
531
- },
532
- eventCollection: {
533
- windowMs: 6e4,
534
- maxRequests: 1e3
535
- }
485
+ * Rate limiting configuration
486
+ * Updated to match server-side implementation
487
+ */
488
+ export const RATE_LIMITS = {
489
+ cliTokenExchange: {
490
+ windowSeconds: 60, // 1 minute
491
+ maxRequests: 5,
492
+ },
493
+ shareTokenGeneration: {
494
+ windowSeconds: 60, // 1 minute
495
+ maxRequests: 10,
496
+ },
497
+ linkCreation: {
498
+ windowSeconds: 60, // 1 minute
499
+ maxRequests: 20,
500
+ },
501
+ linkRedirect: {
502
+ windowSeconds: 60, // 1 minute
503
+ maxRequests: 100,
504
+ },
505
+ apiGeneral: {
506
+ windowSeconds: 60, // 1 minute
507
+ maxRequests: 100,
508
+ },
509
+ // Legacy (deprecated but kept for backwards compatibility)
510
+ cliTokenGeneration: {
511
+ windowMs: 3600000, // 1 hour
512
+ maxRequests: 10,
513
+ },
514
+ cliValidation: {
515
+ windowMs: 3600000, // 1 hour
516
+ maxRequests: 100,
517
+ },
518
+ eventCollection: {
519
+ windowMs: 60000, // 1 minute
520
+ maxRequests: 1000,
521
+ },
536
522
  };
537
523
  /**
538
- * Error messages
539
- */
540
- const ERROR_MESSAGES = {
541
- unauthorized: "Unauthorized access",
542
- forbidden: "Access forbidden",
543
- tokenExpired: "Token has expired",
544
- tokenInvalid: "Invalid token",
545
- tokenNotFound: "Token not found",
546
- tokenAlreadyUsed: "Token has already been used",
547
- tokenRevoked: "Token has been revoked",
548
- tokenMissingJti: "Token missing JTI - please re-authenticate",
549
- userBanned: "User account has been banned",
550
- userDeleted: "User account has been deleted",
551
- shareTokenExpired: "Share token has expired",
552
- shareTokenRevoked: "Share has been revoked",
553
- shareTokenInvalid: "Invalid share token",
554
- invalidUrl: "Invalid URL provided",
555
- invalidUrlProtocol: "URL must use http or https protocol",
556
- openRedirectBlocked: "Open redirect attempt blocked",
557
- invalidInput: "Invalid input provided",
558
- missingRequired: "Missing required fields",
559
- invalidFormat: "Invalid format",
560
- notFound: "Resource not found",
561
- websiteNotFound: "Website not found",
562
- userNotFound: "User not found",
563
- linkNotFound: "Link not found",
564
- tooManyRequests: "Too many requests. Please try again later.",
565
- rateLimitExceeded: "Rate limit exceeded",
566
- internalError: "Internal server error",
567
- serviceUnavailable: "Service temporarily unavailable"
524
+ * Error messages
525
+ */
526
+ export const ERROR_MESSAGES = {
527
+ // Authentication
528
+ unauthorized: "Unauthorized access",
529
+ forbidden: "Access forbidden",
530
+ tokenExpired: "Token has expired",
531
+ tokenInvalid: "Invalid token",
532
+ tokenNotFound: "Token not found",
533
+ tokenAlreadyUsed: "Token has already been used",
534
+ tokenRevoked: "Token has been revoked",
535
+ tokenMissingJti: "Token missing JTI - please re-authenticate",
536
+ userBanned: "User account has been banned",
537
+ userDeleted: "User account has been deleted",
538
+ // Share tokens
539
+ shareTokenExpired: "Share token has expired",
540
+ shareTokenRevoked: "Share has been revoked",
541
+ shareTokenInvalid: "Invalid share token",
542
+ // URL Validation
543
+ invalidUrl: "Invalid URL provided",
544
+ invalidUrlProtocol: "URL must use http or https protocol",
545
+ openRedirectBlocked: "Open redirect attempt blocked",
546
+ // Validation
547
+ invalidInput: "Invalid input provided",
548
+ missingRequired: "Missing required fields",
549
+ invalidFormat: "Invalid format",
550
+ // Resources
551
+ notFound: "Resource not found",
552
+ websiteNotFound: "Website not found",
553
+ userNotFound: "User not found",
554
+ linkNotFound: "Link not found",
555
+ // Rate limiting
556
+ tooManyRequests: "Too many requests. Please try again later.",
557
+ rateLimitExceeded: "Rate limit exceeded",
558
+ // Server
559
+ internalError: "Internal server error",
560
+ serviceUnavailable: "Service temporarily unavailable",
568
561
  };
569
562
  /**
570
- * Success messages
571
- */
572
- const SUCCESS_MESSAGES = {
573
- tokenGenerated: "Setup token generated successfully",
574
- tokenValidated: "Token validated successfully",
575
- tokenRevoked: "Token revoked successfully",
576
- allTokensRevoked: "All tokens revoked successfully",
577
- websiteCreated: "Website created successfully",
578
- linkCreated: "Link created successfully",
579
- shareCreated: "Share created successfully",
580
- onboardingComplete: "Onboarding completed successfully",
581
- setupComplete: "Setup completed successfully"
563
+ * Success messages
564
+ */
565
+ export const SUCCESS_MESSAGES = {
566
+ tokenGenerated: "Setup token generated successfully",
567
+ tokenValidated: "Token validated successfully",
568
+ tokenRevoked: "Token revoked successfully",
569
+ allTokensRevoked: "All tokens revoked successfully",
570
+ websiteCreated: "Website created successfully",
571
+ linkCreated: "Link created successfully",
572
+ shareCreated: "Share created successfully",
573
+ onboardingComplete: "Onboarding completed successfully",
574
+ setupComplete: "Setup completed successfully",
582
575
  };
576
+ export const EVENT_TYPE_VALUES = Object.values(EVENT_TYPES);
577
+ export const SDK_EVENT_TYPE_VALUES = Object.values(SDK_EVENT_TYPES);
578
+ export const VITAL_TYPE_VALUES = Object.values(VITAL_TYPES);
579
+ export const VITAL_RATING_VALUES = Object.values(VITAL_RATINGS);
580
+ export const NAVIGATION_TYPE_VALUES = Object.values(NAVIGATION_TYPES);
581
+ export const FORM_EVENT_TYPE_VALUES = Object.values(FORM_EVENT_TYPES);
582
+ export const FORM_FIELD_TYPE_VALUES = Object.values(FORM_FIELD_TYPES);
583
+ export const DEPLOYMENT_SOURCE_VALUES = Object.values(DEPLOYMENT_SOURCES);
584
+ export function isEventType(value) {
585
+ return EVENT_TYPE_VALUES.includes(value);
586
+ }
587
+ export function isSdkEventType(value) {
588
+ return SDK_EVENT_TYPE_VALUES.includes(value);
589
+ }
590
+ export function isVitalType(value) {
591
+ return VITAL_TYPE_VALUES.includes(value);
592
+ }
593
+ export function isVitalRating(value) {
594
+ return VITAL_RATING_VALUES.includes(value);
595
+ }
596
+ export function isNavigationType(value) {
597
+ return NAVIGATION_TYPE_VALUES.includes(value);
598
+ }
599
+ export function isFormEventType(value) {
600
+ return FORM_EVENT_TYPE_VALUES.includes(value);
601
+ }
602
+ export function isFormFieldType(value) {
603
+ return FORM_FIELD_TYPE_VALUES.includes(value);
604
+ }
605
+ export function isDeploymentSource(value) {
606
+ return DEPLOYMENT_SOURCE_VALUES.includes(value);
607
+ }
608
+ export function normalizeDeploymentSource(value) {
609
+ if (!value) {
610
+ return "custom";
611
+ }
612
+ return isDeploymentSource(value) ? value : "custom";
613
+ }
583
614
  /**
584
- * Utility functions
585
- */
586
- function getEnvVarNames(framework) {
587
- return ENV_VAR_NAMES[framework];
615
+ * Utility functions
616
+ */
617
+ export function getEnvVarNames(framework) {
618
+ return ENV_VAR_NAMES[framework];
588
619
  }
589
- function getFrameworkPackage(framework) {
590
- return FRAMEWORK_PACKAGES[framework] || null;
620
+ export function getFrameworkPackage(framework) {
621
+ return FRAMEWORK_PACKAGES[framework] || null;
591
622
  }
592
- function isValidFramework(framework) {
593
- return framework in ENV_VAR_NAMES;
623
+ export function isValidFramework(framework) {
624
+ return framework in ENV_VAR_NAMES;
594
625
  }
595
- function getApiRoute(route, ...args) {
596
- const routeFn = API_ROUTES[route];
597
- if (typeof routeFn === "function") return routeFn(...args);
598
- return routeFn;
626
+ export function getApiRoute(route, ...args) {
627
+ const routeFn = API_ROUTES[route];
628
+ if (typeof routeFn === "function") {
629
+ return routeFn(...args);
630
+ }
631
+ return routeFn;
599
632
  }
600
633
  /**
601
- * Get plan by ID
602
- */
603
- function getPlan(planId) {
604
- return PLANS[planId];
634
+ * Get plan by ID
635
+ */
636
+ export function getPlan(planId) {
637
+ return PLANS[planId];
605
638
  }
606
639
  /**
607
- * Check if a feature is available for a plan
608
- */
609
- function isPlanFeatureEnabled(planId, feature) {
610
- return PLANS[planId]?.features?.[feature] === true;
640
+ * Check if a feature is available for a plan
641
+ */
642
+ export function isPlanFeatureEnabled(planId, feature) {
643
+ const plan = PLANS[planId];
644
+ return plan?.features?.[feature] === true;
611
645
  }
612
646
  /**
613
- * Get plan limit value (-1 means unlimited)
614
- */
615
- function getPlanLimit(planId, limit) {
616
- return PLANS[planId]?.limits?.[limit] ?? 0;
647
+ * Get plan limit value (-1 means unlimited)
648
+ */
649
+ export function getPlanLimit(planId, limit) {
650
+ return PLANS[planId]?.limits?.[limit] ?? 0;
617
651
  }
618
652
  /**
619
- * Check if usage is at warning threshold
620
- */
621
- function isUsageWarning(current, limit) {
622
- if (limit <= 0) return false;
623
- return current / limit * 100 >= USAGE_THRESHOLDS.warning;
653
+ * Check if usage is at warning threshold
654
+ */
655
+ export function isUsageWarning(current, limit) {
656
+ if (limit <= 0)
657
+ return false; // unlimited
658
+ return (current / limit) * 100 >= USAGE_THRESHOLDS.warning;
624
659
  }
625
660
  /**
626
- * Check if usage is at critical threshold
627
- */
628
- function isUsageCritical(current, limit) {
629
- if (limit <= 0) return false;
630
- return current / limit * 100 >= USAGE_THRESHOLDS.critical;
661
+ * Check if usage is at critical threshold
662
+ */
663
+ export function isUsageCritical(current, limit) {
664
+ if (limit <= 0)
665
+ return false; // unlimited
666
+ return (current / limit) * 100 >= USAGE_THRESHOLDS.critical;
631
667
  }
632
668
  /**
633
- * Calculate Web Vital rating from value (Phase 2)
634
- */
635
- function getVitalRating(metric, value) {
636
- const thresholds = VITAL_THRESHOLDS[metric];
637
- if (value <= thresholds.good) return "good";
638
- if (value <= thresholds.poor) return "needs-improvement";
639
- return "poor";
669
+ * Calculate Web Vital rating from value (Phase 2)
670
+ */
671
+ export function getVitalRating(metric, value) {
672
+ const thresholds = VITAL_THRESHOLDS[metric];
673
+ if (value <= thresholds.good)
674
+ return "good";
675
+ if (value <= thresholds.poor)
676
+ return "needs-improvement";
677
+ return "poor";
640
678
  }
641
679
  /**
642
- * Detect deployment context from environment variables (Phase 2)
643
- * Works in Node.js environments only - returns null in browser
644
- */
645
- function detectDeploymentContext() {
646
- const env = getEnv();
647
- if (!env) return null;
648
- if (env.VERCEL_DEPLOYMENT_ID) return {
649
- deployId: env.VERCEL_DEPLOYMENT_ID,
650
- gitSha: env.VERCEL_GIT_COMMIT_SHA,
651
- gitBranch: env.VERCEL_GIT_COMMIT_REF,
652
- deployUrl: env.VERCEL_URL ? `https://${env.VERCEL_URL}` : void 0,
653
- source: "vercel"
654
- };
655
- if (env.DEPLOY_ID) return {
656
- deployId: env.DEPLOY_ID,
657
- gitSha: env.COMMIT_REF,
658
- gitBranch: env.BRANCH,
659
- deployUrl: env.DEPLOY_URL,
660
- source: "netlify"
661
- };
662
- if (env.CF_PAGES_COMMIT_SHA) return {
663
- deployId: env.CF_PAGES_COMMIT_SHA,
664
- gitSha: env.CF_PAGES_COMMIT_SHA,
665
- gitBranch: env.CF_PAGES_BRANCH,
666
- deployUrl: env.CF_PAGES_URL,
667
- source: "cloudflare"
668
- };
669
- return null;
680
+ * Detect deployment context from environment variables (Phase 2)
681
+ * Works in Node.js environments only - returns null in browser
682
+ */
683
+ export function detectDeploymentContext() {
684
+ // Safe access to process.env in any environment
685
+ const env = getEnv();
686
+ if (!env)
687
+ return null;
688
+ // Vercel
689
+ if (env.VERCEL_DEPLOYMENT_ID) {
690
+ return {
691
+ deployId: env.VERCEL_DEPLOYMENT_ID,
692
+ gitSha: env.VERCEL_GIT_COMMIT_SHA,
693
+ gitBranch: env.VERCEL_GIT_COMMIT_REF,
694
+ deployUrl: env.VERCEL_URL ? `https://${env.VERCEL_URL}` : undefined,
695
+ source: "vercel",
696
+ };
697
+ }
698
+ // Netlify
699
+ if (env.DEPLOY_ID) {
700
+ return {
701
+ deployId: env.DEPLOY_ID,
702
+ gitSha: env.COMMIT_REF,
703
+ gitBranch: env.BRANCH,
704
+ deployUrl: env.DEPLOY_URL,
705
+ source: "netlify",
706
+ };
707
+ }
708
+ // Cloudflare Pages
709
+ if (env.CF_PAGES_COMMIT_SHA) {
710
+ return {
711
+ deployId: env.CF_PAGES_COMMIT_SHA,
712
+ gitSha: env.CF_PAGES_COMMIT_SHA,
713
+ gitBranch: env.CF_PAGES_BRANCH,
714
+ deployUrl: env.CF_PAGES_URL,
715
+ source: "cloudflare",
716
+ };
717
+ }
718
+ return null;
670
719
  }
671
720
  /**
672
- * Safe environment variable access (works in browser and Node.js)
673
- */
721
+ * Safe environment variable access (works in browser and Node.js)
722
+ */
674
723
  function getEnv() {
675
- try {
676
- if (typeof globalThis !== "undefined" && "process" in globalThis) return globalThis.process?.env ?? null;
677
- return null;
678
- } catch {
679
- return null;
680
- }
724
+ try {
725
+ // Check if we're in a Node.js-like environment
726
+ if (typeof globalThis !== "undefined" && "process" in globalThis) {
727
+ const proc = globalThis
728
+ .process;
729
+ return proc?.env ?? null;
730
+ }
731
+ return null;
732
+ }
733
+ catch {
734
+ return null;
735
+ }
681
736
  }
682
-
683
- //#endregion
684
- export { API_ENDPOINTS, API_ROUTES, BILLING_ERRORS, CLI_CONFIG, CLI_TOKEN_STATUS, DEFAULT_API_HOST, DEPLOYMENT_ENV_VARS, DEPLOYMENT_SOURCES, ENV_VAR_NAMES, ERROR_MESSAGES, EVENT_TYPES, EventType, FORM_EVENT_TYPES, FORM_FIELD_TYPES, FRAMEWORK_PACKAGES, FRAMEWORK_PATTERNS, HTTP_STATUS, NAVIGATION_TYPES, ONBOARDING_STEPS, PLANS, PLAN_FEATURES, RATE_LIMITS, SDK_EVENT_TYPES, SUCCESS_MESSAGES, USAGE_THRESHOLDS, USER_ROLES, VITAL_RATINGS, VITAL_THRESHOLDS, VITAL_TYPES, detectDeploymentContext, getApiRoute, getEnvVarNames, getFrameworkPackage, getPlan, getPlanLimit, getVitalRating, isPlanFeatureEnabled, isUsageCritical, isUsageWarning, isValidFramework };
685
- //# sourceMappingURL=index.js.map
737
+ // Export analytics types
738
+ export * from "./analytics-types";
739
+ // Export event protocol types (canonical event structures)
740
+ export * from "./event-protocol";