Loot Airdrops Module
The Loot Airdrops module provides functionality for interacting with the Gamanza Engage Loot Airdrops system. It allows developers to list active airdrops, history, pending claims, prize pools, player wins, and winners, as well as opt players into airdrops and claim rewards.
Accessing the Module
The Loot Airdrops module is accessible through the Gamanza Engage Web Client SDK:
const sdk = GamanzaEngageWebClientSDK.getInstance();
const lootAirdrops = sdk.LootAirdrops;
Methods
getPlayerActiveAirdrops
Returns the active/scheduled airdrops visible to the authenticated player, including isPlayerEligible and localized error messages when the player is not eligible.
Signature:
getPlayerActiveAirdrops(): Promise<AirdropType[]>
Returns
| Type | Description |
|---|---|
Promise<AirdropType[]> | A promise that resolves to an array of visible airdrops |
Example
const activeAirdrops = await sdk.LootAirdrops.getPlayerActiveAirdrops();
Related Events
EVENTS.LOOT_AIRDROPS.ON_STATE_UPDATE— Airdrop lifecycle status changed (scheduled → active → ended / cancelled)EVENTS.LOOT_AIRDROPS.ON_PLAYER_ASSIGNED— Player newly assigned; SDK runs a single-flight fetch-and-overwrite refresh. Widgets should awaitrefreshPlayerActiveAirdrops()and re-render from that result.
invalidatePlayerActiveAirdropsCache
Clears the cached active airdrops list (LAD.v1.active.{playerId}) for the authenticated player. Use this when eligibility may have changed mid-session (for example after a rank-up) and the consumer will immediately call getPlayerActiveAirdrops again.
The cache delete is asynchronous. Always await this method before refetching, or the next getPlayerActiveAirdrops call can still resolve from the stale cache.
EVENTS.RANKS.ON_RANK_UP for the signed-in player also triggers this invalidation inside the SDK.
On EVENTS.LOOT_AIRDROPS.ON_PLAYER_ASSIGNED, prefer refreshPlayerActiveAirdrops instead of calling this method yourself. The SDK already refreshes on that event; a consumer-side invalidate is unnecessary and can race a concurrent plain get.
Signature:
invalidatePlayerActiveAirdropsCache(): Promise<void>
Returns
| Type | Description |
|---|---|
Promise<void> | Resolves when the active airdrops cache entry has been cleared |
Example
await sdk.LootAirdrops.invalidatePlayerActiveAirdropsCache();
const activeAirdrops = await sdk.LootAirdrops.getPlayerActiveAirdrops();
Related Events
EVENTS.RANKS.ON_RANK_UP— SDK clears the active airdrops cache for the authenticated player
refreshPlayerActiveAirdrops
Fetches GET /widget/airdrops and overwrites the active airdrops cache on success. Does not delete the cache first, so a non-OK GET keeps the previous list as a stale fallback. Concurrent callers share one in-flight promise (single-flight), so the SDK's internal ON_PLAYER_ASSIGNED handler and a widget callback that awaits this method only perform one GET.
Use this on EVENTS.LOOT_AIRDROPS.ON_PLAYER_ASSIGNED instead of calling invalidatePlayerActiveAirdropsCache() + getPlayerActiveAirdrops() yourself.
Signature:
refreshPlayerActiveAirdrops(): Promise<AirdropType[]>
Returns
| Type | Description |
|---|---|
Promise<AirdropType[]> | Fresh active airdrops, or the stale cached list / empty array on failure |
Example
sdk.Events.subscribe(EVENTS.LOOT_AIRDROPS.ON_PLAYER_ASSIGNED, async () => {
const activeAirdrops = await sdk.LootAirdrops.refreshPlayerActiveAirdrops();
updateAirdropsUI(activeAirdrops);
});
Related Events
EVENTS.LOOT_AIRDROPS.ON_PLAYER_ASSIGNED— SDK awaits this same single-flight refresh for the authenticated player
getPlayerAirdropsHistory
Returns the ended/cancelled airdrops the authenticated player participated in, most recently finished first, with the airdrop metadata required for history listings.
Signature:
getPlayerAirdropsHistory(): Promise<AirdropHistoryType[]>
Returns
| Type | Description |
|---|---|
Promise<AirdropHistoryType[]> | A promise that resolves to an array of history airdrop entries |
Example
const history = await sdk.LootAirdrops.getPlayerAirdropsHistory();
Related Events
EVENTS.LOOT_AIRDROPS.ON_STATE_UPDATE— Airdrop ended or cancelled; history list should be refreshed
getPlayerPendingClaims
Returns every prize the authenticated player still has to claim (unclaimed and still claimable) across all airdrops, as a flat unpaginated list. Each item includes its airdropId and isAwaitingBetSettlement.
Signature:
getPlayerPendingClaims(): Promise<AirdropPendingClaim[]>
Returns
| Type | Description |
|---|---|
Promise<AirdropPendingClaim[]> | A promise that resolves to an array of pending claims |
Example
const claims = await sdk.LootAirdrops.getPlayerPendingClaims();
for (const claim of claims) {
console.log(claim.airdropId, claim.fireEventId, claim.expirationDate);
}
Related Events
EVENTS.LOOT_AIRDROPS.ON_PLAYER_WON_PRIZE— Player won a prize (new pending claim may appear)EVENTS.LOOT_AIRDROPS.ON_PLAYER_PRIZE_STATUS_UPDATE— Claim status changed (claimed / pending_settlement / expired / cancelled)
getAirdropPrizePool
Returns the prizes configured in the airdrop's loot with their rewards, configured quantity, delivered count, and remaining units (Rewards tab). state.delivered is every unit that left the pool (quantity - remaining), including claimed, expired, cancelled, unclaimed, and pending-settlement prizes. state.percentage is the rounded delivered percentage, or 0 when quantity is 0.
Signature:
getAirdropPrizePool(airdropId: string): Promise<AirdropPrizePoolItem[]>
Parameters
| Name | Type | Description |
|---|---|---|
| airdropId | string | Valid ObjectId of the airdrop |
Returns
| Type | Description |
|---|---|
Promise<AirdropPrizePoolItem[]> | A promise that resolves to an array of prize pool items |
Example
const prizes = await sdk.LootAirdrops.getAirdropPrizePool('airdrop-id-123');
prizes.forEach((prize) => {
console.log(
prize.prizeId,
prize.state.delivered,
prize.remaining,
prize.state.percentage,
);
});
Related Events
EVENTS.LOOT_AIRDROPS.ON_PLAYER_WON_PRIZE— Prize remaining units may change when a win is persistedEVENTS.LOOT_AIRDROPS.ON_PLAYER_PRIZE_STATUS_UPDATE— Prize pool state may change when a claim is settled or cancelled
getPlayerAirdropWins
Returns the prizes the authenticated player has won for a specific airdrop, most recently won first, each with claim lifecycle status and isAwaitingBetSettlement so the UI can enable claim, show a waiting-for-settlement state, or show the final state.
Signature:
getPlayerAirdropWins(airdropId: string): Promise<AirdropPlayerWin[]>
Parameters
| Name | Type | Description |
|---|---|---|
| airdropId | string | Valid ObjectId of the airdrop |
Returns
| Type | Description |
|---|---|
Promise<AirdropPlayerWin[]> | A promise that resolves to an array of player wins |
Example
const wins = await sdk.LootAirdrops.getPlayerAirdropWins('airdrop-id-123');
wins.forEach((win) => {
if (win.status === 'unclaimed') {
console.log('Claimable win:', win.fireEventId);
}
});