> For the complete documentation index, see [llms.txt](https://wiki.playgama.com/playgama/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.playgama.com/playgama/bridge-sdk/migration-v1-to-v2.md).

# Migration v1 → v2

Bridge v2 is a TypeScript rewrite. The entry point is the same (`window.bridge`, `await bridge.initialize(options)`). Below is only what changed in the public API, one section per affected module. Modules not listed here are unchanged.

## Game (removed)

The `bridge.game` module is gone, its members were redistributed:

| v1                                 | v2                                                                |
| ---------------------------------- | ----------------------------------------------------------------- |
| `game.setLoadingProgress(percent)` | `bridge.setGameLoadingProgress(percent)`                          |
| `game.visibilityState`             | `platform.isPaused`, `platform.isAudioEnabled`                    |
| `VISIBILITY_STATE_CHANGED` event   | `PAUSE_STATE_CHANGED`, `AUDIO_STATE_CHANGED` on `bridge.platform` |

```javascript
// v1
bridge.game.setLoadingProgress(100)
bridge.game.on(bridge.EVENT_NAME.VISIBILITY_STATE_CHANGED, (state) => {})

// v2
bridge.setGameLoadingProgress(100)
bridge.platform.on(bridge.EVENT_NAME.PAUSE_STATE_CHANGED, (isPaused) => {})
bridge.platform.on(bridge.EVENT_NAME.AUDIO_STATE_CHANGED, (isEnabled) => {})
```

## Platform

* Removed `getAllGames()`, `getGameById(options)`, `isGetAllGamesSupported`, `isGetGameByIdSupported` — the platform games catalog is now served by the new [Cross-Promo](/playgama/bridge-sdk/api/cross-promo.md) module.
* Added the `isExternalCallsSupported` getter.
* Added the `isExternalLinksAllowed` getter — moved here from the Social module.

## Player

* Added the `isGuest` getter — `true` when the player is unauthorized or running as a guest.

## Storage (breaking)

The storage-type concept is removed; v2 chooses cloud vs local storage automatically.

| v1                                                                     | v2                              |
| ---------------------------------------------------------------------- | ------------------------------- |
| `get(key, storageType, tryParseJson)`                                  | `get(key, tryParseJson = true)` |
| `set(key, value, storageType)`                                         | `set(key, value)`               |
| `delete(key, storageType)`                                             | `delete(key)`                   |
| `isSupported()`, `isAvailable()`, `defaultType`, `bridge.STORAGE_TYPE` | removed                         |

```javascript
// v1
bridge.storage.get('level', bridge.STORAGE_TYPE.LOCAL_STORAGE)
bridge.storage.set('level', 5, bridge.STORAGE_TYPE.PLATFORM_INTERNAL)

// v2
bridge.storage.get('level')
bridge.storage.set('level', 5)
```

{% hint style="warning" %}
The 2nd argument of `get()` is now `tryParseJson`, not a storage type. Calls like `get('key', someType)` will silently reinterpret that value — audit them.
{% endhint %}

## Leaderboards

* Removed the `bridge.leaderboard` (singular) alias — use `bridge.leaderboards`.

## Achievements (breaking)

| v1                                                                                 | v2                                                                                        |
| ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `unlock(options)`                                                                  | `unlock(id)` — a flat game-level id; per-platform ids live in the config file             |
| `getList(options)`                                                                 | `getAchievements()` — no arguments; resolves to `{ id, name?, description?, unlocked }[]` |
| `showNativePopup()`, `isSupported`, `isGetListSupported`, `isNativePopupSupported` | removed                                                                                   |

Achievements now work on every platform, so there is no support flag to check. Where the platform supports them natively the call is forwarded to the platform SDK; everywhere else the SDK tracks them locally and persists the unlocked state through storage (cloud when available, otherwise local) — the same approach as [Daily Rewards](/playgama/bridge-sdk/api/daily-rewards.md). In the local case `getAchievements()` returns the achievements declared in the config with their locally tracked `unlocked` flag, or an empty array when none are configured.

```javascript
// v1
bridge.achievements.unlock({ yandex: { id: 'level_10' } })

// v2
bridge.achievements.unlock('level_10')
await bridge.achievements.getAchievements() // [{ id, name?, description?, unlocked }]
```

See the [Achievements](/playgama/bridge-sdk/api/achievements.md) page for configuration details.

## Remote Config (breaking)

* `get(options)` → `get()` — no arguments.
* Added `setContext(parameters)` to pass segmentation parameters ahead of time.

```javascript
// v1
let options = { }

switch (bridge.platform.id) {
    case 'yandex':
        options = {
            clientFeatures: [ // optional parameter
                { name: 'segment', value: 'whales' }
            ]
        }
        break
}

bridge.remoteConfig.get(options)

// v2
bridge.remoteConfig.setContext({ segment: 'whales' })
const cfg = await bridge.remoteConfig.get()
```

## Cross-Promo (new)

Cross-promotion module: a "more games" modal and a normalized games-list API. Replaces the removed platform games catalog (`getAllGames()` / `getGameById()`).

```javascript
bridge.crossPromo.isVisible                    // boolean — is the promo modal open

await bridge.crossPromo.getGames()             // Promise<Game[]> — full normalized list
await bridge.crossPromo.show()                 // shows a promo modal with random games
bridge.crossPromo.hide()                       // closes the modal
```

See the [Cross-Promo](/playgama/bridge-sdk/api/cross-promo.md) page for details and configuration.

## Social (breaking)

* The `isExternalLinksAllowed` getter moved to `bridge.platform`.
* Options are no longer keyed by platform. v1 took a nested object and recursed into `options[bridge.platform.id]`; v2 takes a flat object of canonical, platform-agnostic fields — `text`, `image`, `url` — that each bridge maps to its native one (VK `url` → `link`, Discord `image` → `mediaUrl`, and so on). `image` accepts a base64 data-URI or a URL; the bridge converts as needed. Any other key is forwarded verbatim to the platform SDK, so raw platform-specific fields still work.
* Per-platform content can now live in the config file: shared values go in the top-level `social[method]` block, platform overrides in `platforms[id].social[method]`; the loader deep-merges them, and call-time options win on top.

```javascript
// v1 — options nested per platform
bridge.social.share({
    vk: { url: 'https://my.game', image: 'https://my.game/cover.png' },
    ok: { url: 'https://my.game' },
})

// v2 — flat canonical fields
bridge.social.share({ url: 'https://my.game', image: 'https://my.game/cover.png' })
```

See the [Social](/playgama/bridge-sdk/api/social.md) page for details and configuration.

## Tasks (new)

Task / quest module. The game declares task groups (daily, weekly, or permanent) in the config, reports gameplay through `addProgress()`, and claims rewards once a task is complete. Progress is persisted through storage and roll-over uses platform server time.

```javascript
await bridge.tasks.getTasks()                  // Task[] — every active task, with live progress
await bridge.tasks.addProgress(metric, amount) // updates progress (amount defaults to 1)
await bridge.tasks.claimReward(taskId)         // true if claimed, false otherwise
```

See the [Tasks](/playgama/bridge-sdk/api/tasks.md) page for the data model and configuration.

## Daily Rewards (new)

Login-streak rewards persisted through storage and platform server time.

```javascript
await bridge.dailyRewards.getRewards()         // string[] — ordered reward ids
await bridge.dailyRewards.getCurrentDay()      // number — 0-based
await bridge.dailyRewards.getCurrentReward()   // string | null
await bridge.dailyRewards.claimCurrentReward() // boolean
```

See the [Daily Rewards](/playgama/bridge-sdk/api/daily-rewards.md) page for details and configuration.

## Constants

| Constant           | Change                                                                                                                                                                                                            |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `PLATFORM_ID`      | removed `ABSOLUTE_GAMES`, `BITQUEST`                                                                                                                                                                              |
| `MODULE_NAME`      | removed `GAME`, `RECORDER`; added `DAILY_REWARDS`, `TASKS`, `CROSS_PROMO`                                                                                                                                         |
| `EVENT_NAME`       | removed `VISIBILITY_STATE_CHANGED`; added `PLATFORM_STORAGE_AVAILABILITY_CHANGED`                                                                                                                                 |
| `STORAGE_TYPE`     | removed entirely                                                                                                                                                                                                  |
| `VISIBILITY_STATE` | no longer exposed on `bridge`                                                                                                                                                                                     |
| `ERROR`            | `ERROR.X.message` still works; v2 adds `ERROR_CODE`, a `BridgeError` class, and a `code` on each entry. New codes: `INITIALIZATION_FAILED`, `CONFIG_LOAD_FAILED`, `CONFIG_PARSE_FAILED`, `STORAGE_QUOTA_EXCEEDED` |
