Interface: AllegroSDK
Defined in: types.ts:135
The top-level Allegro SDK instance, available as window.allegro.
Example
window.allegro.push((allegro) => {
console.log(allegro.member.isAuthenticated());
});
Methods
debug()?
optionaldebug():void
Defined in: types.ts:225
Enable SDK debug mode from the console: window.allegro.debug()
Returns
void
push()
push(
callback):void
Defined in: types.ts:153
Enqueue a callback to run once the SDK is ready.
If the SDK has already initialised, the callback is invoked synchronously.
This mirrors the window.allegro.push(fn) usage pattern.
Parameters
| Parameter | Type | Description |
|---|---|---|
callback | AllegroCallback | Function that receives the fully initialised SDK instance. |
Returns
void
Example
window.allegro.push((allegro) => {
if (allegro.member.isAuthenticated()) {
console.log('Logged in!');
}
});
renderComponentsIn()
renderComponentsIn(
root):void
Defined in: types.ts:238
Render all registered Allegro components found within the given root. Use this to render components inside a shadow DOM or other non-document root.
Parameters
| Parameter | Type |
|---|---|
root | Element | Document | ShadowRoot |
Returns
void
Example
window.allegro.push((allegro) => {
allegro.renderComponentsIn(myShadowRoot);
});
track()
track(
eventName,data?):Promise<TrackResponse>
Defined in: types.ts:174
Track a named event with optional metadata.
Page context (URL, title, referer) is collected automatically.
Pass additional fields via data to enrich the event.
Parameters
| Parameter | Type | Description |
|---|---|---|
eventName | string | Descriptive snake_case event name, e.g. "article_read". |
data? | TrackEventData | Optional event metadata. |
Returns
Promise<TrackResponse>
Resolves with the recorded event ID.
Example
await allegro.track('article_read', {
content_id: '12345',
content_type: 'article',
publisher: 'newsroom',
});
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
components | Record<string, typeof HTMLElement> | Registered custom web components. Empty until the components bundle has loaded. | types.ts:219 |
forms | FormsNamespace | Form fetching and submission methods. | types.ts:213 |
http | HttpClient | HTTP client pre-configured with the session JWT and base URL. Use this to make authenticated API calls to the Allegro backend from outside the SDK, the same way internal modules do. Example window.allegro.push(async (allegro) => { const data = await allegro.http.get('/api/some-endpoint'); }); | types.ts:189 |
interaction | InteractionNamespace | Interaction trigger and management methods. | types.ts:195 |
magicLinkValidation? | "authenticated" | "failed" | null | The result of magic link token validation, if one was attempted on this page load. Set synchronously before the corresponding window event is dispatched, so components that load after the event fires can still read the outcome. | types.ts:246 |
member | MemberNamespace | Member authentication and identity methods. | types.ts:192 |
meters | MetersNamespace | Meter usage from the most recent interaction evaluation. Example window.allegro.push((allegro) => { console.log(allegro.meters.get('monthly-articles')?.remaining); }); | types.ts:207 |
purchase | PurchaseNamespace | Purchase initiation and token exchange methods. | types.ts:210 |
recommendations | RecommendationsNamespace | Ranked recommendations and click reporting. | types.ts:216 |
socialLoginError? | string | null | Why the redirect-based social login on this page load failed, e.g. "auth_cancelled", "no_email", "auth_failed" or "exchange_failed". Set alongside socialLoginValidation = 'failed'. | types.ts:261 |
socialLoginValidation? | "authenticated" | "failed" | "pending" | null | The result of exchanging a redirect-based social login's ?allegro_social_code=, or of an ?allegro_social_error= return, if one happened on this page load. Set synchronously before the corresponding window event is dispatched, so components that load after the event fires can still read the outcome. | types.ts:255 |
tenant | TenantConfig | Tenant-specific configuration (login providers, cookie domain, etc.). | types.ts:222 |