Docs/Reference
.md

API reference

Three functions. None of them throw, and calls before init are ignored.

init(appKey, options?)#

Starts the SDK. Call it once, on the client, at app startup. An invalid key logs one warning, and every later call does nothing.

OptionTypeDefault
hoststringhttps://api.shipabase.devAPI host (proxies)
appVersionstring""Your app version, for version breakdowns
isDebugbooleanautotrue on localhost / 127.0.0.1 or when NODE_ENV is development. Debug events are hidden unless you turn on the debug toggle
flushIntervalnumber5000Milliseconds between batch sends
pageviewsbooleantrueBrowser: send page_viewed on load and on every route change. See Page views

trackEvent(eventName, props?)#

  • eventName: 1–64 characters from [A-Za-z0-9_.:-].
  • props: at most 20 keys of 40 characters. Values: string (≤ 200), finite number or boolean.
  • Never throws. Calls made before init are ignored.
example
trackEvent("invoice_sent", { plan: "pro", count: 3 });

trackPageview(path?)#

Records a page or screen view (page_viewed). In the browser it happens automatically; call it yourself with hash routers or in React Native. Without a path, the current page is used.

example
trackPageview("/settings");

flush(): Promise<void>#

Sends queued events now. It resolves even when the network fails. Useful in short-lived Node processes, before exit.

Delivery#

  • Events are sent in batches of up to 25 (and about 20 KB): every flushInterval, and right away when 25 events are queued.
  • When the tab is hidden or closed, the queue is sent with navigator.sendBeacon.
  • On a network error or a 5xx, the batch is retried once.
  • The queue holds at most 100 events; the oldest are dropped first.