@clianta/sdk 1.6.0 → 1.6.2

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,36 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode, ErrorInfo } 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
-
34
4
  /**
35
5
  * Clianta SDK - Type Definitions
36
6
  * @see SDK_VERSION in core/config.ts
@@ -40,10 +10,6 @@ interface CliantaConfig {
40
10
  projectId?: string;
41
11
  /** Backend API endpoint URL */
42
12
  apiEndpoint?: string;
43
- /** Auth token for server-side API access (user JWT) */
44
- authToken?: string;
45
- /** Workspace API key for server-to-server access (use instead of authToken for external apps) */
46
- apiKey?: string;
47
13
  /** Enable debug mode with verbose logging */
48
14
  debug?: boolean;
49
15
  /** Automatically track page views on load and navigation */
@@ -191,24 +157,6 @@ interface TrackerCore {
191
157
  onReady(callback: () => void): void;
192
158
  /** Check if the SDK is fully initialized and ready */
193
159
  isReady(): boolean;
194
- /** Get the current visitor's profile from the CRM */
195
- getVisitorProfile(): Promise<VisitorProfile | null>;
196
- /** Get the current visitor's recent activity */
197
- getVisitorActivity(options?: VisitorActivityOptions): Promise<{
198
- data: VisitorActivity[];
199
- pagination: {
200
- page: number;
201
- limit: number;
202
- total: number;
203
- pages: number;
204
- };
205
- } | null>;
206
- /** Get a summarized journey timeline for the current visitor */
207
- getVisitorTimeline(): Promise<VisitorTimeline | null>;
208
- /** Get engagement metrics for the current visitor */
209
- getVisitorEngagement(): Promise<EngagementMetrics | null>;
210
- /** Send a server-side inbound event (requires apiKey in config) */
211
- sendEvent(payload: InboundEventPayload): Promise<InboundEventResult>;
212
160
  /** Create or update a contact by email (upsert) */
213
161
  createContact(data: PublicContactData): Promise<PublicCrmResult>;
214
162
  /** Update an existing contact by ID (limited fields) */
@@ -219,76 +167,8 @@ interface TrackerCore {
219
167
  logActivity(data: PublicActivityData): Promise<PublicCrmResult>;
220
168
  /** Create an opportunity (e.g., from "Request Demo" forms) */
221
169
  createOpportunity(data: PublicOpportunityData): Promise<PublicCrmResult>;
222
- }
223
- interface VisitorProfile {
224
- visitorId: string;
225
- contactId?: string;
226
- email?: string;
227
- firstName?: string;
228
- lastName?: string;
229
- company?: string;
230
- jobTitle?: string;
231
- phone?: string;
232
- status?: string;
233
- lifecycleStage?: string;
234
- tags?: string[];
235
- leadScore?: number;
236
- firstSeen?: string;
237
- lastSeen?: string;
238
- sessionCount?: number;
239
- pageViewCount?: number;
240
- totalTimeSpent?: number;
241
- customFields?: Record<string, unknown>;
242
- }
243
- interface VisitorActivity {
244
- _id?: string;
245
- eventType: string;
246
- eventName: string;
247
- url: string;
248
- properties?: Record<string, unknown>;
249
- timestamp: string;
250
- }
251
- interface VisitorTimeline {
252
- visitorId: string;
253
- contactId?: string;
254
- firstSeen: string;
255
- lastSeen: string;
256
- totalSessions: number;
257
- totalPageViews: number;
258
- totalEvents: number;
259
- totalTimeSpentSeconds: number;
260
- averageSessionDurationSeconds: number;
261
- topPages: Array<{
262
- url: string;
263
- views: number;
264
- avgTimeSeconds?: number;
265
- }>;
266
- recentActivities: VisitorActivity[];
267
- devices: Array<{
268
- userAgent: string;
269
- lastSeen: string;
270
- }>;
271
- }
272
- interface EngagementMetrics {
273
- visitorId: string;
274
- totalTimeOnSiteSeconds: number;
275
- averageSessionDurationSeconds: number;
276
- totalPageViews: number;
277
- totalSessions: number;
278
- engagementScore: number;
279
- bounceRate: number;
280
- lastActiveAt: string;
281
- topEvents: Array<{
282
- eventType: string;
283
- count: number;
284
- }>;
285
- }
286
- interface VisitorActivityOptions {
287
- page?: number;
288
- limit?: number;
289
- eventType?: string;
290
- startDate?: string;
291
- endDate?: string;
170
+ /** Destroy the tracker instance, flush pending events, and clean up plugins */
171
+ destroy(): Promise<void>;
292
172
  }
293
173
  interface PublicContactData {
294
174
  email: string;
@@ -348,66 +228,42 @@ interface PublicCrmResult {
348
228
  }
349
229
 
350
230
  interface CliantaProviderProps {
351
- /** Configuration object (from clianta.config.ts) */
352
- config: CliantaConfig;
231
+ /** Project/workspace ID the ONLY required prop */
232
+ projectId: string;
233
+ /** Enable debug logging (default: false) */
234
+ debug?: boolean;
235
+ /** Full config for advanced usage (optional — most users don't need this) */
236
+ config?: Omit<CliantaConfig, 'projectId'>;
353
237
  /** React children */
354
238
  children: ReactNode;
355
- /** Optional error handler when the SDK encounters errors */
239
+ /** Error handler (optional) */
356
240
  onError?: (error: Error, errorInfo: ErrorInfo) => void;
357
241
  }
358
242
  /**
359
- * CliantaProvider - Wrap your app to enable tracking
243
+ * CliantaProvider — Plug-and-play tracking for React/Next.js
360
244
  *
361
- * Includes an ErrorBoundary so SDK failures never crash the host app.
245
+ * Just wrap your app. Everything auto-tracks. Done.
362
246
  *
363
247
  * @example
364
- * // In clianta.config.ts:
365
- * import { CliantaConfig } from '@clianta/sdk';
366
- *
367
- * const config: CliantaConfig = {
368
- * projectId: 'your-project-id',
369
- * apiEndpoint: process.env.NEXT_PUBLIC_CLIANTA_API_ENDPOINT || 'http://localhost:5000',
370
- * debug: process.env.NODE_ENV === 'development',
371
- * };
372
- *
373
- * export default config;
374
- *
375
- * // In app/layout.tsx or main.tsx:
376
- * import { CliantaProvider } from '@clianta/sdk/react';
377
- * import cliantaConfig from '../clianta.config';
378
- *
379
- * <CliantaProvider config={cliantaConfig}>
248
+ * // app/layout.tsx — that's it, one line:
249
+ * <CliantaProvider projectId={process.env.NEXT_PUBLIC_CLIANTA_ID!}>
380
250
  * {children}
381
251
  * </CliantaProvider>
382
252
  */
383
- declare function CliantaProvider({ config, children, onError }: CliantaProviderProps): react_jsx_runtime.JSX.Element;
253
+ declare function CliantaProvider({ projectId, debug, config, children, onError }: CliantaProviderProps): react_jsx_runtime.JSX.Element;
384
254
  /**
385
- * useClianta - Hook to access tracker in any component
386
- *
387
- * @example
388
- * const tracker = useClianta();
389
- * tracker?.track('button_click', 'CTA Button');
255
+ * useClianta Access the tracker instance
390
256
  */
391
257
  declare function useClianta(): TrackerCore | null;
392
258
  /**
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
- * }
259
+ * useCliantaReady Check if SDK is initialized
400
260
  */
401
261
  declare function useCliantaReady(): {
402
262
  isReady: boolean;
403
263
  tracker: TrackerCore | null;
404
264
  };
405
265
  /**
406
- * useCliantaTrack - Convenience hook for tracking events
407
- *
408
- * @example
409
- * const track = useCliantaTrack();
410
- * track('purchase', 'Order Completed', { orderId: '123' });
266
+ * useCliantaTrack Quick tracking hook
411
267
  */
412
268
  declare function useCliantaTrack(): (eventType: string, eventName: string, properties?: Record<string, unknown>) => void;
413
269