@clianta/sdk 1.0.0 → 1.1.1
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/README.md +352 -205
- package/dist/clianta.cjs.js +828 -48
- package/dist/clianta.cjs.js.map +1 -1
- package/dist/clianta.esm.js +828 -49
- package/dist/clianta.esm.js.map +1 -1
- package/dist/clianta.umd.js +828 -48
- 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 +149 -16
- package/dist/react.cjs.js +2661 -0
- package/dist/react.cjs.js.map +1 -0
- package/dist/react.d.ts +141 -0
- package/dist/react.esm.js +2657 -0
- package/dist/react.esm.js.map +1 -0
- package/package.json +18 -2
package/README.md
CHANGED
|
@@ -1,303 +1,450 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
Professional CRM and tracking SDK for
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
### Tracking & Analytics
|
|
8
|
-
- **Page Views** - Automatic page view tracking with SPA support
|
|
9
|
-
- **Form Tracking** - Auto-detect and track form interactions
|
|
10
|
-
- **Scroll Depth** - Track scroll milestones (25%, 50%, 75%, 100%)
|
|
11
|
-
- **Click Tracking** - Track button and CTA clicks
|
|
12
|
-
- **User Engagement** - Detect active user engagement
|
|
13
|
-
- **File Downloads** - Track file downloads
|
|
14
|
-
- **Exit Intent** - Detect when users are about to leave
|
|
15
|
-
- **Error Tracking** - Capture JavaScript errors (optional)
|
|
16
|
-
- **Performance** - Web Vitals and page speed metrics (optional)
|
|
17
|
-
- **Auto-Identify** - Automatically identify leads from form submissions
|
|
18
|
-
- **Offline Support** - Queue events when offline, send when back
|
|
19
|
-
|
|
20
|
-
### CRM API Client
|
|
21
|
-
- **Contacts Management** - Full CRUD operations for contacts
|
|
22
|
-
- **Opportunities Management** - Create, update, and track sales opportunities
|
|
23
|
-
- **Authenticated Requests** - Secure API access with token authentication
|
|
24
|
-
- **Type-Safe** - Full TypeScript support for all CRM operations
|
|
25
|
-
|
|
26
|
-
### Developer Experience
|
|
27
|
-
- **Debug Mode** - Verbose logging for troubleshooting
|
|
28
|
-
- **TypeScript Support** - Full type definitions included
|
|
29
|
-
- **Multiple Formats** - UMD, ESM, and CJS builds
|
|
30
|
-
- **Tree-Shakeable** - Import only what you need
|
|
31
|
-
- **Zero Dependencies** - Lightweight and fast
|
|
1
|
+
# Clianta SDK
|
|
2
|
+
|
|
3
|
+
Professional CRM and tracking SDK for lead generation. Works with any website or JavaScript framework.
|
|
32
4
|
|
|
33
5
|
## Installation
|
|
34
6
|
|
|
35
|
-
### NPM
|
|
7
|
+
### NPM / Yarn (React, Next.js, Vue)
|
|
36
8
|
|
|
37
9
|
```bash
|
|
38
10
|
npm install @clianta/sdk
|
|
11
|
+
# or
|
|
12
|
+
yarn add @clianta/sdk
|
|
39
13
|
```
|
|
40
14
|
|
|
41
|
-
### Script Tag (
|
|
15
|
+
### Script Tag (HTML, WordPress, Webflow)
|
|
42
16
|
|
|
43
17
|
```html
|
|
44
|
-
<script src="https://
|
|
45
|
-
<script>
|
|
46
|
-
const tracker = Clianta.clianta('YOUR_WORKSPACE_ID');
|
|
47
|
-
</script>
|
|
18
|
+
<script src="https://cdn.clianta.online/sdk/v1/clianta.min.js"></script>
|
|
48
19
|
```
|
|
49
20
|
|
|
21
|
+
---
|
|
22
|
+
|
|
50
23
|
## Quick Start
|
|
51
24
|
|
|
52
|
-
###
|
|
25
|
+
### Script Tag (Any Website)
|
|
53
26
|
|
|
54
|
-
```
|
|
27
|
+
```html
|
|
28
|
+
<!-- Add before </head> -->
|
|
29
|
+
<script src="https://cdn.clianta.online/sdk/v1/clianta.min.js"></script>
|
|
30
|
+
<script>
|
|
31
|
+
clianta('YOUR_WORKSPACE_ID', {
|
|
32
|
+
apiEndpoint: 'https://api.clianta.online'
|
|
33
|
+
});
|
|
34
|
+
</script>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### NPM Module
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
55
40
|
import { clianta } from '@clianta/sdk';
|
|
56
41
|
|
|
57
|
-
// Initialize tracker
|
|
58
42
|
const tracker = clianta('YOUR_WORKSPACE_ID', {
|
|
43
|
+
apiEndpoint: 'https://api.clianta.online',
|
|
59
44
|
debug: true,
|
|
60
|
-
apiEndpoint: 'https://api.clianta.online'
|
|
61
45
|
});
|
|
62
46
|
|
|
63
|
-
// Track
|
|
64
|
-
tracker.track('
|
|
65
|
-
buttonId: 'signup-cta',
|
|
66
|
-
location: 'hero-section',
|
|
67
|
-
});
|
|
47
|
+
// Track events
|
|
48
|
+
tracker.track('button_click', 'Signup Button', { location: 'hero' });
|
|
68
49
|
|
|
69
|
-
// Identify
|
|
70
|
-
tracker.identify('
|
|
71
|
-
|
|
72
|
-
lastName: 'Doe',
|
|
73
|
-
company: 'Acme Inc',
|
|
74
|
-
});
|
|
50
|
+
// Identify users
|
|
51
|
+
tracker.identify('user@example.com', { firstName: 'John' });
|
|
52
|
+
```
|
|
75
53
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Framework Guides
|
|
57
|
+
|
|
58
|
+
### Next.js (App Router)
|
|
59
|
+
|
|
60
|
+
Create a provider component:
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
// components/CliantaProvider.tsx
|
|
64
|
+
'use client';
|
|
65
|
+
|
|
66
|
+
import { useEffect } from 'react';
|
|
67
|
+
import { clianta } from '@clianta/sdk';
|
|
68
|
+
|
|
69
|
+
export function CliantaProvider({ children }: { children: React.ReactNode }) {
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
const tracker = clianta(process.env.NEXT_PUBLIC_WORKSPACE_ID!, {
|
|
72
|
+
apiEndpoint: process.env.NEXT_PUBLIC_API_ENDPOINT,
|
|
73
|
+
debug: process.env.NODE_ENV === 'development',
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
return () => { tracker.flush(); };
|
|
77
|
+
}, []);
|
|
78
|
+
|
|
79
|
+
return <>{children}</>;
|
|
80
|
+
}
|
|
80
81
|
```
|
|
81
82
|
|
|
82
|
-
|
|
83
|
+
Use in your layout:
|
|
83
84
|
|
|
84
|
-
```
|
|
85
|
-
|
|
85
|
+
```tsx
|
|
86
|
+
// app/layout.tsx
|
|
87
|
+
import { CliantaProvider } from '@/components/CliantaProvider';
|
|
88
|
+
|
|
89
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
90
|
+
return (
|
|
91
|
+
<html lang="en">
|
|
92
|
+
<body>
|
|
93
|
+
<CliantaProvider>{children}</CliantaProvider>
|
|
94
|
+
</body>
|
|
95
|
+
</html>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
```
|
|
86
99
|
|
|
87
|
-
|
|
88
|
-
const crm = new CRMClient(
|
|
89
|
-
'https://api.clianta.online',
|
|
90
|
-
'YOUR_WORKSPACE_ID',
|
|
91
|
-
'YOUR_AUTH_TOKEN'
|
|
92
|
-
);
|
|
100
|
+
Environment variables (`.env.local`):
|
|
93
101
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
status: 'lead'
|
|
99
|
-
});
|
|
102
|
+
```bash
|
|
103
|
+
NEXT_PUBLIC_WORKSPACE_ID=your-workspace-id
|
|
104
|
+
NEXT_PUBLIC_API_ENDPOINT=https://api.clianta.online
|
|
105
|
+
```
|
|
100
106
|
|
|
101
|
-
|
|
102
|
-
const newContact = await crm.createContact({
|
|
103
|
-
email: 'jane@example.com',
|
|
104
|
-
firstName: 'Jane',
|
|
105
|
-
lastName: 'Smith',
|
|
106
|
-
company: 'Tech Corp'
|
|
107
|
-
});
|
|
107
|
+
---
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
const opportunity = await crm.createOpportunity({
|
|
111
|
-
contactId: newContact.data._id,
|
|
112
|
-
pipelineId: 'pipeline-id',
|
|
113
|
-
stageId: 'stage-id',
|
|
114
|
-
title: 'Enterprise Deal',
|
|
115
|
-
value: 50000,
|
|
116
|
-
currency: 'USD'
|
|
117
|
-
});
|
|
109
|
+
### React (Vite / CRA)
|
|
118
110
|
|
|
119
|
-
|
|
120
|
-
|
|
111
|
+
```tsx
|
|
112
|
+
// App.tsx
|
|
113
|
+
import { useEffect } from 'react';
|
|
114
|
+
import { clianta } from '@clianta/sdk';
|
|
115
|
+
|
|
116
|
+
function App() {
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
const tracker = clianta(import.meta.env.VITE_WORKSPACE_ID, {
|
|
119
|
+
apiEndpoint: import.meta.env.VITE_API_ENDPOINT,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
return () => { tracker.flush(); };
|
|
123
|
+
}, []);
|
|
124
|
+
|
|
125
|
+
return <div>Your App</div>;
|
|
126
|
+
}
|
|
121
127
|
```
|
|
122
128
|
|
|
129
|
+
Track events in components:
|
|
130
|
+
|
|
131
|
+
```tsx
|
|
132
|
+
import { clianta } from '@clianta/sdk';
|
|
133
|
+
|
|
134
|
+
function SignupButton() {
|
|
135
|
+
const handleClick = () => {
|
|
136
|
+
const tracker = clianta(import.meta.env.VITE_WORKSPACE_ID);
|
|
137
|
+
tracker.track('button_click', 'Signup CTA', { location: 'navbar' });
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
return <button onClick={handleClick}>Sign Up</button>;
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
### Vue.js
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
// plugins/clianta.ts
|
|
150
|
+
import { clianta } from '@clianta/sdk';
|
|
151
|
+
|
|
152
|
+
export default {
|
|
153
|
+
install(app: any) {
|
|
154
|
+
const tracker = clianta(import.meta.env.VITE_WORKSPACE_ID, {
|
|
155
|
+
apiEndpoint: import.meta.env.VITE_API_ENDPOINT,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
app.config.globalProperties.$clianta = tracker;
|
|
159
|
+
app.provide('clianta', tracker);
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
```vue
|
|
165
|
+
<script setup>
|
|
166
|
+
import { inject } from 'vue';
|
|
167
|
+
const tracker = inject('clianta');
|
|
168
|
+
|
|
169
|
+
const trackClick = () => {
|
|
170
|
+
tracker.track('button_click', 'CTA Clicked');
|
|
171
|
+
};
|
|
172
|
+
</script>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
### Plain HTML / WordPress / Webflow
|
|
178
|
+
|
|
179
|
+
```html
|
|
180
|
+
<!DOCTYPE html>
|
|
181
|
+
<html>
|
|
182
|
+
<head>
|
|
183
|
+
<title>My Website</title>
|
|
184
|
+
|
|
185
|
+
<!-- Clianta SDK -->
|
|
186
|
+
<script src="https://cdn.clianta.online/sdk/v1/clianta.min.js"></script>
|
|
187
|
+
<script>
|
|
188
|
+
var tracker = clianta('YOUR_WORKSPACE_ID', {
|
|
189
|
+
apiEndpoint: 'https://api.clianta.online'
|
|
190
|
+
});
|
|
191
|
+
</script>
|
|
192
|
+
</head>
|
|
193
|
+
<body>
|
|
194
|
+
<button onclick="tracker.track('button_click', 'CTA Clicked')">
|
|
195
|
+
Click Me
|
|
196
|
+
</button>
|
|
197
|
+
</body>
|
|
198
|
+
</html>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
**WordPress**: Add to `Appearance > Theme Editor > header.php` before `</head>`
|
|
202
|
+
|
|
203
|
+
**Webflow**: Add to `Project Settings > Custom Code > Head Code`
|
|
204
|
+
|
|
205
|
+
**Shopify**: Add to `Online Store > Themes > Edit Code > theme.liquid`
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
123
209
|
## Configuration
|
|
124
210
|
|
|
125
211
|
```typescript
|
|
126
|
-
const tracker = clianta('
|
|
127
|
-
//
|
|
212
|
+
const tracker = clianta('WORKSPACE_ID', {
|
|
213
|
+
// API endpoint (required for self-hosted)
|
|
128
214
|
apiEndpoint: 'https://api.clianta.online',
|
|
129
|
-
|
|
130
|
-
//
|
|
215
|
+
|
|
216
|
+
// Debug mode (console logging)
|
|
131
217
|
debug: false,
|
|
132
|
-
|
|
133
|
-
// Auto
|
|
218
|
+
|
|
219
|
+
// Auto track page views
|
|
134
220
|
autoPageView: true,
|
|
135
|
-
|
|
136
|
-
// Plugins to enable
|
|
221
|
+
|
|
222
|
+
// Plugins to enable
|
|
137
223
|
plugins: [
|
|
138
|
-
'pageView',
|
|
139
|
-
'forms',
|
|
140
|
-
'scroll',
|
|
141
|
-
'clicks',
|
|
142
|
-
'engagement',
|
|
143
|
-
'downloads',
|
|
144
|
-
'exitIntent',
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
// 'performance',
|
|
224
|
+
'pageView', // Page views with SPA support
|
|
225
|
+
'forms', // Auto-detect forms
|
|
226
|
+
'scroll', // Scroll depth tracking
|
|
227
|
+
'clicks', // Button/CTA clicks
|
|
228
|
+
'engagement', // User engagement
|
|
229
|
+
'downloads', // File downloads
|
|
230
|
+
'exitIntent', // Exit intent detection
|
|
231
|
+
'errors', // JavaScript errors (optional)
|
|
232
|
+
'performance', // Web Vitals (optional)
|
|
148
233
|
],
|
|
149
|
-
|
|
150
|
-
// Session timeout (
|
|
234
|
+
|
|
235
|
+
// Session timeout (30 min default)
|
|
151
236
|
sessionTimeout: 30 * 60 * 1000,
|
|
152
|
-
|
|
153
|
-
//
|
|
237
|
+
|
|
238
|
+
// Events per batch
|
|
154
239
|
batchSize: 10,
|
|
155
|
-
|
|
156
|
-
// Flush interval
|
|
240
|
+
|
|
241
|
+
// Flush interval (ms)
|
|
157
242
|
flushInterval: 5000,
|
|
243
|
+
|
|
244
|
+
// GDPR Consent Configuration
|
|
245
|
+
consent: {
|
|
246
|
+
waitForConsent: true, // Buffer events until consent
|
|
247
|
+
anonymousMode: true, // Use anonymous ID until consent
|
|
248
|
+
},
|
|
249
|
+
|
|
250
|
+
// Cookie-less mode (GDPR friendly)
|
|
251
|
+
cookielessMode: false,
|
|
158
252
|
});
|
|
159
253
|
```
|
|
160
254
|
|
|
255
|
+
---
|
|
256
|
+
|
|
161
257
|
## API Reference
|
|
162
258
|
|
|
163
|
-
###
|
|
259
|
+
### `tracker.track(eventType, eventName, properties?)`
|
|
164
260
|
|
|
165
|
-
|
|
166
|
-
Track a custom event.
|
|
261
|
+
Track custom events:
|
|
167
262
|
|
|
168
|
-
|
|
169
|
-
|
|
263
|
+
```typescript
|
|
264
|
+
tracker.track('button_click', 'Add to Cart', {
|
|
265
|
+
productId: '123',
|
|
266
|
+
price: 29.99,
|
|
267
|
+
});
|
|
268
|
+
```
|
|
170
269
|
|
|
171
|
-
|
|
172
|
-
Track a page view (automatic by default).
|
|
270
|
+
### `tracker.identify(email, traits?)`
|
|
173
271
|
|
|
174
|
-
|
|
175
|
-
Enable or disable debug mode.
|
|
272
|
+
Identify a visitor:
|
|
176
273
|
|
|
177
|
-
|
|
178
|
-
|
|
274
|
+
```typescript
|
|
275
|
+
tracker.identify('john@example.com', {
|
|
276
|
+
firstName: 'John',
|
|
277
|
+
lastName: 'Doe',
|
|
278
|
+
company: 'Acme Inc',
|
|
279
|
+
phone: '+1234567890',
|
|
280
|
+
});
|
|
281
|
+
```
|
|
179
282
|
|
|
180
|
-
|
|
181
|
-
Get the current session ID.
|
|
283
|
+
### `tracker.page(name?, properties?)`
|
|
182
284
|
|
|
183
|
-
|
|
184
|
-
Force send all queued events.
|
|
285
|
+
Track page views manually:
|
|
185
286
|
|
|
186
|
-
|
|
187
|
-
|
|
287
|
+
```typescript
|
|
288
|
+
tracker.page('Pricing Page', { plan: 'enterprise' });
|
|
289
|
+
```
|
|
188
290
|
|
|
189
|
-
###
|
|
291
|
+
### `tracker.consent(state)`
|
|
190
292
|
|
|
191
|
-
|
|
192
|
-
- `getContacts(params?)` - Get all contacts with pagination
|
|
193
|
-
- `getContact(contactId)` - Get a single contact
|
|
194
|
-
- `createContact(contact)` - Create a new contact
|
|
195
|
-
- `updateContact(contactId, updates)` - Update a contact
|
|
196
|
-
- `deleteContact(contactId)` - Delete a contact
|
|
293
|
+
Update consent state (GDPR):
|
|
197
294
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
295
|
+
```typescript
|
|
296
|
+
tracker.consent({
|
|
297
|
+
analytics: true,
|
|
298
|
+
marketing: false,
|
|
299
|
+
personalization: true,
|
|
300
|
+
});
|
|
301
|
+
```
|
|
205
302
|
|
|
206
|
-
|
|
303
|
+
### `tracker.getConsentState()`
|
|
207
304
|
|
|
208
|
-
|
|
305
|
+
Get current consent:
|
|
209
306
|
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
|
|
307
|
+
```typescript
|
|
308
|
+
const state = tracker.getConsentState();
|
|
309
|
+
// { analytics: true, marketing: false, personalization: false }
|
|
310
|
+
```
|
|
213
311
|
|
|
214
|
-
|
|
215
|
-
useEffect(() => {
|
|
216
|
-
const tracker = clianta('YOUR_WORKSPACE_ID', {
|
|
217
|
-
debug: process.env.NODE_ENV === 'development'
|
|
218
|
-
});
|
|
312
|
+
### `tracker.deleteData()`
|
|
219
313
|
|
|
220
|
-
|
|
221
|
-
tracker.flush();
|
|
222
|
-
};
|
|
223
|
-
}, []);
|
|
314
|
+
Delete all stored data (GDPR right-to-erasure):
|
|
224
315
|
|
|
225
|
-
|
|
226
|
-
|
|
316
|
+
```typescript
|
|
317
|
+
tracker.deleteData();
|
|
227
318
|
```
|
|
228
319
|
|
|
229
|
-
###
|
|
320
|
+
### `tracker.debug(enabled)`
|
|
230
321
|
|
|
231
|
-
|
|
232
|
-
// app/layout.tsx or pages/_app.tsx
|
|
233
|
-
import { clianta } from '@clianta/sdk';
|
|
322
|
+
Toggle debug mode:
|
|
234
323
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}
|
|
324
|
+
```typescript
|
|
325
|
+
tracker.debug(true); // Enable console logging
|
|
238
326
|
```
|
|
239
327
|
|
|
240
|
-
###
|
|
328
|
+
### `tracker.getVisitorId()` / `tracker.getSessionId()`
|
|
241
329
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
330
|
+
Get current IDs:
|
|
331
|
+
|
|
332
|
+
```typescript
|
|
333
|
+
const visitorId = tracker.getVisitorId();
|
|
334
|
+
const sessionId = tracker.getSessionId();
|
|
335
|
+
```
|
|
246
336
|
|
|
247
|
-
|
|
337
|
+
### `tracker.flush()`
|
|
248
338
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
339
|
+
Force send queued events:
|
|
340
|
+
|
|
341
|
+
```typescript
|
|
342
|
+
await tracker.flush();
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### `tracker.reset()`
|
|
346
|
+
|
|
347
|
+
Reset visitor (for logout):
|
|
252
348
|
|
|
253
|
-
|
|
254
|
-
|
|
349
|
+
```typescript
|
|
350
|
+
tracker.reset();
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## GDPR Compliance
|
|
356
|
+
|
|
357
|
+
### Wait for Consent
|
|
358
|
+
|
|
359
|
+
Buffer all events until user grants consent:
|
|
360
|
+
|
|
361
|
+
```typescript
|
|
362
|
+
const tracker = clianta('WORKSPACE_ID', {
|
|
363
|
+
consent: {
|
|
364
|
+
waitForConsent: true,
|
|
365
|
+
},
|
|
255
366
|
});
|
|
256
|
-
|
|
367
|
+
|
|
368
|
+
// Events are buffered...
|
|
369
|
+
tracker.track('page_view', 'Home');
|
|
370
|
+
|
|
371
|
+
// User accepts cookies
|
|
372
|
+
tracker.consent({ analytics: true });
|
|
373
|
+
// Buffered events are now sent
|
|
257
374
|
```
|
|
258
375
|
|
|
259
|
-
|
|
376
|
+
### Anonymous Mode
|
|
260
377
|
|
|
261
|
-
|
|
378
|
+
Track without persistent visitor ID until consent:
|
|
262
379
|
|
|
263
380
|
```typescript
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
} from '@clianta/sdk';
|
|
381
|
+
const tracker = clianta('WORKSPACE_ID', {
|
|
382
|
+
consent: {
|
|
383
|
+
anonymousMode: true,
|
|
384
|
+
},
|
|
385
|
+
});
|
|
270
386
|
|
|
271
|
-
|
|
387
|
+
// Uses temporary anon_xxx ID
|
|
388
|
+
tracker.track('page_view', 'Home');
|
|
272
389
|
|
|
273
|
-
|
|
390
|
+
// User accepts - upgrades to persistent ID
|
|
391
|
+
tracker.consent({ analytics: true });
|
|
274
392
|
```
|
|
275
393
|
|
|
276
|
-
|
|
394
|
+
### Cookie-less Mode
|
|
277
395
|
|
|
278
|
-
|
|
279
|
-
# Install dependencies
|
|
280
|
-
npm install
|
|
396
|
+
No persistent storage (session only):
|
|
281
397
|
|
|
282
|
-
|
|
283
|
-
|
|
398
|
+
```typescript
|
|
399
|
+
const tracker = clianta('WORKSPACE_ID', {
|
|
400
|
+
cookielessMode: true,
|
|
401
|
+
});
|
|
402
|
+
// Visitor ID stored in sessionStorage only
|
|
403
|
+
```
|
|
284
404
|
|
|
285
|
-
|
|
286
|
-
npm run build:watch
|
|
405
|
+
### Data Deletion
|
|
287
406
|
|
|
288
|
-
|
|
289
|
-
npm test
|
|
407
|
+
Allow users to delete their data:
|
|
290
408
|
|
|
291
|
-
|
|
292
|
-
|
|
409
|
+
```typescript
|
|
410
|
+
function handleDeleteDataRequest() {
|
|
411
|
+
tracker.deleteData();
|
|
412
|
+
showConfirmation('Your data has been deleted');
|
|
413
|
+
}
|
|
293
414
|
```
|
|
294
415
|
|
|
295
|
-
|
|
416
|
+
---
|
|
417
|
+
|
|
418
|
+
## TypeScript
|
|
419
|
+
|
|
420
|
+
Full TypeScript support included:
|
|
421
|
+
|
|
422
|
+
```typescript
|
|
423
|
+
import {
|
|
424
|
+
clianta,
|
|
425
|
+
type TrackerCore,
|
|
426
|
+
type MorrisBConfig,
|
|
427
|
+
type ConsentState,
|
|
428
|
+
type TrackingEvent,
|
|
429
|
+
} from '@clianta/sdk';
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
---
|
|
433
|
+
|
|
434
|
+
## Self-Hosted
|
|
435
|
+
|
|
436
|
+
For self-hosted deployments, configure the API endpoint:
|
|
437
|
+
|
|
438
|
+
```typescript
|
|
439
|
+
const tracker = clianta('WORKSPACE_ID', {
|
|
440
|
+
apiEndpoint: 'https://your-backend.com',
|
|
441
|
+
});
|
|
442
|
+
```
|
|
296
443
|
|
|
297
|
-
|
|
444
|
+
---
|
|
298
445
|
|
|
299
446
|
## Support
|
|
300
447
|
|
|
301
448
|
- Documentation: https://docs.clianta.online
|
|
302
|
-
- Issues: https://github.com/
|
|
303
|
-
-
|
|
449
|
+
- Issues: https://github.com/clianta/sdk/issues
|
|
450
|
+
- Email: support@clianta.online
|