@oursprivacy/platform-sdk 1.60.0 → 1.61.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +58 -15
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts.map +1 -1
  5. package/client.js +10 -1
  6. package/client.js.map +1 -1
  7. package/client.mjs +10 -1
  8. package/client.mjs.map +1 -1
  9. package/core/error.d.mts.map +1 -1
  10. package/core/error.d.ts.map +1 -1
  11. package/core/error.js +2 -1
  12. package/core/error.js.map +1 -1
  13. package/core/error.mjs +2 -1
  14. package/core/error.mjs.map +1 -1
  15. package/internal/utils/log.d.mts +5 -0
  16. package/internal/utils/log.d.mts.map +1 -1
  17. package/internal/utils/log.d.ts +5 -0
  18. package/internal/utils/log.d.ts.map +1 -1
  19. package/internal/utils/log.js +62 -1
  20. package/internal/utils/log.js.map +1 -1
  21. package/internal/utils/log.mjs +60 -0
  22. package/internal/utils/log.mjs.map +1 -1
  23. package/package.json +1 -10
  24. package/resources/destinations.d.mts +7 -7
  25. package/resources/destinations.d.mts.map +1 -1
  26. package/resources/destinations.d.ts +7 -7
  27. package/resources/destinations.d.ts.map +1 -1
  28. package/resources/experiment-settings.d.mts +24 -14
  29. package/resources/experiment-settings.d.mts.map +1 -1
  30. package/resources/experiment-settings.d.ts +24 -14
  31. package/resources/experiment-settings.d.ts.map +1 -1
  32. package/resources/experiment-settings.js +8 -4
  33. package/resources/experiment-settings.js.map +1 -1
  34. package/resources/experiment-settings.mjs +8 -4
  35. package/resources/experiment-settings.mjs.map +1 -1
  36. package/resources/heatmap-pages.d.mts +51 -28
  37. package/resources/heatmap-pages.d.mts.map +1 -1
  38. package/resources/heatmap-pages.d.ts +51 -28
  39. package/resources/heatmap-pages.d.ts.map +1 -1
  40. package/resources/heatmap-pages.js +23 -17
  41. package/resources/heatmap-pages.js.map +1 -1
  42. package/resources/heatmap-pages.mjs +23 -17
  43. package/resources/heatmap-pages.mjs.map +1 -1
  44. package/resources/test-events.d.mts +6 -0
  45. package/resources/test-events.d.mts.map +1 -1
  46. package/resources/test-events.d.ts +6 -0
  47. package/resources/test-events.d.ts.map +1 -1
  48. package/src/client.ts +10 -0
  49. package/src/core/error.ts +2 -1
  50. package/src/internal/utils/log.ts +64 -0
  51. package/src/resources/destinations.ts +9 -2
  52. package/src/resources/experiment-settings.ts +24 -14
  53. package/src/resources/heatmap-pages.ts +53 -28
  54. package/src/resources/test-events.ts +7 -0
  55. package/src/version.ts +1 -1
  56. package/version.d.mts +1 -1
  57. package/version.d.ts +1 -1
  58. package/version.js +1 -1
  59. package/version.mjs +1 -1
package/src/core/error.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import { castToError } from '../internal/errors';
4
+ import { redactSensitiveFields } from '../internal/utils/log';
4
5
 
5
6
  export class OursPrivacyPlatformError extends Error {}
6
7
 
@@ -29,7 +30,7 @@ export class APIError<
29
30
  typeof error.message === 'string' ?
30
31
  error.message
31
32
  : JSON.stringify(error.message)
32
- : error ? JSON.stringify(error)
33
+ : error ? JSON.stringify(redactSensitiveFields(error))
33
34
  : message;
34
35
 
