@clianta/sdk 1.5.0 → 1.5.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/CHANGELOG.md +16 -0
- package/dist/angular.cjs.js +100 -13
- package/dist/angular.cjs.js.map +1 -1
- package/dist/angular.d.ts +67 -1
- package/dist/angular.esm.js +100 -13
- package/dist/angular.esm.js.map +1 -1
- package/dist/clianta.cjs.js +99 -12
- package/dist/clianta.cjs.js.map +1 -1
- package/dist/clianta.esm.js +99 -12
- package/dist/clianta.esm.js.map +1 -1
- package/dist/clianta.umd.js +99 -12
- 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 +93 -2
- package/dist/react.cjs.js +100 -13
- package/dist/react.cjs.js.map +1 -1
- package/dist/react.d.ts +67 -1
- package/dist/react.esm.js +100 -13
- package/dist/react.esm.js.map +1 -1
- package/dist/svelte.cjs.js +100 -13
- package/dist/svelte.cjs.js.map +1 -1
- package/dist/svelte.d.ts +67 -1
- package/dist/svelte.esm.js +100 -13
- package/dist/svelte.esm.js.map +1 -1
- package/dist/vue.cjs.js +100 -13
- package/dist/vue.cjs.js.map +1 -1
- package/dist/vue.d.ts +67 -1
- package/dist/vue.esm.js +100 -13
- package/dist/vue.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/vue.d.ts
CHANGED
|
@@ -139,6 +139,16 @@ interface TrackerCore {
|
|
|
139
139
|
getVisitorEngagement(): Promise<EngagementMetrics | null>;
|
|
140
140
|
/** Send a server-side inbound event (requires apiKey in config) */
|
|
141
141
|
sendEvent(payload: InboundEventPayload): Promise<InboundEventResult>;
|
|
142
|
+
/** Create or update a contact by email (upsert) */
|
|
143
|
+
createContact(data: PublicContactData): Promise<PublicCrmResult>;
|
|
144
|
+
/** Update an existing contact by ID (limited fields) */
|
|
145
|
+
updateContact(contactId: string, data: PublicContactUpdate): Promise<PublicCrmResult>;
|
|
146
|
+
/** Submit a form — creates/updates contact from form data */
|
|
147
|
+
submitForm(formId: string, data: PublicFormSubmission): Promise<PublicCrmResult>;
|
|
148
|
+
/** Log an activity linked to a contact (append-only) */
|
|
149
|
+
logActivity(data: PublicActivityData): Promise<PublicCrmResult>;
|
|
150
|
+
/** Create an opportunity (e.g., from "Request Demo" forms) */
|
|
151
|
+
createOpportunity(data: PublicOpportunityData): Promise<PublicCrmResult>;
|
|
142
152
|
}
|
|
143
153
|
interface VisitorProfile {
|
|
144
154
|
visitorId: string;
|
|
@@ -210,6 +220,62 @@ interface VisitorActivityOptions {
|
|
|
210
220
|
startDate?: string;
|
|
211
221
|
endDate?: string;
|
|
212
222
|
}
|
|
223
|
+
interface PublicContactData {
|
|
224
|
+
email: string;
|
|
225
|
+
firstName?: string;
|
|
226
|
+
lastName?: string;
|
|
227
|
+
company?: string;
|
|
228
|
+
jobTitle?: string;
|
|
229
|
+
phone?: string;
|
|
230
|
+
source?: string;
|
|
231
|
+
tags?: string[];
|
|
232
|
+
customFields?: Record<string, unknown>;
|
|
233
|
+
}
|
|
234
|
+
interface PublicContactUpdate {
|
|
235
|
+
firstName?: string;
|
|
236
|
+
lastName?: string;
|
|
237
|
+
company?: string;
|
|
238
|
+
jobTitle?: string;
|
|
239
|
+
phone?: string;
|
|
240
|
+
tags?: string[];
|
|
241
|
+
customFields?: Record<string, unknown>;
|
|
242
|
+
}
|
|
243
|
+
interface PublicActivityData {
|
|
244
|
+
contactId: string;
|
|
245
|
+
type: 'call' | 'email' | 'meeting' | 'note' | 'other';
|
|
246
|
+
title: string;
|
|
247
|
+
description?: string;
|
|
248
|
+
direction?: 'inbound' | 'outbound';
|
|
249
|
+
duration?: number;
|
|
250
|
+
emailSubject?: string;
|
|
251
|
+
metadata?: Record<string, unknown>;
|
|
252
|
+
}
|
|
253
|
+
interface PublicOpportunityData {
|
|
254
|
+
title: string;
|
|
255
|
+
contactId: string;
|
|
256
|
+
pipelineId: string;
|
|
257
|
+
stageId: string;
|
|
258
|
+
value?: number;
|
|
259
|
+
currency?: string;
|
|
260
|
+
description?: string;
|
|
261
|
+
expectedCloseDate?: string;
|
|
262
|
+
customFields?: Record<string, unknown>;
|
|
263
|
+
}
|
|
264
|
+
interface PublicFormSubmission {
|
|
265
|
+
fields: Record<string, unknown>;
|
|
266
|
+
metadata?: {
|
|
267
|
+
visitorId?: string;
|
|
268
|
+
sessionId?: string;
|
|
269
|
+
pageUrl?: string;
|
|
270
|
+
referrer?: string;
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
interface PublicCrmResult {
|
|
274
|
+
success: boolean;
|
|
275
|
+
data?: Record<string, unknown>;
|
|
276
|
+
error?: string;
|
|
277
|
+
status?: number;
|
|
278
|
+
}
|
|
213
279
|
|
|
214
280
|
/**
|
|
215
281
|
* Clianta SDK - Vue 3 Integration
|
|
@@ -233,7 +299,7 @@ interface CliantaPluginOptions extends CliantaConfig {
|
|
|
233
299
|
* const app = createApp(App);
|
|
234
300
|
* app.use(CliantaPlugin, {
|
|
235
301
|
* projectId: 'your-project-id',
|
|
236
|
-
* apiEndpoint:
|
|
302
|
+
* apiEndpoint: import.meta.env.VITE_CLIANTA_API_ENDPOINT || 'http://localhost:5000',
|
|
237
303
|
* debug: import.meta.env.DEV,
|
|
238
304
|
* });
|
|
239
305
|
* app.mount('#app');
|
package/dist/vue.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Clianta SDK v1.5.
|
|
2
|
+
* Clianta SDK v1.5.1
|
|
3
3
|
* (c) 2026 Clianta
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -11,15 +11,22 @@ import { ref, inject } from 'vue';
|
|
|
11
11
|
*/
|
|
12
12
|
/** SDK Version */
|
|
13
13
|
const SDK_VERSION = '1.4.0';
|
|
14
|
-
/** Default API endpoint
|
|
14
|
+
/** Default API endpoint — reads from env or falls back to localhost */
|
|
15
15
|
const getDefaultApiEndpoint = () => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
// Build-time env var (works with Next.js, Vite, CRA, etc.)
|
|
17
|
+
if (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_CLIANTA_API_ENDPOINT) {
|
|
18
|
+
return process.env.NEXT_PUBLIC_CLIANTA_API_ENDPOINT;
|
|
19
|
+
}
|
|
20
|
+
if (typeof process !== 'undefined' && process.env?.VITE_CLIANTA_API_ENDPOINT) {
|
|
21
|
+
return process.env.VITE_CLIANTA_API_ENDPOINT;
|
|
22
|
+
}
|
|
23
|
+
if (typeof process !== 'undefined' && process.env?.REACT_APP_CLIANTA_API_ENDPOINT) {
|
|
24
|
+
return process.env.REACT_APP_CLIANTA_API_ENDPOINT;
|
|
21
25
|
}
|
|
22
|
-
|
|
26
|
+
if (typeof process !== 'undefined' && process.env?.CLIANTA_API_ENDPOINT) {
|
|
27
|
+
return process.env.CLIANTA_API_ENDPOINT;
|
|
28
|
+
}
|
|
29
|
+
return 'http://localhost:5000';
|
|
23
30
|
};
|
|
24
31
|
/** Core plugins enabled by default */
|
|
25
32
|
const DEFAULT_PLUGINS = [
|
|
@@ -1781,7 +1788,7 @@ class PopupFormsPlugin extends BasePlugin {
|
|
|
1781
1788
|
return;
|
|
1782
1789
|
const config = this.tracker.getConfig();
|
|
1783
1790
|
const workspaceId = this.tracker.getWorkspaceId();
|
|
1784
|
-
const apiEndpoint = config.apiEndpoint || '
|
|
1791
|
+
const apiEndpoint = config.apiEndpoint || 'http://localhost:5000';
|
|
1785
1792
|
try {
|
|
1786
1793
|
const url = encodeURIComponent(window.location.href);
|
|
1787
1794
|
const response = await fetch(`${apiEndpoint}/api/public/lead-forms/${workspaceId}?url=${url}`);
|
|
@@ -1886,7 +1893,7 @@ class PopupFormsPlugin extends BasePlugin {
|
|
|
1886
1893
|
if (!this.tracker)
|
|
1887
1894
|
return;
|
|
1888
1895
|
const config = this.tracker.getConfig();
|
|
1889
|
-
const apiEndpoint = config.apiEndpoint || '
|
|
1896
|
+
const apiEndpoint = config.apiEndpoint || 'http://localhost:5000';
|
|
1890
1897
|
try {
|
|
1891
1898
|
await fetch(`${apiEndpoint}/api/public/lead-forms/${formId}/view`, {
|
|
1892
1899
|
method: 'POST',
|
|
@@ -2133,7 +2140,7 @@ class PopupFormsPlugin extends BasePlugin {
|
|
|
2133
2140
|
if (!this.tracker)
|
|
2134
2141
|
return;
|
|
2135
2142
|
const config = this.tracker.getConfig();
|
|
2136
|
-
const apiEndpoint = config.apiEndpoint || '
|
|
2143
|
+
const apiEndpoint = config.apiEndpoint || 'http://localhost:5000';
|
|
2137
2144
|
const visitorId = this.tracker.getVisitorId();
|
|
2138
2145
|
// Collect form data
|
|
2139
2146
|
const formData = new FormData(formElement);
|
|
@@ -3028,7 +3035,7 @@ class CRMClient {
|
|
|
3028
3035
|
* The contact is upserted in the CRM and matching workflow automations fire automatically.
|
|
3029
3036
|
*
|
|
3030
3037
|
* @example
|
|
3031
|
-
* const crm = new CRMClient('
|
|
3038
|
+
* const crm = new CRMClient('http://localhost:5000', 'WORKSPACE_ID');
|
|
3032
3039
|
* crm.setApiKey('mm_live_...');
|
|
3033
3040
|
*
|
|
3034
3041
|
* await crm.sendEvent({
|
|
@@ -4168,6 +4175,86 @@ class Tracker {
|
|
|
4168
4175
|
this.sessionId = this.createSessionId();
|
|
4169
4176
|
logger.info('All user data deleted');
|
|
4170
4177
|
}
|
|
4178
|
+
// ============================================
|
|
4179
|
+
// PUBLIC CRM METHODS (no API key required)
|
|
4180
|
+
// ============================================
|
|
4181
|
+
/**
|
|
4182
|
+
* Create or update a contact by email (upsert).
|
|
4183
|
+
* Secured by domain whitelist — no API key needed.
|
|
4184
|
+
*/
|
|
4185
|
+
async createContact(data) {
|
|
4186
|
+
return this.publicCrmRequest('/api/public/crm/contacts', 'POST', {
|
|
4187
|
+
workspaceId: this.workspaceId,
|
|
4188
|
+
...data,
|
|
4189
|
+
});
|
|
4190
|
+
}
|
|
4191
|
+
/**
|
|
4192
|
+
* Update an existing contact by ID (limited fields only).
|
|
4193
|
+
*/
|
|
4194
|
+
async updateContact(contactId, data) {
|
|
4195
|
+
return this.publicCrmRequest(`/api/public/crm/contacts/${contactId}`, 'PUT', {
|
|
4196
|
+
workspaceId: this.workspaceId,
|
|
4197
|
+
...data,
|
|
4198
|
+
});
|
|
4199
|
+
}
|
|
4200
|
+
/**
|
|
4201
|
+
* Submit a form — creates/updates contact from form data.
|
|
4202
|
+
*/
|
|
4203
|
+
async submitForm(formId, data) {
|
|
4204
|
+
const payload = {
|
|
4205
|
+
...data,
|
|
4206
|
+
metadata: {
|
|
4207
|
+
...data.metadata,
|
|
4208
|
+
visitorId: this.visitorId,
|
|
4209
|
+
sessionId: this.sessionId,
|
|
4210
|
+
pageUrl: typeof window !== 'undefined' ? window.location.href : undefined,
|
|
4211
|
+
referrer: typeof document !== 'undefined' ? document.referrer || undefined : undefined,
|
|
4212
|
+
},
|
|
4213
|
+
};
|
|
4214
|
+
return this.publicCrmRequest(`/api/public/crm/forms/${formId}/submit`, 'POST', payload);
|
|
4215
|
+
}
|
|
4216
|
+
/**
|
|
4217
|
+
* Log an activity linked to a contact (append-only).
|
|
4218
|
+
*/
|
|
4219
|
+
async logActivity(data) {
|
|
4220
|
+
return this.publicCrmRequest('/api/public/crm/activities', 'POST', {
|
|
4221
|
+
workspaceId: this.workspaceId,
|
|
4222
|
+
...data,
|
|
4223
|
+
});
|
|
4224
|
+
}
|
|
4225
|
+
/**
|
|
4226
|
+
* Create an opportunity (e.g., from "Request Demo" forms).
|
|
4227
|
+
*/
|
|
4228
|
+
async createOpportunity(data) {
|
|
4229
|
+
return this.publicCrmRequest('/api/public/crm/opportunities', 'POST', {
|
|
4230
|
+
workspaceId: this.workspaceId,
|
|
4231
|
+
...data,
|
|
4232
|
+
});
|
|
4233
|
+
}
|
|
4234
|
+
/**
|
|
4235
|
+
* Internal helper for public CRM API calls.
|
|
4236
|
+
*/
|
|
4237
|
+
async publicCrmRequest(path, method, body) {
|
|
4238
|
+
const url = `${this.config.apiEndpoint}${path}`;
|
|
4239
|
+
try {
|
|
4240
|
+
const response = await fetch(url, {
|
|
4241
|
+
method,
|
|
4242
|
+
headers: { 'Content-Type': 'application/json' },
|
|
4243
|
+
body: JSON.stringify(body),
|
|
4244
|
+
});
|
|
4245
|
+
const data = await response.json().catch(() => ({}));
|
|
4246
|
+
if (response.ok) {
|
|
4247
|
+
logger.debug(`Public CRM ${method} ${path} succeeded`);
|
|
4248
|
+
return { success: true, data: data.data ?? data, status: response.status };
|
|
4249
|
+
}
|
|
4250
|
+
logger.error(`Public CRM ${method} ${path} failed (${response.status}):`, data.message);
|
|
4251
|
+
return { success: false, error: data.message, status: response.status };
|
|
4252
|
+
}
|
|
4253
|
+
catch (error) {
|
|
4254
|
+
logger.error(`Public CRM ${method} ${path} error:`, error);
|
|
4255
|
+
return { success: false, error: error.message };
|
|
4256
|
+
}
|
|
4257
|
+
}
|
|
4171
4258
|
/**
|
|
4172
4259
|
* Destroy tracker and cleanup
|
|
4173
4260
|
*/
|
|
@@ -4263,7 +4350,7 @@ const CliantaKey = Symbol('clianta');
|
|
|
4263
4350
|
* const app = createApp(App);
|
|
4264
4351
|
* app.use(CliantaPlugin, {
|
|
4265
4352
|
* projectId: 'your-project-id',
|
|
4266
|
-
* apiEndpoint:
|
|
4353
|
+
* apiEndpoint: import.meta.env.VITE_CLIANTA_API_ENDPOINT || 'http://localhost:5000',
|
|
4267
4354
|
* debug: import.meta.env.DEV,
|
|
4268
4355
|
* });
|
|
4269
4356
|
* app.mount('#app');
|