@unboundcx/sdk 4.13.163 → 4.13.165
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/package.json +1 -1
- package/services/licenses.js +27 -0
- package/services/reporting.js +3 -0
- package/services/reportingMarketing.js +126 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.165",
|
|
4
4
|
"description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
package/services/licenses.js
CHANGED
|
@@ -348,4 +348,31 @@ export class LicensesService {
|
|
|
348
348
|
{ body: { enabled } },
|
|
349
349
|
);
|
|
350
350
|
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Brand owner: turn a tenant's trial flag off or change when it expires.
|
|
354
|
+
* Passing the date does not lock the account.
|
|
355
|
+
* @param {string} accountId
|
|
356
|
+
* @param {Object} trial
|
|
357
|
+
* @param {boolean} [trial.isTrial]
|
|
358
|
+
* @param {string|null} [trial.accountExpiresAt] ISO timestamp, or null to clear
|
|
359
|
+
* @returns {Promise<Object>} `{ accountId, isTrial, accountExpiresAt }`
|
|
360
|
+
* @example
|
|
361
|
+
* await sdk.licenses.setBrandAccountTrial('acct-123', { isTrial: false });
|
|
362
|
+
*/
|
|
363
|
+
async setBrandAccountTrial(accountId, { isTrial, accountExpiresAt } = {}) {
|
|
364
|
+
this.sdk.validateParams(
|
|
365
|
+
{ accountId },
|
|
366
|
+
{ accountId: { type: 'string', required: true } },
|
|
367
|
+
);
|
|
368
|
+
const body = {};
|
|
369
|
+
if (isTrial !== undefined) body.isTrial = isTrial;
|
|
370
|
+
if (accountExpiresAt !== undefined) body.accountExpiresAt = accountExpiresAt;
|
|
371
|
+
return internalRequest(
|
|
372
|
+
this.sdk,
|
|
373
|
+
`/permissions/brand/accounts/${accountId}/trial`,
|
|
374
|
+
'PUT',
|
|
375
|
+
{ body },
|
|
376
|
+
);
|
|
377
|
+
}
|
|
351
378
|
}
|
package/services/reporting.js
CHANGED
|
@@ -11,6 +11,7 @@ import { ReportingIvrMenusService } from './reportingIvrMenus.js';
|
|
|
11
11
|
import { ReportingConversationInsightsService } from './reportingConversationInsights.js';
|
|
12
12
|
import { ReportingSurveysService } from './reportingSurveys.js';
|
|
13
13
|
import { ReportingSalesService } from './reportingSales.js';
|
|
14
|
+
import { ReportingMarketingService } from './reportingMarketing.js';
|
|
14
15
|
import { ReportingUsersService } from './reportingUsers.js';
|
|
15
16
|
import { ReportingViewsService } from './reportingViews.js';
|
|
16
17
|
|
|
@@ -67,6 +68,8 @@ export class ReportingService {
|
|
|
67
68
|
this.surveys = new ReportingSurveysService(sdk);
|
|
68
69
|
// Work Package C analytics-expansion (§4.5, §7 C row): Rep activity-to-revenue + Pipeline/deal-risk.
|
|
69
70
|
this.sales = new ReportingSalesService(sdk);
|
|
71
|
+
// marketing-reports-plan.md §6: website traffic / forms / attribution / scoring / engagement.
|
|
72
|
+
this.marketing = new ReportingMarketingService(sdk);
|
|
70
73
|
// analytics-expansion live-testing fix: report-scoped users list
|
|
71
74
|
// beyond team members (Call log's Users filter) -- own file to keep
|
|
72
75
|
// this file under the 400-line limit.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { internalRequest } from '../base.js';
|
|
2
|
+
|
|
3
|
+
// Local helper, same as reporting.js / reportingSurveys.js (no shared util
|
|
4
|
+
// module between these files today).
|
|
5
|
+
function queryString(params = {}) {
|
|
6
|
+
const parts = [];
|
|
7
|
+
for (const [key, value] of Object.entries(params)) {
|
|
8
|
+
if (value === undefined || value === null || value === '') continue;
|
|
9
|
+
const v = Array.isArray(value) ? value.join(',') : value;
|
|
10
|
+
parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(v)}`);
|
|
11
|
+
}
|
|
12
|
+
return parts.length ? `?${parts.join('&')}` : '';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const RANGE_RULES = {
|
|
16
|
+
from: { type: 'string', required: true },
|
|
17
|
+
to: { type: 'string', required: true },
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// marketing-reports-plan.md §5/§6 -- Marketing reports family
|
|
21
|
+
// (GET /reporting/marketing/*). Own file to keep reporting.js under the
|
|
22
|
+
// repo's 400-line limit. Scope: reporting:marketing:read, family
|
|
23
|
+
// task_router (on the Standard User allow list like reporting:surveys:read).
|
|
24
|
+
// Every method takes ISO `from`/`to` plus optional `timeZone` and the
|
|
25
|
+
// website filters (country, utmSource, utmMedium, utmCampaign, landingPage,
|
|
26
|
+
// page, device). Responses never contain raw IPs.
|
|
27
|
+
export class ReportingMarketingService {
|
|
28
|
+
constructor(sdk) {
|
|
29
|
+
this.sdk = sdk;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
_get(path, params) {
|
|
33
|
+
const { from, to } = params;
|
|
34
|
+
this.sdk.validateParams({ from, to }, RANGE_RULES);
|
|
35
|
+
return internalRequest(
|
|
36
|
+
this.sdk,
|
|
37
|
+
`/reporting/marketing/${path}${queryString(params)}`,
|
|
38
|
+
'GET',
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Website traffic summary (web-snippet sessions only).
|
|
44
|
+
* @returns {Promise<Object>} { kpis, series, topPages, landingPages,
|
|
45
|
+
* referrers, utm, devices, browsers }
|
|
46
|
+
* @example
|
|
47
|
+
* await sdk.reporting.marketing.website({ from, to, timeZone, country: 'US' });
|
|
48
|
+
*/
|
|
49
|
+
async website(params = {}) {
|
|
50
|
+
return this._get('website', params);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Sessions by country; cities included when `country` is set.
|
|
55
|
+
* @returns {Promise<Object>} { countries: [{ code, sessions, visitors, formFills }], cities: [...] }
|
|
56
|
+
*/
|
|
57
|
+
async websiteGeo(params = {}) {
|
|
58
|
+
return this._get('website/geo', params);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Paged session drill list.
|
|
63
|
+
* @param {Object} params - range + filters + { cursor, limit }
|
|
64
|
+
* @returns {Promise<Object>} { rows, nextCursor }
|
|
65
|
+
*/
|
|
66
|
+
async websiteSessions(params = {}) {
|
|
67
|
+
return this._get('website/sessions', params);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Ordered event timeline for one session.
|
|
72
|
+
* @returns {Promise<Object>} { events: [{ at, eventType, url, title, durationSec }] }
|
|
73
|
+
*/
|
|
74
|
+
async sessionEvents(sessionId) {
|
|
75
|
+
this.sdk.validateParams(
|
|
76
|
+
{ sessionId },
|
|
77
|
+
{ sessionId: { type: 'string', required: true } },
|
|
78
|
+
);
|
|
79
|
+
return internalRequest(
|
|
80
|
+
this.sdk,
|
|
81
|
+
`/reporting/marketing/website/sessions/${encodeURIComponent(sessionId)}/events`,
|
|
82
|
+
'GET',
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Form fills summary (status buckets, by form / source page / UTM, countries).
|
|
88
|
+
* @param {Object} params - range + { formId }
|
|
89
|
+
*/
|
|
90
|
+
async forms(params = {}) {
|
|
91
|
+
return this._get('forms', params);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Paged form submissions drill list.
|
|
96
|
+
* @param {Object} params - range + { formId, cursor, limit }
|
|
97
|
+
* @returns {Promise<Object>} { rows, nextCursor }
|
|
98
|
+
*/
|
|
99
|
+
async formSubmissions(params = {}) {
|
|
100
|
+
return this._get('forms/submissions', params);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* First/last-touch attribution by dimension.
|
|
105
|
+
* @param {Object} params - range + { model: 'first'|'last', dimension: 'source'|'medium'|'campaign'|'landingPage' }
|
|
106
|
+
* @returns {Promise<Object>} { model, dimension, kpis, rows }
|
|
107
|
+
*/
|
|
108
|
+
async attribution(params = {}) {
|
|
109
|
+
return this._get('attribution', params);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Lead scoring summary (histogram, rules, trend, top people).
|
|
114
|
+
*/
|
|
115
|
+
async scoring(params = {}) {
|
|
116
|
+
return this._get('scoring', params);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Email & SMS engagement per journey (send-day cohort); steps when `journeyId` is set.
|
|
121
|
+
* @param {Object} params - range + { journeyId }
|
|
122
|
+
*/
|
|
123
|
+
async engagement(params = {}) {
|
|
124
|
+
return this._get('engagement', params);
|
|
125
|
+
}
|
|
126
|
+
}
|