# Interface: AllegroSDK

Defined in: [types.ts:77](https://github.com/alleyinteractive/allegro/blob/6aebbf1d5d34ded3d128c093d7d30abd96d938be/packages/allegro-platform/resources/js/sdk/types.ts#L77)

The top-level Allegro SDK instance, available as `window.allegro`.

## Example[​](#example "Direct link to Example")

```ts
window.allegro.push((allegro) => {
  console.log(allegro.member.isAuthenticated());
});

```

## Methods[​](#methods "Direct link to Methods")

### debug()?[​](#debug "Direct link to debug()?")

> `optional` **debug**(): `void`

Defined in: [types.ts:149](https://github.com/alleyinteractive/allegro/blob/6aebbf1d5d34ded3d128c093d7d30abd96d938be/packages/allegro-platform/resources/js/sdk/types.ts#L149)

Enable SDK debug mode from the console: `window.allegro.debug()`

#### Returns[​](#returns "Direct link to Returns")

`void`

***

### push()[​](#push "Direct link to push()")

> **push**(`callback`): `void`

Defined in: [types.ts:95](https://github.com/alleyinteractive/allegro/blob/6aebbf1d5d34ded3d128c093d7d30abd96d938be/packages/allegro-platform/resources/js/sdk/types.ts#L95)

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[​](#parameters "Direct link to Parameters")

| Parameter  | Type                                                                          | Description                                                |
| ---------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------- |
| `callback` | [`AllegroCallback`](/developer/api-reference/type-aliases/AllegroCallback.md) | Function that receives the fully initialised SDK instance. |

#### Returns[​](#returns-1 "Direct link to Returns")

`void`

#### Example[​](#example-1 "Direct link to Example")

```ts
window.allegro.push((allegro) => {
  if (allegro.member.isAuthenticated()) {
    console.log('Logged in!');
  }
});

```

***

### renderComponentsIn()[​](#rendercomponentsin "Direct link to renderComponentsIn()")

> **renderComponentsIn**(`root`): `void`

Defined in: [types.ts:162](https://github.com/alleyinteractive/allegro/blob/6aebbf1d5d34ded3d128c093d7d30abd96d938be/packages/allegro-platform/resources/js/sdk/types.ts#L162)

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[​](#parameters-1 "Direct link to Parameters")

| Parameter | Type                                    |
| --------- | --------------------------------------- |
| `root`    | `Element` \| `Document` \| `ShadowRoot` |

#### Returns[​](#returns-2 "Direct link to Returns")

`void`

#### Example[​](#example-2 "Direct link to Example")

```ts
window.allegro.push((allegro) => {
  allegro.renderComponentsIn(myShadowRoot);
});

```

***

### track()[​](#track "Direct link to track()")

> **track**(`eventName`, `data?`): `Promise`<[`TrackResponse`](/developer/api-reference/interfaces/TrackResponse.md)>

Defined in: [types.ts:116](https://github.com/alleyinteractive/allegro/blob/6aebbf1d5d34ded3d128c093d7d30abd96d938be/packages/allegro-platform/resources/js/sdk/types.ts#L116)

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[​](#parameters-2 "Direct link to Parameters")

| Parameter   | Type                                                                      | Description                                                |
| ----------- | ------------------------------------------------------------------------- | ---------------------------------------------------------- |
| `eventName` | `string`                                                                  | Descriptive snake\_case event name, e.g. `"article_read"`. |
| `data?`     | [`TrackEventData`](/developer/api-reference/interfaces/TrackEventData.md) | Optional event metadata.                                   |

#### Returns[​](#returns-3 "Direct link to Returns")

`Promise`<[`TrackResponse`](/developer/api-reference/interfaces/TrackResponse.md)>

Resolves with the recorded event ID.

#### Example[​](#example-3 "Direct link to Example")

```ts
await allegro.track('article_read', {
  content_id: '12345',
  content_type: 'article',
  publisher: 'newsroom',
});

```

## Properties[​](#properties "Direct link to Properties")

| Property                   | Type                                                                                  | Description                                                                                                                                                                                                                                                                                                 | Defined in                                                                                                                                                         |
| -------------------------- | ------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| []()`components`           | `Record`<`string`, *typeof* `HTMLElement`>                                            | Registered custom web components.                                                                                                                                                                                                                                                                           | [types.ts:143](https://github.com/alleyinteractive/allegro/blob/6aebbf1d5d34ded3d128c093d7d30abd96d938be/packages/allegro-platform/resources/js/sdk/types.ts#L143) |
| []()`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:131](https://github.com/alleyinteractive/allegro/blob/6aebbf1d5d34ded3d128c093d7d30abd96d938be/packages/allegro-platform/resources/js/sdk/types.ts#L131) |
| []()`interaction`          | [`InteractionNamespace`](/developer/api-reference/interfaces/InteractionNamespace.md) | Interaction trigger and management methods.                                                                                                                                                                                                                                                                 | [types.ts:137](https://github.com/alleyinteractive/allegro/blob/6aebbf1d5d34ded3d128c093d7d30abd96d938be/packages/allegro-platform/resources/js/sdk/types.ts#L137) |
| []()`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:170](https://github.com/alleyinteractive/allegro/blob/6aebbf1d5d34ded3d128c093d7d30abd96d938be/packages/allegro-platform/resources/js/sdk/types.ts#L170) |
| []()`member`               | [`MemberNamespace`](/developer/api-reference/interfaces/MemberNamespace.md)           | Member authentication and identity methods.                                                                                                                                                                                                                                                                 | [types.ts:134](https://github.com/alleyinteractive/allegro/blob/6aebbf1d5d34ded3d128c093d7d30abd96d938be/packages/allegro-platform/resources/js/sdk/types.ts#L134) |
| []()`purchase`             | [`PurchaseNamespace`](/developer/api-reference/interfaces/PurchaseNamespace.md)       | Purchase initiation and token exchange methods.                                                                                                                                                                                                                                                             | [types.ts:140](https://github.com/alleyinteractive/allegro/blob/6aebbf1d5d34ded3d128c093d7d30abd96d938be/packages/allegro-platform/resources/js/sdk/types.ts#L140) |
| []()`tenant`               | [`TenantConfig`](/developer/api-reference/interfaces/TenantConfig.md)                 | Tenant-specific configuration (login providers, cookie domain, etc.).                                                                                                                                                                                                                                       | [types.ts:146](https://github.com/alleyinteractive/allegro/blob/6aebbf1d5d34ded3d128c093d7d30abd96d938be/packages/allegro-platform/resources/js/sdk/types.ts#L146) |
