@heycatch/sdk 0.8.2-dev.1657 → 0.8.3-dev.2140

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
@@ -18,7 +45,7 @@ analytics.init({
18
45
  maskAllText: true, // strip captured elements' text content
19
46
  maskAllElementAttributes: true, // strip captured elements' attributes
20
47
  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
48
+ beforeSend: event => event, // runs on every event right before it's queued; return null to drop it (the SDK's own delivery and attribution keys are put back after it)
22
49
  persistence: 'localStorage', // where the distinct id + super properties are stored
23
50
  disablePersistence: false, // disable persistence entirely
24
51
  cookieExpirationDays: 365, // days before the persistence cookie expires