Skip to content

Commit 696bd22

Browse files
committed
Use posthog.register() to ensure hash is sent with every event
- Clarify the hash must be included with every event - Use register() to set as super property instead of passing via identify() - Link to super properties documentation
1 parent db632f8 commit 696bd22

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

contents/docs/cdp/transformations/secure-event-validation.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,23 @@ distinct_id_hash = generate_distinct_id_hash(distinct_id)
9393

9494
### Using the hash in the browser
9595

96-
Once you've passed the verification hash from your server to the frontend, use it when identifying users with the PostHog JavaScript SDK:
96+
Once you've passed the hash from your server to the frontend, you need to ensure it's included with **every event**. Use `posthog.register()` to set it as a [super property](/docs/libraries/js/usage#super-properties) that will automatically be sent with all subsequent events:
9797

9898
```js
9999
// These values come from your server (e.g., embedded in the page or fetched via API)
100100
const distinctId = window.__POSTHOG_DISTINCT_ID__
101101
const distinctIdHash = window.__POSTHOG_DISTINCT_ID_HASH__
102102

103-
posthog.identify(distinctId, {
103+
// Identify the user
104+
posthog.identify(distinctId)
105+
106+
// Register the hash as a super property so it's sent with every event
107+
posthog.register({
104108
$distinct_id_hash: distinctIdHash
105109
})
106110
```
107111

108-
All subsequent events captured by PostHog will include this verification hash and can be validated by the transformation.
112+
All subsequent events captured by PostHog will automatically include the `$distinct_id_hash` property and can be validated by the transformation.
109113

110114
## Rotating secrets
111115

0 commit comments

Comments
 (0)