tracker.setDebug()
Runtime toggle for the SDK’s debug mode. Most-recent-call wins — overrides both the debug config passed to createBrowserTracker and any ?tb_debug=1 URL override applied at init.
Signature
Section titled “Signature”tracker.setDebug(enabled: boolean): void;Behavior
Section titled “Behavior”When debug is on, the SDK logs:
- gtag exceptions on conversion / event / page-view fires.
- “no-op because
ga4MeasurementIdis unset” messages fromidentifyUser,clearUser,trackPageView. - Dedup no-ops from
trackPageView(consecutive identical paths). - Other diagnostic warnings.
The auto-transactionId warning on trackConversion / trackPurchase / trackRefund fires regardless of debug — losing dual-send is a real failure that should always be loud.
Example
Section titled “Example”import { tracker } from '@/lib/tracker.client';
if (window.location.hostname === 'staging.example.com') { tracker.setDebug(true);}Or wire to a developer-only UI toggle:
'use client';import { tracker } from '@/lib/tracker.client';
export function DebugToggle() { return ( <label> <input type="checkbox" onChange={(e) => tracker.setDebug(e.currentTarget.checked)} /> Trackbridge debug </label> );}For a URL-driven toggle without UI, set debugUrlParam: true on createBrowserTracker to enable the built-in ?tb_debug=1 (or =0) override that runs once at init time.