@clianta/sdk 1.5.0 → 1.6.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/vue.d.ts CHANGED
@@ -86,6 +86,63 @@ interface ConsentState {
86
86
  personalization?: boolean;
87
87
  }
88
88
  type EventType = 'page_view' | 'button_click' | 'form_view' | 'form_submit' | 'form_interaction' | 'scroll_depth' | 'engagement' | 'download' | 'exit_intent' | 'error' | 'performance' | 'time_on_page' | 'custom';
89
+ interface TrackingEvent {
90
+ /** Workspace/project ID */
91
+ workspaceId: string;
92
+ /** Anonymous visitor identifier */
93
+ visitorId: string;
94
+ /** Session identifier */
95
+ sessionId: string;
96
+ /** Event type category */
97
+ eventType: EventType;
98
+ /** Human-readable event name */
99
+ eventName: string;
100
+ /** Current page URL */
101
+ url: string;
102
+ /** Referrer URL */
103
+ referrer?: string;
104
+ /** Event properties/metadata */
105
+ properties: Record<string, unknown>;
106
+ /** Device information */
107
+ device: DeviceInfo;
108
+ /** UTM parameters */
109
+ utm?: UTMParams;
110
+ /** ISO timestamp */
111
+ timestamp: string;
112
+ /** SDK version */
113
+ sdkVersion: string;
114
+ }
115
+ interface DeviceInfo {
116
+ userAgent: string;
117
+ screen: string;
118
+ language: string;
119
+ timezone?: string;
120
+ }
121
+ interface UTMParams {
122
+ utmSource?: string;
123
+ utmMedium?: string;
124
+ utmCampaign?: string;
125
+ utmTerm?: string;
126
+ utmContent?: string;
127
+ }
128
+ interface GroupTraits {
129
+ /** Company/account name */
130
+ name?: string;
131
+ /** Industry */
132
+ industry?: string;
133
+ /** Company size */
134
+ employees?: number;
135
+ /** Annual revenue */
136
+ revenue?: number;
137
+ /** Company website */
138
+ website?: string;
139
+ /** Company plan/tier */
140
+ plan?: string;
141
+ /** Additional custom properties */
142
+ [key: string]: unknown;
143
+ }
144
+ /** Event middleware function — intercept or transform events before they are sent */
145
+ type MiddlewareFn = (event: TrackingEvent, next: () => void) => void;
89
146
  interface UserTraits {
90
147
  firstName?: string;
91
148
  lastName?: string;
@@ -121,6 +178,18 @@ interface TrackerCore {
121
178
  deleteData(): void;
122
179
  /** Get current consent state */
123
180
  getConsentState(): ConsentState;
181
+ /** Associate the current visitor with a group (company/account) */
182
+ group(groupId: string, traits?: GroupTraits): void;
183
+ /** Merge two visitor identities (e.g., anonymous → logged-in) */
184
+ alias(newId: string, previousId?: string): Promise<boolean>;
185
+ /** Track a screen view (for mobile-first PWAs and SPAs) */
186
+ screen(name: string, properties?: Record<string, unknown>): void;
187
+ /** Register event middleware to intercept/transform events before sending */
188
+ use(middleware: MiddlewareFn): void;
189
+ /** Register a callback to be invoked when the SDK is fully initialized */
190
+ onReady(callback: () => void): void;
191
+ /** Check if the SDK is fully initialized and ready */
192
+ isReady(): boolean;
124
193
  /** Get the current visitor's profile from the CRM */
125
194
  getVisitorProfile(): Promise<VisitorProfile | null>;
126
195
  /** Get the current visitor's recent activity */
@@ -139,6 +208,16 @@ interface TrackerCore {
139
208
  getVisitorEngagement(): Promise<EngagementMetrics | null>;
140
209
  /** Send a server-side inbound event (requires apiKey in config) */
141
210
  sendEvent(payload: InboundEventPayload): Promise<InboundEventResult>;
211
+ /** Create or update a contact by email (upsert) */
212
+ createContact(data: PublicContactData): Promise<PublicCrmResult>;
213
+ /** Update an existing contact by ID (limited fields) */
214
+ updateContact(contactId: string, data: PublicContactUpdate): Promise<PublicCrmResult>;
215
+ /** Submit a form — creates/updates contact from form data */
216
+ submitForm(formId: string, data: PublicFormSubmission): Promise<PublicCrmResult>;
217
+ /** Log an activity linked to a contact (append-only) */
218
+ logActivity(data: PublicActivityData): Promise<PublicCrmResult>;
219
+ /** Create an opportunity (e.g., from "Request Demo" forms) */
220
+ createOpportunity(data: PublicOpportunityData): Promise<PublicCrmResult>;
142
221
  }
143
222
  interface VisitorProfile {
144
223
  visitorId: string;
@@ -210,6 +289,62 @@ interface VisitorActivityOptions {
210
289
  startDate?: string;
211
290
  endDate?: string;
212
291
  }
292
+ interface PublicContactData {
293
+ email: string;
294
+ firstName?: string;
295
+ lastName?: string;
296
+ company?: string;
297
+ jobTitle?: string;
298
+ phone?: string;
299
+ source?: string;
300
+ tags?: string[];
301
+ customFields?: Record<string, unknown>;
302
+ }
303
+ interface PublicContactUpdate {
304
+ firstName?: string;
305
+ lastName?: string;
306
+ company?: string;
307
+ jobTitle?: string;
308
+ phone?: string;
309
+ tags?: string[];
310
+ customFields?: Record<string, unknown>;
311
+ }
312
+ interface PublicActivityData {
313
+ contactId: string;
314
+ type: 'call' | 'email' | 'meeting' | 'note' | 'other';
315
+ title: string;
316
+ description?: string;
317
+ direction?: 'inbound' | 'outbound';
318
+ duration?: number;
319
+ emailSubject?: string;
320
+ metadata?: Record<string, unknown>;
321
+ }
322
+ interface PublicOpportunityData {
323
+ title: string;
324
+ contactId: string;
325
+ pipelineId: string;
326
+ stageId: string;
327
+ value?: number;
328
+ currency?: string;
329
+ description?: string;
330
+ expectedCloseDate?: string;
331
+ customFields?: Record<string, unknown>;
332
+ }
333
+ interface PublicFormSubmission {
334
+ fields: Record<string, unknown>;
335
+ metadata?: {
336
+ visitorId?: string;
337
+ sessionId?: string;
338
+ pageUrl?: string;
339
+ referrer?: string;
340
+ };
341
+ }
342
+ interface PublicCrmResult {
343
+ success: boolean;
344
+ data?: Record<string, unknown>;
345
+ error?: string;
346
+ status?: number;
347
+ }
213
348
 
214
349
  /**
215
350
  * Clianta SDK - Vue 3 Integration
@@ -233,7 +368,7 @@ interface CliantaPluginOptions extends CliantaConfig {
233
368
  * const app = createApp(App);
234
369
  * app.use(CliantaPlugin, {
235
370
  * projectId: 'your-project-id',
236
- * apiEndpoint: 'https://api.clianta.online',
371
+ * apiEndpoint: import.meta.env.VITE_CLIANTA_API_ENDPOINT || 'http://localhost:5000',
237
372
  * debug: import.meta.env.DEV,
238
373
  * });
239
374
  * app.mount('#app');