@pomeloanalytics/api 0.1.0-beta.3 → 0.1.0-beta.5

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 CHANGED
@@ -1,5 +1,47 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.0-beta.5
4
+
5
+ - **Type break.** `quotas` of `/v1/me`, and `meta.usage` and `meta.billable_overage`
6
+ of metered responses, are now optional: an API token limited to followed
7
+ workspaces does not receive the organization's consumption. Narrow them
8
+ before use (`data.quotas?.used_units`). Unrestricted tokens still receive them.
9
+ - Add `pomelo.tenants.write(body, options?)` for `POST /v1/tenants` (scope
10
+ `tenants:write`, never restricted to some tenants): additive, idempotent
11
+ registration of up to 100 tenants of a site. New types `TenantsWriteBody` and
12
+ `TenantsWriteData`; the body keeps wire field names.
13
+ - The client sends one JSON POST for this operation; every other operation
14
+ remains a single GET.
15
+
16
+ ## 0.1.0-beta.4
17
+
18
+ - Sync the reviewed public contract for a single audience measurement and the
19
+ Campagnes option. Availability statuses `locked_by_profile` and
20
+ `partially_available_after_effective_at`, the reasons `strict_safe_route`,
21
+ `extended_data_required` and `requested_period_crosses_profile_change`, and
22
+ the availability fields `currentProfile`, `classification`, `readModel` and
23
+ `collectionProfileEffectiveAt` are removed. Reasons are now
24
+ `campaigns_option_required`, `outside_source_coverage` or `null`.
25
+ - Acquisition responses add `campaigns_enabled`, `consented_sessions` and the
26
+ `contents` and `terms` dimensions, and drop the `tagged_*` coverage fields.
27
+ - Rates, shares and means are `number | null` (null under 10 contributors);
28
+ envelopes may carry `small_site`.
29
+ - `meta.surface.reportingPrecision` is
30
+ `{ version: 'exact-masked-counts-v1', minimumCount: 10, rateStep: 0.01 }`:
31
+ counts are exact from 10 and `null` from 1 to 9 (never 0, never 5; render as
32
+ `< 10`). Rates, means and p75 are `null` under 10 contributors; `delta` and
33
+ `delta_pct` are published only when both counts are.
34
+ - Timeseries responses add `period_total`; Acquisition details add the
35
+ `referrer_sources` and `referrer_types` dimensions; Content `include` no
36
+ longer accepts `details` (`summary` or `full`).
37
+ - `small_site.reason` (`small_site` or `filter_complement`) says why the
38
+ totals come from a wider period: too few visits, or a filter that sets 1 to
39
+ 9 visits of the site apart (its rates and means are then null).
40
+ - Report filters accept only values published for the period (10 visits or
41
+ more); others are refused with 422 `INVALID_PARAMS`
42
+ (`reason: filter_value_not_published`).
43
+ - The HTTP client implementation is unchanged.
44
+
3
45
  ## 0.1.0-beta.3
4
46
 
5
47
  - Add optional per-metric Content sample counts and the selected measurement method to generated API types.
package/README.md CHANGED
@@ -51,8 +51,8 @@ const { data: account } = await pomelo.me();
51
51
 
52
52
  Create a read token in the Pomelo dashboard as described in the getting-started
53
53
  guide. Keep it in server configuration, outside source control and browser code.
54
- API access depends on your plan and the token's permissions. The API enforces
55
- collection-profile availability for each endpoint.
54
+ API access depends on your plan and the token's permissions. Each report
55
+ returns `availability`, which tells you whether the requested period is covered.
56
56
 
57
57
  ## Read metrics
58
58
 
@@ -88,6 +88,7 @@ The default timeout is 30 seconds and covers reading the response body.
88
88
  | `pomelo.me(options?)` | `/v1/me` |
89
89
  | `pomelo.sites.list(options?)` | `/v1/sites` |
90
90
  | `pomelo.tenants.list(params, options?)` | `/v1/tenants` |
91
+ | `pomelo.tenants.write(body, options?)` | `POST /v1/tenants` |
91
92
  | `pomelo.metrics.timeseries(params, options?)` | `/v1/metrics/timeseries` |
92
93
  | `pomelo.metrics.breakdown(params, options?)` | `/v1/metrics/breakdown` |
93
94
  | `pomelo.reports.overview(params, options?)` | `/v1/reports/overview` |
