Docs

Advanced Setup

How the script-tag stub buffers calls before the SDK has loaded

Last updated:

The script tag in Setup installs a tiny stub on window.SessionSight that buffers calls, asynchronously loads the real bundle, and replays the buffered calls (including your init) once it’s ready.

You can call methods on window.SessionSight immediately, before the bundle finishes downloading.

Return values pre-load

While the bundle is loading, any call made through the stub returns a Promise that resolves once the SDK replays the queue.

For example, goals.increment(...) returns Promise<GoalResult> if the page is still fetching the bundle. Once the bundle has loaded, window.SessionSight is replaced with the real SDK and calls return synchronously again.

Code that ignores the return value (the common case) works either way.

Property reads pre-load

Only method calls are supported while the bundle is loading. Reading a property (like a future SessionSight.ready) returns a proxy, not a real value.

If you need to gate work on SDK availability, use .then() on any proxy method call, or defer that code until after the bundle has loaded.

Build outputs

The npm package ships three artifacts:

FileFormatUse
dist/index.jsES moduleimport SessionSight from '@sessionsight/insights'
dist/index.d.tsTypeScript declarationsEditor type support
dist/sessionsight.jsIIFE (minified)<script> tag, exposes window.SessionSight