@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/index.d.ts CHANGED
@@ -1,945 +1,1222 @@
1
1
  /**
2
- * Clianta SDK - Type Definitions
3
- * @see SDK_VERSION in core/config.ts
2
+ * Clianta SDK - Event Triggers Manager
3
+ * Manages event-driven automation and email notifications
4
4
  */
5
- interface CliantaConfig {
6
- /** Project ID (required for config file pattern) */
7
- projectId?: string;
8
- /** Backend API endpoint URL */
9
- apiEndpoint?: string;
10
- /** Auth token for server-side API access */
11
- authToken?: string;
12
- /** Enable debug mode with verbose logging */
13
- debug?: boolean;
14
- /** Automatically track page views on load and navigation */
15
- autoPageView?: boolean;
16
- /** Plugins to enable (default: all core plugins) */
17
- plugins?: PluginName[];
18
- /** Session timeout in milliseconds (default: 30 minutes) */
19
- sessionTimeout?: number;
20
- /** Maximum events to batch before sending (default: 10) */
21
- batchSize?: number;
22
- /** Interval to flush events in milliseconds (default: 5000) */
23
- flushInterval?: number;
24
- /** Consent configuration */
25
- consent?: ConsentConfig;
26
- /** Cookie domain for cross-subdomain tracking */
27
- cookieDomain?: string;
28
- /** Use cookies instead of localStorage for visitor ID */
29
- useCookies?: boolean;
30
- /** Cookie-less mode: use sessionStorage only (no persistent storage) */
31
- cookielessMode?: boolean;
32
- }
33
- type PluginName = 'pageView' | 'forms' | 'scroll' | 'clicks' | 'engagement' | 'downloads' | 'exitIntent' | 'errors' | 'performance' | 'popupForms';
34
- interface ConsentConfig {
35
- /** Default consent state before user action */
36
- defaultConsent?: ConsentState;
37
- /** Wait for consent before tracking anything */
38
- waitForConsent?: boolean;
39
- /** Storage key for consent state */
40
- storageKey?: string;
41
- /** Anonymous mode: track without visitor ID until explicit consent */
42
- anonymousMode?: boolean;
43
- }
44
- interface ConsentState {
45
- /** Consent for analytics/essential tracking */
46
- analytics?: boolean;
47
- /** Consent for marketing/advertising tracking */
48
- marketing?: boolean;
49
- /** Consent for personalization */
50
- personalization?: boolean;
51
- }
52
- type EventType = 'page_view' | 'button_click' | 'form_view' | 'form_submit' | 'form_interaction' | 'scroll_depth' | 'engagement' | 'download' | 'exit_intent' | 'error' | 'performance' | 'time_on_page' | 'custom';
53
- interface TrackingEvent {
54
- /** Workspace/project ID */
55
- workspaceId: string;
56
- /** Anonymous visitor identifier */
57
- visitorId: string;
58
- /** Session identifier */
59
- sessionId: string;
60
- /** Event type category */
61
- eventType: EventType;
62
- /** Human-readable event name */
63
- eventName: string;
64
- /** Current page URL */
65
- url: string;
66
- /** Referrer URL */
67
- referrer?: string;
68
- /** Event properties/metadata */
69
- properties: Record<string, unknown>;
70
- /** Device information */
71
- device: DeviceInfo;
72
- /** UTM parameters */
73
- utm?: UTMParams;
74
- /** ISO timestamp */
75
- timestamp: string;
76
- /** SDK version */
77
- sdkVersion: string;
5
+
6
+ /**
7
+ * Event Triggers Manager
8
+ * Handles event-driven automation based on CRM actions
9
+ *
10
+ * Similar to:
11
+ * - Salesforce: Process Builder, Flow Automation
12
+ * - HubSpot: Workflows, Email Sequences
13
+ * - Pipedrive: Workflow Automation
14
+ */
15
+ declare class EventTriggersManager {
16
+ private apiEndpoint;
17
+ private workspaceId;
18
+ private authToken?;
19
+ private triggers;
20
+ private listeners;
21
+ constructor(apiEndpoint: string, workspaceId: string, authToken?: string);
22
+ /**
23
+ * Set authentication token
24
+ */
25
+ setAuthToken(token: string): void;
26
+ /**
27
+ * Make authenticated API request
28
+ */
29
+ private request;
30
+ /**
31
+ * Get all event triggers
32
+ */
33
+ getTriggers(): Promise<ApiResponse<EventTrigger[]>>;
34
+ /**
35
+ * Get a single trigger by ID
36
+ */
37
+ getTrigger(triggerId: string): Promise<ApiResponse<EventTrigger>>;
38
+ /**
39
+ * Create a new event trigger
40
+ */
41
+ createTrigger(trigger: Partial<EventTrigger>): Promise<ApiResponse<EventTrigger>>;
42
+ /**
43
+ * Update an existing trigger
44
+ */
45
+ updateTrigger(triggerId: string, updates: Partial<EventTrigger>): Promise<ApiResponse<EventTrigger>>;
46
+ /**
47
+ * Delete a trigger
48
+ */
49
+ deleteTrigger(triggerId: string): Promise<ApiResponse<void>>;
50
+ /**
51
+ * Activate a trigger
52
+ */
53
+ activateTrigger(triggerId: string): Promise<ApiResponse<EventTrigger>>;
54
+ /**
55
+ * Deactivate a trigger
56
+ */
57
+ deactivateTrigger(triggerId: string): Promise<ApiResponse<EventTrigger>>;
58
+ /**
59
+ * Register a local event listener for client-side triggers
60
+ * This allows immediate client-side reactions to events
61
+ */
62
+ on(eventType: TriggerEventType, callback: (data: unknown) => void): void;
63
+ /**
64
+ * Remove an event listener
65
+ */
66
+ off(eventType: TriggerEventType, callback: (data: unknown) => void): void;
67
+ /**
68
+ * Emit an event (client-side only)
69
+ * This will trigger any registered local listeners
70
+ */
71
+ emit(eventType: TriggerEventType, data: unknown): void;
72
+ /**
73
+ * Check if conditions are met for a trigger
74
+ * Supports dynamic field evaluation including custom fields and nested paths
75
+ */
76
+ private evaluateConditions;
77
+ /**
78
+ * Execute actions for a triggered event (client-side preview)
79
+ * Note: Actual execution happens on the backend
80
+ */
81
+ executeActions(trigger: EventTrigger, data: Record<string, unknown>): Promise<void>;
82
+ /**
83
+ * Execute a single action
84
+ */
85
+ private executeAction;
86
+ /**
87
+ * Execute send email action (via backend API)
88
+ */
89
+ private executeSendEmail;
90
+ /**
91
+ * Execute webhook action
92
+ */
93
+ private executeWebhook;
94
+ /**
95
+ * Execute create task action
96
+ */
97
+ private executeCreateTask;
98
+ /**
99
+ * Execute update contact action
100
+ */
101
+ private executeUpdateContact;
102
+ /**
103
+ * Replace variables in a string template
104
+ * Supports syntax like {{contact.email}}, {{opportunity.value}}
105
+ */
106
+ private replaceVariables;
107
+ /**
108
+ * Get nested value from object using dot notation
109
+ * Supports dynamic field access including custom fields
110
+ */
111
+ private getNestedValue;
112
+ /**
113
+ * Extract all available field paths from a data object
114
+ * Useful for dynamic field discovery based on platform-specific attributes
115
+ * @param obj - The data object to extract fields from
116
+ * @param prefix - Internal use for nested paths
117
+ * @param maxDepth - Maximum depth to traverse (default: 3)
118
+ * @returns Array of field paths (e.g., ['email', 'contact.firstName', 'customFields.industry'])
119
+ */
120
+ private extractAvailableFields;
121
+ /**
122
+ * Get available fields from sample data
123
+ * Helps with dynamic field detection for platform-specific attributes
124
+ * @param sampleData - Sample data object to analyze
125
+ * @returns Array of available field paths
126
+ */
127
+ getAvailableFields(sampleData: Record<string, unknown>): string[];
128
+ /**
129
+ * Create a simple email trigger
130
+ * Helper method for common use case
131
+ */
132
+ createEmailTrigger(config: {
133
+ name: string;
134
+ eventType: TriggerEventType;
135
+ to: string;
136
+ subject: string;
137
+ body: string;
138
+ conditions?: TriggerCondition[];
139
+ }): Promise<ApiResponse<EventTrigger>>;
140
+ /**
141
+ * Create a task creation trigger
142
+ */
143
+ createTaskTrigger(config: {
144
+ name: string;
145
+ eventType: TriggerEventType;
146
+ taskTitle: string;
147
+ taskDescription?: string;
148
+ priority?: 'low' | 'medium' | 'high' | 'urgent';
149
+ dueDays?: number;
150
+ conditions?: TriggerCondition[];
151
+ }): Promise<ApiResponse<EventTrigger>>;
152
+ /**
153
+ * Create a webhook trigger
154
+ */
155
+ createWebhookTrigger(config: {
156
+ name: string;
157
+ eventType: TriggerEventType;
158
+ webhookUrl: string;
159
+ method?: 'POST' | 'PUT' | 'PATCH';
160
+ conditions?: TriggerCondition[];
161
+ }): Promise<ApiResponse<EventTrigger>>;
78
162
  }
79
- interface DeviceInfo {
80
- userAgent: string;
81
- screen: string;
82
- language: string;
83
- timezone?: string;
163
+
164
+ /**
165
+ * Clianta SDK - CRM API Client
166
+ * @see SDK_VERSION in core/config.ts
167
+ */
168
+
169
+ type InboundEventType = 'user.registered' | 'user.updated' | 'user.subscribed' | 'user.unsubscribed' | 'contact.created' | 'contact.updated' | 'purchase.completed';
170
+ interface InboundEventPayload {
171
+ /** Event type (e.g. "user.registered") */
172
+ event: InboundEventType;
173
+ /** Contact data — at least email or phone is required */
174
+ contact: {
175
+ email?: string;
176
+ phone?: string;
177
+ firstName?: string;
178
+ lastName?: string;
179
+ company?: string;
180
+ jobTitle?: string;
181
+ tags?: string[];
182
+ };
183
+ /** Optional extra data stored as customFields on the contact */
184
+ data?: Record<string, unknown>;
84
185
  }
85
- interface UTMParams {
86
- utmSource?: string;
87
- utmMedium?: string;
88
- utmCampaign?: string;
89
- utmTerm?: string;
90
- utmContent?: string;
186
+ interface InboundEventResult {
187
+ success: boolean;
188
+ contactCreated: boolean;
189
+ contactId?: string;
190
+ event: string;
191
+ error?: string;
91
192
  }
92
- interface UserTraits {
93
- firstName?: string;
94
- lastName?: string;
95
- company?: string;
96
- phone?: string;
97
- title?: string;
98
- [key: string]: unknown;
99
- }
100
- interface Plugin {
101
- /** Unique plugin name */
102
- name: PluginName;
103
- /** Initialize the plugin (can be sync or async) */
104
- init(tracker: TrackerCore): void | Promise<void>;
105
- /** Cleanup when plugin is disabled */
106
- destroy?(): void;
107
- }
108
- interface TrackerCore {
109
- /** Track a custom event */
110
- track(eventType: EventType | string, eventName: string, properties?: Record<string, unknown>): void;
111
- /** Identify a visitor */
112
- identify(email: string, traits?: UserTraits): void;
113
- /** Track a page view */
114
- page(name?: string, properties?: Record<string, unknown>): void;
115
- /** Update consent state */
116
- consent(state: ConsentState): void;
117
- /** Toggle debug mode */
118
- debug(enabled: boolean): void;
119
- /** Get visitor ID */
120
- getVisitorId(): string;
121
- /** Get session ID */
122
- getSessionId(): string;
123
- /** Force flush event queue */
124
- flush(): Promise<void>;
125
- /** Reset visitor (for logout) */
126
- reset(): void;
127
- /** Get current configuration */
128
- getConfig(): CliantaConfig;
129
- /** Get workspace ID */
130
- getWorkspaceId(): string;
131
- /** Delete all stored user data (GDPR right-to-erasure) */
132
- deleteData(): void;
133
- /** Get current consent state */
134
- getConsentState(): ConsentState;
135
- }
136
- interface Contact {
137
- _id?: string;
138
- workspaceId: string;
139
- email: string;
140
- firstName?: string;
141
- lastName?: string;
142
- company?: string;
143
- jobTitle?: string;
144
- phone?: string;
145
- status?: 'lead' | 'contact' | 'customer';
146
- lifecycleStage?: 'subscriber' | 'lead' | 'mql' | 'sql' | 'opportunity' | 'customer' | 'evangelist';
147
- source?: string;
148
- tags?: string[];
149
- leadScore?: number;
150
- customFields?: Record<string, unknown>;
151
- companyId?: string;
152
- assignedTo?: string;
153
- createdAt?: string;
154
- updatedAt?: string;
155
- }
156
- interface Company {
157
- _id?: string;
158
- workspaceId: string;
159
- name: string;
160
- industry?: string;
161
- website?: string;
162
- phone?: string;
163
- address?: {
164
- street?: string;
165
- city?: string;
166
- state?: string;
167
- country?: string;
168
- postalCode?: string;
169
- };
170
- companySize?: string;
171
- annualRevenue?: number;
172
- status?: 'prospect' | 'active' | 'inactive' | 'churned';
173
- accountTier?: 'enterprise' | 'mid-market' | 'smb';
174
- isTargetAccount?: boolean;
175
- tags?: string[];
176
- customFields?: Record<string, unknown>;
177
- assignedTo?: string;
178
- createdAt?: string;
179
- updatedAt?: string;
180
- }
181
- interface Pipeline {
182
- _id?: string;
183
- workspaceId: string;
184
- name: string;
185
- description?: string;
186
- stages: PipelineStage[];
187
- isDefault?: boolean;
188
- isActive?: boolean;
189
- createdAt?: string;
190
- updatedAt?: string;
191
- }
192
- interface PipelineStage {
193
- _id?: string;
194
- name: string;
195
- order: number;
196
- probability?: number;
197
- color?: string;
198
- rottenDays?: number;
199
- }
200
- interface Task {
201
- _id?: string;
202
- workspaceId: string;
203
- title: string;
204
- description?: string;
205
- status?: 'pending' | 'in_progress' | 'completed' | 'cancelled';
206
- priority?: 'low' | 'medium' | 'high' | 'urgent';
207
- dueDate?: string;
208
- reminderDate?: string;
209
- completedAt?: string;
210
- tags?: string[];
211
- relatedContactId?: string;
212
- relatedCompanyId?: string;
213
- relatedOpportunityId?: string;
214
- assignedTo?: string;
215
- createdAt?: string;
216
- updatedAt?: string;
217
- }
218
- interface Activity {
219
- _id?: string;
220
- workspaceId: string;
221
- type: 'call' | 'email' | 'meeting' | 'note' | 'task' | 'other';
222
- title: string;
223
- description?: string;
224
- direction?: 'inbound' | 'outbound';
225
- duration?: number;
226
- outcome?: string;
227
- emailSubject?: string;
228
- emailBody?: string;
229
- metadata?: Record<string, unknown>;
230
- contactId?: string;
231
- companyId?: string;
232
- opportunityId?: string;
233
- userId?: string;
234
- createdAt?: string;
235
- updatedAt?: string;
236
- }
237
- interface Opportunity {
238
- _id?: string;
239
- workspaceId: string;
240
- contactId: string;
241
- companyId?: string;
242
- pipelineId: string;
243
- stageId: string;
244
- title: string;
245
- value?: number;
246
- currency?: string;
247
- probability?: number;
248
- expectedCloseDate?: string;
249
- status?: 'open' | 'won' | 'lost';
250
- priority?: 'low' | 'medium' | 'high';
251
- lostReason?: string;
252
- customFields?: Record<string, unknown>;
253
- assignedTo?: string;
254
- createdAt?: string;
255
- updatedAt?: string;
256
- }
257
- interface ApiResponse<T> {
258
- success: boolean;
259
- data?: T;
260
- error?: string;
261
- status: number;
262
- }
263
- interface PaginatedResponse<T> {
264
- data: T[];
265
- pagination: {
266
- page: number;
267
- limit: number;
268
- total: number;
269
- pages: number;
270
- };
271
- }
272
- type TriggerEventType = 'contact.created' | 'contact.updated' | 'contact.deleted' | 'opportunity.created' | 'opportunity.updated' | 'opportunity.stage_changed' | 'opportunity.won' | 'opportunity.lost' | 'task.created' | 'task.completed' | 'task.overdue' | 'activity.logged' | 'form.submitted';
273
- interface TriggerCondition {
274
- /**
275
- * Field to check - supports dynamic field names including custom fields
276
- * Examples: 'status', 'lifecycleStage', 'leadScore', 'customFields.industry'
277
- * Use dot notation for nested fields: 'contact.email', 'customFields.accountType'
278
- */
279
- field: string;
280
- /** Operator for comparison */
281
- operator: 'equals' | 'not_equals' | 'contains' | 'greater_than' | 'less_than' | 'in' | 'not_in';
282
- /** Value to compare against */
283
- value: unknown;
284
- }
285
- interface EmailTemplate {
286
- /** Template ID */
287
- _id?: string;
288
- /** Template name */
289
- name: string;
290
- /** Email subject line (supports variables) */
291
- subject: string;
292
- /** Email body (supports HTML and variables) */
293
- body: string;
294
- /** Variables available in this template */
295
- variables?: string[];
296
- /** Sender email address */
297
- fromEmail?: string;
298
- /** Sender name */
299
- fromName?: string;
300
- }
301
- interface EmailAction {
302
- /** Action type identifier */
303
- type: 'send_email';
304
- /** Email template ID or inline template */
305
- templateId?: string;
306
- /** Inline email subject (if not using template) */
307
- subject?: string;
308
- /** Inline email body (if not using template) */
309
- body?: string;
310
- /** Recipient email (supports variables like {{contact.email}}) */
311
- to: string;
312
- /** CC recipients */
313
- cc?: string[];
314
- /** BCC recipients */
315
- bcc?: string[];
316
- /** Sender email */
317
- from?: string;
318
- /** Delay in minutes before sending */
319
- delayMinutes?: number;
320
- }
321
- interface WebhookAction {
322
- /** Action type identifier */
323
- type: 'webhook';
324
- /** Webhook URL to call */
325
- url: string;
326
- /** HTTP method */
327
- method: 'POST' | 'PUT' | 'PATCH';
328
- /** Custom headers */
329
- headers?: Record<string, string>;
330
- /** Request body template (supports variables) */
331
- body?: string;
332
- }
333
- interface TaskAction {
334
- /** Action type identifier */
335
- type: 'create_task';
336
- /** Task title (supports variables) */
337
- title: string;
338
- /** Task description */
339
- description?: string;
340
- /** Task priority */
341
- priority?: 'low' | 'medium' | 'high' | 'urgent';
342
- /** Due date in days from trigger */
343
- dueDays?: number;
344
- /** Assign to user ID */
345
- assignedTo?: string;
346
- }
347
- interface ContactUpdateAction {
348
- /** Action type identifier */
349
- type: 'update_contact';
350
- /** Fields to update */
351
- updates: Partial<Contact>;
352
- }
353
- type TriggerAction = EmailAction | WebhookAction | TaskAction | ContactUpdateAction;
354
- interface EventTrigger {
355
- /** Trigger ID */
356
- _id?: string;
357
- /** Workspace ID */
358
- workspaceId: string;
359
- /** Trigger name */
360
- name: string;
361
- /** Description of what this trigger does */
362
- description?: string;
363
- /** Event type that activates this trigger */
364
- eventType: TriggerEventType;
365
- /** Conditions that must be met for trigger to fire */
366
- conditions?: TriggerCondition[];
367
- /** Actions to execute when trigger fires */
368
- actions: TriggerAction[];
369
- /** Whether this trigger is active */
370
- isActive?: boolean;
371
- /** Created timestamp */
372
- createdAt?: string;
373
- /** Updated timestamp */
374
- updatedAt?: string;
375
- }
376
- interface TriggerExecution {
377
- /** Execution ID */
378
- _id?: string;
379
- /** Trigger ID that was executed */
380
- triggerId: string;
381
- /** Event that triggered the execution */
382
- eventType: TriggerEventType;
383
- /** Entity ID that triggered the event */
384
- entityId: string;
385
- /** Execution status */
386
- status: 'pending' | 'success' | 'failed';
387
- /** Error message if failed */
388
- error?: string;
389
- /** Actions executed */
390
- actionsExecuted: number;
391
- /** Execution timestamp */
392
- executedAt: string;
393
- }
394
-
395
- /**
396
- * Clianta SDK - Main Tracker Class
397
- * @see SDK_VERSION in core/config.ts
398
- */
399
-
400
193
  /**
401
- * Main Clianta Tracker Class
194
+ * CRM API Client for managing contacts and opportunities
402
195
  */
403
- declare class Tracker implements TrackerCore {
196
+ declare class CRMClient {
197
+ private apiEndpoint;
404
198
  private workspaceId;
405
- private config;
406
- private transport;
407
- private queue;
408
- private plugins;
409
- private visitorId;
410
- private sessionId;
411
- private isInitialized;
412
- private consentManager;
413
- /** Pending identify retry on next flush */
414
- private pendingIdentify;
415
- constructor(workspaceId: string, userConfig?: CliantaConfig);
199
+ private authToken?;
200
+ private apiKey?;
201
+ triggers: EventTriggersManager;
202
+ constructor(apiEndpoint: string, workspaceId: string, authToken?: string, apiKey?: string);
203
+ /**
204
+ * Set authentication token for API requests (user JWT)
205
+ */
206
+ setAuthToken(token: string): void;
207
+ /**
208
+ * Set workspace API key for server-to-server requests.
209
+ * Use this instead of setAuthToken when integrating from an external app.
210
+ */
211
+ setApiKey(key: string): void;
212
+ /**
213
+ * Validate required parameter exists
214
+ * @throws {Error} if value is null/undefined or empty string
215
+ */
216
+ private validateRequired;
217
+ /**
218
+ * Make authenticated API request
219
+ */
220
+ private request;
221
+ /**
222
+ * Send an inbound event from an external app (e.g. user signup on client website).
223
+ * Requires the client to be initialized with an API key via setApiKey() or the constructor.
224
+ *
225
+ * The contact is upserted in the CRM and matching workflow automations fire automatically.
226
+ *
227
+ * @example
228
+ * const crm = new CRMClient('https://api.clianta.online', 'WORKSPACE_ID');
229
+ * crm.setApiKey('mm_live_...');
230
+ *
231
+ * await crm.sendEvent({
232
+ * event: 'user.registered',
233
+ * contact: { email: 'alice@example.com', firstName: 'Alice' },
234
+ * data: { plan: 'free', signupSource: 'homepage' },
235
+ * });
236
+ */
237
+ sendEvent(payload: InboundEventPayload): Promise<InboundEventResult>;
238
+ /**
239
+ * Get all contacts with pagination
240
+ */
241
+ getContacts(params?: {
242
+ page?: number;
243
+ limit?: number;
244
+ search?: string;
245
+ status?: string;
246
+ }): Promise<ApiResponse<PaginatedResponse<Contact>>>;
247
+ /**
248
+ * Get a single contact by ID
249
+ */
250
+ getContact(contactId: string): Promise<ApiResponse<Contact>>;
251
+ /**
252
+ * Create a new contact
253
+ */
254
+ createContact(contact: Partial<Contact>): Promise<ApiResponse<Contact>>;
255
+ /**
256
+ * Update an existing contact
257
+ */
258
+ updateContact(contactId: string, updates: Partial<Contact>): Promise<ApiResponse<Contact>>;
416
259
  /**
417
- * Create visitor ID based on storage mode
260
+ * Delete a contact
418
261
  */
419
- private createVisitorId;
262
+ deleteContact(contactId: string): Promise<ApiResponse<void>>;
420
263
  /**
421
- * Create session ID
264
+ * Get all opportunities with pagination
422
265
  */
423
- private createSessionId;
266
+ getOpportunities(params?: {
267
+ page?: number;
268
+ limit?: number;
269
+ pipelineId?: string;
270
+ stageId?: string;
271
+ }): Promise<ApiResponse<PaginatedResponse<Opportunity>>>;
424
272
  /**
425
- * Handle consent state changes
273
+ * Get a single opportunity by ID
426
274
  */
427
- private onConsentChange;
275
+ getOpportunity(opportunityId: string): Promise<ApiResponse<Opportunity>>;
428
276
  /**
429
- * Initialize enabled plugins
430
- * Handles both sync and async plugin init methods
277
+ * Create a new opportunity
431
278
  */
432
- private initPlugins;
279
+ createOpportunity(opportunity: Partial<Opportunity>): Promise<ApiResponse<Opportunity>>;
433
280
  /**
434
- * Track a custom event
281
+ * Update an existing opportunity
435
282
  */
436
- track(eventType: EventType | string, eventName: string, properties?: Record<string, unknown>): void;
283
+ updateOpportunity(opportunityId: string, updates: Partial<Opportunity>): Promise<ApiResponse<Opportunity>>;
437
284
  /**
438
- * Track a page view
285
+ * Delete an opportunity
439
286
  */
440
- page(name?: string, properties?: Record<string, unknown>): void;
287
+ deleteOpportunity(opportunityId: string): Promise<ApiResponse<void>>;
441
288
  /**
442
- * Identify a visitor
289
+ * Move opportunity to a different stage
443
290
  */
444
- identify(email: string, traits?: UserTraits): Promise<void>;
291
+ moveOpportunity(opportunityId: string, stageId: string): Promise<ApiResponse<Opportunity>>;
445
292
  /**
446
- * Retry pending identify call
293
+ * Get all companies with pagination
447
294
  */
448
- private retryPendingIdentify;
295
+ getCompanies(params?: {
296
+ page?: number;
297
+ limit?: number;
298
+ search?: string;
299
+ status?: string;
300
+ industry?: string;
301
+ }): Promise<ApiResponse<PaginatedResponse<Company>>>;
449
302
  /**
450
- * Update consent state
303
+ * Get a single company by ID
451
304
  */
452
- consent(state: ConsentState): void;
305
+ getCompany(companyId: string): Promise<ApiResponse<Company>>;
453
306
  /**
454
- * Get current consent state
307
+ * Create a new company
455
308
  */
456
- getConsentState(): ConsentState;
309
+ createCompany(company: Partial<Company>): Promise<ApiResponse<Company>>;
457
310
  /**
458
- * Toggle debug mode
311
+ * Update an existing company
459
312
  */
460
- debug(enabled: boolean): void;
313
+ updateCompany(companyId: string, updates: Partial<Company>): Promise<ApiResponse<Company>>;
461
314
  /**
462
- * Get visitor ID
315
+ * Delete a company
463
316
  */
464
- getVisitorId(): string;
317
+ deleteCompany(companyId: string): Promise<ApiResponse<void>>;
465
318
  /**
466
- * Get session ID
319
+ * Get contacts belonging to a company
467
320
  */
468
- getSessionId(): string;
321
+ getCompanyContacts(companyId: string, params?: {
322
+ page?: number;
323
+ limit?: number;
324
+ }): Promise<ApiResponse<PaginatedResponse<Contact>>>;
469
325
  /**
470
- * Get workspace ID
326
+ * Get deals/opportunities belonging to a company
471
327
  */
472
- getWorkspaceId(): string;
328
+ getCompanyDeals(companyId: string, params?: {
329
+ page?: number;
330
+ limit?: number;
331
+ }): Promise<ApiResponse<PaginatedResponse<Opportunity>>>;
473
332
  /**
474
- * Get current configuration
333
+ * Get all pipelines
475
334
  */
476
- getConfig(): CliantaConfig;
335
+ getPipelines(): Promise<ApiResponse<Pipeline[]>>;
477
336
  /**
478
- * Force flush event queue
337
+ * Get a single pipeline by ID
479
338
  */
480
- flush(): Promise<void>;
339
+ getPipeline(pipelineId: string): Promise<ApiResponse<Pipeline>>;
481
340
  /**
482
- * Reset visitor and session (for logout)
341
+ * Create a new pipeline
483
342
  */
484
- reset(): void;
343
+ createPipeline(pipeline: Partial<Pipeline>): Promise<ApiResponse<Pipeline>>;
485
344
  /**
486
- * Delete all stored user data (GDPR right-to-erasure)
345
+ * Update an existing pipeline
487
346
  */
488
- deleteData(): void;
347
+ updatePipeline(pipelineId: string, updates: Partial<Pipeline>): Promise<ApiResponse<Pipeline>>;
489
348
  /**
490
- * Destroy tracker and cleanup
349
+ * Delete a pipeline
491
350
  */
492
- destroy(): Promise<void>;
493
- }
494
-
495
- /**
496
- * Clianta SDK - Event Triggers Manager
497
- * Manages event-driven automation and email notifications
498
- */
499
-
500
- /**
501
- * Event Triggers Manager
502
- * Handles event-driven automation based on CRM actions
503
- *
504
- * Similar to:
505
- * - Salesforce: Process Builder, Flow Automation
506
- * - HubSpot: Workflows, Email Sequences
507
- * - Pipedrive: Workflow Automation
508
- */
509
- declare class EventTriggersManager {
510
- private apiEndpoint;
511
- private workspaceId;
512
- private authToken?;
513
- private triggers;
514
- private listeners;
515
- constructor(apiEndpoint: string, workspaceId: string, authToken?: string);
351
+ deletePipeline(pipelineId: string): Promise<ApiResponse<void>>;
516
352
  /**
517
- * Set authentication token
353
+ * Get all tasks with pagination
518
354
  */
519
- setAuthToken(token: string): void;
355
+ getTasks(params?: {
356
+ page?: number;
357
+ limit?: number;
358
+ status?: string;
359
+ priority?: string;
360
+ contactId?: string;
361
+ companyId?: string;
362
+ opportunityId?: string;
363
+ }): Promise<ApiResponse<PaginatedResponse<Task>>>;
520
364
  /**
521
- * Make authenticated API request
365
+ * Get a single task by ID
522
366
  */
523
- private request;
367
+ getTask(taskId: string): Promise<ApiResponse<Task>>;
524
368
  /**
525
- * Get all event triggers
369
+ * Create a new task
526
370
  */
527
- getTriggers(): Promise<ApiResponse<EventTrigger[]>>;
371
+ createTask(task: Partial<Task>): Promise<ApiResponse<Task>>;
528
372
  /**
529
- * Get a single trigger by ID
373
+ * Update an existing task
530
374
  */
531
- getTrigger(triggerId: string): Promise<ApiResponse<EventTrigger>>;
375
+ updateTask(taskId: string, updates: Partial<Task>): Promise<ApiResponse<Task>>;
532
376
  /**
533
- * Create a new event trigger
377
+ * Mark a task as completed
534
378
  */
535
- createTrigger(trigger: Partial<EventTrigger>): Promise<ApiResponse<EventTrigger>>;
379
+ completeTask(taskId: string): Promise<ApiResponse<Task>>;
536
380
  /**
537
- * Update an existing trigger
381
+ * Delete a task
538
382
  */
539
- updateTrigger(triggerId: string, updates: Partial<EventTrigger>): Promise<ApiResponse<EventTrigger>>;
383
+ deleteTask(taskId: string): Promise<ApiResponse<void>>;
540
384
  /**
541
- * Delete a trigger
385
+ * Get activities for a contact
542
386
  */
543
- deleteTrigger(triggerId: string): Promise<ApiResponse<void>>;
387
+ getContactActivities(contactId: string, params?: {
388
+ page?: number;
389
+ limit?: number;
390
+ type?: string;
391
+ }): Promise<ApiResponse<PaginatedResponse<Activity>>>;
544
392
  /**
545
- * Activate a trigger
393
+ * Get activities for an opportunity/deal
546
394
  */
547
- activateTrigger(triggerId: string): Promise<ApiResponse<EventTrigger>>;
395
+ getOpportunityActivities(opportunityId: string, params?: {
396
+ page?: number;
397
+ limit?: number;
398
+ type?: string;
399
+ }): Promise<ApiResponse<PaginatedResponse<Activity>>>;
548
400
  /**
549
- * Deactivate a trigger
401
+ * Create a new activity
550
402
  */
551
- deactivateTrigger(triggerId: string): Promise<ApiResponse<EventTrigger>>;
403
+ createActivity(activity: Partial<Activity>): Promise<ApiResponse<Activity>>;
552
404
  /**
553
- * Register a local event listener for client-side triggers
554
- * This allows immediate client-side reactions to events
405
+ * Update an existing activity
555
406
  */
556
- on(eventType: TriggerEventType, callback: (data: unknown) => void): void;
407
+ updateActivity(activityId: string, updates: Partial<Activity>): Promise<ApiResponse<Activity>>;
557
408
  /**
558
- * Remove an event listener
409
+ * Delete an activity
559
410
  */
560
- off(eventType: TriggerEventType, callback: (data: unknown) => void): void;
411
+ deleteActivity(activityId: string): Promise<ApiResponse<void>>;
561
412
  /**
562
- * Emit an event (client-side only)
563
- * This will trigger any registered local listeners
413
+ * Log a call activity
564
414
  */
565
- emit(eventType: TriggerEventType, data: unknown): void;
415
+ logCall(data: {
416
+ contactId?: string;
417
+ opportunityId?: string;
418
+ direction: 'inbound' | 'outbound';
419
+ duration?: number;
420
+ outcome?: string;
421
+ notes?: string;
422
+ }): Promise<ApiResponse<Activity>>;
566
423
  /**
567
- * Check if conditions are met for a trigger
568
- * Supports dynamic field evaluation including custom fields and nested paths
424
+ * Log a meeting activity
569
425
  */
570
- private evaluateConditions;
426
+ logMeeting(data: {
427
+ contactId?: string;
428
+ opportunityId?: string;
429
+ title: string;
430
+ duration?: number;
431
+ outcome?: string;
432
+ notes?: string;
433
+ }): Promise<ApiResponse<Activity>>;
571
434
  /**
572
- * Execute actions for a triggered event (client-side preview)
573
- * Note: Actual execution happens on the backend
435
+ * Add a note to a contact or opportunity
574
436
  */
575
- executeActions(trigger: EventTrigger, data: Record<string, unknown>): Promise<void>;
437
+ addNote(data: {
438
+ contactId?: string;
439
+ opportunityId?: string;
440
+ content: string;
441
+ }): Promise<ApiResponse<Activity>>;
576
442
  /**
577
- * Execute a single action
443
+ * Get all email templates
578
444
  */
579
- private executeAction;
445
+ getEmailTemplates(params?: {
446
+ page?: number;
447
+ limit?: number;
448
+ }): Promise<ApiResponse<PaginatedResponse<EmailTemplate>>>;
580
449
  /**
581
- * Execute send email action (via backend API)
450
+ * Get a single email template by ID
582
451
  */
583
- private executeSendEmail;
452
+ getEmailTemplate(templateId: string): Promise<ApiResponse<EmailTemplate>>;
584
453
  /**
585
- * Execute webhook action
454
+ * Create a new email template
586
455
  */
587
- private executeWebhook;
456
+ createEmailTemplate(template: Partial<EmailTemplate>): Promise<ApiResponse<EmailTemplate>>;
457
+ /**
458
+ * Update an email template
459
+ */
460
+ updateEmailTemplate(templateId: string, updates: Partial<EmailTemplate>): Promise<ApiResponse<EmailTemplate>>;
461
+ /**
462
+ * Delete an email template
463
+ */
464
+ deleteEmailTemplate(templateId: string): Promise<ApiResponse<void>>;
465
+ /**
466
+ * Send an email using a template
467
+ */
468
+ sendEmail(data: {
469
+ to: string;
470
+ templateId?: string;
471
+ subject?: string;
472
+ body?: string;
473
+ cc?: string[];
474
+ bcc?: string[];
475
+ variables?: Record<string, unknown>;
476
+ contactId?: string;
477
+ }): Promise<ApiResponse<{
478
+ messageId: string;
479
+ }>>;
480
+ /**
481
+ * Get a contact by email address.
482
+ * Returns the first matching contact from a search query.
483
+ */
484
+ getContactByEmail(email: string): Promise<ApiResponse<PaginatedResponse<Contact>>>;
485
+ /**
486
+ * Get activity timeline for a contact
487
+ */
488
+ getContactActivity(contactId: string, params?: {
489
+ page?: number;
490
+ limit?: number;
491
+ type?: string;
492
+ startDate?: string;
493
+ endDate?: string;
494
+ }): Promise<ApiResponse<PaginatedResponse<Activity>>>;
588
495
  /**
589
- * Execute create task action
496
+ * Get engagement metrics for a contact (via their linked visitor data)
590
497
  */
591
- private executeCreateTask;
498
+ getContactEngagement(contactId: string): Promise<ApiResponse<{
499
+ totalTimeOnSiteSeconds: number;
500
+ averageSessionDurationSeconds: number;
501
+ totalPageViews: number;
502
+ totalSessions: number;
503
+ engagementScore: number;
504
+ lastActiveAt: string;
505
+ }>>;
592
506
  /**
593
- * Execute update contact action
507
+ * Get a full timeline for a contact including events, activities, and opportunities
594
508
  */
595
- private executeUpdateContact;
509
+ getContactTimeline(contactId: string, params?: {
510
+ page?: number;
511
+ limit?: number;
512
+ }): Promise<ApiResponse<PaginatedResponse<{
513
+ type: 'event' | 'activity' | 'opportunity' | 'note';
514
+ title: string;
515
+ description?: string;
516
+ timestamp: string;
517
+ metadata?: Record<string, unknown>;
518
+ }>>>;
596
519
  /**
597
- * Replace variables in a string template
598
- * Supports syntax like {{contact.email}}, {{opportunity.value}}
520
+ * Search contacts with advanced filters
599
521
  */
600
- private replaceVariables;
522
+ searchContacts(query: string, filters?: {
523
+ status?: string;
524
+ lifecycleStage?: string;
525
+ source?: string;
526
+ tags?: string[];
527
+ page?: number;
528
+ limit?: number;
529
+ }): Promise<ApiResponse<PaginatedResponse<Contact>>>;
601
530
  /**
602
- * Get nested value from object using dot notation
603
- * Supports dynamic field access including custom fields
531
+ * List all webhook subscriptions
604
532
  */
605
- private getNestedValue;
533
+ listWebhooks(params?: {
534
+ page?: number;
535
+ limit?: number;
536
+ }): Promise<ApiResponse<PaginatedResponse<{
537
+ _id: string;
538
+ url: string;
539
+ events: string[];
540
+ isActive: boolean;
541
+ createdAt: string;
542
+ }>>>;
543
+ /**
544
+ * Create a new webhook subscription
545
+ */
546
+ createWebhook(data: {
547
+ url: string;
548
+ events: string[];
549
+ secret?: string;
550
+ }): Promise<ApiResponse<{
551
+ _id: string;
552
+ url: string;
553
+ events: string[];
554
+ isActive: boolean;
555
+ }>>;
606
556
  /**
607
- * Extract all available field paths from a data object
608
- * Useful for dynamic field discovery based on platform-specific attributes
609
- * @param obj - The data object to extract fields from
610
- * @param prefix - Internal use for nested paths
611
- * @param maxDepth - Maximum depth to traverse (default: 3)
612
- * @returns Array of field paths (e.g., ['email', 'contact.firstName', 'customFields.industry'])
557
+ * Delete a webhook subscription
613
558
  */
614
- private extractAvailableFields;
559
+ deleteWebhook(webhookId: string): Promise<ApiResponse<void>>;
615
560
  /**
616
- * Get available fields from sample data
617
- * Helps with dynamic field detection for platform-specific attributes
618
- * @param sampleData - Sample data object to analyze
619
- * @returns Array of available field paths
561
+ * Get all event triggers
620
562
  */
621
- getAvailableFields(sampleData: Record<string, unknown>): string[];
563
+ getEventTriggers(): Promise<ApiResponse<EventTrigger[]>>;
622
564
  /**
623
- * Create a simple email trigger
624
- * Helper method for common use case
565
+ * Create a new event trigger
625
566
  */
626
- createEmailTrigger(config: {
627
- name: string;
628
- eventType: TriggerEventType;
629
- to: string;
630
- subject: string;
631
- body: string;
632
- conditions?: TriggerCondition[];
633
- }): Promise<ApiResponse<EventTrigger>>;
567
+ createEventTrigger(trigger: Partial<EventTrigger>): Promise<ApiResponse<EventTrigger>>;
634
568
  /**
635
- * Create a task creation trigger
569
+ * Update an event trigger
636
570
  */
637
- createTaskTrigger(config: {
638
- name: string;
639
- eventType: TriggerEventType;
640
- taskTitle: string;
641
- taskDescription?: string;
642
- priority?: 'low' | 'medium' | 'high' | 'urgent';
643
- dueDays?: number;
644
- conditions?: TriggerCondition[];
645
- }): Promise<ApiResponse<EventTrigger>>;
571
+ updateEventTrigger(triggerId: string, updates: Partial<EventTrigger>): Promise<ApiResponse<EventTrigger>>;
646
572
  /**
647
- * Create a webhook trigger
573
+ * Delete an event trigger
648
574
  */
649
- createWebhookTrigger(config: {
650
- name: string;
651
- eventType: TriggerEventType;
652
- webhookUrl: string;
653
- method?: 'POST' | 'PUT' | 'PATCH';
654
- conditions?: TriggerCondition[];
655
- }): Promise<ApiResponse<EventTrigger>>;
575
+ deleteEventTrigger(triggerId: string): Promise<ApiResponse<void>>;
576
+ }
577
+
578
+ /**
579
+ * Clianta SDK - Type Definitions
580
+ * @see SDK_VERSION in core/config.ts
581
+ */
582
+ interface CliantaConfig {
583
+ /** Project ID (required for config file pattern) */
584
+ projectId?: string;
585
+ /** Backend API endpoint URL */
586
+ apiEndpoint?: string;
587
+ /** Auth token for server-side API access (user JWT) */
588
+ authToken?: string;
589
+ /** Workspace API key for server-to-server access (use instead of authToken for external apps) */
590
+ apiKey?: string;
591
+ /** Enable debug mode with verbose logging */
592
+ debug?: boolean;
593
+ /** Automatically track page views on load and navigation */
594
+ autoPageView?: boolean;
595
+ /** Plugins to enable (default: all core plugins) */
596
+ plugins?: PluginName[];
597
+ /** Session timeout in milliseconds (default: 30 minutes) */
598
+ sessionTimeout?: number;
599
+ /** Maximum events to batch before sending (default: 10) */
600
+ batchSize?: number;
601
+ /** Interval to flush events in milliseconds (default: 5000) */
602
+ flushInterval?: number;
603
+ /** Consent configuration */
604
+ consent?: ConsentConfig;
605
+ /** Cookie domain for cross-subdomain tracking */
606
+ cookieDomain?: string;
607
+ /** Use cookies instead of localStorage for visitor ID */
608
+ useCookies?: boolean;
609
+ /** Cookie-less mode: use sessionStorage only (no persistent storage) */
610
+ cookielessMode?: boolean;
611
+ /** Queue persistence mode: 'session' (default), 'local' (survives browser restart), 'none' */
612
+ persistMode?: 'session' | 'local' | 'none';
613
+ }
614
+ type PluginName = 'pageView' | 'forms' | 'scroll' | 'clicks' | 'engagement' | 'downloads' | 'exitIntent' | 'errors' | 'performance' | 'popupForms';
615
+ interface ConsentConfig {
616
+ /** Default consent state before user action */
617
+ defaultConsent?: ConsentState;
618
+ /** Wait for consent before tracking anything */
619
+ waitForConsent?: boolean;
620
+ /** Storage key for consent state */
621
+ storageKey?: string;
622
+ /** Anonymous mode: track without visitor ID until explicit consent */
623
+ anonymousMode?: boolean;
624
+ }
625
+ interface ConsentState {
626
+ /** Consent for analytics/essential tracking */
627
+ analytics?: boolean;
628
+ /** Consent for marketing/advertising tracking */
629
+ marketing?: boolean;
630
+ /** Consent for personalization */
631
+ personalization?: boolean;
632
+ }
633
+ type EventType = 'page_view' | 'button_click' | 'form_view' | 'form_submit' | 'form_interaction' | 'scroll_depth' | 'engagement' | 'download' | 'exit_intent' | 'error' | 'performance' | 'time_on_page' | 'custom';
634
+ interface TrackingEvent {
635
+ /** Workspace/project ID */
636
+ workspaceId: string;
637
+ /** Anonymous visitor identifier */
638
+ visitorId: string;
639
+ /** Session identifier */
640
+ sessionId: string;
641
+ /** Event type category */
642
+ eventType: EventType;
643
+ /** Human-readable event name */
644
+ eventName: string;
645
+ /** Current page URL */
646
+ url: string;
647
+ /** Referrer URL */
648
+ referrer?: string;
649
+ /** Event properties/metadata */
650
+ properties: Record<string, unknown>;
651
+ /** Device information */
652
+ device: DeviceInfo;
653
+ /** UTM parameters */
654
+ utm?: UTMParams;
655
+ /** ISO timestamp */
656
+ timestamp: string;
657
+ /** SDK version */
658
+ sdkVersion: string;
659
+ }
660
+ interface DeviceInfo {
661
+ userAgent: string;
662
+ screen: string;
663
+ language: string;
664
+ timezone?: string;
665
+ }
666
+ interface UTMParams {
667
+ utmSource?: string;
668
+ utmMedium?: string;
669
+ utmCampaign?: string;
670
+ utmTerm?: string;
671
+ utmContent?: string;
672
+ }
673
+ interface UserTraits {
674
+ firstName?: string;
675
+ lastName?: string;
676
+ company?: string;
677
+ phone?: string;
678
+ title?: string;
679
+ [key: string]: unknown;
680
+ }
681
+ interface Plugin {
682
+ /** Unique plugin name */
683
+ name: PluginName;
684
+ /** Initialize the plugin (can be sync or async) */
685
+ init(tracker: TrackerCore): void | Promise<void>;
686
+ /** Cleanup when plugin is disabled */
687
+ destroy?(): void;
688
+ }
689
+ interface TrackerCore {
690
+ /** Track a custom event */
691
+ track(eventType: EventType | string, eventName: string, properties?: Record<string, unknown>): void;
692
+ /** Identify a visitor — returns the contactId if successful */
693
+ identify(email: string, traits?: UserTraits): Promise<string | null>;
694
+ /** Track a page view */
695
+ page(name?: string, properties?: Record<string, unknown>): void;
696
+ /** Update consent state */
697
+ consent(state: ConsentState): void;
698
+ /** Toggle debug mode */
699
+ debug(enabled: boolean): void;
700
+ /** Get visitor ID */
701
+ getVisitorId(): string;
702
+ /** Get session ID */
703
+ getSessionId(): string;
704
+ /** Force flush event queue */
705
+ flush(): Promise<void>;
706
+ /** Reset visitor (for logout) */
707
+ reset(): void;
708
+ /** Get current configuration */
709
+ getConfig(): CliantaConfig;
710
+ /** Get workspace ID */
711
+ getWorkspaceId(): string;
712
+ /** Delete all stored user data (GDPR right-to-erasure) */
713
+ deleteData(): void;
714
+ /** Get current consent state */
715
+ getConsentState(): ConsentState;
716
+ /** Get the current visitor's profile from the CRM */
717
+ getVisitorProfile(): Promise<VisitorProfile | null>;
718
+ /** Get the current visitor's recent activity */
719
+ getVisitorActivity(options?: VisitorActivityOptions): Promise<{
720
+ data: VisitorActivity[];
721
+ pagination: {
722
+ page: number;
723
+ limit: number;
724
+ total: number;
725
+ pages: number;
726
+ };
727
+ } | null>;
728
+ /** Get a summarized journey timeline for the current visitor */
729
+ getVisitorTimeline(): Promise<VisitorTimeline | null>;
730
+ /** Get engagement metrics for the current visitor */
731
+ getVisitorEngagement(): Promise<EngagementMetrics | null>;
732
+ /** Send a server-side inbound event (requires apiKey in config) */
733
+ sendEvent(payload: InboundEventPayload): Promise<InboundEventResult>;
734
+ }
735
+ interface Contact {
736
+ _id?: string;
737
+ workspaceId: string;
738
+ email: string;
739
+ firstName?: string;
740
+ lastName?: string;
741
+ company?: string;
742
+ jobTitle?: string;
743
+ phone?: string;
744
+ status?: 'lead' | 'contact' | 'customer';
745
+ lifecycleStage?: 'subscriber' | 'lead' | 'mql' | 'sql' | 'opportunity' | 'customer' | 'evangelist';
746
+ source?: string;
747
+ tags?: string[];
748
+ leadScore?: number;
749
+ customFields?: Record<string, unknown>;
750
+ companyId?: string;
751
+ assignedTo?: string;
752
+ createdAt?: string;
753
+ updatedAt?: string;
754
+ }
755
+ interface Company {
756
+ _id?: string;
757
+ workspaceId: string;
758
+ name: string;
759
+ industry?: string;
760
+ website?: string;
761
+ phone?: string;
762
+ address?: {
763
+ street?: string;
764
+ city?: string;
765
+ state?: string;
766
+ country?: string;
767
+ postalCode?: string;
768
+ };
769
+ companySize?: string;
770
+ annualRevenue?: number;
771
+ status?: 'prospect' | 'active' | 'inactive' | 'churned';
772
+ accountTier?: 'enterprise' | 'mid-market' | 'smb';
773
+ isTargetAccount?: boolean;
774
+ tags?: string[];
775
+ customFields?: Record<string, unknown>;
776
+ assignedTo?: string;
777
+ createdAt?: string;
778
+ updatedAt?: string;
779
+ }
780
+ interface Pipeline {
781
+ _id?: string;
782
+ workspaceId: string;
783
+ name: string;
784
+ description?: string;
785
+ stages: PipelineStage[];
786
+ isDefault?: boolean;
787
+ isActive?: boolean;
788
+ createdAt?: string;
789
+ updatedAt?: string;
656
790
  }
657
-
658
- /**
659
- * Clianta SDK - CRM API Client
660
- * @see SDK_VERSION in core/config.ts
661
- */
662
-
663
- /**
664
- * CRM API Client for managing contacts and opportunities
665
- */
666
- declare class CRMClient {
667
- private apiEndpoint;
668
- private workspaceId;
669
- private authToken?;
670
- triggers: EventTriggersManager;
671
- constructor(apiEndpoint: string, workspaceId: string, authToken?: string);
672
- /**
673
- * Set authentication token for API requests
674
- */
675
- setAuthToken(token: string): void;
676
- /**
677
- * Validate required parameter exists
678
- * @throws {Error} if value is null/undefined or empty string
679
- */
680
- private validateRequired;
681
- /**
682
- * Make authenticated API request
683
- */
684
- private request;
685
- /**
686
- * Get all contacts with pagination
687
- */
688
- getContacts(params?: {
689
- page?: number;
690
- limit?: number;
691
- search?: string;
692
- status?: string;
693
- }): Promise<ApiResponse<PaginatedResponse<Contact>>>;
694
- /**
695
- * Get a single contact by ID
696
- */
697
- getContact(contactId: string): Promise<ApiResponse<Contact>>;
698
- /**
699
- * Create a new contact
700
- */
701
- createContact(contact: Partial<Contact>): Promise<ApiResponse<Contact>>;
702
- /**
703
- * Update an existing contact
704
- */
705
- updateContact(contactId: string, updates: Partial<Contact>): Promise<ApiResponse<Contact>>;
706
- /**
707
- * Delete a contact
708
- */
709
- deleteContact(contactId: string): Promise<ApiResponse<void>>;
710
- /**
711
- * Get all opportunities with pagination
712
- */
713
- getOpportunities(params?: {
714
- page?: number;
715
- limit?: number;
716
- pipelineId?: string;
717
- stageId?: string;
718
- }): Promise<ApiResponse<PaginatedResponse<Opportunity>>>;
719
- /**
720
- * Get a single opportunity by ID
721
- */
722
- getOpportunity(opportunityId: string): Promise<ApiResponse<Opportunity>>;
723
- /**
724
- * Create a new opportunity
725
- */
726
- createOpportunity(opportunity: Partial<Opportunity>): Promise<ApiResponse<Opportunity>>;
727
- /**
728
- * Update an existing opportunity
729
- */
730
- updateOpportunity(opportunityId: string, updates: Partial<Opportunity>): Promise<ApiResponse<Opportunity>>;
731
- /**
732
- * Delete an opportunity
733
- */
734
- deleteOpportunity(opportunityId: string): Promise<ApiResponse<void>>;
735
- /**
736
- * Move opportunity to a different stage
737
- */
738
- moveOpportunity(opportunityId: string, stageId: string): Promise<ApiResponse<Opportunity>>;
739
- /**
740
- * Get all companies with pagination
741
- */
742
- getCompanies(params?: {
743
- page?: number;
744
- limit?: number;
745
- search?: string;
746
- status?: string;
747
- industry?: string;
748
- }): Promise<ApiResponse<PaginatedResponse<Company>>>;
749
- /**
750
- * Get a single company by ID
751
- */
752
- getCompany(companyId: string): Promise<ApiResponse<Company>>;
753
- /**
754
- * Create a new company
755
- */
756
- createCompany(company: Partial<Company>): Promise<ApiResponse<Company>>;
757
- /**
758
- * Update an existing company
759
- */
760
- updateCompany(companyId: string, updates: Partial<Company>): Promise<ApiResponse<Company>>;
761
- /**
762
- * Delete a company
763
- */
764
- deleteCompany(companyId: string): Promise<ApiResponse<void>>;
765
- /**
766
- * Get contacts belonging to a company
767
- */
768
- getCompanyContacts(companyId: string, params?: {
769
- page?: number;
770
- limit?: number;
771
- }): Promise<ApiResponse<PaginatedResponse<Contact>>>;
772
- /**
773
- * Get deals/opportunities belonging to a company
774
- */
775
- getCompanyDeals(companyId: string, params?: {
776
- page?: number;
777
- limit?: number;
778
- }): Promise<ApiResponse<PaginatedResponse<Opportunity>>>;
779
- /**
780
- * Get all pipelines
781
- */
782
- getPipelines(): Promise<ApiResponse<Pipeline[]>>;
783
- /**
784
- * Get a single pipeline by ID
785
- */
786
- getPipeline(pipelineId: string): Promise<ApiResponse<Pipeline>>;
791
+ interface PipelineStage {
792
+ _id?: string;
793
+ name: string;
794
+ order: number;
795
+ probability?: number;
796
+ color?: string;
797
+ rottenDays?: number;
798
+ }
799
+ interface Task {
800
+ _id?: string;
801
+ workspaceId: string;
802
+ title: string;
803
+ description?: string;
804
+ status?: 'pending' | 'in_progress' | 'completed' | 'cancelled';
805
+ priority?: 'low' | 'medium' | 'high' | 'urgent';
806
+ dueDate?: string;
807
+ reminderDate?: string;
808
+ completedAt?: string;
809
+ tags?: string[];
810
+ relatedContactId?: string;
811
+ relatedCompanyId?: string;
812
+ relatedOpportunityId?: string;
813
+ assignedTo?: string;
814
+ createdAt?: string;
815
+ updatedAt?: string;
816
+ }
817
+ interface Activity {
818
+ _id?: string;
819
+ workspaceId: string;
820
+ type: 'call' | 'email' | 'meeting' | 'note' | 'task' | 'other';
821
+ title: string;
822
+ description?: string;
823
+ direction?: 'inbound' | 'outbound';
824
+ duration?: number;
825
+ outcome?: string;
826
+ emailSubject?: string;
827
+ emailBody?: string;
828
+ metadata?: Record<string, unknown>;
829
+ contactId?: string;
830
+ companyId?: string;
831
+ opportunityId?: string;
832
+ userId?: string;
833
+ createdAt?: string;
834
+ updatedAt?: string;
835
+ }
836
+ interface Opportunity {
837
+ _id?: string;
838
+ workspaceId: string;
839
+ contactId: string;
840
+ companyId?: string;
841
+ pipelineId: string;
842
+ stageId: string;
843
+ title: string;
844
+ value?: number;
845
+ currency?: string;
846
+ probability?: number;
847
+ expectedCloseDate?: string;
848
+ status?: 'open' | 'won' | 'lost';
849
+ priority?: 'low' | 'medium' | 'high';
850
+ lostReason?: string;
851
+ customFields?: Record<string, unknown>;
852
+ assignedTo?: string;
853
+ createdAt?: string;
854
+ updatedAt?: string;
855
+ }
856
+ interface ApiResponse<T> {
857
+ success: boolean;
858
+ data?: T;
859
+ error?: string;
860
+ status: number;
861
+ }
862
+ interface PaginatedResponse<T> {
863
+ data: T[];
864
+ pagination: {
865
+ page: number;
866
+ limit: number;
867
+ total: number;
868
+ pages: number;
869
+ };
870
+ }
871
+ type TriggerEventType = 'contact.created' | 'contact.updated' | 'contact.deleted' | 'opportunity.created' | 'opportunity.updated' | 'opportunity.stage_changed' | 'opportunity.won' | 'opportunity.lost' | 'task.created' | 'task.completed' | 'task.overdue' | 'activity.logged' | 'form.submitted';
872
+ interface TriggerCondition {
787
873
  /**
788
- * Create a new pipeline
874
+ * Field to check - supports dynamic field names including custom fields
875
+ * Examples: 'status', 'lifecycleStage', 'leadScore', 'customFields.industry'
876
+ * Use dot notation for nested fields: 'contact.email', 'customFields.accountType'
789
877
  */
790
- createPipeline(pipeline: Partial<Pipeline>): Promise<ApiResponse<Pipeline>>;
878
+ field: string;
879
+ /** Operator for comparison */
880
+ operator: 'equals' | 'not_equals' | 'contains' | 'greater_than' | 'less_than' | 'in' | 'not_in';
881
+ /** Value to compare against */
882
+ value: unknown;
883
+ }
884
+ interface EmailTemplate {
885
+ /** Template ID */
886
+ _id?: string;
887
+ /** Template name */
888
+ name: string;
889
+ /** Email subject line (supports variables) */
890
+ subject: string;
891
+ /** Email body (supports HTML and variables) */
892
+ body: string;
893
+ /** Variables available in this template */
894
+ variables?: string[];
895
+ /** Sender email address */
896
+ fromEmail?: string;
897
+ /** Sender name */
898
+ fromName?: string;
899
+ }
900
+ interface EmailAction {
901
+ /** Action type identifier */
902
+ type: 'send_email';
903
+ /** Email template ID or inline template */
904
+ templateId?: string;
905
+ /** Inline email subject (if not using template) */
906
+ subject?: string;
907
+ /** Inline email body (if not using template) */
908
+ body?: string;
909
+ /** Recipient email (supports variables like {{contact.email}}) */
910
+ to: string;
911
+ /** CC recipients */
912
+ cc?: string[];
913
+ /** BCC recipients */
914
+ bcc?: string[];
915
+ /** Sender email */
916
+ from?: string;
917
+ /** Delay in minutes before sending */
918
+ delayMinutes?: number;
919
+ }
920
+ interface WebhookAction {
921
+ /** Action type identifier */
922
+ type: 'webhook';
923
+ /** Webhook URL to call */
924
+ url: string;
925
+ /** HTTP method */
926
+ method: 'POST' | 'PUT' | 'PATCH';
927
+ /** Custom headers */
928
+ headers?: Record<string, string>;
929
+ /** Request body template (supports variables) */
930
+ body?: string;
931
+ }
932
+ interface TaskAction {
933
+ /** Action type identifier */
934
+ type: 'create_task';
935
+ /** Task title (supports variables) */
936
+ title: string;
937
+ /** Task description */
938
+ description?: string;
939
+ /** Task priority */
940
+ priority?: 'low' | 'medium' | 'high' | 'urgent';
941
+ /** Due date in days from trigger */
942
+ dueDays?: number;
943
+ /** Assign to user ID */
944
+ assignedTo?: string;
945
+ }
946
+ interface ContactUpdateAction {
947
+ /** Action type identifier */
948
+ type: 'update_contact';
949
+ /** Fields to update */
950
+ updates: Partial<Contact>;
951
+ }
952
+ type TriggerAction = EmailAction | WebhookAction | TaskAction | ContactUpdateAction;
953
+ interface EventTrigger {
954
+ /** Trigger ID */
955
+ _id?: string;
956
+ /** Workspace ID */
957
+ workspaceId: string;
958
+ /** Trigger name */
959
+ name: string;
960
+ /** Description of what this trigger does */
961
+ description?: string;
962
+ /** Event type that activates this trigger */
963
+ eventType: TriggerEventType;
964
+ /** Conditions that must be met for trigger to fire */
965
+ conditions?: TriggerCondition[];
966
+ /** Actions to execute when trigger fires */
967
+ actions: TriggerAction[];
968
+ /** Whether this trigger is active */
969
+ isActive?: boolean;
970
+ /** Created timestamp */
971
+ createdAt?: string;
972
+ /** Updated timestamp */
973
+ updatedAt?: string;
974
+ }
975
+ interface TriggerExecution {
976
+ /** Execution ID */
977
+ _id?: string;
978
+ /** Trigger ID that was executed */
979
+ triggerId: string;
980
+ /** Event that triggered the execution */
981
+ eventType: TriggerEventType;
982
+ /** Entity ID that triggered the event */
983
+ entityId: string;
984
+ /** Execution status */
985
+ status: 'pending' | 'success' | 'failed';
986
+ /** Error message if failed */
987
+ error?: string;
988
+ /** Actions executed */
989
+ actionsExecuted: number;
990
+ /** Execution timestamp */
991
+ executedAt: string;
992
+ }
993
+ interface VisitorProfile {
994
+ visitorId: string;
995
+ contactId?: string;
996
+ email?: string;
997
+ firstName?: string;
998
+ lastName?: string;
999
+ company?: string;
1000
+ jobTitle?: string;
1001
+ phone?: string;
1002
+ status?: string;
1003
+ lifecycleStage?: string;
1004
+ tags?: string[];
1005
+ leadScore?: number;
1006
+ firstSeen?: string;
1007
+ lastSeen?: string;
1008
+ sessionCount?: number;
1009
+ pageViewCount?: number;
1010
+ totalTimeSpent?: number;
1011
+ customFields?: Record<string, unknown>;
1012
+ }
1013
+ interface VisitorActivity {
1014
+ _id?: string;
1015
+ eventType: string;
1016
+ eventName: string;
1017
+ url: string;
1018
+ properties?: Record<string, unknown>;
1019
+ timestamp: string;
1020
+ }
1021
+ interface VisitorTimeline {
1022
+ visitorId: string;
1023
+ contactId?: string;
1024
+ firstSeen: string;
1025
+ lastSeen: string;
1026
+ totalSessions: number;
1027
+ totalPageViews: number;
1028
+ totalEvents: number;
1029
+ totalTimeSpentSeconds: number;
1030
+ averageSessionDurationSeconds: number;
1031
+ topPages: Array<{
1032
+ url: string;
1033
+ views: number;
1034
+ avgTimeSeconds?: number;
1035
+ }>;
1036
+ recentActivities: VisitorActivity[];
1037
+ devices: Array<{
1038
+ userAgent: string;
1039
+ lastSeen: string;
1040
+ }>;
1041
+ }
1042
+ interface EngagementMetrics {
1043
+ visitorId: string;
1044
+ totalTimeOnSiteSeconds: number;
1045
+ averageSessionDurationSeconds: number;
1046
+ totalPageViews: number;
1047
+ totalSessions: number;
1048
+ engagementScore: number;
1049
+ bounceRate: number;
1050
+ lastActiveAt: string;
1051
+ topEvents: Array<{
1052
+ eventType: string;
1053
+ count: number;
1054
+ }>;
1055
+ }
1056
+ interface VisitorActivityOptions {
1057
+ page?: number;
1058
+ limit?: number;
1059
+ eventType?: string;
1060
+ startDate?: string;
1061
+ endDate?: string;
1062
+ }
1063
+ interface ContactTimelineOptions {
1064
+ page?: number;
1065
+ limit?: number;
1066
+ includeEvents?: boolean;
1067
+ includeActivities?: boolean;
1068
+ includeOpportunities?: boolean;
1069
+ }
1070
+
1071
+ /**
1072
+ * Main Clianta Tracker Class
1073
+ */
1074
+ declare class Tracker implements TrackerCore {
1075
+ private workspaceId;
1076
+ private config;
1077
+ private transport;
1078
+ private queue;
1079
+ private plugins;
1080
+ private visitorId;
1081
+ private sessionId;
1082
+ private isInitialized;
1083
+ private consentManager;
1084
+ /** contactId after a successful identify() call */
1085
+ private contactId;
1086
+ /** Pending identify retry on next flush */
1087
+ private pendingIdentify;
1088
+ /** Registered event schemas for validation */
1089
+ private eventSchemas;
1090
+ constructor(workspaceId: string, userConfig?: CliantaConfig);
791
1091
  /**
792
- * Update an existing pipeline
1092
+ * Create visitor ID based on storage mode
793
1093
  */
794
- updatePipeline(pipelineId: string, updates: Partial<Pipeline>): Promise<ApiResponse<Pipeline>>;
1094
+ private createVisitorId;
795
1095
  /**
796
- * Delete a pipeline
1096
+ * Create session ID
797
1097
  */
798
- deletePipeline(pipelineId: string): Promise<ApiResponse<void>>;
1098
+ private createSessionId;
799
1099
  /**
800
- * Get all tasks with pagination
1100
+ * Handle consent state changes
801
1101
  */
802
- getTasks(params?: {
803
- page?: number;
804
- limit?: number;
805
- status?: string;
806
- priority?: string;
807
- contactId?: string;
808
- companyId?: string;
809
- opportunityId?: string;
810
- }): Promise<ApiResponse<PaginatedResponse<Task>>>;
1102
+ private onConsentChange;
811
1103
  /**
812
- * Get a single task by ID
1104
+ * Initialize enabled plugins
1105
+ * Handles both sync and async plugin init methods
813
1106
  */
814
- getTask(taskId: string): Promise<ApiResponse<Task>>;
1107
+ private initPlugins;
815
1108
  /**
816
- * Create a new task
1109
+ * Track a custom event
817
1110
  */
818
- createTask(task: Partial<Task>): Promise<ApiResponse<Task>>;
1111
+ track(eventType: EventType | string, eventName: string, properties?: Record<string, unknown>): void;
819
1112
  /**
820
- * Update an existing task
1113
+ * Track a page view
821
1114
  */
822
- updateTask(taskId: string, updates: Partial<Task>): Promise<ApiResponse<Task>>;
1115
+ page(name?: string, properties?: Record<string, unknown>): void;
823
1116
  /**
824
- * Mark a task as completed
1117
+ * Identify a visitor.
1118
+ * Links the anonymous visitorId to a CRM contact and returns the contactId.
1119
+ * All subsequent track() calls will include the contactId automatically.
825
1120
  */
826
- completeTask(taskId: string): Promise<ApiResponse<Task>>;
1121
+ identify(email: string, traits?: UserTraits): Promise<string | null>;
827
1122
  /**
828
- * Delete a task
1123
+ * Send a server-side inbound event via the API key endpoint.
1124
+ * Convenience proxy to CRMClient.sendEvent() — requires apiKey in config.
829
1125
  */
830
- deleteTask(taskId: string): Promise<ApiResponse<void>>;
1126
+ sendEvent(payload: InboundEventPayload): Promise<InboundEventResult>;
831
1127
  /**
832
- * Get activities for a contact
1128
+ * Get the current visitor's profile from the CRM.
1129
+ * Returns visitor data and linked contact info if identified.
1130
+ * Only returns data for the current visitor (privacy-safe for frontend).
833
1131
  */
834
- getContactActivities(contactId: string, params?: {
835
- page?: number;
836
- limit?: number;
837
- type?: string;
838
- }): Promise<ApiResponse<PaginatedResponse<Activity>>>;
1132
+ getVisitorProfile(): Promise<VisitorProfile | null>;
839
1133
  /**
840
- * Get activities for an opportunity/deal
1134
+ * Get the current visitor's recent activity/events.
1135
+ * Returns paginated list of tracking events for this visitor.
841
1136
  */
842
- getOpportunityActivities(opportunityId: string, params?: {
843
- page?: number;
844
- limit?: number;
845
- type?: string;
846
- }): Promise<ApiResponse<PaginatedResponse<Activity>>>;
1137
+ getVisitorActivity(options?: VisitorActivityOptions): Promise<{
1138
+ data: VisitorActivity[];
1139
+ pagination: {
1140
+ page: number;
1141
+ limit: number;
1142
+ total: number;
1143
+ pages: number;
1144
+ };
1145
+ } | null>;
847
1146
  /**
848
- * Create a new activity
1147
+ * Get a summarized journey timeline for the current visitor.
1148
+ * Includes top pages, sessions, time spent, and recent activities.
849
1149
  */
850
- createActivity(activity: Partial<Activity>): Promise<ApiResponse<Activity>>;
1150
+ getVisitorTimeline(): Promise<VisitorTimeline | null>;
851
1151
  /**
852
- * Update an existing activity
1152
+ * Get engagement metrics for the current visitor.
1153
+ * Includes time on site, page views, bounce rate, and engagement score.
853
1154
  */
854
- updateActivity(activityId: string, updates: Partial<Activity>): Promise<ApiResponse<Activity>>;
1155
+ getVisitorEngagement(): Promise<EngagementMetrics | null>;
855
1156
  /**
856
- * Delete an activity
1157
+ * Retry pending identify call
857
1158
  */
858
- deleteActivity(activityId: string): Promise<ApiResponse<void>>;
1159
+ private retryPendingIdentify;
859
1160
  /**
860
- * Log a call activity
1161
+ * Update consent state
861
1162
  */
862
- logCall(data: {
863
- contactId?: string;
864
- opportunityId?: string;
865
- direction: 'inbound' | 'outbound';
866
- duration?: number;
867
- outcome?: string;
868
- notes?: string;
869
- }): Promise<ApiResponse<Activity>>;
1163
+ consent(state: ConsentState): void;
870
1164
  /**
871
- * Log a meeting activity
1165
+ * Get current consent state
872
1166
  */
873
- logMeeting(data: {
874
- contactId?: string;
875
- opportunityId?: string;
876
- title: string;
877
- duration?: number;
878
- outcome?: string;
879
- notes?: string;
880
- }): Promise<ApiResponse<Activity>>;
1167
+ getConsentState(): ConsentState;
881
1168
  /**
882
- * Add a note to a contact or opportunity
1169
+ * Toggle debug mode
883
1170
  */
884
- addNote(data: {
885
- contactId?: string;
886
- opportunityId?: string;
887
- content: string;
888
- }): Promise<ApiResponse<Activity>>;
1171
+ debug(enabled: boolean): void;
889
1172
  /**
890
- * Get all email templates
1173
+ * Register a schema for event validation.
1174
+ * When debug mode is enabled, events will be validated against registered schemas.
1175
+ *
1176
+ * @example
1177
+ * tracker.registerEventSchema('purchase', {
1178
+ * productId: 'string',
1179
+ * price: 'number',
1180
+ * quantity: 'number',
1181
+ * });
891
1182
  */
892
- getEmailTemplates(params?: {
893
- page?: number;
894
- limit?: number;
895
- }): Promise<ApiResponse<PaginatedResponse<EmailTemplate>>>;
1183
+ registerEventSchema(eventType: string, schema: Record<string, 'string' | 'number' | 'boolean' | 'object' | 'array'>): void;
896
1184
  /**
897
- * Get a single email template by ID
1185
+ * Validate event properties against a registered schema (debug mode only)
898
1186
  */
899
- getEmailTemplate(templateId: string): Promise<ApiResponse<EmailTemplate>>;
1187
+ private validateEventSchema;
900
1188
  /**
901
- * Create a new email template
1189
+ * Get visitor ID
902
1190
  */
903
- createEmailTemplate(template: Partial<EmailTemplate>): Promise<ApiResponse<EmailTemplate>>;
1191
+ getVisitorId(): string;
904
1192
  /**
905
- * Update an email template
1193
+ * Get session ID
906
1194
  */
907
- updateEmailTemplate(templateId: string, updates: Partial<EmailTemplate>): Promise<ApiResponse<EmailTemplate>>;
1195
+ getSessionId(): string;
908
1196
  /**
909
- * Delete an email template
1197
+ * Get workspace ID
910
1198
  */
911
- deleteEmailTemplate(templateId: string): Promise<ApiResponse<void>>;
1199
+ getWorkspaceId(): string;
912
1200
  /**
913
- * Send an email using a template
1201
+ * Get current configuration
914
1202
  */
915
- sendEmail(data: {
916
- to: string;
917
- templateId?: string;
918
- subject?: string;
919
- body?: string;
920
- cc?: string[];
921
- bcc?: string[];
922
- variables?: Record<string, unknown>;
923
- contactId?: string;
924
- }): Promise<ApiResponse<{
925
- messageId: string;
926
- }>>;
1203
+ getConfig(): CliantaConfig;
927
1204
  /**
928
- * Get all event triggers
1205
+ * Force flush event queue
929
1206
  */
930
- getEventTriggers(): Promise<ApiResponse<EventTrigger[]>>;
1207
+ flush(): Promise<void>;
931
1208
  /**
932
- * Create a new event trigger
1209
+ * Reset visitor and session (for logout)
933
1210
  */
934
- createEventTrigger(trigger: Partial<EventTrigger>): Promise<ApiResponse<EventTrigger>>;
1211
+ reset(): void;
935
1212
  /**
936
- * Update an event trigger
1213
+ * Delete all stored user data (GDPR right-to-erasure)
937
1214
  */
938
- updateEventTrigger(triggerId: string, updates: Partial<EventTrigger>): Promise<ApiResponse<EventTrigger>>;
1215
+ deleteData(): void;
939
1216
  /**
940
- * Delete an event trigger
1217
+ * Destroy tracker and cleanup
941
1218
  */
942
- deleteEventTrigger(triggerId: string): Promise<ApiResponse<void>>;
1219
+ destroy(): Promise<void>;
943
1220
  }
944
1221
 
945
1222
  /**
@@ -1038,7 +1315,7 @@ interface StoredConsent {
1038
1315
  */
1039
1316
 
1040
1317
  /** SDK Version */
1041
- declare const SDK_VERSION = "1.3.0";
1318
+ declare const SDK_VERSION = "1.4.0";
1042
1319
 
1043
1320
  /**
1044
1321
  * Clianta SDK
@@ -1073,4 +1350,4 @@ declare const SDK_VERSION = "1.3.0";
1073
1350
  declare function clianta(workspaceId: string, config?: CliantaConfig): TrackerCore;
1074
1351
 
1075
1352
  export { CRMClient, ConsentManager, EventTriggersManager, SDK_VERSION, Tracker, clianta, clianta as default };
1076
- export type { Activity, ApiResponse, CliantaConfig, Company, ConsentChangeCallback, ConsentConfig, ConsentManagerConfig, ConsentState, Contact, ContactUpdateAction, EmailAction, EmailTemplate, EventTrigger, EventType, Opportunity, PaginatedResponse, Pipeline, PipelineStage, Plugin, PluginName, StoredConsent, Task, TaskAction, TrackerCore, TrackingEvent, TriggerAction, TriggerCondition, TriggerEventType, TriggerExecution, UserTraits, WebhookAction };
1353
+ export type { Activity, ApiResponse, CliantaConfig, Company, ConsentChangeCallback, ConsentConfig, ConsentManagerConfig, ConsentState, Contact, ContactTimelineOptions, ContactUpdateAction, EmailAction, EmailTemplate, EngagementMetrics, EventTrigger, EventType, InboundEventPayload, InboundEventResult, InboundEventType, Opportunity, PaginatedResponse, Pipeline, PipelineStage, Plugin, PluginName, StoredConsent, Task, TaskAction, TrackerCore, TrackingEvent, TriggerAction, TriggerCondition, TriggerEventType, TriggerExecution, UserTraits, VisitorActivity, VisitorActivityOptions, VisitorProfile, VisitorTimeline, WebhookAction };