Appearance
React (Vite)
Install
sh
npx simpledatalogs init
npm install simpledatalogsinit adds the key to .env.local and two lines to src/main.jsx (or .tsx), after showing you the diff.
Or by hand
sh
# .env.local
VITE_SIMPLEDATALOGS_KEY=sdl_pub_…jsx
// src/main.jsx, after the other imports
import { init } from 'simpledatalogs'
init({ key: import.meta.env.VITE_SIMPLEDATALOGS_KEY, autocapture: true })Send everything, or only what you choose
- Everything:
autocapture: true. - Only your own events: drop it and track what matters:
js
// analytics.js
import { init } from 'simpledatalogs'
export const sdl = init({ key: import.meta.env.VITE_SIMPLEDATALOGS_KEY })jsx
sdl.track('checkout_started', { items: cart.length })In the first minute
session_startand apage_viewwithpath,title,referrerandutm_*.- A
page_viewon every React Router (or anyhistory.pushState) navigation that changes the path. - Uncaught errors and unhandled rejections on the Logs tab.
Autocapture defaults
| Feature | autocapture: true |
|---|---|
| Page views, including SPA routes | on |
| Sessions | on |
| Errors and unhandled rejections | on |
| Outbound link clicks | off |
| Do Not Track / Global Privacy Control | respected |
See the JavaScript SDK for every flag.