What the SDK Does (and Doesnβt Do)
@gu1/sdk-web is the browser channel of the Gu1 SDK: it runs inside your web app and captures what your backend cannot see β device signals (canvas, WebGL, navigator properties), environment integrity, and the user journey, including everything before login. It shares the event model with the React Native SDK: the events you already send from your backend stay exactly as they are, they just carry an extra sessionId so the Gu1 engine can join both worlds.
The SDK is fail-open by design: it never blocks the page, never propagates errors (the only exception is invalid configuration at init), and does not access user data.
1. Install
The SDK ships via private npm (scope
@gu1, restricted package), so npm install returns 404 without read access to the scope. Ask Gu1 for a read-only token and configure an .npmrc in your project, passing the token via an environment variable (never commit it). The <script> (CDN) channel needs no token..npmrc to your project:
<script> (IIFE build β exposes window.Gu1Sdk). Load it from the Gu1 CDN with the version pinned and the SRI hash (each release publishes its own v<version> URL):
Content Security Policy: if the page enforces a CSP, allow
connect-src https://api.<tenant>.gu1.ai (the SDK sends events and reads /sdk/config) and β only for the <script> channel β script-src https://cdn.gu1.ai.2. Initialize
With a bundler (ESM):<script> (IIFE), the SDK is available on window.Gu1Sdk:
sessionId, collects device signals (canvas, WebGL, navigator) and environment integrity, and ships them in the background. Nothing else is required on the page for signal capture.
3. The sessionId Towards Your Backend (1 Header)
To link your backend events to the device session, attach thesessionId as a header on the web appβs calls to your own backend:
- First authenticated request: send Gu1 an event with the
sessionId+ the userβsentityExternalId. Gu1 retroactively binds the whole session, including everything before login. - Existing events: add the optional camelCase
sessionIdfield to the events you already send toPOST /events/userβ events without it keep working unchanged.
4. Transactions (1 Line)
On the transactions you send to Gu1, thesessionId travels in metadata:
5. Verify
- Load the page in sandbox β the session appears in your Gu1 dashboard with device signals.
- Log in β the session gets bound to the user (retroactive binding).
- Run a test transaction β the transaction shows session context in its evaluation.
Integration Summary
Any new signals Gu1 enables in the future are switched on through remote configuration β no web app redeploys, no coordination required.