Skip to main content
Version 2.0 gives you exact-URL initialization, bounded event queuing, explicit readiness, and complete public types. Older initialization code remains compatible. The current stable release is 2.0.8.
The command below resolves the current npm release. Review breaking changes before accepting a future major version, and update your lockfile. Version 2.0.8 waits for the browser runtime to initialize, rather than treating its bootstrap queue as ready.
For installations that stay on the compatible 2.x line, use your package manager’s update command within the saved major range. Bundled or self-hosted SDK files still require a tested rebuild and redeployment. See update behavior.

Preserve the exact tracking URL

Earlier integrations often passed only a tracking origin:
In 2.0, copy the exact URL from Bily > Settings > Apps > More settings > Install tracking:
Keep every query parameter and encoded character. Do not reduce the URL to an origin or rebuild it in code. The string overload and trackingDomain remain available for compatibility. The deprecated verbose option remains an alias for debug.

Load Bily one way

Choose one installation path for each website surface.
  • Plain HTML keeps the exact raw script tag and does not install the package.
  • JavaScript, React, and Next.js install @bilyai/js and let init() load the script. Follow a framework guide when it reserves one script element for the SDK to reuse.
In SDK-based applications, remove unmanaged script tags, manual injection helpers, and framework script components. Keep only a framework-reserved element that the SDK explicitly reuses.

Send one page view per route

The browser script records the initial page and supported client-side navigation automatically. Do not add manual PageView calls for those navigations; use track() for business events. Remove older router hooks that call track("PageView"). Verify direct loads, client navigation, and browser Back and Forward before deploying.

Let early events queue

The SDK queues track() calls made before loading finishes. Your event code does not need to await ready(). Use ready() for installation checks and diagnostics. It resolves after runtime initialization, not merely after the bootstrap loads, and is not a destination delivery receipt:
Version 2.0 bounds the queue, lets you configure the load timeout, reports script load errors, and supports retry after a terminal load failure.

Confirm payload behavior

Version 2.0 now:
  • Supports top-level products payloads.
  • Defaults an omitted product quantity to 1.
  • Preserves product image and client userGroup fields.
  • Preserves zero-valued totals, taxes, discounts, and shipping fees.
  • Calculates an order total from product price and quantity when order.total is absent.
  • Adds event_id and ts when you omit them.
  • Accepts custom event strings while retaining known-event autocomplete.
After upgrading, run representative product, cart, checkout, and order payloads through staging.

Handle a nullable tracking ID

getBilyTrackingId() returns string | null. Update code that assumed a string:
Expect null during server rendering.

Import types from the package root

Version 2.0 exports the complete public payload types:
Do not import types from internal package files.

Adopt current event names

Compatibility aliases still work. Use current names for new code: See the complete event name reference for every normalized alias.

Verify the upgrade

  1. Confirm the exact tracking URL remains unchanged in the browser.
  2. Confirm one automatic initial PageView.
  3. Confirm one automatic event for each later supported SPA route, including Back and Forward.
  4. Trigger events before loading finishes and verify their delivery order.
  5. Test script failure and stalled runtime initialization through the ready() rejection path.
  6. Test server rendering without window or document.
  7. Verify zero-valued order fields and optional product quantities.
  8. Search the browser bundle for credentials and private tokens.

Verification checklist

Confirm installation and event behavior before you update production.