@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/CHANGELOG.md +36 -0
- package/dist/angular.cjs.js +358 -57
- package/dist/angular.cjs.js.map +1 -1
- package/dist/angular.d.ts +136 -1
- package/dist/angular.esm.js +358 -57
- package/dist/angular.esm.js.map +1 -1
- package/dist/clianta.cjs.js +357 -56
- package/dist/clianta.cjs.js.map +1 -1
- package/dist/clianta.esm.js +357 -56
- package/dist/clianta.esm.js.map +1 -1
- package/dist/clianta.umd.js +357 -56
- package/dist/clianta.umd.js.map +1 -1
- package/dist/clianta.umd.min.js +2 -2
- package/dist/clianta.umd.min.js.map +1 -1
- package/dist/index.d.ts +242 -8
- package/dist/react.cjs.js +425 -69
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.d.ts +156 -4
- package/dist/react.esm.js +426 -71
- package/dist/react.esm.js.map +1 -1
- package/dist/svelte.cjs.js +358 -57
- package/dist/svelte.cjs.js.map +1 -1
- package/dist/svelte.d.ts +136 -1
- package/dist/svelte.esm.js +358 -57
- package/dist/svelte.esm.js.map +1 -1
- package/dist/vue.cjs.js +358 -57
- package/dist/vue.cjs.js.map +1 -1
- package/dist/vue.d.ts +136 -1
- package/dist/vue.esm.js +358 -57
- package/dist/vue.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
2
|
+
import { ReactNode, ErrorInfo } from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Clianta SDK - CRM API Client
|
|
@@ -87,6 +87,63 @@ interface ConsentState {
|
|
|
87
87
|
personalization?: boolean;
|
|
88
88
|
}
|
|
89
89
|
type EventType = 'page_view' | 'button_click' | 'form_view' | 'form_submit' | 'form_interaction' | 'scroll_depth' | 'engagement' | 'download' | 'exit_intent' | 'error' | 'performance' | 'time_on_page' | 'custom';
|
|
90
|
+
interface TrackingEvent {
|
|
91
|
+
/** Workspace/project ID */
|
|
92
|
+
workspaceId: string;
|
|
93
|
+
/** Anonymous visitor identifier */
|
|
94
|
+
visitorId: string;
|
|
95
|
+
/** Session identifier */
|
|
96
|
+
sessionId: string;
|
|
97
|
+
/** Event type category */
|
|
98
|
+
eventType: EventType;
|
|
99
|
+
/** Human-readable event name */
|
|
100
|
+
eventName: string;
|
|
101
|
+
/** Current page URL */
|
|
102
|
+
url: string;
|
|
103
|
+
/** Referrer URL */
|
|
104
|
+
referrer?: string;
|
|
105
|
+
/** Event properties/metadata */
|
|
106
|
+
properties: Record<string, unknown>;
|
|
107
|
+
/** Device information */
|
|
108
|
+
device: DeviceInfo;
|
|
109
|
+
/** UTM parameters */
|
|
110
|
+
utm?: UTMParams;
|
|
111
|
+
/** ISO timestamp */
|
|
112
|
+
timestamp: string;
|
|
113
|
+
/** SDK version */
|
|
114
|
+
sdkVersion: string;
|
|
115
|
+
}
|
|
116
|
+
interface DeviceInfo {
|
|
117
|
+
userAgent: string;
|
|
118
|
+
screen: string;
|
|
119
|
+
language: string;
|
|
120
|
+
timezone?: string;
|
|
121
|
+
}
|
|
122
|
+
interface UTMParams {
|
|
123
|
+
utmSource?: string;
|
|
124
|
+
utmMedium?: string;
|
|
125
|
+
utmCampaign?: string;
|
|
126
|
+
utmTerm?: string;
|
|
127
|
+
utmContent?: string;
|
|
128
|
+
}
|
|
129
|
+
interface GroupTraits {
|
|
130
|
+
/** Company/account name */
|
|
131
|
+
name?: string;
|
|
132
|
+
/** Industry */
|
|
133
|
+
industry?: string;
|
|
134
|
+
/** Company size */
|
|
135
|
+
employees?: number;
|
|
136
|
+
/** Annual revenue */
|
|
137
|
+
revenue?: number;
|
|
138
|
+
/** Company website */
|
|
139
|
+
website?: string;
|
|
140
|
+
/** Company plan/tier */
|
|
141
|
+
plan?: string;
|
|
142
|
+
/** Additional custom properties */
|
|
143
|
+
[key: string]: unknown;
|
|
144
|
+
}
|
|
145
|
+
/** Event middleware function — intercept or transform events before they are sent */
|
|
146
|
+
type MiddlewareFn = (event: TrackingEvent, next: () => void) => void;
|
|
90
147
|
interface UserTraits {
|
|
91
148
|
firstName?: string;
|
|
92
149
|
lastName?: string;
|
|
@@ -122,6 +179,18 @@ interface TrackerCore {
|
|
|
122
179
|
deleteData(): void;
|
|
123
180
|
/** Get current consent state */
|
|
124
181
|
getConsentState(): ConsentState;
|
|
182
|
+
/** Associate the current visitor with a group (company/account) */
|
|
183
|
+
group(groupId: string, traits?: GroupTraits): void;
|
|
184
|
+
/** Merge two visitor identities (e.g., anonymous → logged-in) */
|
|
185
|
+
alias(newId: string, previousId?: string): Promise<boolean>;
|
|
186
|
+
/** Track a screen view (for mobile-first PWAs and SPAs) */
|
|
187
|
+
screen(name: string, properties?: Record<string, unknown>): void;
|
|
188
|
+
/** Register event middleware to intercept/transform events before sending */
|
|
189
|
+
use(middleware: MiddlewareFn): void;
|
|
190
|
+
/** Register a callback to be invoked when the SDK is fully initialized */
|
|
191
|
+
onReady(callback: () => void): void;
|
|
192
|
+
/** Check if the SDK is fully initialized and ready */
|
|
193
|
+
isReady(): boolean;
|
|
125
194
|
/** Get the current visitor's profile from the CRM */
|
|
126
195
|
getVisitorProfile(): Promise<VisitorProfile | null>;
|
|
127
196
|
/** Get the current visitor's recent activity */
|
|
@@ -140,6 +209,16 @@ interface TrackerCore {
|
|
|
140
209
|
getVisitorEngagement(): Promise<EngagementMetrics | null>;
|
|
141
210
|
/** Send a server-side inbound event (requires apiKey in config) */
|
|
142
211
|
sendEvent(payload: InboundEventPayload): Promise<InboundEventResult>;
|
|
212
|
+
/** Create or update a contact by email (upsert) */
|
|
213
|
+
createContact(data: PublicContactData): Promise<PublicCrmResult>;
|
|
214
|
+
/** Update an existing contact by ID (limited fields) */
|
|
215
|
+
updateContact(contactId: string, data: PublicContactUpdate): Promise<PublicCrmResult>;
|
|
216
|
+
/** Submit a form — creates/updates contact from form data */
|
|
217
|
+
submitForm(formId: string, data: PublicFormSubmission): Promise<PublicCrmResult>;
|
|
218
|
+
/** Log an activity linked to a contact (append-only) */
|
|
219
|
+
logActivity(data: PublicActivityData): Promise<PublicCrmResult>;
|
|
220
|
+
/** Create an opportunity (e.g., from "Request Demo" forms) */
|
|
221
|
+
createOpportunity(data: PublicOpportunityData): Promise<PublicCrmResult>;
|
|
143
222
|
}
|
|
144
223
|
interface VisitorProfile {
|
|
145
224
|
visitorId: string;
|
|
@@ -211,23 +290,83 @@ interface VisitorActivityOptions {
|
|
|
211
290
|
startDate?: string;
|
|
212
291
|
endDate?: string;
|
|
213
292
|
}
|
|
293
|
+
interface PublicContactData {
|
|
294
|
+
email: string;
|
|
295
|
+
firstName?: string;
|
|
296
|
+
lastName?: string;
|
|
297
|
+
company?: string;
|
|
298
|
+
jobTitle?: string;
|
|
299
|
+
phone?: string;
|
|
300
|
+
source?: string;
|
|
301
|
+
tags?: string[];
|
|
302
|
+
customFields?: Record<string, unknown>;
|
|
303
|
+
}
|
|
304
|
+
interface PublicContactUpdate {
|
|
305
|
+
firstName?: string;
|
|
306
|
+
lastName?: string;
|
|
307
|
+
company?: string;
|
|
308
|
+
jobTitle?: string;
|
|
309
|
+
phone?: string;
|
|
310
|
+
tags?: string[];
|
|
311
|
+
customFields?: Record<string, unknown>;
|
|
312
|
+
}
|
|
313
|
+
interface PublicActivityData {
|
|
314
|
+
contactId: string;
|
|
315
|
+
type: 'call' | 'email' | 'meeting' | 'note' | 'other';
|
|
316
|
+
title: string;
|
|
317
|
+
description?: string;
|
|
318
|
+
direction?: 'inbound' | 'outbound';
|
|
319
|
+
duration?: number;
|
|
320
|
+
emailSubject?: string;
|
|
321
|
+
metadata?: Record<string, unknown>;
|
|
322
|
+
}
|
|
323
|
+
interface PublicOpportunityData {
|
|
324
|
+
title: string;
|
|
325
|
+
contactId: string;
|
|
326
|
+
pipelineId: string;
|
|
327
|
+
stageId: string;
|
|
328
|
+
value?: number;
|
|
329
|
+
currency?: string;
|
|
330
|
+
description?: string;
|
|
331
|
+
expectedCloseDate?: string;
|
|
332
|
+
customFields?: Record<string, unknown>;
|
|
333
|
+
}
|
|
334
|
+
interface PublicFormSubmission {
|
|
335
|
+
fields: Record<string, unknown>;
|
|
336
|
+
metadata?: {
|
|
337
|
+
visitorId?: string;
|
|
338
|
+
sessionId?: string;
|
|
339
|
+
pageUrl?: string;
|
|
340
|
+
referrer?: string;
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
interface PublicCrmResult {
|
|
344
|
+
success: boolean;
|
|
345
|
+
data?: Record<string, unknown>;
|
|
346
|
+
error?: string;
|
|
347
|
+
status?: number;
|
|
348
|
+
}
|
|
214
349
|
|
|
215
350
|
interface CliantaProviderProps {
|
|
216
351
|
/** Configuration object (from clianta.config.ts) */
|
|
217
352
|
config: CliantaConfig;
|
|
218
353
|
/** React children */
|
|
219
354
|
children: ReactNode;
|
|
355
|
+
/** Optional error handler when the SDK encounters errors */
|
|
356
|
+
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
220
357
|
}
|
|
221
358
|
/**
|
|
222
359
|
* CliantaProvider - Wrap your app to enable tracking
|
|
223
360
|
*
|
|
361
|
+
* Includes an ErrorBoundary so SDK failures never crash the host app.
|
|
362
|
+
*
|
|
224
363
|
* @example
|
|
225
364
|
* // In clianta.config.ts:
|
|
226
365
|
* import { CliantaConfig } from '@clianta/sdk';
|
|
227
366
|
*
|
|
228
367
|
* const config: CliantaConfig = {
|
|
229
368
|
* projectId: 'your-project-id',
|
|
230
|
-
* apiEndpoint:
|
|
369
|
+
* apiEndpoint: process.env.NEXT_PUBLIC_CLIANTA_API_ENDPOINT || 'http://localhost:5000',
|
|
231
370
|
* debug: process.env.NODE_ENV === 'development',
|
|
232
371
|
* };
|
|
233
372
|
*
|
|
@@ -241,7 +380,7 @@ interface CliantaProviderProps {
|
|
|
241
380
|
* {children}
|
|
242
381
|
* </CliantaProvider>
|
|
243
382
|
*/
|
|
244
|
-
declare function CliantaProvider({ config, children }: CliantaProviderProps): react_jsx_runtime.JSX.Element;
|
|
383
|
+
declare function CliantaProvider({ config, children, onError }: CliantaProviderProps): react_jsx_runtime.JSX.Element;
|
|
245
384
|
/**
|
|
246
385
|
* useClianta - Hook to access tracker in any component
|
|
247
386
|
*
|
|
@@ -250,6 +389,19 @@ declare function CliantaProvider({ config, children }: CliantaProviderProps): re
|
|
|
250
389
|
* tracker?.track('button_click', 'CTA Button');
|
|
251
390
|
*/
|
|
252
391
|
declare function useClianta(): TrackerCore | null;
|
|
392
|
+
/**
|
|
393
|
+
* useCliantaReady - Hook to check if SDK is initialized
|
|
394
|
+
*
|
|
395
|
+
* @example
|
|
396
|
+
* const { isReady, tracker } = useCliantaReady();
|
|
397
|
+
* if (isReady) {
|
|
398
|
+
* tracker.track('purchase', 'Order', { value: 99 });
|
|
399
|
+
* }
|
|
400
|
+
*/
|
|
401
|
+
declare function useCliantaReady(): {
|
|
402
|
+
isReady: boolean;
|
|
403
|
+
tracker: TrackerCore | null;
|
|
404
|
+
};
|
|
253
405
|
/**
|
|
254
406
|
* useCliantaTrack - Convenience hook for tracking events
|
|
255
407
|
*
|
|
@@ -259,5 +411,5 @@ declare function useClianta(): TrackerCore | null;
|
|
|
259
411
|
*/
|
|
260
412
|
declare function useCliantaTrack(): (eventType: string, eventName: string, properties?: Record<string, unknown>) => void;
|
|
261
413
|
|
|
262
|
-
export { CliantaProvider, useClianta, useCliantaTrack };
|
|
414
|
+
export { CliantaProvider, useClianta, useCliantaReady, useCliantaTrack };
|
|
263
415
|
export type { CliantaConfig, CliantaProviderProps, TrackerCore };
|