import { consent, feedback, flush, identify, init, sendFeedback, track } from '@invisitdev/web'Every function except init() forwards to the running tracker. Calls made before init() are queued and applied once it starts. On the server every function is a silent no-op.
init
function init(options: InitOptions): Tracker | undefinedStarts the tracker once per page and returns it. Calling it again returns the same tracker, and warns when debug is on. The options are listed in Install with npm.
It returns undefined:
- on the server, with no
windowordocument; - while a site owner has the heatmap overlay open;
- for a browser that opted out with
#invisit-ignore; - in a browser driven by automation, such as Playwright, Puppeteer or Selenium, where
navigator.webdriveris true, unlessdebugis on; - without a
site.
If the script tag already started invisit on the page, init() reuses that tracker and ignores its own options.
track
function track(name: string, properties?: Properties, options?: { actionId?: string }): voidRecords a custom event. See Custom events for naming rules and limits.
identify
function identify(externalUserId: string): voidLinks the visitor to your own user id, up to 128 characters, stored hashed. See Identifying users.
consent
function consent(state: 'granted' | 'denied' | 'unknown'): voidRecords the visitor’s consent answer. 'denied' stops all collection; with requireConsent: true, nothing is sent until 'granted'; 'unknown' forgets the answer. Remembered on the device unless storage: 'none'.
feedback
function feedback(): voidOpens the feedback widget, when the site has it enabled in the dashboard.
sendFeedback
function sendFeedback(input: { message: string; email?: string }): Promise<boolean>Sends one message from your own feedback form. Resolves to true once the collector accepted it, and to false when there is no running tracker.
flush
function flush(): voidSends queued events now instead of with the next batch. Useful right before a hard navigation you control.
Tracker
The object init() returns has every function above, plus:
| Member | What it does |
|---|---|
conversion(name, properties?) |
Records a conversion, reported apart from ordinary events. |
pageview() |
Records a page view now. Only needed for navigation the tracker cannot see. |
stop() |
Stops the tracker and removes its listeners. |
version |
The tracker version. |
Types
import type {
ConsentState,
FeedbackMessage,
InitOptions,
Properties,
Tracker,
} from '@invisitdev/web'Source
The package is MIT-licensed and published in full, built with signed npm provenance from the commit it names.