@clianta/sdk 1.0.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 +96 -0
- package/LICENSE +21 -0
- package/README.md +303 -0
- package/dist/clianta.cjs.js +1809 -0
- package/dist/clianta.cjs.js.map +1 -0
- package/dist/clianta.esm.js +1801 -0
- package/dist/clianta.esm.js.map +1 -0
- package/dist/clianta.umd.js +1815 -0
- package/dist/clianta.umd.js.map +1 -0
- package/dist/clianta.umd.min.js +7 -0
- package/dist/clianta.umd.min.js.map +1 -0
- package/dist/index.d.ts +353 -0
- package/package.json +69 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the Clianta SDK will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2026-01-30
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial release of Clianta SDK
|
|
12
|
+
- **Tracking & Analytics**
|
|
13
|
+
- Automatic page view tracking with SPA support
|
|
14
|
+
- Form tracking with auto-identification
|
|
15
|
+
- Scroll depth tracking (25%, 50%, 75%, 100%)
|
|
16
|
+
- Click tracking for buttons and CTAs
|
|
17
|
+
- User engagement detection
|
|
18
|
+
- File download tracking
|
|
19
|
+
- Exit intent detection
|
|
20
|
+
- JavaScript error tracking (optional plugin)
|
|
21
|
+
- Web Vitals and performance metrics (optional plugin)
|
|
22
|
+
- Offline event queue with automatic retry
|
|
23
|
+
- Event batching for efficient transmission
|
|
24
|
+
|
|
25
|
+
- **CRM API Client**
|
|
26
|
+
- Full CRUD operations for contacts
|
|
27
|
+
- Full CRUD operations for opportunities
|
|
28
|
+
- Opportunity stage management
|
|
29
|
+
- Authenticated API requests with token support
|
|
30
|
+
- Paginated list queries
|
|
31
|
+
- Type-safe API responses
|
|
32
|
+
|
|
33
|
+
- **Developer Experience**
|
|
34
|
+
- Full TypeScript support with type definitions
|
|
35
|
+
- Multiple build formats (UMD, ESM, CJS)
|
|
36
|
+
- Debug mode with verbose logging
|
|
37
|
+
- Plugin-based architecture
|
|
38
|
+
- Tree-shakeable exports
|
|
39
|
+
- Zero runtime dependencies
|
|
40
|
+
|
|
41
|
+
- **Privacy & Compliance**
|
|
42
|
+
- Consent management system
|
|
43
|
+
- Cookie-less tracking option
|
|
44
|
+
- Visitor ID persistence across sessions
|
|
45
|
+
- Session management with configurable timeout
|
|
46
|
+
|
|
47
|
+
### Technical Details
|
|
48
|
+
- SDK Version: 1.0.0
|
|
49
|
+
- Build Formats: UMD (minified & unminified), ESM, CJS
|
|
50
|
+
- TypeScript: Full type definitions included
|
|
51
|
+
- Bundle Size: ~8KB gzipped (tracking only), ~12KB with CRM client
|
|
52
|
+
- Browser Support: Modern browsers (ES2015+)
|
|
53
|
+
- Node.js: 18.0.0+
|
|
54
|
+
|
|
55
|
+
## [Unreleased]
|
|
56
|
+
|
|
57
|
+
### Planned Features
|
|
58
|
+
- Workflow automation helpers
|
|
59
|
+
- Email campaign integration
|
|
60
|
+
- Advanced analytics and reporting
|
|
61
|
+
- Real-time notifications
|
|
62
|
+
- Webhook management
|
|
63
|
+
- Custom event validation
|
|
64
|
+
- A/B testing support
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Migration Guide
|
|
69
|
+
|
|
70
|
+
### From MorrisB SDK v3.x
|
|
71
|
+
|
|
72
|
+
The Clianta SDK is a complete rebrand and enhancement of the MorrisB Tracking SDK.
|
|
73
|
+
|
|
74
|
+
**Breaking Changes:**
|
|
75
|
+
1. Package name changed from `@morrisb/tracker` to `@clianta/sdk`
|
|
76
|
+
2. Global variable changed from `MorrisB` to `Clianta`
|
|
77
|
+
3. Initialization function changed from `morrisb()` to `clianta()`
|
|
78
|
+
4. Default API endpoint changed to `https://api.clianta.online`
|
|
79
|
+
|
|
80
|
+
**Migration Steps:**
|
|
81
|
+
|
|
82
|
+
```diff
|
|
83
|
+
- import { morrisb } from '@morrisb/tracker';
|
|
84
|
+
+ import { clianta } from '@clianta/sdk';
|
|
85
|
+
|
|
86
|
+
- const tracker = morrisb('workspace-id');
|
|
87
|
+
+ const tracker = clianta('workspace-id');
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**New Features:**
|
|
91
|
+
- CRM API client for managing contacts and opportunities
|
|
92
|
+
- Enhanced TypeScript support
|
|
93
|
+
- Improved error handling
|
|
94
|
+
- Better offline support
|
|
95
|
+
|
|
96
|
+
All tracking features remain compatible with the previous version.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Clianta
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
# @clianta/sdk
|
|
2
|
+
|
|
3
|
+
Professional CRM and tracking SDK for Clianta - Track visitors, manage contacts, opportunities, and analyze user behavior.
|
|
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
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
### NPM
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npm install @clianta/sdk
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Script Tag (CDN)
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<script src="https://unpkg.com/@clianta/sdk@1.0.0/dist/clianta.umd.min.js"></script>
|
|
45
|
+
<script>
|
|
46
|
+
const tracker = Clianta.clianta('YOUR_WORKSPACE_ID');
|
|
47
|
+
</script>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Quick Start
|
|
51
|
+
|
|
52
|
+
### Tracking
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
import { clianta } from '@clianta/sdk';
|
|
56
|
+
|
|
57
|
+
// Initialize tracker
|
|
58
|
+
const tracker = clianta('YOUR_WORKSPACE_ID', {
|
|
59
|
+
debug: true,
|
|
60
|
+
apiEndpoint: 'https://api.clianta.online'
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Track custom event
|
|
64
|
+
tracker.track('custom', 'Button Clicked', {
|
|
65
|
+
buttonId: 'signup-cta',
|
|
66
|
+
location: 'hero-section',
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Identify a visitor
|
|
70
|
+
tracker.identify('john@example.com', {
|
|
71
|
+
firstName: 'John',
|
|
72
|
+
lastName: 'Doe',
|
|
73
|
+
company: 'Acme Inc',
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Manual page view (automatic by default)
|
|
77
|
+
tracker.page('Pricing Page', {
|
|
78
|
+
plan: 'enterprise',
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### CRM API
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
import { CRMClient } from '@clianta/sdk';
|
|
86
|
+
|
|
87
|
+
// Initialize CRM client
|
|
88
|
+
const crm = new CRMClient(
|
|
89
|
+
'https://api.clianta.online',
|
|
90
|
+
'YOUR_WORKSPACE_ID',
|
|
91
|
+
'YOUR_AUTH_TOKEN'
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
// Get all contacts
|
|
95
|
+
const contacts = await crm.getContacts({
|
|
96
|
+
page: 1,
|
|
97
|
+
limit: 50,
|
|
98
|
+
status: 'lead'
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Create a new contact
|
|
102
|
+
const newContact = await crm.createContact({
|
|
103
|
+
email: 'jane@example.com',
|
|
104
|
+
firstName: 'Jane',
|
|
105
|
+
lastName: 'Smith',
|
|
106
|
+
company: 'Tech Corp'
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Create an opportunity
|
|
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
|
+
});
|
|
118
|
+
|
|
119
|
+
// Update opportunity stage
|
|
120
|
+
await crm.moveOpportunity(opportunity.data._id, 'new-stage-id');
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Configuration
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
const tracker = clianta('YOUR_WORKSPACE_ID', {
|
|
127
|
+
// Backend API URL (auto-detected by default)
|
|
128
|
+
apiEndpoint: 'https://api.clianta.online',
|
|
129
|
+
|
|
130
|
+
// Enable debug logging
|
|
131
|
+
debug: false,
|
|
132
|
+
|
|
133
|
+
// Auto-track page views
|
|
134
|
+
autoPageView: true,
|
|
135
|
+
|
|
136
|
+
// Plugins to enable (default: all core plugins)
|
|
137
|
+
plugins: [
|
|
138
|
+
'pageView',
|
|
139
|
+
'forms',
|
|
140
|
+
'scroll',
|
|
141
|
+
'clicks',
|
|
142
|
+
'engagement',
|
|
143
|
+
'downloads',
|
|
144
|
+
'exitIntent',
|
|
145
|
+
// Optional:
|
|
146
|
+
// 'errors',
|
|
147
|
+
// 'performance',
|
|
148
|
+
],
|
|
149
|
+
|
|
150
|
+
// Session timeout (default: 30 minutes)
|
|
151
|
+
sessionTimeout: 30 * 60 * 1000,
|
|
152
|
+
|
|
153
|
+
// Batch size before sending (default: 10)
|
|
154
|
+
batchSize: 10,
|
|
155
|
+
|
|
156
|
+
// Flush interval in ms (default: 5000)
|
|
157
|
+
flushInterval: 5000,
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## API Reference
|
|
162
|
+
|
|
163
|
+
### Tracker Methods
|
|
164
|
+
|
|
165
|
+
#### `tracker.track(eventType, eventName, properties?)`
|
|
166
|
+
Track a custom event.
|
|
167
|
+
|
|
168
|
+
#### `tracker.identify(email, traits?)`
|
|
169
|
+
Identify a visitor and link to a contact.
|
|
170
|
+
|
|
171
|
+
#### `tracker.page(name?, properties?)`
|
|
172
|
+
Track a page view (automatic by default).
|
|
173
|
+
|
|
174
|
+
#### `tracker.debug(enabled)`
|
|
175
|
+
Enable or disable debug mode.
|
|
176
|
+
|
|
177
|
+
#### `tracker.getVisitorId()`
|
|
178
|
+
Get the current visitor ID.
|
|
179
|
+
|
|
180
|
+
#### `tracker.getSessionId()`
|
|
181
|
+
Get the current session ID.
|
|
182
|
+
|
|
183
|
+
#### `tracker.flush()`
|
|
184
|
+
Force send all queued events.
|
|
185
|
+
|
|
186
|
+
#### `tracker.reset()`
|
|
187
|
+
Reset visitor data (call on logout).
|
|
188
|
+
|
|
189
|
+
### CRM Client Methods
|
|
190
|
+
|
|
191
|
+
#### Contacts
|
|
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
|
|
197
|
+
|
|
198
|
+
#### Opportunities
|
|
199
|
+
- `getOpportunities(params?)` - Get all opportunities with pagination
|
|
200
|
+
- `getOpportunity(opportunityId)` - Get a single opportunity
|
|
201
|
+
- `createOpportunity(opportunity)` - Create a new opportunity
|
|
202
|
+
- `updateOpportunity(opportunityId, updates)` - Update an opportunity
|
|
203
|
+
- `deleteOpportunity(opportunityId)` - Delete an opportunity
|
|
204
|
+
- `moveOpportunity(opportunityId, stageId)` - Move opportunity to a different stage
|
|
205
|
+
|
|
206
|
+
## Framework Integration
|
|
207
|
+
|
|
208
|
+
### React
|
|
209
|
+
|
|
210
|
+
```tsx
|
|
211
|
+
import { useEffect } from 'react';
|
|
212
|
+
import { clianta } from '@clianta/sdk';
|
|
213
|
+
|
|
214
|
+
function App() {
|
|
215
|
+
useEffect(() => {
|
|
216
|
+
const tracker = clianta('YOUR_WORKSPACE_ID', {
|
|
217
|
+
debug: process.env.NODE_ENV === 'development'
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
return () => {
|
|
221
|
+
tracker.flush();
|
|
222
|
+
};
|
|
223
|
+
}, []);
|
|
224
|
+
|
|
225
|
+
return <div>Your App</div>;
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Next.js
|
|
230
|
+
|
|
231
|
+
```tsx
|
|
232
|
+
// app/layout.tsx or pages/_app.tsx
|
|
233
|
+
import { clianta } from '@clianta/sdk';
|
|
234
|
+
|
|
235
|
+
if (typeof window !== 'undefined') {
|
|
236
|
+
clianta('YOUR_WORKSPACE_ID');
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Vue.js
|
|
241
|
+
|
|
242
|
+
```vue
|
|
243
|
+
<script setup>
|
|
244
|
+
import { onMounted, onUnmounted } from 'vue';
|
|
245
|
+
import { clianta } from '@clianta/sdk';
|
|
246
|
+
|
|
247
|
+
let tracker;
|
|
248
|
+
|
|
249
|
+
onMounted(() => {
|
|
250
|
+
tracker = clianta('YOUR_WORKSPACE_ID');
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
onUnmounted(() => {
|
|
254
|
+
tracker?.flush();
|
|
255
|
+
});
|
|
256
|
+
</script>
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## TypeScript Support
|
|
260
|
+
|
|
261
|
+
The SDK is written in TypeScript and includes full type definitions:
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
import type {
|
|
265
|
+
TrackerCore,
|
|
266
|
+
Contact,
|
|
267
|
+
Opportunity,
|
|
268
|
+
ApiResponse
|
|
269
|
+
} from '@clianta/sdk';
|
|
270
|
+
|
|
271
|
+
const tracker: TrackerCore = clianta('workspace-id');
|
|
272
|
+
|
|
273
|
+
const response: ApiResponse<Contact> = await crm.getContact('contact-id');
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## Development
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
# Install dependencies
|
|
280
|
+
npm install
|
|
281
|
+
|
|
282
|
+
# Build
|
|
283
|
+
npm run build
|
|
284
|
+
|
|
285
|
+
# Watch mode
|
|
286
|
+
npm run build:watch
|
|
287
|
+
|
|
288
|
+
# Run tests
|
|
289
|
+
npm test
|
|
290
|
+
|
|
291
|
+
# Type check
|
|
292
|
+
npm run typecheck
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## License
|
|
296
|
+
|
|
297
|
+
MIT © Clianta
|
|
298
|
+
|
|
299
|
+
## Support
|
|
300
|
+
|
|
301
|
+
- Documentation: https://docs.clianta.online
|
|
302
|
+
- Issues: https://github.com/xeet991fx/cliantaSDK/issues
|
|
303
|
+
- Website: https://clianta.online
|