Skip to main content
Use ready() when you need to confirm that Bily loaded. Normal event tracking does not wait for it because track() queues early calls.

Check readiness

function ready(): Promise<void>;

Verify the installation

In the browser, call init() before awaiting ready().
import { init, ready } from "@bilyai/js";

init({
  scriptUrl: "https://tracking.example.com/b.js?shop=store.example.com",
  loadTimeoutMs: 15_000,
});

try {
  await ready();
  console.info("Bily is ready");
} catch (error) {
  console.error("Bily failed to load", error);
}

Know when it resolves

The promise resolves when Bily can accept queued events. During server rendering, it resolves immediately because there is no browser script to load.

Handle a rejection

The promise rejects when:
  • The browser reports a script load error.
  • Bily does not become ready before loadTimeoutMs.
  • The script loads but does not expose a usable Bily browser API.
The default timeout is 15 seconds. Set a value from 1 to 60 seconds through init().

Retry one failed load

After a terminal load failure, call init() again. Then call ready() for the new attempt.
async function loadBily() {
  const options = {
    scriptUrl: "https://tracking.example.com/b.js?shop=store.example.com",
  } as const;

  init(options);

  try {
    await ready();
  } catch {
    init(options);
    await ready();
  }
}
If production keeps failing, check the URL, network policy, and duplicate installation. Do not retry indefinitely.

Troubleshooting

Resolve timeouts, script errors, and conflicting configuration.