@heycatch/sdk 0.8.3 → 0.8.4-dev.2561

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 CHANGED
@@ -5,6 +5,33 @@ 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
+ ## Sign-in and sign-out
9
+
10
+ Call `setIdentity` right after sign-in and `resetIdentity` on sign-out:
11
+
12
+ ```ts
13
+ // After sign-in. A stable internal user id - never an email or a session
14
+ // token. Email and name, if you send them, go in the properties.
15
+ analytics.setIdentity(user.id, { email: user.email, name: user.name });
16
+
17
+ analytics.resetIdentity(); // on sign-out, so the next person starts anonymous
18
+ ```
19
+
20
+ Skip `resetIdentity` and the device keeps the signed-out user's identity.
21
+ Everything the next person does before signing in is recorded as the
22
+ previous user. On a shared device - a work tablet, a kiosk, a family
23
+ computer - whoever uses it without signing in lands in the last signed-in
24
+ user's profile, which then describes several people. HeyCatch's per-user summaries and recommendations are written from
25
+ those profiles, so they end up describing someone who does not exist.
26
+
27
+ `setIdentity` with a different user than the one already signed in resets
28
+ on its own, so a direct account switch is safe. What it cannot know is that
29
+ someone signed out and left: only your sign-out handler knows that.
30
+
31
+ `resetIdentity` works in the browser and in React Native. On the server it
32
+ is a no-op, so isomorphic sign-out code still resolves there - but the call
33
+ has to run on the device to take effect.
34
+
8
35
  ## Privacy & consent options
9
36
 
10
37
  `init()` accepts optional privacy/consent options alongside `projectKey`. Every
@@ -59,6 +86,14 @@ analytics.optOutCapturing(); // consent withdrawn - stop again
59
86
  While the gate is closed nothing is written to browser storage either, so no
60
87
  identifier lands before consent - not just "no events sent".
61
88
 
89
+ A visitor who arrives through one of your HeyCatch short links lands on a URL
90
+ carrying `?utm_source=heycatch&utm_campaign=<letter>`. The SDK removes those
91
+ from the address bar a second after the first capture has read them - and
92
+ behind the gate, that first capture is the one `optInCapturing()` makes, so
93
+ the URL stays as it is until then and the visit is still attributed after
94
+ consent. Your own UTM links (any `utm_source` other than `heycatch`) are never
95
+ touched.
96
+
62
97
  Call `init()` before either one. Neither is remembered if it runs first -
63
98
  there is no transport yet to carry the decision - and both warn on the
64
99
  console when that happens rather than failing quietly. `init()`'s own config