35
36
  if (status && msg) {
@@ -82,6 +82,58 @@ export function loggerFor(client: OursPrivacyPlatform): Logger {
82
82
  return levelLogger;
83
83
  }
84
84
 
85
+ const sensitiveFields = new Set<string>([
86
+ 'accesstoken',
87
+ 'apikey',
88
+ 'clientsecret',
89
+ 'credentials',
90
+ 'ingesturl',
91
+ 'installscript',
92
+ 'password',
93
+ 'projectapikey',
94
+ 'refreshtoken',
95
+ 'samplecurl',
96
+ 'testingesturl',
97
+ 'testinstallscript',
98
+ 'testtoken',
99
+ 'token',
100
+ 'websdktoken',
101
+ ]);
102
+
103
+ const redactValue = (value: unknown): unknown => {
104
+ if (Array.isArray(value)) {
105
+ return value.map(redactValue);
106
+ }
107
+ if (typeof value !== 'object' || value === null) {
108
+ return value;
109
+ }
110
+ const prototype = Object.getPrototypeOf(value);
111
+ if (prototype !== Object.prototype && prototype !== null) {
112
+ return value;
113
+ }
114
+ return Object.fromEntries(
115
+ Object.entries(value).map(([name, field]) => [
116
+ name,
117
+ sensitiveFields.has(name.toLowerCase().replace(/[-_]/g, '')) ? '***' : redactValue(field),
118
+ ]),
119
+ );
120
+ };
121
+
122
+ /**
123
+ * Returns a copy of a request or response body with sensitive field values replaced, for debug output only.
124
+ * A string is treated as serialized JSON.
125
+ */
126
+ export const redactSensitiveFields = (value: unknown): unknown => {
127
+ if (typeof value !== 'string') {
128
+ return redactValue(value);
129
+ }
130
+ try {
131
+ return JSON.stringify(redactValue(JSON.parse(value)));
132
+ } catch {
133
+ return value;
134
+ }
135
+ };
136
+
85
137
  export const formatRequestDetails = (details: {
86
138
  options?: RequestOptions | undefined;
87
139
  headers?: Headers | Record<string, string> | undefined;
@@ -97,6 +149,18 @@ export const formatRequestDetails = (details: {
97
149
  if (details.options) {
98
150
  details.options = { ...details.options };
99
151
  delete details.options['headers']; // redundant + leaks internals
152
+ if ('body' in details.options) {
153
+ details.options.body = redactSensitiveFields(details.options.body);
154
+ }
155
+ if ('query' in details.options) {
156
+ details.options.query = redactSensitiveFields(details.options.query) as typeof details.options.query;
157
+ }
158
+ }
159
+ if ('body' in details) {
160
+ details.body = redactSensitiveFields(details.body);
161
+ }
162
+ if ('message' in details) {
163
+ details.message = redactSensitiveFields(details.message);
100
164
  }
101
165
  if (details.headers) {
102
166
  details.headers = Object.fromEntries(
@@ -104,6 +104,7 @@ export interface DestinationListResponse {
104
104
  | 'ActiveCampaignApi'
105
105
  | 'Admitad'
106
106
  | 'AdobeAnalytics'
107
+ | 'Affiliatly'
107
108
  | 'AmazonDSP'
108
109
  | 'Amplitude'
109
110
  | 'AppLovin'
@@ -228,6 +229,7 @@ export interface DestinationCreateResponse {
228
229
  | 'ActiveCampaignApi'
229
230
  | 'Admitad'
230
231
  | 'AdobeAnalytics'
232
+ | 'Affiliatly'
231
233
  | 'AmazonDSP'
232
234
  | 'Amplitude'
233
235
  | 'AppLovin'
@@ -352,6 +354,7 @@ export interface DestinationRetrieveResponse {
352
354
  | 'ActiveCampaignApi'
353
355
  | 'Admitad'
354
356
  | 'AdobeAnalytics'
357
+ | 'Affiliatly'
355
358
  | 'AmazonDSP'
356
359
  | 'Amplitude'
357
360
  | 'AppLovin'
@@ -476,6 +479,7 @@ export interface DestinationUpdateResponse {
476
479
  | 'ActiveCampaignApi'
477
480
  | 'Admitad'
478
481
  | 'AdobeAnalytics'
482
+ | 'Affiliatly'
479
483
  | 'AmazonDSP'
480
484
  | 'Amplitude'
481
485
  | 'AppLovin'
@@ -671,7 +675,8 @@ export namespace DestinationTypesResponse {
671
675
  | 'Fullstory'
672
676
  | 'GravityCAPI'
673
677
  | 'LeadSquared'
674
- | 'Trybe';
678
+ | 'Trybe'
679
+ | 'Affiliatly';
675
680
 
676
681
  capabilities: Entity.Capabilities;
677
682
 
@@ -839,6 +844,7 @@ export interface DestinationListParams extends CursorParams {
839
844
  | 'ActiveCampaignApi'
840
845
  | 'Admitad'
841
846
  | 'AdobeAnalytics'
847
+ | 'Affiliatly'
842
848
  | 'AmazonDSP'
843
849
  | 'Amplitude'
844
850
  | 'AppLovin'
@@ -1022,7 +1028,8 @@ export interface DestinationCreateParams {
1022
1028
  | 'Fullstory'
1023
1029
  | 'GravityCAPI'
1024
1030
  | 'LeadSquared'
1025
- | 'Trybe';
1031
+ | 'Trybe'
1032
+ | 'Affiliatly';
1026
1033
 
1027
1034
  /**
1028
1035
  * Restrict dispatch to these source IDs. Omit on create or send `null` to accept
@@ -60,14 +60,18 @@ export class ExperimentSettings extends APIResource {
60
60
  }
61
61
 
62
62
  /**
63
- * Partially update an experiment settings. Only the fields you send are changed.
64
- * Requires API-key scope or current OAuth user permission:
65
- * experimentSettings:update
63
+ * Partially update an experiment settings record. Only the fields you send change.
64
+ * Discover the ID with GET /rest/v1/experiment-settings. Missing IDs and IDs this
65
+ * credential cannot access return the same 404; returns 403 when Experimentation
66
+ * is disabled for an otherwise authorized record. Requires API-key scope or
67
+ * current OAuth user permission: experimentSettings:update
66
68
  *
67
69
  * @example
68
70
  * ```ts
69
71
  * const experimentSetting =
70
- * await client.experimentSettings.update('id');
72
+ * await client.experimentSettings.update(
73
+ * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
74
+ * );
71
75
  * ```
72
76
  */
73
77
  update(
@@ -388,22 +392,25 @@ export interface ExperimentSettingDeleteResponse {
388
392
  export interface ExperimentSettingCreateParams {
389
393
  /**
390
394
  * Cookie name used to persist sticky variant assignments in the browser. Defaults
391
- * to `_cord_exp` when omitted on create.
395
+ * to `_cord_exp` when omitted on create; omitted or null keeps the saved value on
396
+ * update.
392
397
  */
393
398
  cookieName?: string | null;
394
399
 
395
400
  /**
396
401
  * Human-readable name for this experimentation configuration. Defaults to
397
- * `Experiment Settings` when omitted on create.
402
+ * `Experiment Settings` when omitted on create; omitted or null keeps the saved
403
+ * value on update.
398
404
  */
399
405
  name?: string | null;
400
406
 
401
407
  /**
402
408
  * Limits which domains can load your experiments. When set, experiments using this
403
409
  * settings record are only served on these domains; the SDK refuses to load
404
- * anywhere else and your experiments never run on those hosts. Separate from
405
- * source `whitelistDomains`, which limits which domains can send events to the
406
- * CDP.
410
+ * anywhere else and your experiments never run on those hosts. On update, an empty
411
+ * array clears the allowlist (all domains served), and omitted or null keeps the
412
+ * saved value. Separate from source `whitelistDomains`, which limits which domains
413
+ * can send events to the CDP.
407
414
  */
408
415
  whitelistDomains?: Array<string> | null;
409
416
  }
@@ -411,22 +418,25 @@ export interface ExperimentSettingCreateParams {
411
418
  export interface ExperimentSettingUpdateParams {
412
419
  /**
413
420
  * Cookie name used to persist sticky variant assignments in the browser. Defaults
414
- * to `_cord_exp` when omitted on create.
421
+ * to `_cord_exp` when omitted on create; omitted or null keeps the saved value on
422
+ * update.
415
423
  */
416
424
  cookieName?: string | null;
417
425
 
418
426
  /**
419
427
  * Human-readable name for this experimentation configuration. Defaults to
420
- * `Experiment Settings` when omitted on create.
428
+ * `Experiment Settings` when omitted on create; omitted or null keeps the saved
429
+ * value on update.
421
430
  */
422
431
  name?: string | null;
423
432
 
424
433
  /**
425
434
  * Limits which domains can load your experiments. When set, experiments using this
426
435
  * settings record are only served on these domains; the SDK refuses to load
427
- * anywhere else and your experiments never run on those hosts. Separate from
428
- * source `whitelistDomains`, which limits which domains can send events to the
429
- * CDP.
436
+ * anywhere else and your experiments never run on those hosts. On update, an empty
437
+ * array clears the allowlist (all domains served), and omitted or null keeps the
438
+ * saved value. Separate from source `whitelistDomains`, which limits which domains
439
+ * can send events to the CDP.
430
440
  */
431
441
  whitelistDomains?: Array<string> | null;
432
442
  }
@@ -8,14 +8,15 @@ import { RequestOptions } from '../internal/request-options';
8
8
  export class HeatmapPages extends APIResource {
9
9
  /**
10
10
  * List pages with heatmap coverage in a date window, ranked for triage. Each
11
- * entity is identified by `pageKey`, normally origin + pathname with the query
12
- * string stripped; an account-configured split may include one significant query
13
- * parameter. Preserve the returned `pageKey` when calling
14
- * `GET /rest/v1/heatmap-pages/summary`. Supports cursor pagination, with cursor
15
- * depth capped at roughly 10,000 entries; if you need pages beyond that, narrow
16
- * `from`/`to` or add filters rather than paginating further. `from`/`to` are UTC
17
- * calendar days in `YYYY-MM-DD`; the window must be 60 days or fewer. Requires
18
- * API-key scope or current OAuth user permission: web-analytics:view
11
+ * entity is identified by `pageKey` (origin + pathname, query string stripped).
12
+ * Use `queryParameterFilter` to inspect one survey step or other URL parameter
13
+ * value; filtering narrows events without creating separate page rows. Pass the
14
+ * same filter and returned `pageKey` to `GET /rest/v1/heatmap-pages/summary`.
15
+ * Supports cursor pagination, with cursor depth capped at roughly 10,000 entries;
16
+ * if you need pages beyond that, narrow `from`/`to` or add filters rather than
17
+ * paginating further. `from`/`to` are UTC calendar days in `YYYY-MM-DD`; the
18
+ * window must be 60 days or fewer. Requires API-key scope or current OAuth user
19
+ * permission: web-analytics:view
19
20
  */
20
21
  list(
21
22
  query: HeatmapPageListParams,
@@ -32,15 +33,20 @@ export class HeatmapPages extends APIResource {
32
33
  * depth, and up to 5 curated in-app replay URLs in a single payload. Designed as a
33
34
  * one-call diagnosis surface for an AI assistant or marketer — answers "what is
34
35
  * happening on this page?" without fanning out across five endpoints. `pageKey`
35
- * comes from `GET /rest/v1/heatmap-pages`. The endpoint is identified by query
36
- * params rather than a path id because heatmap pages are not stored entities; this
37
- * is a documented derived-read exception. `breakpoint` scopes the bin/scroll
38
- * aggregations; replays are returned across all breakpoints regardless of
39
- * `breakpoint` (weighted to cover multiple viewports) so callers can compare
40
- * devices. `clickGrid` always supplies fine click positions for rendering.
41
- * `clickBins` derives compatible 64×64 counts from the same grid; its totals must
42
- * not be added to them. Requires API-key scope or current OAuth user permission:
43
- * web-analytics:view
36
+ * comes from `GET /rest/v1/heatmap-pages`. A base key includes all query variants
37
+ * regardless of saved splits. Reuse the same `queryParameterFilter` to scope all
38
+ * aggregates and replay links to the selected survey step. Legacy saved split keys
39
+ * remain supported without a filter; combining a query string in `pageKey` with
40
+ * `queryParameterFilter` returns 400. This reads retained historical events
41
+ * containing the parameter, requires no account setting, and does not change
42
+ * web-analytics page paths. The endpoint is identified by query params rather than
43
+ * a path id because heatmap pages are not stored entities; this is a documented
44
+ * derived-read exception. `breakpoint` scopes the bin/scroll aggregations; replays
45
+ * are returned across all breakpoints regardless of `breakpoint` (weighted to
46
+ * cover multiple viewports) so callers can compare devices. `clickGrid` always
47
+ * supplies fine click positions for rendering. `clickBins` derives compatible
48
+ * 64×64 counts from the same grid; its totals must not be added to them. Requires
49
+ * API-key scope or current OAuth user permission: web-analytics:view
44
50
  */
45
51
  summary(query: HeatmapPageSummaryParams, options?: RequestOptions): APIPromise<HeatmapPageSummaryResponse> {
46
52
  return this._client.get('/rest/v1/heatmap-pages/summary', { query, ...options });
@@ -59,10 +65,9 @@ export interface HeatmapPageListResponse {
59
65
  issueScore: number;
60
66
 
61
67
  /**
62
- * Stable per-page identifier. It is normally origin + pathname with the query
63
- * string stripped, but an account-configured split may include one significant
64
- * query parameter. Preserve the returned value when calling
65
- * `GET /rest/v1/heatmap-pages/summary` and the heatmap MCP tools.
68
+ * Stable per-page identifier: origin + pathname with the query string stripped.
69
+ * Query-parameter filtering narrows events without changing this key. Use the same
70
+ * filter when requesting the page summary.
66
71
  */
67
72
  pageKey: string;
68
73
 
@@ -175,7 +180,7 @@ export namespace HeatmapPageSummaryResponse {
175
180
  /**
176
181
  * Viewport bucket the session was recorded under.
177
182
  */
178
- breakpoint: 'desktop' | 'mobile' | 'tablet';
183
+ breakpoint: 'mobile' | 'tablet' | 'desktop';
179
184
 
180
185
  /**
181
186
  * Absolute link to view the session replay in the OursPrivacy web app. Opens the
@@ -216,6 +221,16 @@ export interface HeatmapPageListParams extends CursorParams {
216
221
  */
217
222
  country?: string;
218
223
 
224
+ /**
225
+ * Filter heatmap events by one URL query parameter, such as
226
+ * {"name":"p","values":["Contact Details"]}. Send as JSON in an HTTP query string
227
+ * and as an object in MCP. Matches any listed decoded value; values: [] matches
228
+ * any non-empty value. Apply the same filter to the list and summary. Works on
229
+ * retained historical events containing the parameter, requires no account
230
+ * setting, and does not change web-analytics page paths.
231
+ */
232
+ queryParameterFilter?: string;
233
+
219
234
  /**
220
235
  * Filter by visitor region (state/province as stored on events).
221
236
  */
@@ -229,7 +244,7 @@ export interface HeatmapPageListParams extends CursorParams {
229
244
  /**
230
245
  * Sort key. Defaults to `CLICKS` (descending).
231
246
  */
232
- sortBy?: 'CLICKS' | 'DEAD_RATE' | 'ISSUE_SCORE' | 'RAGE_RATE';
247
+ sortBy?: 'CLICKS' | 'RAGE_RATE' | 'DEAD_RATE' | 'ISSUE_SCORE';
233
248
 
234
249
  /**
235
250
  * Sort direction. Defaults to `DESC`.
@@ -243,7 +258,7 @@ export interface HeatmapPageSummaryParams {
243
258
  * computed for. Replays are returned for all breakpoints regardless of this value
244
259
  * so callers can compare across devices.
245
260
  */
246
- breakpoint: 'desktop' | 'mobile' | 'tablet';
261
+ breakpoint: 'mobile' | 'tablet' | 'desktop';
247
262
 
248
263
  /**
249
264
  * Inclusive lower bound of the heatmap window, as a UTC calendar day in
@@ -253,10 +268,10 @@ export interface HeatmapPageSummaryParams {
253
268
  from: string;
254
269
 
255
270
  /**
256
- * Page identifier returned by `GET /rest/v1/heatmap-pages`. It is normally
257
- * origin + pathname with the query string stripped, but may include one
258
- * account-configured significant query parameter. Pass the returned value
259
- * unchanged.
271
+ * Base page identifier returned by the heatmap pages list. Pass it unchanged,
272
+ * together with the same queryParameterFilter to inspect the same survey step. A
273
+ * legacy saved split key is accepted only without queryParameterFilter; combining
274
+ * them returns 400.
260
275
  */
261
276
  pageKey: string;
262
277
 
@@ -277,6 +292,16 @@ export interface HeatmapPageSummaryParams {
277
292
  */
278
293
  country?: string;
279
294
 
295
+ /**
296
+ * Filter heatmap events by one URL query parameter, such as
297
+ * {"name":"p","values":["Contact Details"]}. Send as JSON in an HTTP query string
298
+ * and as an object in MCP. Matches any listed decoded value; values: [] matches
299
+ * any non-empty value. Apply the same filter to the list and summary. Works on
300
+ * retained historical events containing the parameter, requires no account
301
+ * setting, and does not change web-analytics page paths.
302
+ */
303
+ queryParameterFilter?: string;
304
+
280
305
  /**
281
306
  * Filter by visitor region (state/province as stored on events).
282
307
  */
@@ -331,6 +331,13 @@ export namespace TestEventCreateParams {
331
331
  */
332
332
  adset_id?: string | null;
333
333
 
334
+ /**
335
+ * The raw Affiliatly tracking cookie value (affiliatly_v3), set by the Affiliatly
336
+ * script when a visitor lands from an affiliate link. Web-only. Ex:
337
+ * id_hash=abc&id_user=123&aff_uid=45
338
+ */
339
+ affiliatly_v3?: string | null;
340
+
334
341
  /**
335
342
  * The AppLovin alart query parameter. Ex: alart123
336
343
  */
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.60.0'; // x-release-please-version
1
+ export const VERSION = '1.61.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.60.0";
1
+ export declare const VERSION = "1.61.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.60.0";
1
+ export declare const VERSION = "1.61.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '1.60.0'; // x-release-please-version
4
+ exports.VERSION = '1.61.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '1.60.0'; // x-release-please-version
1
+ export const VERSION = '1.61.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map