Feature readiness
SDK lifecycle — when features are ready, how calls queue, and how to wait for full initialisation.
Every SDK method is safe to call at any time after vt.init(). The SDK queues calls internally and applies them in order when each feature is ready. No timing hacks needed.
#SDK initialised
The sdk:initialized event fires after DOM boot, feature start, and the initial config load. This is the single lifecycle hook for "SDK is fully wired".
import { vt } from '@v-tilt/browser'
vt.init('YOUR_PROJECT_TOKEN', { api_host: 'https://www.vtilt.com' })
// Features are constructed during init(). sdk:initialized fires after boot + start.
vt.on('sdk:initialized', () => {
console.log('SDK ready — features started')
})#Early calls are safe
Feature methods like vt.openChat() and vt.showChat() queue internally before the feature is ready. They flush automatically in call order — no promises or await needed.
import { vt } from '@v-tilt/browser'
vt.init('YOUR_PROJECT_TOKEN', {
api_host: 'https://www.vtilt.com',
chat: { enabled: true, bubble: { visible: false } },
})
// Safe immediately after init — calls queue until the feature is ready.
vt.showChat()
vt.hideChat()
vt.openChat()#How it works
Several internal layers queue work so public API calls never get lost:
- Boot gate — queues calls made before
DOMContentLoaded. - Feature deferral — queues calls until async initialisation completes (e.g. chat settings fetched).
- Lazy load — queues calls until the external script loads.
- Remote config + ingest —
vt.capture()events buffer for HTTP until__remote_config_loaded(see Event tracking). Google Tag uses the same flag before installinggtag, with a capped pre-commit queue only; after that,dataLayerorders calls untilgtag.jsis ready.
Implementation details live in the repository under docs/patterns/tracker-feature-lifecycle.md.