@oursprivacy/platform-sdk 1.21.0 → 1.23.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 (112) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +8 -8
  3. package/client.d.mts +16 -19
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +16 -19
  6. package/client.d.ts.map +1 -1
  7. package/client.js +8 -11
  8. package/client.js.map +1 -1
  9. package/client.mjs +8 -11
  10. package/client.mjs.map +1 -1
  11. package/package.json +1 -1
  12. package/resources/allowed-events.d.mts +206 -5
  13. package/resources/allowed-events.d.mts.map +1 -1
  14. package/resources/allowed-events.d.ts +206 -5
  15. package/resources/allowed-events.d.ts.map +1 -1
  16. package/resources/allowed-events.js +48 -4
  17. package/resources/allowed-events.js.map +1 -1
  18. package/resources/allowed-events.mjs +48 -4
  19. package/resources/allowed-events.mjs.map +1 -1
  20. package/resources/consent-analytics.d.mts +57 -0
  21. package/resources/consent-analytics.d.mts.map +1 -0
  22. package/resources/consent-analytics.d.ts +57 -0
  23. package/resources/consent-analytics.d.ts.map +1 -0
  24. package/resources/consent-analytics.js +22 -0
  25. package/resources/consent-analytics.js.map +1 -0
  26. package/resources/consent-analytics.mjs +18 -0
  27. package/resources/consent-analytics.mjs.map +1 -0
  28. package/resources/consent-settings.d.mts +198 -1
  29. package/resources/consent-settings.d.mts.map +1 -1
  30. package/resources/consent-settings.d.ts +198 -1
  31. package/resources/consent-settings.d.ts.map +1 -1
  32. package/resources/consent-settings.js +40 -0
  33. package/resources/consent-settings.js.map +1 -1
  34. package/resources/consent-settings.mjs +40 -0
  35. package/resources/consent-settings.mjs.map +1 -1
  36. package/resources/data-governance.d.mts +793 -0
  37. package/resources/data-governance.d.mts.map +1 -0
  38. package/resources/data-governance.d.ts +793 -0
  39. package/resources/data-governance.d.ts.map +1 -0
  40. package/resources/data-governance.js +70 -0
  41. package/resources/data-governance.js.map +1 -0
  42. package/resources/data-governance.mjs +66 -0
  43. package/resources/data-governance.mjs.map +1 -0
  44. package/resources/default-mappings.d.mts +60 -3
  45. package/resources/default-mappings.d.mts.map +1 -1
  46. package/resources/default-mappings.d.ts +60 -3
  47. package/resources/default-mappings.d.ts.map +1 -1
  48. package/resources/destinations.d.mts +78 -5
  49. package/resources/destinations.d.mts.map +1 -1
  50. package/resources/destinations.d.ts +78 -5
  51. package/resources/destinations.d.ts.map +1 -1
  52. package/resources/destinations.js +11 -0
  53. package/resources/destinations.js.map +1 -1
  54. package/resources/destinations.mjs +11 -0
  55. package/resources/destinations.mjs.map +1 -1
  56. package/resources/index.d.mts +6 -7
  57. package/resources/index.d.mts.map +1 -1
  58. package/resources/index.d.ts +6 -7
  59. package/resources/index.d.ts.map +1 -1
  60. package/resources/index.js +5 -7
  61. package/resources/index.js.map +1 -1
  62. package/resources/index.mjs +2 -3
  63. package/resources/index.mjs.map +1 -1
  64. package/resources/mappings.d.mts +362 -16
  65. package/resources/mappings.d.mts.map +1 -1
  66. package/resources/mappings.d.ts +362 -16
  67. package/resources/mappings.d.ts.map +1 -1
  68. package/resources/mappings.js +41 -0
  69. package/resources/mappings.js.map +1 -1
  70. package/resources/mappings.mjs +41 -0
  71. package/resources/mappings.mjs.map +1 -1
  72. package/src/client.ts +75 -60
  73. package/src/resources/allowed-events.ts +232 -4
  74. package/src/resources/consent-analytics.ts +76 -0
  75. package/src/resources/consent-settings.ts +272 -0
  76. package/src/resources/data-governance.ts +1091 -0
  77. package/src/resources/default-mappings.ts +60 -3
  78. package/src/resources/destinations.ts +189 -4
  79. package/src/resources/index.ts +31 -22
  80. package/src/resources/mappings.ts +517 -15
  81. package/src/version.ts +1 -1
  82. package/version.d.mts +1 -1
  83. package/version.d.ts +1 -1
  84. package/version.js +1 -1
  85. package/version.mjs +1 -1
  86. package/resources/destination-types.d.mts +0 -146
  87. package/resources/destination-types.d.mts.map +0 -1
  88. package/resources/destination-types.d.ts +0 -146
  89. package/resources/destination-types.d.ts.map +0 -1
  90. package/resources/destination-types.js +0 -28
  91. package/resources/destination-types.js.map +0 -1
  92. package/resources/destination-types.mjs +0 -24
  93. package/resources/destination-types.mjs.map +0 -1
  94. package/resources/global-dispatch-centers.d.mts +0 -349
  95. package/resources/global-dispatch-centers.d.mts.map +0 -1
  96. package/resources/global-dispatch-centers.d.ts +0 -349
  97. package/resources/global-dispatch-centers.d.ts.map +0 -1
  98. package/resources/global-dispatch-centers.js +0 -43
  99. package/resources/global-dispatch-centers.js.map +0 -1
  100. package/resources/global-dispatch-centers.mjs +0 -39
  101. package/resources/global-dispatch-centers.mjs.map +0 -1
  102. package/resources/mapping-templates.d.mts +0 -101
  103. package/resources/mapping-templates.d.mts.map +0 -1
  104. package/resources/mapping-templates.d.ts +0 -101
  105. package/resources/mapping-templates.d.ts.map +0 -1
  106. package/resources/mapping-templates.js +0 -22
  107. package/resources/mapping-templates.js.map +0 -1
  108. package/resources/mapping-templates.mjs +0 -18
  109. package/resources/mapping-templates.mjs.map +0 -1
  110. package/src/resources/destination-types.ts +0 -373
  111. package/src/resources/global-dispatch-centers.ts +0 -458
  112. package/src/resources/mapping-templates.ts +0 -203
