# Developer Platform Overview

The Allegro SDK is a lightweight JavaScript library for event tracking, session management, and member authentication. It loads asynchronously and exposes its API on `window.allegro`.

## Installation[​](#installation "Direct link to Installation")

Add the loader script to your page:

```html
<script src="https://your-allegro-instance.com/client.js"></script>

```

For more information, see [the script tag documentation](/developer/guides/script-tag.md).

## Core Concepts[​](#core-concepts "Direct link to Core Concepts")

### Async Queue[​](#async-queue "Direct link to Async Queue")

The SDK uses an async queue pattern so you can start using it before it finishes loading:

```html
<script>
    window.allegro = window.allegro || [];

    // Queue a callback
    window.allegro.push(function (allegro) {
        allegro.track('page_view');
    });
</script>

<script src="https://your-allegro-instance.com/client.js"></script>

```

When the SDK loads, it replaces the array with the full SDK, drains the queue, and executes each callback.

### `allegro.push(callback)`[​](#allegropushcallback "Direct link to allegropushcallback")

Queue a function to run when the SDK is ready. If the SDK has already loaded, the callback executes immediately.

```js
window.allegro.push(function (allegro) {
    // SDK is ready — use allegro.track(), allegro.member, etc.
});

```

## What's Available[​](#whats-available "Direct link to What's Available")

| Namespace             | Description                                               |
| --------------------- | --------------------------------------------------------- |
| `allegro.track()`     | Track events with automatic session and device management |
| `allegro.member`      | Authenticate members, get user info and entitlements      |
| `allegro.interaction` | Trigger interaction events                                |

See the [Quick Start](/developer/getting-started/quick-start.md) guide for a complete working example, or browse the [API Reference](/developer/api-reference.md) for full type documentation.

## Session & Device Management[​](#session--device-management "Direct link to Session & Device Management")

The SDK manages two cookies automatically:

| Cookie               | Lifetime   | Purpose                                  |
| -------------------- | ---------- | ---------------------------------------- |
| `allegro_device_id`  | 10 years   | Persistent device identifier (UUID v4)   |
| `allegro_session_id` | 30 minutes | Session identifier, extended on activity |

Sessions are created automatically on the first `track()` or `member.login()` call.

## Error Handling[​](#error-handling "Direct link to Error Handling")

API errors throw an `AllegroApiError` with the HTTP status and response body:

```js
try {
    await allegro.member.login('bad@email.com', 'wrong');
} catch (error) {
    console.error(error.status); // e.g. 401
    console.error(error.body); // server response
}

```

Errors inside `push()` callbacks are caught and logged to the console — they won't break the queue or prevent other callbacks from running.
