@heycatch/sdk 0.7.0 → 0.7.1-dev.1456
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 +82 -0
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +26 -2
- package/dist/index.d.ts +26 -2
- package/dist/index.js +2 -2
- package/dist/react-native.cjs +1 -1
- package/dist/react-native.d.cts +20 -2
- package/dist/react-native.d.ts +20 -2
- package/dist/react-native.js +1 -1
- package/dist/server.cjs +2 -2
- package/dist/server.d.cts +30 -3
- package/dist/server.d.ts +30 -3
- package/dist/server.js +2 -2
- package/dist/{shared-B8y8fJCD.d.cts → shared-BFhHwsG8.d.cts} +116 -5
- package/dist/{shared-B8y8fJCD.d.ts → shared-BFhHwsG8.d.ts} +116 -5
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -5,6 +5,88 @@ The official [HeyCatch](https://heycatch.ai) package for your app.
|
|
|
5
5
|
_(AI Agents: the setup guide is https://heycatch.ai/agents.md - you also need
|
|
6
6
|
the project key from the user's HeyCatch dashboard Install page.)_
|
|
7
7
|
|
|
8
|
+
## Privacy & consent options
|
|
9
|
+
|
|
10
|
+
`init()` accepts optional privacy/consent options alongside `projectKey`. Every
|
|
11
|
+
one is unset by default, and each takes effect only when you set it - so
|
|
12
|
+
`init({ projectKey })` on its own captures exactly as it always has:
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
analytics.init({
|
|
16
|
+
projectKey: 'hck_pk_...',
|
|
17
|
+
autocapture: false, // turn off automatic click/form-submit capture (pageviews and rage-clicks are captured separately, unaffected)
|
|
18
|
+
maskAllText: true, // strip captured elements' text content
|
|
19
|
+
maskAllElementAttributes: true, // strip captured elements' attributes
|
|
20
|
+
propertyDenylist: ['some_property'], // drop specific properties from every event (HeyCatch's own attribution keys can't be denylisted)
|
|
21
|
+
beforeSend: event => event, // runs on every event right before it's queued; return null to drop it
|
|
22
|
+
persistence: 'localStorage', // where the distinct id + super properties are stored
|
|
23
|
+
disablePersistence: false, // disable persistence entirely
|
|
24
|
+
cookieExpirationDays: 365, // days before the persistence cookie expires
|
|
25
|
+
optOutCapturingByDefault: true, // start with capturing off - see below
|
|
26
|
+
respectDnt: true, // honor the browser's Do Not Track signal
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
In the browser, setting `autocapture: false`, `maskAllText: true`, or
|
|
31
|
+
`maskAllElementAttributes: true` logs a one-line console notice naming what
|
|
32
|
+
it costs you in the dashboard. (The other entries ignore these options, so
|
|
33
|
+
they have nothing to warn about - see the platform notes below.)
|
|
34
|
+
|
|
35
|
+
### Consent gate
|
|
36
|
+
|
|
37
|
+
Set `optOutCapturingByDefault: true` to capture nothing until your visitor
|
|
38
|
+
agrees (behind a cookie banner, for example), then:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
analytics.optInCapturing(); // consent granted - start capturing
|
|
42
|
+
analytics.optOutCapturing(); // consent withdrawn - stop again
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
While the gate is closed nothing is written to browser storage either, so no
|
|
46
|
+
identifier lands before consent - not just "no events sent".
|
|
47
|
+
|
|
48
|
+
Call `init()` before either one. Neither is remembered if it runs first -
|
|
49
|
+
there is no transport yet to carry the decision - and both warn on the
|
|
50
|
+
console when that happens rather than failing quietly. `init()`'s own config
|
|
51
|
+
always wins, so a call made too early can never silently flip
|
|
52
|
+
`optOutCapturingByDefault` back on.
|
|
53
|
+
|
|
54
|
+
`optInCapturing` / `optOutCapturing` exist on every entry, so shared code
|
|
55
|
+
compiles everywhere. They are a real gate in the browser and in React
|
|
56
|
+
Native. On the server they are no-ops: a server event has no ambient visitor
|
|
57
|
+
to consent for - each one already names its `userId` and only happens
|
|
58
|
+
because your code called it.
|
|
59
|
+
|
|
60
|
+
The remaining options above are browser behaviour. React Native honours
|
|
61
|
+
`optOutCapturingByDefault`; the rest describe a DOM and a browser store it
|
|
62
|
+
does not have. The server entry accepts the same `HeyCatchConfig` so one
|
|
63
|
+
object works under every import condition, and ignores them.
|
|
64
|
+
|
|
65
|
+
## Delivery options
|
|
66
|
+
|
|
67
|
+
By default the SDK batches captured events for a few seconds before sending
|
|
68
|
+
them, which is right for a single-page app. On a **multi-page site** - one
|
|
69
|
+
where each click is a full page load - a visitor can navigate away inside
|
|
70
|
+
that window, and iOS Safari in particular does not reliably let the batch out
|
|
71
|
+
as the page is torn down. The symptom is mobile pageviews missing from your
|
|
72
|
+
dashboard while desktop looks fine. Two options, both browser-only and both
|
|
73
|
+
unset by default:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
analytics.init({
|
|
77
|
+
projectKey: 'hck_pk_...',
|
|
78
|
+
requestBatching: false, // send every event as it happens - the fix for multi-page sites
|
|
79
|
+
flushIntervalMs: 250, // or keep batching but shrink the window (250-5000 ms; default 3000)
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Set one or the other - with batching off the interval has nothing to act on.
|
|
84
|
+
The cost is one request per captured event, and autocapture is on by default:
|
|
85
|
+
the count follows how much a visitor clicks, not how many pages they open, so a
|
|
86
|
+
busy page sends more requests than a quiet one. `flushIntervalMs: 250` is the
|
|
87
|
+
middle ground - still batched, but a window short enough that a navigation
|
|
88
|
+
rarely lands inside it.
|
|
89
|
+
|
|
8
90
|
## License
|
|
9
91
|
|
|
10
92
|
MIT
|