@entrolytics/shared 2.0.6 → 2.2.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.d.cts CHANGED
@@ -1,3 +1,189 @@
1
+ interface DateRangeFilter {
2
+ websiteId: string;
3
+ startDate: Date;
4
+ endDate: Date;
5
+ filters?: {
6
+ country?: string;
7
+ device?: 'desktop' | 'mobile' | 'tablet';
8
+ browser?: string;
9
+ path?: string;
10
+ };
11
+ }
12
+ interface OverviewStats {
13
+ pageviews: number;
14
+ visitors: number;
15
+ sessions: number;
16
+ pagesPerVisitor: number;
17
+ avgLoadTime: number;
18
+ }
19
+ interface TimeseriesData {
20
+ date: Date;
21
+ pageviews: number;
22
+ visitors: number;
23
+ sessions: number;
24
+ }
25
+ interface TopPage {
26
+ path: string;
27
+ views: number;
28
+ uniqueVisitors: number;
29
+ avgLoadTime: number;
30
+ p95LoadTime: number;
31
+ }
32
+ interface Referrer {
33
+ referrerDomain: string;
34
+ visits: number;
35
+ uniqueVisitors: number;
36
+ }
37
+ interface DeviceStats {
38
+ deviceType: string;
39
+ browser: string;
40
+ os: string;
41
+ pageviews: number;
42
+ uniqueVisitors: number;
43
+ }
44
+ interface GeoStats {
45
+ country: string;
46
+ city: string;
47
+ pageviews: number;
48
+ uniqueVisitors: number;
49
+ }
50
+ interface RealtimeStats {
51
+ visitors: number;
52
+ sessions: number;
53
+ pageviews: number;
54
+ }
55
+ interface RealtimeEvent {
56
+ timestamp: Date;
57
+ eventType: string;
58
+ eventName?: string;
59
+ path: string;
60
+ visitorId: string;
61
+ country?: string;
62
+ deviceType: string;
63
+ browser: string;
64
+ }
65
+ interface ActivePage {
66
+ path: string;
67
+ viewers: number;
68
+ }
69
+ /**
70
+ * Core event interface
71
+ */
72
+ interface EntrolyticsEvent {
73
+ id: string;
74
+ websiteId: string;
75
+ sessionId: string;
76
+ visitorId: string;
77
+ timestamp: Date;
78
+ eventType: string;
79
+ eventName?: string;
80
+ url: string;
81
+ path: string;
82
+ referrer?: string;
83
+ referrerDomain?: string;
84
+ browser: string;
85
+ browserVersion?: string;
86
+ os: string;
87
+ osVersion?: string;
88
+ deviceType: 'desktop' | 'mobile' | 'tablet';
89
+ screenWidth?: number;
90
+ screenHeight?: number;
91
+ country?: string;
92
+ city?: string;
93
+ region?: string;
94
+ loadTime?: number;
95
+ domInteractive?: number;
96
+ domComplete?: number;
97
+ utmSource?: string;
98
+ utmMedium?: string;
99
+ utmCampaign?: string;
100
+ utmTerm?: string;
101
+ utmContent?: string;
102
+ properties?: Record<string, unknown>;
103
+ }
104
+
105
+ /**
106
+ * Event Protocol Types
107
+ *
108
+ * These types define the canonical event structures used across the Entrolytics ecosystem.
109
+ * Used by: API Server, SDKs, CLI, worker processes.
110
+ *
111
+ * This file was extracted from the internal @entrolytics/protocol package to enable
112
+ * sharing with external packages.
113
+ */
114
+ /**
115
+ * Core event types supported by the analytics platform
116
+ */
117
+ declare const EventType$1: {
118
+ readonly PageView: "pageview";
119
+ readonly Custom: "custom_event";
120
+ readonly Click: "click";
121
+ };
122
+ type EventType$1 = (typeof EventType$1)[keyof typeof EventType$1];
123
+ /**
124
+ * Event payload as sent from client SDKs
125
+ */
126
+ interface EventPayload {
127
+ websiteId: string;
128
+ sessionId: string;
129
+ visitorId: string;
130
+ url: string;
131
+ referrer?: string;
132
+ eventType: EventType$1;
133
+ eventName?: string;
134
+ properties?: Record<string, unknown>;
135
+ screenWidth?: number;
136
+ screenHeight?: number;
137
+ loadTime?: number;
138
+ domInteractive?: number;
139
+ domComplete?: number;
140
+ utmSource?: string;
141
+ utmMedium?: string;
142
+ utmCampaign?: string;
143
+ utmTerm?: string;
144
+ utmContent?: string;
145
+ }
146
+ /**
147
+ * Event DB row structure as stored in ClickHouse
148
+ * Uses snake_case to match database column naming convention
149
+ */
150
+ interface EventDBRow {
151
+ id: string;
152
+ website_id: string;
153
+ session_id: string;
154
+ visitor_id: string;
155
+ timestamp: string;
156
+ event_type: EventType$1;
157
+ event_name: string | null;
158
+ url: string;
159
+ path: string;
160
+ referrer: string | null;
161
+ referrer_domain: string | null;
162
+ browser: string;
163
+ browser_version: string | null;
164
+ os: string;
165
+ os_version: string | null;
166
+ device_type: 'desktop' | 'mobile' | 'tablet';
167
+ screen_width: number | null;
168
+ screen_height: number | null;
169
+ country: string | null;
170
+ city: string | null;
171
+ region: string | null;
172
+ load_time: number | null;
173
+ dom_interactive: number | null;
174
+ dom_complete: number | null;
175
+ utm_source: string | null;
176
+ utm_medium: string | null;
177
+ utm_campaign: string | null;
178
+ utm_term: string | null;
179
+ utm_content: string | null;
180
+ properties: string;
181
+ }
182
+ /**
183
+ * Device types for analytics segmentation
184
+ */
185
+ type DeviceType = 'desktop' | 'mobile' | 'tablet';
186
+
1
187
  /**
2
188
  * Shared constants across Entrolytics ecosystem
3
189
  * Used by: CLI, SDKs, Dashboard, Integrations
@@ -125,68 +311,68 @@ declare const BILLING_ERRORS: {
125
311
  * API endpoint configuration
126
312
  */
