Skip to main content
The SDK has two event mechanisms: a DOM event on window for readiness, and an internal emitter for everything after that.

Window event: cbh:ready

Dispatched on window once, after initialisation. A CustomEvent whose detail.sdk is the SDK instance.
Because it fires once, a listener added after initialisation never receives it. Check window.CashbackHive?.initialized first. See Lifecycle.

Emitter methods

on()

Subscribe to an event. Returns an unsubscribe function, which is convenient in frameworks with effect cleanup:
Handlers that throw are caught and logged with console.error; they don’t affect other handlers or the SDK.

off()

Unsubscribe a specific handler. Equivalent to calling the function returned by on().

Emitter events

ready

Emitted synchronously inside init(), immediately after initialisation completes.
string
The SDK version.
Because it’s emitted during init(), you can only observe it if you registered a handler before initialisation — which is only possible with manual initialisation. For auto-initialised installs, use the cbh:ready window event instead.

click

Emitted by openOffer() before the URL is opened. Not emitted by trackingUrl().
string
The offer’s slug.
string
The fully built tracked URL that will be opened.

auth:change

Emitted whenever the cached member changes identity: a member signs in, signs out, or a token restored from storage resolves to a member on load. It is not emitted when the same member’s profile is refreshed (same id).
Member | null
The new member, or null after sign-out.
Triggers for auth:change:

Type map