@kk-forge/artel-collector 0.1.0 → 0.1.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/README.md +7 -7
- package/dist/transport.js +5 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ const usage = newCollector({
|
|
|
24
24
|
transport: newHttpTransport('https://intake.example.com/v1/public/relay'),
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
void usage.track('
|
|
27
|
+
void usage.track('report_exported', { format: 'pdf', pages: 12, with_images: true });
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
### Options
|
|
@@ -34,7 +34,7 @@ void usage.track('screenshot_taken', { mode: 'visible' });
|
|
|
34
34
|
- `version`: the product version, such as `1.2.3` or `1.2.3-beta.1`, up to 32 characters.
|
|
35
35
|
- `lang`: the interface language as a BCP 47 code, such as `en` or `pt-BR`. Optional.
|
|
36
36
|
- `storage`: where the collector keeps its state. See "Storage".
|
|
37
|
-
- `transport`: `newHttpTransport(endpoint)`, or a function that delivers the envelope body. It resolves within 30 seconds to the intake's HTTP status, or to `0` when the request did not reach the intake.
|
|
37
|
+
- `transport`: `newHttpTransport(endpoint)`, which posts without cookies or a referrer, or a function that delivers the envelope body. It resolves within 30 seconds to the intake's HTTP status, or to `0` when the request did not reach the intake.
|
|
38
38
|
- `getId`: returns the user's id in a `full` channel once they consented, or `undefined`. The collector never creates an id.
|
|
39
39
|
- `getPage`: returns `{ page, referrer }` for an event of a site channel, the path without the query string and the referring host. The collector reads no page itself, and cuts the two to 256 and 128 characters.
|
|
40
40
|
- `lock`: runs an operation while no other context that shares `storage` runs one, such as `newWebLock()` from the web module. Without it, two contexts recording at once may both mark the first event of a day, or overwrite each other's queued events.
|
|
@@ -45,9 +45,9 @@ void usage.track('screenshot_taken', { mode: 'visible' });
|
|
|
45
45
|
|
|
46
46
|
### Methods
|
|
47
47
|
|
|
48
|
-
Every method returns a promise that resolves and never rejects. A failure goes to `onError`.
|
|
48
|
+
Every method returns a promise that resolves and never rejects. A failure goes to `onError`. So a call whose result you do not wait for is marked `void`, as in the examples.
|
|
49
49
|
|
|
50
|
-
- `track(name, params?)` records an event.
|
|
50
|
+
- `track(name, params?)` records an event. The name and each param name must be on the product's allowlist and match this form: a lowercase letter, then lowercase letters, digits and `_`, up to 40 characters. A param value is a string up to 64 characters, a number or a boolean.
|
|
51
51
|
- `installed()` sends `installed` once per install. A later call sends no event.
|
|
52
52
|
- `updated()` sends `updated` when `version` differs from the last version seen. Call it after `installed()`, so that a fresh install does not also count as an update.
|
|
53
53
|
- `setEnabled(on)` with `false` drops the events not sent yet, sends `usage_counts_off` and stops sending. With `true` it sends `usage_counts_on`. The choice persists.
|
|
@@ -139,7 +139,7 @@ chrome.runtime.onInstalled.addListener(async ({ reason }) => {
|
|
|
139
139
|
});
|
|
140
140
|
|
|
141
141
|
// content script
|
|
142
|
-
void forwardTrack('
|
|
142
|
+
void forwardTrack('link_shared', { target: 'clipboard' });
|
|
143
143
|
```
|
|
144
144
|
|
|
145
145
|
## What is sent
|
|
@@ -156,11 +156,11 @@ One envelope per request:
|
|
|
156
156
|
"batch": "9f2c41d07ab35e18",
|
|
157
157
|
"events": [
|
|
158
158
|
{
|
|
159
|
-
"name": "
|
|
159
|
+
"name": "report_exported",
|
|
160
160
|
"day": "2026-10-29",
|
|
161
161
|
"first": ["day", "week"],
|
|
162
162
|
"age_days": 3,
|
|
163
|
-
"params": { "
|
|
163
|
+
"params": { "format": "pdf", "pages": 12, "with_images": true }
|
|
164
164
|
}
|
|
165
165
|
]
|
|
166
166
|
}
|
package/dist/transport.js
CHANGED
|
@@ -16,6 +16,11 @@ fetch = (input, init) => globalThis.fetch(input, init), clock = systemClock, } =
|
|
|
16
16
|
// This type skips a CORS preflight. The intake reads the body as JSON.
|
|
17
17
|
headers: { 'content-type': 'text/plain;charset=UTF-8' },
|
|
18
18
|
body,
|
|
19
|
+
// An extension with host access, or a page on the intake's own origin, would otherwise send the user's cookies
|
|
20
|
+
// for that host. The intake reads none.
|
|
21
|
+
credentials: 'omit',
|
|
22
|
+
// A page's own policy could otherwise send its full address, which `getPage` exists to keep out.
|
|
23
|
+
referrerPolicy: 'no-referrer',
|
|
19
24
|
keepalive: true,
|
|
20
25
|
signal: timeout.signal,
|
|
21
26
|
});
|