@@ -99,6 +100,15 @@ The default timeout is 30 seconds and covers reading the response body.
99
100
  | `pomelo.usage.current(options?)` | `/v1/usage/current` |
100
101
  | `pomelo.usage.history(params?, options?)` | `/v1/usage/history` |
101
102
 
103
+ `tenants.write` is the only operation that is not a GET. It needs a token with the
104
+ dedicated `tenants:write` scope (never restricted to some tenants), takes the
105
+ wire body (`{ site_id, tenants: [{ tenant_id, tenant_slug, tenant_name, status? }] }`,
106
+ at most 100 tenants) and is additive and idempotent.
107
+
108
+ A token restricted to followed workspaces does not see the organization's
109
+ consumption: `/v1/me` has no `quotas`, and `meta.usage` and `meta.billable_overage`
110
+ are absent from metered responses. Treat them as optional.
111
+
102
112
  Parameters use camelCase (`siteId`, `tenantId`, `actionFamily`, `actionKey`) and map
103
113
  to the API's exact wire names. Other names, such as `from`, `to`, `metric`, and
104
114
  `include`, are unchanged. `filters` is a JSON string, as defined by the API.
@@ -107,7 +117,7 @@ Response fields are never renamed.
107
117
  Dates use inclusive UTC `YYYY-MM-DD` values. Pass explicit dates to bound a read.
108
118
  The server owns defaults, period validation, entitlements, and numeric limits;
109
119
  the SDK does not choose content depth, clamp limits, or change a requested range.
110
- The `details` alias for content `include` remains accepted by the public contract.
120
+ Content `include` accepts `summary` or `full`.
111
121
 
112
122
  Full Content responses can include `current.metric_method` and
113
123
  `current.pages[].performance.n_lcp`, `n_fcp`, `n_inp`, `n_cls` and `n_ttfb`.
@@ -145,8 +155,9 @@ if ('channels' in data.current) {
145
155
  }
146
156
  ```
147
157
 
148
- For Acquisition, `details` is a distinct shape. For Content, `details` is the
149
- deprecated alias for `full`. Actions accepts `summary`, `full`, and `details`
158
+ For Acquisition, `details` is a distinct shape (it adds the `referrer_sources`
159
+ and `referrer_types` dimensions). Content accepts only `summary` and `full`.
160
+ Actions accepts `summary`, `full`, and `details`
150
161
  using its single response schema; summary leaves detail lists empty on the server.
151
162
  Omitting `include` leaves the server's selection unchanged.
152
163
 
@@ -169,7 +180,7 @@ if ('dimensions' in data.current && data.current.impact) {
169
180
  }
170
181
  ```
171
182
 
172
- Impact is conditional on the server response and Extended data. It reports
183
+ Impact is conditional on the server response and on the Campagnes option. It reports
173
184
  distinct converted visits using first-pageview attribution; repeated goal
174
185
  matches count once. Check availability as well as the optional impact object.
175
186
  The SDK supplies no impact defaults or enrichment.
@@ -187,11 +198,28 @@ curl --get 'https://api.pomeloanalytics.com/v1/reports/acquisition' \
187
198
  --data-urlencode 'goal_id=goal-test'