127
313
  declare const API_ENDPOINTS: {
128
- readonly production: "https://ng.entrolytics.click";
314
+ readonly production: "https://entrolytics.click";
129
315
  readonly development: "http://localhost:3000";
130
316
  };
131
317
  /**
132
318
  * Default API host
133
319
  */
134
- declare const DEFAULT_API_HOST: "https://ng.entrolytics.click" | "http://localhost:3000";
320
+ declare const DEFAULT_API_HOST: "https://entrolytics.click" | "http://localhost:3000";
135
321
  /**
136
322
  * Environment variable naming conventions by framework
137
323
  */
138
324
  declare const ENV_VAR_NAMES: {
139
325
  readonly nextjs: {
140
- readonly websiteId: "NEXT_PUBLIC_ENTROLYTICS_NG_WEBSITE_ID";
326
+ readonly websiteId: "NEXT_PUBLIC_ENTROLYTICS_WEBSITE_ID";
141
327
  readonly host: "NEXT_PUBLIC_ENTROLYTICS_HOST";
142
328
  readonly envFile: ".env.local";
143
329
  };
144
330
  readonly react: {
145
- readonly websiteId: "VITE_ENTROLYTICS_NG_WEBSITE_ID";
331
+ readonly websiteId: "VITE_ENTROLYTICS_WEBSITE_ID";
146
332
  readonly host: "VITE_ENTROLYTICS_HOST";
147
333
  readonly envFile: ".env";
148
334
  readonly fallback: {
149
- readonly websiteId: "REACT_APP_ENTROLYTICS_NG_WEBSITE_ID";
335
+ readonly websiteId: "REACT_APP_ENTROLYTICS_WEBSITE_ID";
150
336
  readonly host: "REACT_APP_ENTROLYTICS_HOST";
151
337
  };
152
338
  };
153
339
  readonly vue: {
154
- readonly websiteId: "VITE_ENTROLYTICS_NG_WEBSITE_ID";
340
+ readonly websiteId: "VITE_ENTROLYTICS_WEBSITE_ID";
155
341
  readonly host: "VITE_ENTROLYTICS_HOST";
156
342
  readonly envFile: ".env";
157
343
  };
158
344
  readonly svelte: {
159
- readonly websiteId: "PUBLIC_ENTROLYTICS_NG_WEBSITE_ID";
345
+ readonly websiteId: "PUBLIC_ENTROLYTICS_WEBSITE_ID";
160
346
  readonly host: "PUBLIC_ENTROLYTICS_HOST";
161
347
  readonly envFile: ".env";
162
348
  };
163
349
  readonly astro: {
164
- readonly websiteId: "PUBLIC_ENTROLYTICS_NG_WEBSITE_ID";
350
+ readonly websiteId: "PUBLIC_ENTROLYTICS_WEBSITE_ID";
165
351
  readonly host: "PUBLIC_ENTROLYTICS_HOST";
166
352
  readonly envFile: ".env";
167
353
  };
168
354
  readonly html: {
169
- readonly websiteId: "ENTROLYTICS_NG_WEBSITE_ID";
355
+ readonly websiteId: "ENTROLYTICS_WEBSITE_ID";
170
356
  readonly host: "ENTROLYTICS_HOST";
171
357
  readonly envFile: ".env";
172
358
  };
173
359
  readonly node: {
174
- readonly websiteId: "ENTROLYTICS_NG_WEBSITE_ID";
360
+ readonly websiteId: "ENTROLYTICS_WEBSITE_ID";
175
361
  readonly host: "ENTROLYTICS_HOST";
176
362
  readonly envFile: ".env";
177
363
  };
178
364
  readonly php: {
179
- readonly websiteId: "ENTROLYTICS_NG_WEBSITE_ID";
365
+ readonly websiteId: "ENTROLYTICS_WEBSITE_ID";
180
366
  readonly host: "ENTROLYTICS_HOST";
181
367
  readonly envFile: ".env";
182
368
  };
183
369
  readonly python: {
184
- readonly websiteId: "ENTROLYTICS_NG_WEBSITE_ID";
370
+ readonly websiteId: "ENTROLYTICS_WEBSITE_ID";
185
371
  readonly host: "ENTROLYTICS_HOST";
186
372
  readonly envFile: ".env";
187
373
  };
188
374
  readonly go: {
189
- readonly websiteId: "ENTROLYTICS_NG_WEBSITE_ID";
375
+ readonly websiteId: "ENTROLYTICS_WEBSITE_ID";
190
376
  readonly host: "ENTROLYTICS_HOST";
191
377
  readonly envFile: ".env";
192
378
  };
@@ -202,13 +388,25 @@ declare const CLI_CONFIG: {
202
388
  readonly minCliVersion: "1.0.0";
203
389
  };
204
390
  /**
205
- * Standard event types
391
+ * Core event types - matches backend protocol values exactly
392
+ * Used by: API Server, SDKs, CLI, worker processes
393
+ * See: entrolytics/packages/protocol/src/events.ts
206
394
  */
207
395
  declare const EVENT_TYPES: {
208
- readonly pageView: "page_view";
396
+ readonly pageView: "pageview";
397
+ readonly custom: "custom_event";
398
+ readonly click: "click";
399
+ };
400
+ /**
401
+ * Extended event types for SDK-level semantics
402
+ * These are higher-level event categories used by SDKs
403
+ * They map to the core EVENT_TYPES when sent to the backend
404
+ */
405
+ declare const SDK_EVENT_TYPES: {
406
+ readonly pageView: "pageview";
209
407
  readonly click: "click";
210
408
  readonly formSubmit: "form_submit";
211
- readonly custom: "custom";
409
+ readonly custom: "custom_event";
212
410
  readonly error: "error";
213
411
  readonly performance: "performance";
214
412
  };
@@ -548,6 +746,7 @@ interface CliAccessTokenMetadata {
548
746
  }
549
747
  type Framework = keyof typeof ENV_VAR_NAMES;
550
748
  type EventType = (typeof EVENT_TYPES)[keyof typeof EVENT_TYPES];
749
+ type SdkEventType = (typeof SDK_EVENT_TYPES)[keyof typeof SDK_EVENT_TYPES];
551
750
  type OnboardingStep = (typeof ONBOARDING_STEPS)[keyof typeof ONBOARDING_STEPS];
552
751
  type CliTokenStatus = (typeof CLI_TOKEN_STATUS)[keyof typeof CLI_TOKEN_STATUS];
553
752
  type UserRole = (typeof USER_ROLES)[keyof typeof USER_ROLES];
@@ -605,47 +804,47 @@ interface DeploymentContext {
605
804
  * Utility functions
606
805
  */
607
806
  declare function getEnvVarNames(framework: Framework): {
608
- readonly websiteId: "NEXT_PUBLIC_ENTROLYTICS_NG_WEBSITE_ID";
807
+ readonly websiteId: "NEXT_PUBLIC_ENTROLYTICS_WEBSITE_ID";
609
808
  readonly host: "NEXT_PUBLIC_ENTROLYTICS_HOST";
610
809
  readonly envFile: ".env.local";
611
810
  } | {
612
- readonly websiteId: "VITE_ENTROLYTICS_NG_WEBSITE_ID";
811
+ readonly websiteId: "VITE_ENTROLYTICS_WEBSITE_ID";
613
812
  readonly host: "VITE_ENTROLYTICS_HOST";
614
813
  readonly envFile: ".env";
615
814
  readonly fallback: {
616
- readonly websiteId: "REACT_APP_ENTROLYTICS_NG_WEBSITE_ID";
815
+ readonly websiteId: "REACT_APP_ENTROLYTICS_WEBSITE_ID";
617
816
  readonly host: "REACT_APP_ENTROLYTICS_HOST";
618
817
  };
619
818
  } | {
620
- readonly websiteId: "VITE_ENTROLYTICS_NG_WEBSITE_ID";
819
+ readonly websiteId: "VITE_ENTROLYTICS_WEBSITE_ID";
621
820
  readonly host: "VITE_ENTROLYTICS_HOST";
622
821
  readonly envFile: ".env";
623
822
  } | {
624
- readonly websiteId: "PUBLIC_ENTROLYTICS_NG_WEBSITE_ID";
823
+ readonly websiteId: "PUBLIC_ENTROLYTICS_WEBSITE_ID";
625
824
  readonly host: "PUBLIC_ENTROLYTICS_HOST";
626
825
  readonly envFile: ".env";
627
826
  } | {
628
- readonly websiteId: "PUBLIC_ENTROLYTICS_NG_WEBSITE_ID";
827
+ readonly websiteId: "PUBLIC_ENTROLYTICS_WEBSITE_ID";
629
828
  readonly host: "PUBLIC_ENTROLYTICS_HOST";
630
829
  readonly envFile: ".env";
631
830
  } | {
632
- readonly websiteId: "ENTROLYTICS_NG_WEBSITE_ID";
831
+ readonly websiteId: "ENTROLYTICS_WEBSITE_ID";
633
832
  readonly host: "ENTROLYTICS_HOST";
634
833
  readonly envFile: ".env";
635
834
  } | {
636
- readonly websiteId: "ENTROLYTICS_NG_WEBSITE_ID";
835
+ readonly websiteId: "ENTROLYTICS_WEBSITE_ID";
637
836
  readonly host: "ENTROLYTICS_HOST";
638
837
  readonly envFile: ".env";
639
838
  } | {
640
- readonly websiteId: "ENTROLYTICS_NG_WEBSITE_ID";
839
+ readonly websiteId: "ENTROLYTICS_WEBSITE_ID";
641
840
  readonly host: "ENTROLYTICS_HOST";
642
841
  readonly envFile: ".env";
643
842
  } | {
644
- readonly websiteId: "ENTROLYTICS_NG_WEBSITE_ID";
843
+ readonly websiteId: "ENTROLYTICS_WEBSITE_ID";
645
844
  readonly host: "ENTROLYTICS_HOST";
646
845
  readonly envFile: ".env";
647
846
  } | {
648
- readonly websiteId: "ENTROLYTICS_NG_WEBSITE_ID";
847
+ readonly websiteId: "ENTROLYTICS_WEBSITE_ID";
649
848
  readonly host: "ENTROLYTICS_HOST";
650
849
  readonly envFile: ".env";
651
850
  };
@@ -682,4 +881,4 @@ declare function getVitalRating(metric: VitalType, value: number): VitalRating;
682
881
  */
683
882
  declare function detectDeploymentContext(): DeploymentContext | null;
684
883
 
685
- export { API_ENDPOINTS, API_ROUTES, BILLING_ERRORS, type BillingError, CLI_CONFIG, CLI_TOKEN_STATUS, type CliAccessTokenMetadata, type CliTokenStatus, DEFAULT_API_HOST, DEPLOYMENT_ENV_VARS, DEPLOYMENT_SOURCES, type DeploymentContext, type DeploymentSource, ENV_VAR_NAMES, ERROR_MESSAGES, EVENT_TYPES, type EventType, FORM_EVENT_TYPES, FORM_FIELD_TYPES, FRAMEWORK_PACKAGES, FRAMEWORK_PATTERNS, type FormEventData, type FormEventType, type FormFieldType, type Framework, HTTP_STATUS, NAVIGATION_TYPES, type NavigationType, ONBOARDING_STEPS, type OnboardingStep, PLANS, PLAN_FEATURES, type Plan, type PlanFeature, type PlanId, RATE_LIMITS, SUCCESS_MESSAGES, USAGE_THRESHOLDS, USER_ROLES, type UserRole, VITAL_RATINGS, VITAL_THRESHOLDS, VITAL_TYPES, type VitalRating, type VitalType, type WebVitalData, detectDeploymentContext, getApiRoute, getEnvVarNames, getFrameworkPackage, getPlan, getPlanLimit, getVitalRating, isPlanFeatureEnabled, isUsageCritical, isUsageWarning, isValidFramework };
884
+ export { API_ENDPOINTS, API_ROUTES, type ActivePage, BILLING_ERRORS, type BillingError, CLI_CONFIG, CLI_TOKEN_STATUS, type CliAccessTokenMetadata, type CliTokenStatus, DEFAULT_API_HOST, DEPLOYMENT_ENV_VARS, DEPLOYMENT_SOURCES, type DateRangeFilter, type DeploymentContext, type DeploymentSource, type DeviceStats, type DeviceType, ENV_VAR_NAMES, ERROR_MESSAGES, EVENT_TYPES, type EntrolyticsEvent, type EventDBRow, type EventPayload, type EventType, FORM_EVENT_TYPES, FORM_FIELD_TYPES, FRAMEWORK_PACKAGES, FRAMEWORK_PATTERNS, type FormEventData, type FormEventType, type FormFieldType, type Framework, type GeoStats, HTTP_STATUS, NAVIGATION_TYPES, type NavigationType, ONBOARDING_STEPS, type OnboardingStep, type OverviewStats, PLANS, PLAN_FEATURES, type Plan, type PlanFeature, type PlanId, RATE_LIMITS, type RealtimeEvent, type RealtimeStats, type Referrer, SDK_EVENT_TYPES, SUCCESS_MESSAGES, type SdkEventType, type TimeseriesData, type TopPage, USAGE_THRESHOLDS, USER_ROLES, type UserRole, VITAL_RATINGS, VITAL_THRESHOLDS, VITAL_TYPES, type VitalRating, type VitalType, type WebVitalData, detectDeploymentContext, getApiRoute, getEnvVarNames, getFrameworkPackage, getPlan, getPlanLimit, getVitalRating, isPlanFeatureEnabled, isUsageCritical, isUsageWarning, isValidFramework };