With the package
revenue.amount is an integer in the currency’s smallest unit: 4999 is $49.99. Event names are stored exactly as written, so Purchase and purchase are two events. A call made before the tracker has loaded waits for it, and no call ever throws.
Typed events
A few names are built in, with typed properties:signup, login, purchase, subscription_started, trial_started, file_download, outbound_link_click and 404. Declare your own in any file your compiler sees. With strict: true, a misspelt name is a type error.
src/analytics.d.ts
`view_${string}`, covers every name it matches, so a name built at run time still compiles under strict: true. A call such as track(`view_${slug}`, { variant: "b" }) checks its properties against the declaration. The declarations are types only and add nothing to your bundle.
Typed tracked links
A link component that tracks a click can keep each event name paired with its properties.EventName lists every name track() knows, and TrackArgs gives the properties a name takes:
components/tracked-link.tsx
Without the package
On a site with the plain script tag, tag the element in HTML. A click on a link or a button sends the event, and a form sends it on submit. Eachdata-highseat-prop-* attribute becomes a property.
window.highseat.track("signup", { plan: "pro" }) once the tracker has loaded.
Check your calls
In development, the package logs everytrack() and identify() call to the browser console, with its properties. It also warns once per page when nothing can reach Highseat: the page has no tracker script, or the script failed to load, as one an ad blocker stopped does. Logging is on when process.env.NODE_ENV is development. Pass debug to <Highseat /> to turn it on in a production build, or debug={false} to turn it off.