0.0.3 • Published 2 years ago
@rosnik/browser-sdk v0.0.3
browser-sdk
ROSNIK Browser SDK
Getting Started
Install
npm add @rosnik/browser-sdkConfiguration
Then in your application code:
import { Rosnik } from "@rosnik/browser-sdk"
Rosnik.init({
apiKey: 'api-key',
allowedDomains: ["api.example.com"]
})We'll send Journey IDs to the domains allowed.
This allows you to connect events across the frontend and backend.
Alternatively, you can send these headers yourself by not setting
allowedDomains, in which case we won't patch fetch.
To set active user context:
Rosnik.setUser("user-id")Tracking Events
You can track the following events:
- User interactions, e.g. "edit text"
Rosnik.trackUserTextEdit({before: string, after: string })- Explicit user feedback
Rosnik.trackUserFeedback({ score: number, openFeedback: string });- Goal completion
Rosnik.trackUserGoal({goalName: string})Compatibility notes
We patch fetch using fetch-intercept so there are
some browsers where we won't automatically send headers
to the AI service: https://caniuse.com/?search=fetch