@clianta/sdk 1.3.0 → 1.5.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/react.d.ts CHANGED
@@ -1,6 +1,36 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
3
 
4
+ /**
5
+ * Clianta SDK - CRM API Client
6
+ * @see SDK_VERSION in core/config.ts
7
+ */
8
+
9
+ type InboundEventType = 'user.registered' | 'user.updated' | 'user.subscribed' | 'user.unsubscribed' | 'contact.created' | 'contact.updated' | 'purchase.completed';
10
+ interface InboundEventPayload {
11
+ /** Event type (e.g. "user.registered") */
12
+ event: InboundEventType;
13
+ /** Contact data — at least email or phone is required */
14
+ contact: {
15
+ email?: string;
16
+ phone?: string;
17
+ firstName?: string;
18
+ lastName?: string;
19
+ company?: string;
20
+ jobTitle?: string;
21
+ tags?: string[];
22
+ };
23
+ /** Optional extra data stored as customFields on the contact */
24
+ data?: Record<string, unknown>;
25
+ }
26
+ interface InboundEventResult {
27
+ success: boolean;
28
+ contactCreated: boolean;
29
+ contactId?: string;
30
+ event: string;
31
+ error?: string;
32
+ }
33
+
4
34
  /**
5
35
  * Clianta SDK - Type Definitions
6
36
  * @see SDK_VERSION in core/config.ts
@@ -10,8 +40,10 @@ interface CliantaConfig {
10
40
  projectId?: string;
11
41
  /** Backend API endpoint URL */
12
42
  apiEndpoint?: string;
13
- /** Auth token for server-side API access */
43
+ /** Auth token for server-side API access (user JWT) */
14
44
  authToken?: string;
45
+ /** Workspace API key for server-to-server access (use instead of authToken for external apps) */
46
+ apiKey?: string;
15
47
  /** Enable debug mode with verbose logging */
16
48
  debug?: boolean;
17
49
  /** Automatically track page views on load and navigation */
@@ -32,6 +64,8 @@ interface CliantaConfig {
32
64
  useCookies?: boolean;
33
65
  /** Cookie-less mode: use sessionStorage only (no persistent storage) */
34
66
  cookielessMode?: boolean;
67
+ /** Queue persistence mode: 'session' (default), 'local' (survives browser restart), 'none' */
68
+ persistMode?: 'session' | 'local' | 'none';
35
69
  }
36
70
  type PluginName = 'pageView' | 'forms' | 'scroll' | 'clicks' | 'engagement' | 'downloads' | 'exitIntent' | 'errors' | 'performance' | 'popupForms';
37
71
  interface ConsentConfig {
@@ -64,8 +98,8 @@ interface UserTraits {
64
98
  interface TrackerCore {
65
99
  /** Track a custom event */
66
100
  track(eventType: EventType | string, eventName: string, properties?: Record<string, unknown>): void;
67
- /** Identify a visitor */
68
- identify(email: string, traits?: UserTraits): void;
101
+ /** Identify a visitor — returns the contactId if successful */
102
+ identify(email: string, traits?: UserTraits): Promise<string | null>;
69
103
  /** Track a page view */
70
104
  page(name?: string, properties?: Record<string, unknown>): void;
71
105
  /** Update consent state */
@@ -88,6 +122,94 @@ interface TrackerCore {
88
122
  deleteData(): void;
89
123
  /** Get current consent state */
90
124
  getConsentState(): ConsentState;
125
+ /** Get the current visitor's profile from the CRM */
126
+ getVisitorProfile(): Promise<VisitorProfile | null>;
127
+ /** Get the current visitor's recent activity */
128
+ getVisitorActivity(options?: VisitorActivityOptions): Promise<{
129
+ data: VisitorActivity[];
130
+ pagination: {
131
+ page: number;
132
+ limit: number;
133
+ total: number;
134
+ pages: number;
135
+ };
136
+ } | null>;
137
+ /** Get a summarized journey timeline for the current visitor */
138
+ getVisitorTimeline(): Promise<VisitorTimeline | null>;
139
+ /** Get engagement metrics for the current visitor */
140
+ getVisitorEngagement(): Promise<EngagementMetrics | null>;
141
+ /** Send a server-side inbound event (requires apiKey in config) */
142
+ sendEvent(payload: InboundEventPayload): Promise<InboundEventResult>;
143
+ }
144
+ interface VisitorProfile {
145
+ visitorId: string;
146
+ contactId?: string;
147
+ email?: string;
148
+ firstName?: string;
149
+ lastName?: string;
150
+ company?: string;
151
+ jobTitle?: string;
152
+ phone?: string;
153
+ status?: string;
154
+ lifecycleStage?: string;
155
+ tags?: string[];
156
+ leadScore?: number;
157
+ firstSeen?: string;
158
+ lastSeen?: string;
159
+ sessionCount?: number;
160
+ pageViewCount?: number;
161
+ totalTimeSpent?: number;
162
+ customFields?: Record<string, unknown>;
163
+ }
164
+ interface VisitorActivity {
165
+ _id?: string;
166
+ eventType: string;
167
+ eventName: string;
168
+ url: string;
169
+ properties?: Record<string, unknown>;
170
+ timestamp: string;
171
+ }
172
+ interface VisitorTimeline {
173
+ visitorId: string;
174
+ contactId?: string;
175
+ firstSeen: string;
176
+ lastSeen: string;
177
+ totalSessions: number;
178
+ totalPageViews: number;
179
+ totalEvents: number;
180
+ totalTimeSpentSeconds: number;
181
+ averageSessionDurationSeconds: number;
182
+ topPages: Array<{
183
+ url: string;
184
+ views: number;
185
+ avgTimeSeconds?: number;
186
+ }>;
187
+ recentActivities: VisitorActivity[];
188
+ devices: Array<{
189
+ userAgent: string;
190
+ lastSeen: string;
191
+ }>;
192
+ }
193
+ interface EngagementMetrics {
194
+ visitorId: string;
195
+ totalTimeOnSiteSeconds: number;
196
+ averageSessionDurationSeconds: number;
197
+ totalPageViews: number;
198
+ totalSessions: number;
199
+ engagementScore: number;
200
+ bounceRate: number;
201
+ lastActiveAt: string;
202
+ topEvents: Array<{
203
+ eventType: string;
204
+ count: number;
205
+ }>;
206
+ }
207
+ interface VisitorActivityOptions {
208
+ page?: number;
209
+ limit?: number;
210
+ eventType?: string;
211
+ startDate?: string;
212
+ endDate?: string;
91
213
  }
92
214
 
93
215
  interface CliantaProviderProps {