188
199
  ```
189
200
 
190
- HTTP 200 on a mixed route means its strict-safe baseline succeeded. Check
191
- `availability.sections` for sections that remain locked or only partially
192
- available. Tenant-scoped reads use a stable opaque `tenantId`; the server checks
201
+ Check `availability.sections` for sections that are unavailable or only
202
+ partially available: `reason` is `campaigns_option_required` when the Campagnes
203
+ option is off, `outside_source_coverage` when the period is not covered, or
204
+ `null`. Tenant-scoped reads use a stable opaque `tenantId`; the server checks
193
205
  the token's permissions and the site's configuration.
194
206
 
207
+ ## Reporting precision
208
+
209
+ `meta.surface.reportingPrecision` is
210
+ `{ version: 'exact-masked-counts-v1', minimumCount: 10, rateStep: 0.01 }`.
211
+ Counts are exact from 10. A count from 1 to 9 is published as `null`: display
212
+ it as `< 10`. It is never `0` and never a representative value such as 5.
213
+ `0` is a measured zero. Rates, shares, means and p75 values are `null` under 10
214
+ contributors. `delta` and `delta_pct` are published only when both counts are.
215
+ `timeseries` responses carry `period_total`, which is `null` when masked.
216
+
217
+ The SDK returns these values unchanged: it does not retry, round or rebuild
218
+ anything. A masked value stays `null`: never add it up, subtract it or compute
219
+ a gap from it. A missing observation is signalled by the field or the
220
+ availability state of the section, not by a number. Responses may also carry
221
+ `small_site`.
222
+
195
223
  ## Errors and request metadata
196
224
 
197
225
  HTTP failures throw `PomeloApiError`, exposing `status`, `code`, `requestId`, and
package/dist/client.d.ts CHANGED
@@ -9,6 +9,9 @@ export type ApiParams<Path extends ApiPath> = [WireParams<Path>] extends [never]
9
9
  [Key in keyof WireParams<Path> as Key extends string ? CamelCase<Key> : never]: WireParams<Path>[Key];
10
10
  };
11
11
  export type TenantsParams = ApiParams<'/v1/tenants'>;
12
+ /** Body of `POST /v1/tenants`: wire field names (`site_id`, `tenant_slug`, ...). */
13
+ export type TenantsWriteBody = paths['/v1/tenants']['post']['requestBody']['content']['application/json'];
14
+ export type TenantsWriteData = paths['/v1/tenants']['post']['responses'][200]['content']['application/json'];
12
15
  export type TimeseriesParams = ApiParams<'/v1/metrics/timeseries'>;
13
16
  export type BreakdownParams = ApiParams<'/v1/metrics/breakdown'>;
14
17
  export type OverviewParams = ApiParams<'/v1/reports/overview'>;
@@ -18,7 +21,7 @@ export type ActionsParams = ApiParams<'/v1/reports/actions'>;
18
21
  export type GoalsParams = ApiParams<'/v1/goals'>;
19
22
  export type GoalConversionsParams = ApiParams<'/v1/goals/conversions'>;
20
23
  export type UsageHistoryParams = ApiParams<'/v1/usage/history'>;
21
- /** Server-side API client. Each operation performs exactly one GET request. */
24
+ /** Server-side API client. Each operation performs exactly one request: GET, except `tenants.write` (POST). */
22
25
  export declare class PomeloClient {
23
26
  #private;
24
27
  constructor(options: PomeloClientOptions);
@@ -28,6 +31,12 @@ export declare class PomeloClient {
28
31
  };
29
32
  readonly tenants: {
30
33
  list: (params: TenantsParams, options?: RequestOptions) => Promise<ApiResponse<ApiData<"/v1/tenants">>>;
34
+ /**
35
+ * Registers or updates tenants of a site (additive, idempotent). Requires a token
36
+ * with the `tenants:write` scope, which cannot be restricted to some tenants.
37
+ * The body keeps the wire field names of the public contract.
38
+ */
39
+ write: (body: TenantsWriteBody, options?: RequestOptions) => Promise<ApiResponse<TenantsWriteData>>;
31
40
  };
32
41
  readonly metrics: {
33
42
  timeseries: (params: TimeseriesParams, options?: RequestOptions) => Promise<ApiResponse<ApiData<"/v1/metrics/timeseries">>>;
package/dist/client.js CHANGED
@@ -10,7 +10,7 @@ function wireQuery(params) {
10
10
  }
11
11
  return query;
12
12
  }
13
- /** Server-side API client. Each operation performs exactly one GET request. */
13
+ /** Server-side API client. Each operation performs exactly one request: GET, except `tenants.write` (POST). */
14
14
  export class PomeloClient {
15
15
  #transport;
16
16
  constructor(options) {
@@ -22,6 +22,12 @@ export class PomeloClient {
22
22
  };
23
23
  tenants = {
24
24
  list: (params, options) => this.#transport.get('/v1/tenants', wireQuery(params), options),
25
+ /**
26
+ * Registers or updates tenants of a site (additive, idempotent). Requires a token
27
+ * with the `tenants:write` scope, which cannot be restricted to some tenants.
28
+ * The body keeps the wire field names of the public contract.
29
+ */
30
+ write: (body, options) => this.#transport.post('/v1/tenants', body, options),
25
31
  };
26
32
  metrics = {
27
33
  timeseries: (params, options) => this.#transport.get('/v1/metrics/timeseries', wireQuery(params), options),