0.6.0: LeaderboardSession.claim, rank_not_eligible is recoverable
onClaim replaces onRewardClaimed. rewardClaimed() is a deprecated alias removed in the next version.
This commit is contained in:
@@ -1,5 +1,15 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.6.0
|
||||||
|
|
||||||
|
- `LeaderboardSession.claim()` / effect `claim()` completes the leaderboard
|
||||||
|
node with handle `onClaim`. The server matches live rank to an authored
|
||||||
|
place and continues from that place (Grant Reward and/or In-App Message).
|
||||||
|
- `rewardClaimed()` is a deprecated alias for `claim()` and will be removed
|
||||||
|
in the next SDK version.
|
||||||
|
- `rank_not_eligible` on Claim leaves the session open (retry Claim or End);
|
||||||
|
it no longer fails the run.
|
||||||
|
|
||||||
## 0.5.1
|
## 0.5.1
|
||||||
|
|
||||||
- `QuestMetrics` / `reportProgress`: custom free-text metrics no longer
|
- `QuestMetrics` / `reportProgress`: custom free-text metrics no longer
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@rudder/js-sdk",
|
"name": "@rudder/js-sdk",
|
||||||
"version": "0.5.1",
|
"version": "0.6.0",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"registry": "https://hub.rudder.build/api/packages/rudder/npm/"
|
"registry": "https://hub.rudder.build/api/packages/rudder/npm/"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ export interface StoreOfferEffect {
|
|||||||
|
|
||||||
export interface LeaderboardEffect {
|
export interface LeaderboardEffect {
|
||||||
end(): Promise<void>;
|
end(): Promise<void>;
|
||||||
|
claim(): Promise<void>;
|
||||||
|
/** @deprecated Use {@link LeaderboardEffect.claim}. Removed in the next SDK version. */
|
||||||
rewardClaimed(): Promise<void>;
|
rewardClaimed(): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +193,8 @@ export class EffectsCenter implements Effects {
|
|||||||
emitLeaderboard(session: LeaderboardSession): void {
|
emitLeaderboard(session: LeaderboardSession): void {
|
||||||
this.emit(this.leaderboardHandlers, {
|
this.emit(this.leaderboardHandlers, {
|
||||||
end: () => session.end(),
|
end: () => session.end(),
|
||||||
rewardClaimed: () => session.rewardClaimed(),
|
claim: () => session.claim(),
|
||||||
|
rewardClaimed: () => session.claim(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,10 @@ function isTransientHttpError(err: unknown): boolean {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isRankNotEligible(err: unknown): boolean {
|
||||||
|
return err instanceof RudderHttpError && err.code === 'rank_not_eligible';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export class ScenarioService<TConfig extends RemoteConfigShape = RemoteConfigShape> {
|
export class ScenarioService<TConfig extends RemoteConfigShape = RemoteConfigShape> {
|
||||||
private readonly runs = new Map<string, RuntimeRun>();
|
private readonly runs = new Map<string, RuntimeRun>();
|
||||||
@@ -434,6 +438,10 @@ export class ScenarioService<TConfig extends RemoteConfigShape = RemoteConfigSha
|
|||||||
await this.persist();
|
await this.persist();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
run.pendingTransitions--;
|
run.pendingTransitions--;
|
||||||
|
if (isRankNotEligible(err)) {
|
||||||
|
await this.persist();
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
this.failRun(
|
this.failRun(
|
||||||
run,
|
run,
|
||||||
nodeId,
|
nodeId,
|
||||||
|
|||||||
@@ -180,14 +180,19 @@ export class LeaderboardSession {
|
|||||||
|
|
||||||
async end(): Promise<void> {
|
async end(): Promise<void> {
|
||||||
if (this.resolved) return;
|
if (this.resolved) return;
|
||||||
this.resolved = true;
|
|
||||||
await this.context.complete('onEnd');
|
await this.context.complete('onEnd');
|
||||||
|
this.resolved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async rewardClaimed(): Promise<void> {
|
async claim(): Promise<void> {
|
||||||
if (this.resolved) return;
|
if (this.resolved) return;
|
||||||
|
await this.context.complete('onClaim');
|
||||||
this.resolved = true;
|
this.resolved = true;
|
||||||
await this.context.complete('onRewardClaimed');
|
}
|
||||||
|
|
||||||
|
/** @deprecated Use {@link LeaderboardSession.claim}. Removed in the next SDK version. */
|
||||||
|
async rewardClaimed(): Promise<void> {
|
||||||
|
return this.claim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user