@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/clianta.umd.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
|
*/
|
|
@@ -15,15 +15,22 @@
|
|
|
15
15
|
*/
|
|
16
16
|
/** SDK Version */
|
|
17
17
|
const SDK_VERSION = '1.4.0';
|
|
18
|
-
/** Default API endpoint
|
|
18
|
+
/** Default API endpoint — reads from env or falls back to localhost */
|
|
19
19
|
const getDefaultApiEndpoint = () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
// Build-time env var (works with Next.js, Vite, CRA, etc.)
|
|
21
|
+
if (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_CLIANTA_API_ENDPOINT) {
|
|
22
|
+
return process.env.NEXT_PUBLIC_CLIANTA_API_ENDPOINT;
|
|
23
|
+
}
|
|
24
|
+
if (typeof process !== 'undefined' && process.env?.VITE_CLIANTA_API_ENDPOINT) {
|
|
25
|
+
return process.env.VITE_CLIANTA_API_ENDPOINT;
|
|
26
|
+
}
|
|
27
|
+
if (typeof process !== 'undefined' && process.env?.REACT_APP_CLIANTA_API_ENDPOINT) {
|
|
28
|
+
return process.env.REACT_APP_CLIANTA_API_ENDPOINT;
|
|
25
29
|
}
|
|
26
|
-
|
|
30
|
+
if (typeof process !== 'undefined' && process.env?.CLIANTA_API_ENDPOINT) {
|
|
31
|
+
return process.env.CLIANTA_API_ENDPOINT;
|
|
32
|
+
}
|
|
33
|
+
return 'http://localhost:5000';
|
|
27
34
|
};
|
|
28
35
|
/** Core plugins enabled by default */
|
|
29
36
|
const DEFAULT_PLUGINS = [
|
|
@@ -1785,7 +1792,7 @@
|
|
|
1785
1792
|
return;
|
|
1786
1793
|
const config = this.tracker.getConfig();
|
|
1787
1794
|
const workspaceId = this.tracker.getWorkspaceId();
|
|
1788
|
-
const apiEndpoint = config.apiEndpoint || '
|
|
1795
|
+
const apiEndpoint = config.apiEndpoint || 'http://localhost:5000';
|
|
1789
1796
|
try {
|
|
1790
1797
|
const url = encodeURIComponent(window.location.href);
|
|
1791
1798
|
const response = await fetch(`${apiEndpoint}/api/public/lead-forms/${workspaceId}?url=${url}`);
|
|
@@ -1890,7 +1897,7 @@
|
|
|
1890
1897
|
if (!this.tracker)
|
|
1891
1898
|
return;
|
|
1892
1899
|
const config = this.tracker.getConfig();
|
|
1893
|
-
const apiEndpoint = config.apiEndpoint || '
|
|
1900
|
+
const apiEndpoint = config.apiEndpoint || 'http://localhost:5000';
|
|
1894
1901
|
try {
|
|
1895
1902
|
await fetch(`${apiEndpoint}/api/public/lead-forms/${formId}/view`, {
|
|
1896
1903
|
method: 'POST',
|
|
@@ -2137,7 +2144,7 @@
|
|
|
2137
2144
|
if (!this.tracker)
|
|
2138
2145
|
return;
|
|
2139
2146
|
const config = this.tracker.getConfig();
|
|
2140
|
-
const apiEndpoint = config.apiEndpoint || '
|
|
2147
|
+
const apiEndpoint = config.apiEndpoint || 'http://localhost:5000';
|
|
2141
2148
|
const visitorId = this.tracker.getVisitorId();
|
|
2142
2149
|
// Collect form data
|
|
2143
2150
|
const formData = new FormData(formElement);
|
|
@@ -3032,7 +3039,7 @@
|
|
|
3032
3039
|
* The contact is upserted in the CRM and matching workflow automations fire automatically.
|
|
3033
3040
|
*
|
|
3034
3041
|
* @example
|
|
3035
|
-
* const crm = new CRMClient('
|
|
3042
|
+
* const crm = new CRMClient('http://localhost:5000', 'WORKSPACE_ID');
|
|
3036
3043
|
* crm.setApiKey('mm_live_...');
|
|
3037
3044
|
*
|
|
3038
3045
|
* await crm.sendEvent({
|
|
@@ -4172,6 +4179,86 @@
|
|
|
4172
4179
|
this.sessionId = this.createSessionId();
|
|
4173
4180
|
logger.info('All user data deleted');
|
|
4174
4181
|
}
|
|
4182
|
+
// ============================================
|
|
4183
|
+
// PUBLIC CRM METHODS (no API key required)
|
|
4184
|
+
// ============================================
|
|
4185
|
+
/**
|
|
4186
|
+
* Create or update a contact by email (upsert).
|
|
4187
|
+
* Secured by domain whitelist — no API key needed.
|
|
4188
|
+
*/
|
|
4189
|
+
async createContact(data) {
|
|
4190
|
+
return this.publicCrmRequest('/api/public/crm/contacts', 'POST', {
|
|
4191
|
+
workspaceId: this.workspaceId,
|
|
4192
|
+
...data,
|
|
4193
|
+
});
|
|
4194
|
+
}
|
|
4195
|
+
/**
|
|
4196
|
+
* Update an existing contact by ID (limited fields only).
|
|
4197
|
+
*/
|
|
4198
|
+
async updateContact(contactId, data) {
|
|
4199
|
+
return this.publicCrmRequest(`/api/public/crm/contacts/${contactId}`, 'PUT', {
|
|
4200
|
+
workspaceId: this.workspaceId,
|
|
4201
|
+
...data,
|
|
4202
|
+
});
|
|
4203
|
+
}
|
|
4204
|
+
/**
|
|
4205
|
+
* Submit a form — creates/updates contact from form data.
|
|
4206
|
+
*/
|
|
4207
|
+
async submitForm(formId, data) {
|
|
4208
|
+
const payload = {
|
|
4209
|
+
...data,
|
|
4210
|
+
metadata: {
|
|
4211
|
+
...data.metadata,
|
|
4212
|
+
visitorId: this.visitorId,
|
|
4213
|
+
sessionId: this.sessionId,
|
|
4214
|
+
pageUrl: typeof window !== 'undefined' ? window.location.href : undefined,
|
|
4215
|
+
referrer: typeof document !== 'undefined' ? document.referrer || undefined : undefined,
|
|
4216
|
+
},
|
|
4217
|
+
};
|
|
4218
|
+
return this.publicCrmRequest(`/api/public/crm/forms/${formId}/submit`, 'POST', payload);
|
|
4219
|
+
}
|
|
4220
|
+
/**
|
|
4221
|
+
* Log an activity linked to a contact (append-only).
|
|
4222
|
+
*/
|
|
4223
|
+
async logActivity(data) {
|
|
4224
|
+
return this.publicCrmRequest('/api/public/crm/activities', 'POST', {
|
|
4225
|
+
workspaceId: this.workspaceId,
|
|
4226
|
+
...data,
|
|
4227
|
+
});
|
|
4228
|
+
}
|
|
4229
|
+
/**
|
|
4230
|
+
* Create an opportunity (e.g., from "Request Demo" forms).
|
|
4231
|
+
*/
|
|
4232
|
+
async createOpportunity(data) {
|
|
4233
|
+
return this.publicCrmRequest('/api/public/crm/opportunities', 'POST', {
|
|
4234
|
+
workspaceId: this.workspaceId,
|
|
4235
|
+
...data,
|
|
4236
|
+
});
|
|
4237
|
+
}
|
|
4238
|
+
/**
|
|
4239
|
+
* Internal helper for public CRM API calls.
|
|
4240
|
+
*/
|
|
4241
|
+
async publicCrmRequest(path, method, body) {
|
|
4242
|
+
const url = `${this.config.apiEndpoint}${path}`;
|
|
4243
|
+
try {
|
|
4244
|
+
const response = await fetch(url, {
|
|
4245
|
+
method,
|
|
4246
|
+
headers: { 'Content-Type': 'application/json' },
|
|
4247
|
+
body: JSON.stringify(body),
|
|
4248
|
+
});
|
|
4249
|
+
const data = await response.json().catch(() => ({}));
|
|
4250
|
+
if (response.ok) {
|
|
4251
|
+
logger.debug(`Public CRM ${method} ${path} succeeded`);
|
|
4252
|
+
return { success: true, data: data.data ?? data, status: response.status };
|
|
4253
|
+
}
|
|
4254
|
+
logger.error(`Public CRM ${method} ${path} failed (${response.status}):`, data.message);
|
|
4255
|
+
return { success: false, error: data.message, status: response.status };
|
|
4256
|
+
}
|
|
4257
|
+
catch (error) {
|
|
4258
|
+
logger.error(`Public CRM ${method} ${path} error:`, error);
|
|
4259
|
+
return { success: false, error: error.message };
|
|
4260
|
+
}
|
|
4261
|
+
}
|
|
4175
4262
|
/**
|
|
4176
4263
|
* Destroy tracker and cleanup
|
|
4177
4264
|
*/
|