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