Reference

@invisitdev/web reference

.mdllms.txt

Every function and type in @invisitdev/web, the browser tracker as a typed ES module, with signatures, return values and behavior.

@invisitdev/web
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

@invisitdev/web
function init(options: InitOptions): Tracker | undefined

Starts 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 window or document;
  • 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.webdriver is true, unless debug is on;
  • without a site.

If the script tag already started invisit on the page, init() reuses that tracker and ignores its own options.

track

@invisitdev/web
function track(name: string, properties?: Properties, options?: { actionId?: string }): void

Records a custom event. See Custom events for naming rules and limits.

identify

@invisitdev/web
function identify(externalUserId: string): void

Links the visitor to your own user id, up to 128 characters, stored hashed. See Identifying users.

@invisitdev/web
function consent(state: 'granted' | 'denied' | 'unknown'): void

Records 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

@invisitdev/web
function feedback(): void

Opens the feedback widget, when the site has it enabled in the dashboard.

sendFeedback

@invisitdev/web
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

@invisitdev/web
function flush(): void

Sends 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

src/analytics.ts
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.