@@ -7,28 +7,77 @@ import { path } from '../internal/utils/path';
7
7
 
8
8
  export class AllowedEvents extends APIResource {
9
9
  /**
10
- * List all allowed events. Requires scope: allowedEvent:list
10
+ * List every allowed event for this account. Allowed events sit between sources
11
+ * and destinations in the dispatch flow — only inbound events whose `event` field
12
+ * matches the `name` of an allowed event (case-insensitive) can be routed to that
13
+ * event's `destinationIds`. Events without a matching allowed event are dropped.
14
+ * The list is not paginated; the per-account count is bounded. System events
15
+ * (names beginning with `$`, e.g. `$heatmap_click`) are hidden from the response —
16
+ * only `$identify` is creatable as an allowed event. Requires scope:
17
+ * allowedEvent:list
11
18
  */
12
19
  list(options?: RequestOptions): APIPromise<AllowedEventListResponse> {
13
20
  return this._client.get('/rest/v1/allowed-events', options);
14
21
  }
15
22
 
16
23
  /**
17
- * Create a new allowed event. Requires scope: allowedEvent:create
24
+ * Create a new allowed event for this account.
25
+ *
26
+ * - `name` is required, trimmed, case-insensitively unique within the account, and
27
+ * rejected if it exceeds the platform event-name length limit.
28
+ * - Names starting with `$` are reserved for system events. Only `$identify` is
29
+ * accepted.
30
+ * - `destinationIds` is optional. Unknown ids and ids belonging to other accounts
31
+ * are silently filtered out at write time (the destination must exist on this
32
+ * account to be saved).
33
+ *
34
+ * Returns the full entity so callers can read the server-assigned `id`,
35
+ * `createdAt`, and the filtered `destinationIds` without a follow-up GET. Known
36
+ * input failures (duplicate name, name length, `$`-prefix reservation, empty name)
37
+ * are returned as HTTP 409 with the reason in the response `error` field. Requires
38
+ * scope: allowedEvent:create
18
39
  */
19
40
  create(body: AllowedEventCreateParams, options?: RequestOptions): APIPromise<AllowedEventCreateResponse> {
20
41
  return this._client.post('/rest/v1/allowed-events', { body, ...options });
21
42
  }
22
43
 
23
44
  /**
24
- * Find a single allowed event by ID. Requires scope: allowedEvent:find
45
+ * Fetch a single allowed event by id. Returns 404 when no record matches the
46
+ * supplied id or it belongs to a different account. Requires scope:
47
+ * allowedEvent:find
25
48
  */
26
49
  retrieve(id: string, options?: RequestOptions): APIPromise<AllowedEventRetrieveResponse> {
27
50
  return this._client.get(path`/rest/v1/allowed-events/${id}`, options);
28
51
  }
29
52
 
30
53
  /**
31
- * Delete an allowed event. Requires scope: allowedEvent:delete
54
+ * Partially update an allowed event. Only the fields you send are changed; omitted
55
+ * fields keep their current value.
56
+ *
57
+ * - `destinationIds` is replaced wholesale when sent — the canonical way to add or
58
+ * remove a destination is to fetch, modify the array, and PATCH it back. Stale
59
+ * ids (deleted destinations or destinations on another account) are silently
60
+ * filtered out at write time.
61
+ * - `name` is subject to the same rules as create: case-insensitive uniqueness,
62
+ * length cap, `$`-prefix reservation.
63
+ * - `trigger` accepts `null` to clear the existing value.
64
+ *
65
+ * Returns the full entity. Known input failures (duplicate name, length,
66
+ * `$`-prefix, empty name) are returned as HTTP 409 with the reason in the response
67
+ * `error` field. Requires scope: allowedEvent:update
68
+ */
69
+ update(
70
+ id: string,
71
+ body: AllowedEventUpdateParams,
72
+ options?: RequestOptions,
73
+ ): APIPromise<AllowedEventUpdateResponse> {
74
+ return this._client.patch(path`/rest/v1/allowed-events/${id}`, { body, ...options });
75
+ }
76
+
77
+ /**
78
+ * Delete an allowed event. After deletion, inbound events whose `event` field
79
+ * matches the deleted name are no longer routed and are dropped at the allow-list
80
+ * stage of the dispatch flow. Requires scope: allowedEvent:delete
32
81
  */
33
82
  delete(id: string, options?: RequestOptions): APIPromise<AllowedEventDeleteResponse> {
34
83
  return this._client.delete(path`/rest/v1/allowed-events/${id}`, options);
@@ -41,39 +90,193 @@ export interface AllowedEventListResponse {
41
90
 
42
91
  export namespace AllowedEventListResponse {
43
92
  export interface Entity {
93
+ /**
94
+ * Server-assigned UUID for this allowed event.
95
+ */
44
96
  id: string;
45
97
 
98
+ /**
99
+ * ISO 8601 timestamp when the allowed event was created.
100
+ */
46
101
  createdAt: string;
47
102
 
103
+ /**
104
+ * Destinations that receive this event. Empty array means the event is allowed but
105
+ * routed nowhere (effectively dropped). PATCH replaces this list wholesale.
106
+ */
48
107
  destinationIds: Array<string>;
49
108
 
109
+ /**
110
+ * Case-insensitive event name. Inbound events whose `event` field matches this
111
+ * value are gated through this allowed event. Reserved: names starting with `$`
112
+ * are system events and cannot be created (except `$identify`).
113
+ */
50
114
  name: string;
51
115
 
116
+ /**
117
+ * Optional free-form trigger description. Not used by the dispatch pipeline —
118
+ * surfaced in the dashboard so teams can record where each event fires.
119
+ */
120
+ trigger?: string | null;
121
+
122
+ /**
123
+ * ISO 8601 timestamp of the last PATCH. Equal to createdAt on a freshly created
124
+ * event.
125
+ */
52
126
  updatedAt?: string | null;
53
127
  }
54
128
  }
55
129
 
56
130
  export interface AllowedEventCreateResponse {
131
+ /**
132
+ * Server-assigned UUID for this allowed event.
133
+ */
57
134
  id: string;
58
135
 
136
+ /**
137
+ * ISO 8601 timestamp when the allowed event was created.
138
+ */
59
139
  createdAt: string;
60
140
 
141
+ /**
142
+ * Destinations that receive this event. Empty array means the event is allowed but
143
+ * routed nowhere (effectively dropped). PATCH replaces this list wholesale.
144
+ */
61
145
  destinationIds: Array<string>;
62
146
 
147
+ /**
148
+ * Case-insensitive event name. Inbound events whose `event` field matches this
149
+ * value are gated through this allowed event. Reserved: names starting with `$`
150
+ * are system events and cannot be created (except `$identify`).
151
+ */
63
152
  name: string;
64
153
 
154
+ /**
155
+ * ISO 8601 timestamp of the most recent successful dispatch to any destination on
156
+ * `destinationIds`. Lags `lastTriggeredAt` when consent or governance rules drop
157
+ * the event before dispatch.
158
+ */
159
+ lastDispatchedAt?: string | null;
160
+
161
+ /**
162
+ * ISO 8601 timestamp of the most recent inbound event observed for this name.
163
+ * Useful for spotting events that were configured but never fired. Null when never
164
+ * observed.
165
+ */
166
+ lastTriggeredAt?: string | null;
167
+
168
+ /**
169
+ * Optional free-form trigger description. Not used by the dispatch pipeline —
170
+ * surfaced in the dashboard so teams can record where each event fires.
171
+ */
172
+ trigger?: string | null;
173
+
174
+ /**
175
+ * ISO 8601 timestamp of the last PATCH. Equal to createdAt on a freshly created
176
+ * event.
177
+ */
65
178
  updatedAt?: string | null;
66
179
  }
67
180
 
68
181
  export interface AllowedEventRetrieveResponse {
182
+ /**
183
+ * Server-assigned UUID for this allowed event.
184
+ */
185
+ id: string;
186
+
187
+ /**
188
+ * ISO 8601 timestamp when the allowed event was created.
189
+ */
190
+ createdAt: string;
191
+
192
+ /**
193
+ * Destinations that receive this event. Empty array means the event is allowed but
194
+ * routed nowhere (effectively dropped). PATCH replaces this list wholesale.
195
+ */
196
+ destinationIds: Array<string>;
197
+
198
+ /**
199
+ * Case-insensitive event name. Inbound events whose `event` field matches this
200
+ * value are gated through this allowed event. Reserved: names starting with `$`
201
+ * are system events and cannot be created (except `$identify`).
202
+ */
203
+ name: string;
204
+
205
+ /**
206
+ * ISO 8601 timestamp of the most recent successful dispatch to any destination on
207
+ * `destinationIds`. Lags `lastTriggeredAt` when consent or governance rules drop
208
+ * the event before dispatch.
209
+ */
210
+ lastDispatchedAt?: string | null;
211
+
212
+ /**
213
+ * ISO 8601 timestamp of the most recent inbound event observed for this name.
214
+ * Useful for spotting events that were configured but never fired. Null when never
215
+ * observed.
216
+ */
217
+ lastTriggeredAt?: string | null;
218
+
219
+ /**
220
+ * Optional free-form trigger description. Not used by the dispatch pipeline —
221
+ * surfaced in the dashboard so teams can record where each event fires.
222
+ */
223
+ trigger?: string | null;
224
+
225
+ /**
226
+ * ISO 8601 timestamp of the last PATCH. Equal to createdAt on a freshly created
227
+ * event.
228
+ */
229
+ updatedAt?: string | null;
230
+ }
231
+
232
+ export interface AllowedEventUpdateResponse {
233
+ /**
234
+ * Server-assigned UUID for this allowed event.
235
+ */
69
236
  id: string;
70
237
 
238
+ /**
239
+ * ISO 8601 timestamp when the allowed event was created.
240
+ */
71
241
  createdAt: string;
72
242
 
243
+ /**
244
+ * Destinations that receive this event. Empty array means the event is allowed but
245
+ * routed nowhere (effectively dropped). PATCH replaces this list wholesale.
246
+ */
73
247
  destinationIds: Array<string>;
74
248
 
249
+ /**
250
+ * Case-insensitive event name. Inbound events whose `event` field matches this
251
+ * value are gated through this allowed event. Reserved: names starting with `$`
252
+ * are system events and cannot be created (except `$identify`).
253
+ */
75
254
  name: string;
76
255
 
256
+ /**
257
+ * ISO 8601 timestamp of the most recent successful dispatch to any destination on
258
+ * `destinationIds`. Lags `lastTriggeredAt` when consent or governance rules drop
259
+ * the event before dispatch.
260
+ */
261
+ lastDispatchedAt?: string | null;
262
+
263
+ /**
264
+ * ISO 8601 timestamp of the most recent inbound event observed for this name.
265
+ * Useful for spotting events that were configured but never fired. Null when never
266
+ * observed.
267
+ */
268
+ lastTriggeredAt?: string | null;
269
+
270
+ /**
271
+ * Optional free-form trigger description. Not used by the dispatch pipeline —
272
+ * surfaced in the dashboard so teams can record where each event fires.
273
+ */
274
+ trigger?: string | null;
275
+
276
+ /**
277
+ * ISO 8601 timestamp of the last PATCH. Equal to createdAt on a freshly created
278
+ * event.
279
+ */
77
280
  updatedAt?: string | null;
78
281
  }
79
282
 
@@ -85,12 +288,37 @@ export interface AllowedEventCreateParams {
85
288
  destinationIds?: Array<string> | null;
86
289
  }
87
290
 
291
+ export interface AllowedEventUpdateParams {
292
+ /**
293
+ * Destinations that should receive this event. Wholesale replacement — the sent
294
+ * list becomes the new value. Stale IDs (destinations from another account or
295
+ * deleted destinations) are silently filtered out at write time. Send `[]` to gate
296
+ * the event from every destination.
297
+ */
298
+ destinationIds?: Array<string> | null;
299
+
300
+ /**
301
+ * New event name. Subject to the same rules as create: case-insensitive uniqueness
302
+ * within the account, max length enforced by the platform, and the `$`-prefix
303
+ * reservation (only `$identify` is allowed). Omit to leave the name unchanged.
304
+ */
305
+ name?: string | null;
306
+
307
+ /**
308
+ * Free-form trigger description shown in the dashboard. Send `null` to clear. Not
309
+ * used by the dispatch pipeline.
310
+ */
311
+ trigger?: string | null;
312
+ }
313
+
88
314
  export declare namespace AllowedEvents {
89
315
  export {
90
316
  type AllowedEventListResponse as AllowedEventListResponse,
91
317
  type AllowedEventCreateResponse as AllowedEventCreateResponse,
92
318
  type AllowedEventRetrieveResponse as AllowedEventRetrieveResponse,
319
+ type AllowedEventUpdateResponse as AllowedEventUpdateResponse,
93
320
  type AllowedEventDeleteResponse as AllowedEventDeleteResponse,
94
321
  type AllowedEventCreateParams as AllowedEventCreateParams,
322
+ type AllowedEventUpdateParams as AllowedEventUpdateParams,
95
323
  };
96
324
  }
@@ -0,0 +1,76 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import { APIPromise } from '../core/api-promise';
5
+ import { RequestOptions } from '../internal/request-options';
6
+
7
+ export class ConsentAnalytics extends APIResource {
8
+ /**
9
+ * Account-wide blocking stats from the Global Consent Center for the window: how
10
+ * many dispatches were attempted, how many were blocked, and a per-category
11
+ * breakdown of the blocks (with `percentageBlocked` = share of `totalDispatches`).
12
+ * Not scoped to a single consent settings record — this aggregates across every
13
+ * destination in the account. The endpoint is identified by query params rather
14
+ * than a path id because the report is account-scoped; this is a documented
15
+ * derived-read exception. Reuses the API-key scope `consentSettings:list` because
16
+ * the report crosses every consent setting. Requires scope: consentSettings:list
17
+ */
18
+ list(
19
+ query: ConsentAnalyticsListParams,
20
+ options?: RequestOptions,
21
+ ): APIPromise<ConsentAnalyticsListResponse> {
22
+ return this._client.get('/rest/v1/consent-analytics', { query, ...options });
23
+ }
24
+ }
25
+
26
+ export interface ConsentAnalyticsListResponse {
27
+ /**
28
+ * Per-category breakdown of blocked dispatches. `categoryName` is `Unknown` when
29
+ * the upstream block message could not be parsed; `percentageBlocked` is the share
30
+ * of `totalDispatches` blocked under that category.
31
+ */
32
+ items: Array<ConsentAnalyticsListResponse.Item>;
33
+
34
+ /**
35
+ * Total dispatches blocked by the Global Consent Center across all categories.
36
+ */
37
+ totalBlocked: number;
38
+
39
+ /**
40
+ * Total dispatches attempted across all destinations for the window.
41
+ */
42
+ totalDispatches: number;
43
+ }
44
+
45
+ export namespace ConsentAnalyticsListResponse {
46
+ export interface Item {
47
+ blockedCount: number;
48
+
49
+ categoryName: string;
50
+
51
+ percentageBlocked: number;
52
+ }
53
+ }
54
+
55
+ export interface ConsentAnalyticsListParams {
56
+ /**
57
+ * Inclusive lower bound of the analytics window, as a UTC calendar day in
58
+ * `YYYY-MM-DD` format. The window between `from` and `to` must be 60 days or
59
+ * fewer.
60
+ */
61
+ from: string;
62
+
63
+ /**
64
+ * Inclusive upper bound of the analytics window, as a UTC calendar day in
65
+ * `YYYY-MM-DD` format. The window between `from` and `to` must be 60 days or
66
+ * fewer.
67
+ */
68
+ to: string;
69
+ }
70
+
71
+ export declare namespace ConsentAnalytics {
72
+ export {
73
+ type ConsentAnalyticsListResponse as ConsentAnalyticsListResponse,
74
+ type ConsentAnalyticsListParams as ConsentAnalyticsListParams,
75
+ };
76
+ }
@@ -66,6 +66,61 @@ export class ConsentSettings extends APIResource {
66
66
  delete(id: string, options?: RequestOptions): APIPromise<ConsentSettingDeleteResponse> {
67
67
  return this._client.delete(path`/rest/v1/consent-settings/${id}`, options);
68
68
  }
69
+
70
+ /**
71
+ * Time-series consent analytics for a single consent settings record: banner
72
+ * views, opt-ins, opt-outs, close-icon clicks, and derived opt-in/out rates per
73
+ * UTC day (or per UTC hour with `granularity=HOURLY`). The window is zero-filled
74
+ * so callers get a contiguous series, and rates are person-level
75
+ * (`COUNT(DISTINCT visitor_id)`). Use the optional `pagePath` and `region` filters
76
+ * to scope to one page or one visitor region; use `compareWithPreviousPeriod=true`
77
+ * to also receive the matching prior window. `DAILY` allows a 90-day window;
78
+ * `HOURLY` is capped at 14 days. Reuses the API-key scope `consentSettings:find`
79
+ * because the endpoint is identified by a consent settings `id`. Requires scope:
80
+ * consentSettings:find
81
+ */
82
+ analytics(
83
+ id: string,
84
+ query: ConsentSettingAnalyticsParams,
85
+ options?: RequestOptions,
86
+ ): APIPromise<ConsentSettingAnalyticsResponse> {
87
+ return this._client.get(path`/rest/v1/consent-settings/${id}/analytics`, { query, ...options });
88
+ }
89
+
90
+ /**
91
+ * Per-page consent breakdown for one consent settings record, ranked by opt-outs
92
+ * (descending). Each row bundles banner views, opt-outs, close-icon clicks, and
93
+ * the derived opt-out rate. Documented exception to the cursor-pagination
94
+ * standard: this is a derived read whose underlying GraphQL contract is
95
+ * offset/limit-based; cursors are not used. `search` is a substring match against
96
+ * `pathname`; `region` filters to one visitor region. Reuses the API-key scope
97
+ * `consentSettings:find`. Requires scope: consentSettings:find
98
+ */
99
+ pageAnalysis(
100
+ id: string,
101
+ query: ConsentSettingPageAnalysisParams,
102
+ options?: RequestOptions,
103
+ ): APIPromise<ConsentSettingPageAnalysisResponse> {
104
+ return this._client.get(path`/rest/v1/consent-settings/${id}/page-analysis`, { query, ...options });
105
+ }
106
+
107
+ /**
108
+ * Region-grouped consent totals for the window: banner views, opt-ins, opt-outs,
109
+ * close-icon clicks, and derived rates per visitor `country_region_name`, ranked
110
+ * by banner views (descending). Visitors whose region cannot be resolved (e.g. bot
111
+ * traffic, IP geo failure) are bucketed under the literal `Unknown` so per-region
112
+ * counts always sum to the global totals. Use this to discover the region names
113
+ * you can later pass to the `region` filter on
114
+ * `GET /rest/v1/consent-settings/{id}/analytics`. Reuses the API-key scope
115
+ * `consentSettings:find`. Requires scope: consentSettings:find
116
+ */
117
+ analyticsByRegion(
118
+ id: string,
119
+ query: ConsentSettingAnalyticsByRegionParams,
120
+ options?: RequestOptions,
121
+ ): APIPromise<ConsentSettingAnalyticsByRegionResponse> {
122
+ return this._client.get(path`/rest/v1/consent-settings/${id}/analytics-by-region`, { query, ...options });
123
+ }
69
124
  }
70
125
 
71
126
  export interface ConsentSettingListResponse {
@@ -2624,6 +2679,115 @@ export namespace ConsentSettingDeleteResponse {
2624
2679
  }
2625
2680
  }
2626
2681
 
2682
+ export interface ConsentSettingAnalyticsResponse {
2683
+ /**
2684
+ * One entry per time bucket (day or hour, depending on `granularity`) covering the
2685
+ * full window — empty windows are zero-filled so callers can render contiguous
2686
+ * time series without gap-handling logic.
2687
+ */
2688
+ items: Array<ConsentSettingAnalyticsResponse.Item>;
2689
+ }
2690
+
2691
+ export namespace ConsentSettingAnalyticsResponse {
2692
+ export interface Item {
2693
+ bannerViews: number;
2694
+
2695
+ closeIconClicks: number;
2696
+
2697
+ dateTime: string;
2698
+
2699
+ explicitOptIns: number;
2700
+
2701
+ explicitOptOuts: number;
2702
+
2703
+ optInRate: number;
2704
+
2705
+ optOutRate: number;
2706
+
2707
+ percentageChangeBannerViews?: number | null;
2708
+
2709
+ percentageChangeCloseIconClicks?: number | null;
2710
+
2711
+ percentageChangeExplicitOptIns?: number | null;
2712
+
2713
+ percentageChangeExplicitOptOuts?: number | null;
2714
+
2715
+ previousBannerViews?: number | null;
2716
+
2717
+ previousCloseIconClicks?: number | null;
2718
+
2719
+ previousExplicitOptIns?: number | null;
2720
+
2721
+ previousExplicitOptOuts?: number | null;
2722
+
2723
+ previousOptInRate?: number | null;
2724
+
2725
+ previousOptOutRate?: number | null;
2726
+ }
2727
+ }
2728
+
2729
+ export interface ConsentSettingPageAnalysisResponse {
2730
+ /**
2731
+ * True when at least one more page is available beyond the current window.
2732
+ */
2733
+ hasMore: boolean;
2734
+
2735
+ /**
2736
+ * Pages with consent activity in the window, ranked by opt-outs (descending). Each
2737
+ * page bundles banner views, opt-outs, close-icon clicks, and the derived opt-out
2738
+ * rate.
2739
+ */
2740
+ items: Array<ConsentSettingPageAnalysisResponse.Item>;
2741
+
2742
+ /**
2743
+ * Running count of pages loaded so far (`offset + items.length`). Approximate for
2744
+ * load-more flows; query without `offset` to get the exact size of the first page.
2745
+ */
2746
+ total: number;
2747
+ }
2748
+
2749
+ export namespace ConsentSettingPageAnalysisResponse {
2750
+ export interface Item {
2751
+ bannerViews: number;
2752
+
2753
+ closeIconClicks: number;
2754
+
2755
+ optOutRate: number;
2756
+
2757
+ optOuts: number;
2758
+
2759
+ page: string;
2760
+ }
2761
+ }
2762
+
2763
+ export interface ConsentSettingAnalyticsByRegionResponse {
2764
+ /**
2765
+ * Per-region totals for the window, ranked by banner views (descending). Visitors
2766
+ * whose region cannot be resolved (e.g. bot traffic, IP geo failure) are bucketed
2767
+ * under the literal `Unknown`, so the per-region counts always sum to the global
2768
+ * totals.
2769
+ */
2770
+ regions: Array<ConsentSettingAnalyticsByRegionResponse.Region>;
2771
+ }
2772
+
2773
+ export namespace ConsentSettingAnalyticsByRegionResponse {
2774
+ export interface Region {
2775
+ bannerViews: number;
2776
+
2777
+ closeIconClicks: number;
2778
+
2779
+ explicitOptIns: number;
2780
+
2781
+ explicitOptOuts: number;
2782
+
2783
+ optInRate: number;
2784
+
2785
+ optOutRate: number;
2786
+
2787
+ regionName: string;
2788
+ }
2789
+ }
2790
+
2627
2791
  export interface ConsentSettingReplaceParams {
2628
2792
  /**
2629
2793
  * Top-level consent categories. Server re-stamps `priority` to 0..N.
@@ -3422,6 +3586,108 @@ export namespace ConsentSettingUpdateParams {
3422
3586
  }
3423
3587
  }
3424
3588
 
3589
+ export interface ConsentSettingAnalyticsParams {
3590
+ /**
3591
+ * Inclusive lower bound of the analytics window, as a UTC calendar day in
3592
+ * `YYYY-MM-DD` format. The window between `from` and `to` must be 90 days or fewer
3593
+ * (14 for `HOURLY` granularity).
3594
+ */
3595
+ from: string;
3596
+
3597
+ /**
3598
+ * Inclusive upper bound of the analytics window, as a UTC calendar day in
3599
+ * `YYYY-MM-DD` format. The window between `from` and `to` must be 90 days or fewer
3600
+ * (14 for `HOURLY` granularity).
3601
+ */
3602
+ to: string;
3603
+
3604
+ /**
3605
+ * When `true`, each bucket also returns the matching bucket from the immediately
3606
+ * preceding window of equal length (in `previous*` and `percentageChange*`
3607
+ * fields). Defaults to `false`.
3608
+ */
3609
+ compareWithPreviousPeriod?: boolean;
3610
+
3611
+ /**
3612
+ * Bucket size for the time-series rollup. `DAILY` (default) buckets per UTC day;
3613
+ * `HOURLY` buckets per UTC hour and limits the window to 14 days.
3614
+ */
3615
+ granularity?: 'DAILY' | 'HOURLY';
3616
+
3617
+ /**
3618
+ * Filter to events whose `default_properties.pathname` equals this value (exact
3619
+ * match, case-sensitive). Use this to drill into a single page.
3620
+ */
3621
+ pagePath?: string;
3622
+
3623
+ /**
3624
+ * Filter results to events whose `request_context.country_region_name` is in this
3625
+ * set. Pass a single region (e.g. `California`) or a comma-separated list
3626
+ * (`California,Texas`). Case-sensitive. Use
3627
+ * `GET /rest/v1/consent-settings/{id}/analytics-by-region` to discover the region
3628
+ * names available for an account.
3629
+ */
3630
+ regions?: string;
3631
+ }
3632
+
3633
+ export interface ConsentSettingPageAnalysisParams {
3634
+ /**
3635
+ * Inclusive lower bound of the analytics window, as a UTC calendar day in
3636
+ * `YYYY-MM-DD` format. The window between `from` and `to` must be 90 days or fewer
3637
+ * (14 for `HOURLY` granularity).
3638
+ */
3639
+ from: string;
3640
+
3641
+ /**
3642
+ * Inclusive upper bound of the analytics window, as a UTC calendar day in
3643
+ * `YYYY-MM-DD` format. The window between `from` and `to` must be 90 days or fewer
3644
+ * (14 for `HOURLY` granularity).
3645
+ */
3646
+ to: string;
3647
+
3648
+ /**
3649
+ * Maximum number of pages to return. Defaults to 50.
3650
+ */
3651
+ limit?: number;
3652
+
3653
+ /**
3654
+ * Skip this many top-ranked pages before returning. Use together with `limit` for
3655
+ * load-more pagination.
3656
+ */
3657
+ offset?: number | null;
3658
+
3659
+ /**
3660
+ * Filter results to events whose `request_context.country_region_name` is in this
3661
+ * set. Pass a single region (e.g. `California`) or a comma-separated list
3662
+ * (`California,Texas`). Case-sensitive. Use
3663
+ * `GET /rest/v1/consent-settings/{id}/analytics-by-region` to discover the region
3664
+ * names available for an account.
3665
+ */
3666
+ regions?: string;
3667
+
3668
+ /**
3669
+ * Case-sensitive substring match against `default_properties.pathname`. Wrapped in
3670
+ * `%...%` server-side.
3671
+ */
3672
+ search?: string;
3673
+ }
3674
+
3675
+ export interface ConsentSettingAnalyticsByRegionParams {
3676
+ /**
3677
+ * Inclusive lower bound of the analytics window, as a UTC calendar day in
3678
+ * `YYYY-MM-DD` format. The window between `from` and `to` must be 90 days or fewer
3679
+ * (14 for `HOURLY` granularity).
3680
+ */
3681
+ from: string;
3682
+
3683
+ /**
3684
+ * Inclusive upper bound of the analytics window, as a UTC calendar day in
3685
+ * `YYYY-MM-DD` format. The window between `from` and `to` must be 90 days or fewer
3686
+ * (14 for `HOURLY` granularity).
3687
+ */
3688
+ to: string;
3689
+ }
3690
+
3425
3691
  export declare namespace ConsentSettings {
3426
3692
  export {
3427
3693
  type ConsentSettingListResponse as ConsentSettingListResponse,
@@ -3430,7 +3696,13 @@ export declare namespace ConsentSettings {
3430
3696
  type ConsentSettingReplaceResponse as ConsentSettingReplaceResponse,
3431
3697
  type ConsentSettingUpdateResponse as ConsentSettingUpdateResponse,
3432
3698
  type ConsentSettingDeleteResponse as ConsentSettingDeleteResponse,
3699
+ type ConsentSettingAnalyticsResponse as ConsentSettingAnalyticsResponse,
3700
+ type ConsentSettingPageAnalysisResponse as ConsentSettingPageAnalysisResponse,
3701
+ type ConsentSettingAnalyticsByRegionResponse as ConsentSettingAnalyticsByRegionResponse,
3433
3702
  type ConsentSettingReplaceParams as ConsentSettingReplaceParams,
3434
3703
  type ConsentSettingUpdateParams as ConsentSettingUpdateParams,
3704
+ type ConsentSettingAnalyticsParams as ConsentSettingAnalyticsParams,
3705
+ type ConsentSettingPageAnalysisParams as ConsentSettingPageAnalysisParams,
3706
+ type ConsentSettingAnalyticsByRegionParams as ConsentSettingAnalyticsByRegionParams,
3435
3707
  };
3436
3708
  }