@clianta/sdk 1.6.1 → 1.6.3

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 CHANGED
@@ -1,62 +1,47 @@
1
1
  # Clianta SDK
2
2
 
3
- Client-side tracking and CRM SDK for lead generation. Installs on your customer's website and automatically tracks visitors, captures forms, identifies leads, and writes data to your CRM — all from the frontend, no API key required.
3
+ > **Enterprise-grade visitor intelligence for your CRM.**
4
+ > Auto-captures every interaction on your website and feeds it directly into Clianta CRM — zero manual tracking code required.
4
5
 
5
- ## ✨ Key Features
6
+ [![npm](https://img.shields.io/npm/v/@clianta/sdk)](https://www.npmjs.com/package/@clianta/sdk)
7
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue)](https://www.typescriptlang.org/)
6
8
 
7
- - 📊 **Auto-Tracking** — Page views, clicks, forms, scroll depth, downloads, engagement, exit intent, errors, performance
8
- - 🔍 **Auto-Identify** — Detects email fields in forms and links anonymous visitors to CRM contacts
9
- - 🏢 **Group & Alias** — Associate visitors with companies (`group()`) and merge identities across devices (`alias()`)
10
- - 📱 **Screen Views** — Track mobile-first PWA / SPA screens with `screen()`
11
- - 🔧 **Event Middleware** — Intercept, transform, or drop events before they're sent with `use()`
12
- - 📝 **Public CRM API** — Create contacts, submit forms, log activities, create opportunities — secured by domain whitelist
13
- - 🔒 **GDPR Compliant** — Built-in consent management with event buffering, anonymous mode, cookie-less mode
14
- - ⚡ **Framework Support** — React, Next.js, Vue, Angular, Svelte, or vanilla JS
15
- - 🛡️ **Error Boundary** — React ErrorBoundary ensures SDK crashes never break your client's app
16
- - 📦 **~8KB gzipped** — Lightweight, zero dependencies
9
+ ---
10
+
11
+ ## Quick Start
17
12
 
18
- ## Installation
13
+ ### 1. Install
19
14
 
20
15
  ```bash
21
16
  npm install @clianta/sdk
22
- # or
23
- yarn add @clianta/sdk
24
17
  ```
25
18
 
26
- ### Script Tag (HTML, WordPress, Webflow)
19
+ ### 2. Integrate
27
20
 
28
- ```html
29
- <script src="https://cdn.clianta.online/sdk/v1/clianta.min.js"></script>
30
- ```
21
+ Pick your framework below. Each section includes the correct env vars and file paths for that framework.
31
22
 
32
23
  ---
33
24
 
34
- ## Quick Start
35
-
36
- ### React / Next.js (Recommended)
25
+ #### Next.js (App Router)
37
26
 
38
- ```tsx
39
- // clianta.config.ts
40
- import type { CliantaConfig } from '@clianta/sdk';
41
-
42
- const config: CliantaConfig = {
43
- projectId: 'YOUR_WORKSPACE_ID',
44
- debug: process.env.NODE_ENV === 'development',
45
- };
27
+ **Environment Variables** — set in `.env` or your hosting dashboard (Vercel, Netlify, etc.):
46
28
 
47
- export default config;
29
+ ```bash
30
+ NEXT_PUBLIC_CLIANTA_PROJECT_ID=your-project-id
31
+ NEXT_PUBLIC_CLIANTA_API_ENDPOINT=https://your-crm-backend.com
48
32
  ```
49
33
 
34
+ **Integration** — wrap your app in `app/layout.tsx`:
35
+
50
36
  ```tsx
51
37
  // app/layout.tsx
52
38
  import { CliantaProvider } from '@clianta/sdk/react';
53
- import cliantaConfig from '../clianta.config';
54
39
 
55
40
  export default function RootLayout({ children }: { children: React.ReactNode }) {
56
41
  return (
57
42
  <html lang="en">
58
43
  <body>
59
- <CliantaProvider config={cliantaConfig} onError={(err) => console.error(err)}>
44
+ <CliantaProvider projectId={process.env.NEXT_PUBLIC_CLIANTA_PROJECT_ID!}>
60
45
  {children}
61
46
  </CliantaProvider>
62
47
  </body>
@@ -65,84 +50,83 @@ export default function RootLayout({ children }: { children: React.ReactNode })
65
50
  }
66
51
  ```
67
52
 
68
- ```tsx
69
- // Any component
70
- import { useClianta, useCliantaReady } from '@clianta/sdk/react';
53
+ ---
71
54
 
72
- function PricingPage() {
73
- const tracker = useClianta();
74
- const { isReady } = useCliantaReady();
55
+ #### React (Vite)
75
56
 
76
- const handleClick = () => {
77
- tracker?.track('button_click', 'Get Started', { plan: 'pro' });
78
- };
57
+ **Environment Variables** set in `.env` or your hosting dashboard:
79
58
 
80
- return <button onClick={handleClick}>Get Started</button>;
81
- }
59
+ ```bash
60
+ VITE_CLIANTA_PROJECT_ID=your-project-id
61
+ VITE_CLIANTA_API_ENDPOINT=https://your-crm-backend.com
82
62
  ```
83
63
 
84
- ### NPM Module (Vanilla)
85
-
86
- ```typescript
87
- import { clianta } from '@clianta/sdk';
88
-
89
- const tracker = clianta('YOUR_WORKSPACE_ID', {
90
- debug: true,
91
- });
64
+ **Integration** wrap your app in `src/main.tsx`:
92
65
 
93
- tracker.track('button_click', 'Signup Button', { location: 'hero' });
94
- tracker.identify('user@example.com', { firstName: 'John' });
66
+ ```tsx
67
+ // src/main.tsx
68
+ import React from 'react';
69
+ import ReactDOM from 'react-dom/client';
70
+ import { CliantaProvider } from '@clianta/sdk/react';
71
+ import App from './App';
72
+
73
+ ReactDOM.createRoot(document.getElementById('root')!).render(
74
+ <React.StrictMode>
75
+ <CliantaProvider projectId={import.meta.env.VITE_CLIANTA_PROJECT_ID}>
76
+ <App />
77
+ </CliantaProvider>
78
+ </React.StrictMode>
79
+ );
95
80
  ```
96
81
 
97
- ### Script Tag (Any Website)
98
-
99
- ```html
100
- <script src="https://cdn.clianta.online/sdk/v1/clianta.min.js"></script>
101
- <script>
102
- var tracker = clianta('YOUR_WORKSPACE_ID');
103
- </script>
104
- ```
82
+ ---
105
83
 
106
- **WordPress**: Add to `Appearance > Theme Editor > header.php` before `</head>`
107
- **Webflow**: Add to `Project Settings > Custom Code > Head Code`
108
- **Shopify**: Add to `Online Store > Themes > Edit Code > theme.liquid`
84
+ #### Vue 3 (Vite)
109
85
 
110
- ---
86
+ **Environment Variables** — set in `.env` or your hosting dashboard:
111
87
 
112
- ## Framework Integrations
88
+ ```bash
89
+ VITE_CLIANTA_PROJECT_ID=your-project-id
90
+ VITE_CLIANTA_API_ENDPOINT=https://your-crm-backend.com
91
+ ```
113
92
 
114
- ### Vue 3
93
+ **Integration** register the plugin in `src/main.ts`:
115
94
 
116
95
  ```typescript
117
- // main.ts
96
+ // src/main.ts
118
97
  import { createApp } from 'vue';
119
98
  import { CliantaPlugin } from '@clianta/sdk/vue';
120
99
  import App from './App.vue';
121
100
 
122
101
  const app = createApp(App);
123
102
  app.use(CliantaPlugin, {
124
- projectId: 'YOUR_WORKSPACE_ID',
103
+ projectId: import.meta.env.VITE_CLIANTA_PROJECT_ID,
125
104
  });
126
105
  app.mount('#app');
127
106
  ```
128
107
 
129
- ```vue
130
- <script setup>
131
- import { useClianta, useCliantaTrack } from '@clianta/sdk/vue';
108
+ ---
109
+
110
+ #### Angular 16+
132
111
 
133
- const tracker = useClianta();
134
- const track = useCliantaTrack();
112
+ **Environment Variables** set in `src/environments/environment.ts`:
135
113
 
136
- track('button_click', 'CTA Clicked', { page: 'home' });
137
- </script>
114
+ ```typescript
115
+ // src/environments/environment.ts
116
+ export const environment = {
117
+ production: false,
118
+ cliantaProjectId: 'your-project-id',
119
+ cliantaApiEndpoint: 'https://your-crm-backend.com',
120
+ };
138
121
  ```
139
122
 
140
- ### Angular
123
+ **Integration** — create a service at `src/app/clianta.service.ts`:
141
124
 
142
125
  ```typescript
143
- // clianta.service.ts
126
+ // src/app/clianta.service.ts
144
127
  import { Injectable, OnDestroy } from '@angular/core';
145
- import { createCliantaTracker, type CliantaTrackerInstance } from '@clianta/sdk/angular';
128
+ import { createCliantaTracker, CliantaTrackerInstance } from '@clianta/sdk/angular';
129
+ import { environment } from '../environments/environment';
146
130
 
147
131
  @Injectable({ providedIn: 'root' })
148
132
  export class CliantaService implements OnDestroy {
@@ -151,29 +135,46 @@ export class CliantaService implements OnDestroy {
151
135
  constructor() {
152
136
  this.instance = createCliantaTracker({
153
137
  projectId: environment.cliantaProjectId,
138
+ apiEndpoint: environment.cliantaApiEndpoint,
154
139
  });
155
140
  }
156
141
 
157
142
  get tracker() { return this.instance.tracker; }
158
143
 
159
- track(eventType: string, eventName: string, props?: Record<string, unknown>) {
160
- this.instance.tracker?.track(eventType, eventName, props);
144
+ track(eventType: string, eventName: string, properties?: Record<string, unknown>) {
145
+ this.instance.tracker?.track(eventType, eventName, properties);
146
+ }
147
+
148
+ identify(email: string, traits?: Record<string, unknown>) {
149
+ return this.instance.tracker?.identify(email, traits);
161
150
  }
162
151
 
163
152
  ngOnDestroy() { this.instance.destroy(); }
164
153
  }
165
154
  ```
166
155
 
167
- ### Svelte
156
+ ---
157
+
158
+ #### Svelte / SvelteKit
159
+
160
+ **Environment Variables** — set in `.env` or your hosting dashboard:
161
+
162
+ ```bash
163
+ VITE_CLIANTA_PROJECT_ID=your-project-id
164
+ VITE_CLIANTA_API_ENDPOINT=https://your-crm-backend.com
165
+ ```
166
+
167
+ **Integration** — initialize in `src/routes/+layout.svelte`:
168
168
 
169
169
  ```svelte
170
- <!-- +layout.svelte -->
170
+ <!-- src/routes/+layout.svelte -->
171
171
  <script>
172
172
  import { initClianta } from '@clianta/sdk/svelte';
173
173
  import { setContext } from 'svelte';
174
174
 
175
175
  const clianta = initClianta({
176
- projectId: 'YOUR_WORKSPACE_ID',
176
+ projectId: import.meta.env.VITE_CLIANTA_PROJECT_ID,
177
+ apiEndpoint: import.meta.env.VITE_CLIANTA_API_ENDPOINT,
177
178
  });
178
179
 
179
180
  setContext('clianta', clianta);
@@ -182,260 +183,131 @@ export class CliantaService implements OnDestroy {
182
183
  <slot />
183
184
  ```
184
185
 
185
- ```svelte
186
- <!-- Any component -->
187
- <script>
188
- import { getContext } from 'svelte';
189
- const clianta = getContext('clianta');
190
-
191
- function handleClick() {
192
- clianta.track('button_click', 'CTA', { page: 'home' });
193
- }
194
- </script>
195
-
196
- <button on:click={handleClick}>Click Me</button>
197
- ```
186
+ **Done.** Every visitor interaction on your website is now flowing into your CRM.
198
187
 
199
188
  ---
200
189
 
201
- ## Configuration
202
-
203
- ```typescript
204
- const tracker = clianta('WORKSPACE_ID', {
205
- debug: false,
206
- autoPageView: true,
207
-
208
- plugins: [
209
- 'pageView', // Page views with SPA support
210
- 'forms', // Auto-detect & identify from forms
211
- 'scroll', // Scroll depth (25%, 50%, 75%, 100%)
212
- 'clicks', // Button/CTA clicks
213
- 'engagement', // User engagement detection
214
- 'downloads', // File download tracking
215
- 'exitIntent', // Exit intent detection
216
- 'errors', // JavaScript error tracking
217
- 'performance', // Web Vitals (LCP, FCP, CLS)
218
- ],
219
-
220
- batchSize: 10,
221
- flushInterval: 5000,
222
- sessionTimeout: 30 * 60 * 1000,
223
-
224
- consent: {
225
- waitForConsent: true,
226
- anonymousMode: true,
227
- },
228
-
229
- cookielessMode: false,
230
- });
231
- ```
190
+ ## What Gets Captured Automatically
232
191
 
233
- ---
192
+ Once integrated, the SDK captures the following with **zero additional code**:
234
193
 
235
- ## API Reference
194
+ | Category | What It Captures |
195
+ |---|---|
196
+ | **Page Views** | Every page load + SPA route changes (history API) |
197
+ | **Form Submissions** | All forms auto-captured with field data |
198
+ | **Visitor Identity** | Detects email fields in forms → auto-links visitor to CRM contact |
199
+ | **Scroll Depth** | 25%, 50%, 75%, 100% milestones |
200
+ | **Click Tracking** | Buttons, CTAs, navigation links |
201
+ | **File Downloads** | PDF, ZIP, DOC, XLSX, CSV, and more |
202
+ | **Engagement** | Active time on page vs idle time |
203
+ | **Exit Intent** | Mouse leaving viewport (desktop) |
204
+ | **JavaScript Errors** | Error message, stack trace, source file |
205
+ | **Core Web Vitals** | LCP, FCP, CLS, TTFB, FID |
236
206
 
237
- ### Tracking
207
+ Every event is enriched with: `visitorId`, `sessionId`, `contactId` (after auto-identify), UTM parameters, device/browser info, and `websiteDomain`.
238
208
 
239
- ```typescript
240
- // Custom events
241
- tracker.track('purchase', 'Order Completed', { orderId: '123', value: 99.99 });
209
+ ---
242
210
 
243
- // Page views (auto-tracked, or manual)
244
- tracker.page('Pricing Page', { plan: 'enterprise' });
211
+ ## Optional: Advanced Features
245
212
 
246
- // Screen views (mobile PWAs / SPAs)
247
- tracker.screen('Dashboard', { section: 'analytics' });
248
- ```
213
+ The SDK works perfectly without any of the following. These are for teams that want deeper control.
249
214
 
250
- ### Identification
215
+ ### Custom Event Tracking
251
216
 
252
217
  ```typescript
253
- // Identify visitor by email → creates/links CRM contact
254
- const contactId = await tracker.identify('john@example.com', {
255
- firstName: 'John',
256
- lastName: 'Doe',
257
- company: 'Acme Inc',
258
- phone: '+1234567890',
259
- });
218
+ import { useClianta } from '@clianta/sdk/react';
219
+
220
+ const tracker = useClianta();
221
+ tracker?.track('purchase', 'Order Completed', { value: 99, currency: 'USD' });
260
222
  ```
261
223
 
262
- ### Company Association (ABM)
224
+ ### Manual Identification
263
225
 
264
226
  ```typescript
265
- // Associate visitor with a company
266
- tracker.group('company-123', {
267
- name: 'Acme Inc',
268
- industry: 'SaaS',
269
- employees: 200,
270
- plan: 'enterprise',
271
- });
272
- // All subsequent events include groupId
227
+ tracker?.identify('user@example.com', { firstName: 'John', company: 'Acme' });
273
228
  ```
274
229
 
275
- ### Identity Merging
230
+ ### Company Association
276
231
 
277
232
  ```typescript
278
- // Merge anonymous visitor with a known user (cross-device)
279
- await tracker.alias('known-user-456');
280
-
281
- // Or merge two specific IDs
282
- await tracker.alias('new-id', 'old-anonymous-id');
233
+ tracker?.group('company-123', { name: 'Acme Inc', plan: 'enterprise' });
283
234
  ```
284
235
 
285
236
  ### Event Middleware
286
237
 
287
238
  ```typescript
288
- // Strip PII before sending events
289
- tracker.use((event, next) => {
290
- delete event.properties.email;
291
- delete event.properties.phone;
292
- next(); // pass through — or don't call next() to drop the event
293
- });
294
-
295
- // Add custom context to all events
296
- tracker.use((event, next) => {
297
- event.properties.appVersion = '2.1.0';
298
- event.properties.environment = 'production';
239
+ tracker?.use((event, next) => {
240
+ // Strip sensitive data before sending
241
+ delete event.properties.creditCard;
299
242
  next();
300
243
  });
301
244
  ```
302
245
 
303
- ### Lifecycle
304
-
305
- ```typescript
306
- // Wait for SDK to be ready
307
- tracker.onReady(() => {
308
- console.log('Clianta SDK initialized!');
309
- });
310
-
311
- // Check if ready synchronously
312
- if (tracker.isReady()) {
313
- tracker.track('ready_check', 'SDK Ready');
314
- }
315
-
316
- // React hook
317
- const { isReady, tracker } = useCliantaReady();
318
- ```
319
-
320
- ### Public CRM API
321
-
322
- Write CRM data directly from the frontend — no API key needed, secured by domain whitelist:
246
+ ### Frontend CRM Operations
323
247
 
324
248
  ```typescript
325
- // Create or upsert a contact
326
- await tracker.createContact({
327
- email: 'lead@example.com',
328
- firstName: 'Jane',
329
- source: 'website',
330
- });
249
+ // Create or update a contact (secured by domain whitelist, no API key needed)
250
+ await tracker?.createContact({ email: 'lead@example.com', firstName: 'Jane', company: 'Acme' });
331
251
 
332
- // Submit a form (auto-creates/updates contact)
333
- await tracker.submitForm('contact-form', {
334
- email: 'visitor@example.com',
335
- firstName: 'Alex',
336
- message: 'I want a demo',
337
- });
338
-
339
- // Log an activity
340
- await tracker.logActivity({
341
- contactId: 'contact-123',
342
- type: 'meeting',
343
- subject: 'Product Demo',
344
- });
252
+ // Submit a form programmatically
253
+ await tracker?.submitForm('demo-request', { email: 'visitor@co.com', message: 'Demo please' });
345
254
 
346
- // Create an opportunity
347
- await tracker.createOpportunity({
348
- title: 'Enterprise Deal',
349
- contactEmail: 'lead@example.com',
350
- value: 50000,
351
- pipelineId: 'pipeline-1',
352
- });
255
+ // Create a sales opportunity
256
+ await tracker?.createOpportunity({ title: 'Enterprise Deal', contactEmail: 'vp@acme.com', value: 50000 });
353
257
  ```
354
258
 
355
- ### Consent & GDPR
356
-
357
- ```typescript
358
- // Wait for consent — events are buffered until granted
359
- const tracker = clianta('WORKSPACE_ID', {
360
- consent: { waitForConsent: true },
361
- });
362
-
363
- tracker.track('page_view', 'Home'); // buffered
364
-
365
- // User accepts cookies
366
- tracker.consent({ analytics: true, marketing: false });
367
- // → buffered events flush automatically
259
+ ### GDPR / Consent Management
368
260
 
369
- // Get current consent state
370
- const state = tracker.getConsentState();
371
-
372
- // Delete all stored data (GDPR right-to-erasure)
373
- tracker.deleteData();
374
-
375
- // Cookie-less mode (session only, no persistent storage)
376
- const tracker = clianta('WORKSPACE_ID', { cookielessMode: true });
377
- ```
261
+ ```tsx
262
+ // Buffer events until consent is given:
263
+ <CliantaProvider projectId="xxx" config={{ consent: { waitForConsent: true } }}>
378
264
 
379
- ### Utility
265
+ // In your cookie banner:
266
+ tracker?.consent({ analytics: true, marketing: false });
380
267
 
381
- ```typescript
382
- tracker.getVisitorId(); // Current anonymous visitor ID
383
- tracker.getSessionId(); // Current session ID
384
- tracker.getWorkspaceId(); // Workspace this tracker belongs to
385
- await tracker.flush(); // Force send queued events
386
- tracker.reset(); // Reset visitor (for logout)
387
- tracker.debug(true); // Enable console logging
268
+ // Right to erasure:
269
+ tracker?.deleteData();
388
270
  ```
389
271
 
390
272
  ---
391
273
 
392
274
  ## TypeScript
393
275
 
394
- Full TypeScript support with type exports:
276
+ Full type support included:
395
277
 
396
278
  ```typescript
397
- import {
398
- clianta,
399
- type TrackerCore,
400
- type CliantaConfig,
401
- type ConsentState,
402
- type TrackingEvent,
403
- type GroupTraits,
404
- type MiddlewareFn,
405
- type PublicContactData,
406
- type PublicFormSubmission,
407
- type PublicCrmResult,
408
- } from '@clianta/sdk';
279
+ import type { TrackerCore, CliantaConfig, GroupTraits, MiddlewareFn } from '@clianta/sdk';
409
280
  ```
410
281
 
411
282
  ---
412
283
 
413
- ## What Gets Auto-Tracked
414
-
415
- Once installed, the SDK automatically captures (no code needed):
416
-
417
- | Event | Data Collected |
418
- |-------|---------------|
419
- | **Page Views** | URL, title, referrer, SPA navigation |
420
- | **Form Submissions** | All form fields, auto-identifies by email |
421
- | **Scroll Depth** | 25%, 50%, 75%, 100% milestones |
422
- | **Button Clicks** | Element text, ID, CSS selector |
423
- | **Downloads** | File URL, extension, click source |
424
- | **Engagement** | Time on page, active vs idle |
425
- | **Exit Intent** | Mouse leaving viewport (desktop) |
426
- | **Errors** | Error message, stack trace, URL |
427
- | **Performance** | LCP, FCP, CLS, TTFB (Web Vitals) |
284
+ ## Configuration Reference
428
285
 
429
- Every event is enriched with: `visitorId`, `sessionId`, `contactId` (if identified), `groupId` (if grouped), UTM parameters, device info, and `websiteDomain`.
286
+ | Option | Type | Default | Description |
287
+ |---|---|---|---|
288
+ | `projectId` | `string` | — | Your project ID from Clianta dashboard |
289
+ | `apiEndpoint` | `string` | Auto-detect from env vars | CRM backend URL |
290
+ | `debug` | `boolean` | `false` | Enable verbose console logging |
291
+ | `plugins` | `PluginName[]` | All enabled | Plugins to activate |
292
+ | `consent` | `ConsentConfig` | `undefined` | GDPR consent configuration |
293
+ | `cookielessMode` | `boolean` | `false` | Session-only storage (no persistence) |
294
+ | `sessionTimeout` | `number` | `1800000` | Session timeout in ms (default: 30 min) |
295
+ | `batchSize` | `number` | `10` | Events to batch before sending |
296
+ | `flushInterval` | `number` | `5000` | Auto-flush interval in ms |
430
297
 
431
298
  ---
432
299
 
300
+ ## Security
433
301
 
302
+ - **Domain Whitelisting** — Only requests from your registered domains are accepted
303
+ - **No API Keys on Frontend** — CRM write operations are secured by project ID + domain whitelist
304
+ - **Rate Limiting** — 100 requests/minute per IP
305
+ - **Field Whitelisting** — Only safe fields accepted (no `leadScore`, `assignedTo`, etc.)
434
306
 
435
307
  ---
436
308
 
437
309
  ## Support
438
310
 
439
- - Documentation: https://docs.clianta.online
440
- - Issues: https://github.com/clianta/sdk/issues
441
- - Email: support@clianta.online
311
+ - **Documentation**: [docs.clianta.online](https://docs.clianta.online)
312
+ - **NPM**: [@clianta/sdk](https://www.npmjs.com/package/@clianta/sdk)
313
+ - **Email**: support@clianta.online
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Clianta SDK v1.6.1
2
+ * Clianta SDK v1.6.3
3
3
  * (c) 2026 Clianta
4
4
  * Released under the MIT License.
5
5
  */
@@ -10,7 +10,7 @@
10
10
  * @see SDK_VERSION in core/config.ts
11
11
  */
12
12
  /** SDK Version */
13
- const SDK_VERSION = '1.6.1';
13
+ const SDK_VERSION = '1.6.2';
14
14
  /** Default API endpoint — reads from env or falls back to localhost */
15
15
  const getDefaultApiEndpoint = () => {
16
16
  // Build-time env var (works with Next.js, Vite, CRA, etc.)
@@ -28,7 +28,7 @@ const getDefaultApiEndpoint = () => {
28
28
  }
29
29
  return 'http://localhost:5000';
30
30
  };
31
- /** Core plugins enabled by default */
31
+ /** Core plugins enabled by default — all auto-track with zero config */
32
32
  const DEFAULT_PLUGINS = [
33
33
  'pageView',
34
34
  'forms',
@@ -37,6 +37,8 @@ const DEFAULT_PLUGINS = [
37
37
  'engagement',
38
38
  'downloads',
39
39
  'exitIntent',
40
+ 'errors',
41
+ 'performance',
40
42
  ];
41
43
  /** Default configuration values */
42
44
  const DEFAULT_CONFIG = {
@@ -3212,7 +3214,7 @@ function clianta(workspaceId, config) {
3212
3214
  globalInstance = new Tracker(workspaceId, config);
3213
3215
  return globalInstance;
3214
3216
  }
3215
- // Attach to window for <script> tag usage
3217
+ // Attach to window for <script> tag usage + AUTO-INIT
3216
3218
  if (typeof window !== 'undefined') {
3217
3219
  window.clianta = clianta;
3218
3220
  window.Clianta = {
@@ -3220,6 +3222,32 @@ if (typeof window !== 'undefined') {
3220
3222
  Tracker,
3221
3223
  ConsentManager,
3222
3224
  };
3225
+ // ============================================
3226
+ // AUTO-INIT FROM SCRIPT TAG
3227
+ // ============================================
3228
+ // Enables true plug-and-play:
3229
+ // <script src="clianta.min.js" data-project-id="YOUR_ID"></script>
3230
+ // That's it — everything auto-tracks.
3231
+ const autoInit = () => {
3232
+ const scripts = document.querySelectorAll('script[data-project-id]');
3233
+ const script = scripts[scripts.length - 1]; // last matching script
3234
+ if (!script)
3235
+ return;
3236
+ const projectId = script.getAttribute('data-project-id');
3237
+ if (!projectId)
3238
+ return;
3239
+ const debug = script.hasAttribute('data-debug');
3240
+ const instance = clianta(projectId, { debug });
3241
+ // Expose the auto-initialized instance globally
3242
+ window.__clianta = instance;
3243
+ };
3244
+ // Run after DOM is ready
3245
+ if (document.readyState === 'loading') {
3246
+ document.addEventListener('DOMContentLoaded', autoInit);
3247
+ }
3248
+ else {
3249
+ autoInit();
3250
+ }
3223
3251
  }
3224
3252
 
3225
3253
  /**
@@ -3241,8 +3269,6 @@ if (typeof window !== 'undefined') {
3241
3269
  * constructor() {
3242
3270
  * this.instance = createCliantaTracker({
3243
3271
  * projectId: environment.cliantaProjectId,
3244
- * apiEndpoint: environment.cliantaApiEndpoint,
3245
- * debug: !environment.production,
3246
3272
  * });
3247
3273
  * }
3248
3274
  *
@@ -3270,7 +3296,6 @@ if (typeof window !== 'undefined') {
3270
3296
  * @example
3271
3297
  * const instance = createCliantaTracker({
3272
3298
  * projectId: 'your-project-id',
3273
- * apiEndpoint: environment.cliantaApiEndpoint || 'http://localhost:5000',
3274
3299
  * });
3275
3300
  *
3276
3301
  * instance.tracker?.track('page_view', 'Home Page');