@looplay/sdk 0.8.3 → 0.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import type { EmitGameEventResponse, GameAssetDto, GameEventKey, GameOwnedAssetDto, GameStoreDto, GameStoreOfferPurchaseResultDto, PagingResponse, TaskListQuery } from './LooplaySDK.types';
1
+ import type { EmitGameEventResponse, GameAssetDto, GameEventKey, GameOwnedAssetDto, GameStoreDto, GameStoreOfferPurchaseResultDto, PagingResponse } from './LooplaySDK.types';
2
2
  import { ServiceClient } from './service-client';
3
3
  import type { ServiceClientOptions } from './service-client';
4
4
  export interface ApiClientOptions extends Omit<ServiceClientOptions, 'baseUrl'> {
@@ -20,12 +20,13 @@ export declare class ApiClient {
20
20
  private readonly getAnonymousId?;
21
21
  private trackingSession?;
22
22
  private trackingSessionPromise?;
23
- private currentAttemptId?;
24
- private gameplayAttempt?;
25
- private gameplayAttemptPromise?;
23
+ private currentPlaySessionId?;
24
+ private playSession?;
25
+ private playSessionPromise?;
26
26
  constructor(options: ApiClientOptions);
27
27
  /** Expose the underlying route-level client (requires manual bearerToken/gameKey passing). */
28
28
  unsafeRaw(): ServiceClient;
29
+ detectIntegration(gameKey: string): Promise<boolean>;
29
30
  private requireToken;
30
31
  /**
31
32
  * Resolves auth for the tracking endpoints: a real bearer token if logged
@@ -43,24 +44,24 @@ export declare class ApiClient {
43
44
  */
44
45
  private ensureTrackingSession;
45
46
  /**
46
- * Signs (and caches until near expiry) the `attemptToken` required by
47
- * `trackPlay`/`trackMatch`/`emit` for the current attempt — does not
47
+ * Signs (and caches until near expiry) the `playSessionToken` required by
48
+ * `trackPlay`/`trackMatch`/`emit` for the current play session — does not
48
49
  * swallow failures, unlike `ensureTrackingSession`, since these calls
49
50
  * are rejected outright without a valid token.
50
51
  */
51
- private ensureGameplayAttempt;
52
+ private ensurePlaySession;
52
53
  /**
53
54
  * Call once when the game view opens, before any play/match tracking.
54
55
  * `gameKey` is the game's public `appId`.
55
56
  */
56
57
  trackView(gameKey: string): Promise<boolean>;
57
58
  /**
58
- * Starts a new play attempt and returns its id. Call when the user
59
+ * Starts a new play session and returns its id. Call when the user
59
60
  * presses Play; `trackPlay`/`trackMatch`/`emit` reuse this id (and the
60
- * signed `attemptToken` backing it) across calls until the next
61
- * `startAttempt()`, auto-starting one on first use if none was started.
61
+ * signed `playSessionToken` backing it) across calls until the next
62
+ * `startPlaySession()`, auto-starting one on first use if none was started.
62
63
  */
63
- startAttempt(): string;
64
+ startPlaySession(): string;
64
65
  trackPlay(gameKey: string, playTimeSeconds?: number): Promise<boolean>;
65
66
  trackMatch(gameKey: string, body: {
66
67
  matchId: string;
@@ -83,7 +84,7 @@ export declare class ApiClient {
83
84
  listMyStorePurchases(gameKey: string): Promise<GameStoreOfferPurchaseResultDto[]>;
84
85
  /**
85
86
  * Spends coin balance to purchase a store offer — signs a checkout intent
86
- * first, then redeems it, mirroring the gameplay attempt flow above.
87
+ * first, then redeems it, mirroring the play session flow above.
87
88
  * Self-serve: only the player's own access token is used, no secret pair
88
89
  * required, safe to call directly from the game client. Also see
89
90
  * `onStorePurchase` to react to the result in real time from any tab.
@@ -96,10 +97,4 @@ export declare class ApiClient {
96
97
  getMyBalance(): Promise<any>;
97
98
  getBalances(query?: Record<string, any>): Promise<any>;
98
99
  getBalanceHistory(query?: Record<string, any>): Promise<PagingResponse<any>>;
99
- listReferrals(query?: Record<string, any>): Promise<PagingResponse<any>>;
100
- setReferral(body: Record<string, any>): Promise<boolean>;
101
- listTasks(query?: TaskListQuery): Promise<any[]>;
102
- listFinishedTasks(query?: TaskListQuery): Promise<any[]>;
103
- startTask(body: Record<string, any>): Promise<any>;
104
- claimTask(body: Record<string, any>): Promise<any>;
105
100
  }
@@ -1,9 +1,9 @@
1
1
  import { type HttpClientOptions } from './http';
2
- import type { AuthResultDto, CompleteGameplayAttemptRequest, CompleteGameplayMatchRequest, EmitGameEventResponse, GameAssetDto, GameOwnedAssetDto, GameplayAttemptSessionDto, GameStoreCheckoutIntentDto, GameStoreDto, GameStoreOfferPurchaseResultDto, GameTrackingSessionDto, PagingResponse, RecordGameplayActionRequest, SdkCreateGameStoreCheckoutIntentRequest, SdkPurchaseGameStoreOfferRuntimeRequest, StartGameplayAttemptRequest, TaskListQuery } from './LooplaySDK.types';
2
+ import type { AuthResultDto, CompletePlaySessionRequest, CompleteGameplayMatchRequest, EmitGameEventResponse, GameAssetDto, GameOwnedAssetDto, PlaySessionDto, GameStoreCheckoutIntentDto, GameStoreDto, GameStoreOfferPurchaseResultDto, GameTrackingSessionDto, PagingResponse, RecordGameplayActionRequest, SdkCreateGameStoreCheckoutIntentRequest, SdkPurchaseGameStoreOfferRuntimeRequest, StartPlaySessionRequest } from './LooplaySDK.types';
3
3
  export interface ServiceClientOptions extends HttpClientOptions {
4
4
  }
5
5
  /**
6
- * Auth for the tracking endpoints (view/attempt/match/action), which accept
6
+ * Auth for the tracking endpoints (view/play-session/match/action), which accept
7
7
  * either a real user's `bearerToken` (full tracking, eligible for
8
8
  * quest/reward) or an `anonId` for an unauthenticated device
9
9
  * (analytics-only — the backend never awards quest/reward progress to an
@@ -41,9 +41,9 @@ export declare class ServiceClient {
41
41
  refresh(refreshToken: string): Promise<AuthResultDto>;
42
42
  logout(refreshToken: string): Promise<boolean>;
43
43
  recordGameView(gameKey: string, auth?: TrackingAuth): Promise<boolean>;
44
- /** Signs a fresh `attemptToken` — required by `completeGameplayAttempt`/`completeGameplayMatch`/`recordGameplayAction`. */
45
- startGameplayAttempt(gameKey: string, auth?: TrackingAuth, body?: StartGameplayAttemptRequest): Promise<GameplayAttemptSessionDto>;
46
- completeGameplayAttempt(gameKey: string, auth: TrackingAuth, body: CompleteGameplayAttemptRequest): Promise<boolean>;
44
+ /** Signs a fresh `playSessionToken` — required by `completePlaySession`/`completeGameplayMatch`/`recordGameplayAction`. */
45
+ startPlaySession(gameKey: string, auth?: TrackingAuth, body?: StartPlaySessionRequest): Promise<PlaySessionDto>;
46
+ completePlaySession(gameKey: string, auth: TrackingAuth, body: CompletePlaySessionRequest): Promise<boolean>;
47
47
  completeGameplayMatch(gameKey: string, auth: TrackingAuth, body: CompleteGameplayMatchRequest): Promise<boolean>;
48
48
  recordGameplayAction(gameKey: string, auth: TrackingAuth, body: RecordGameplayActionRequest): Promise<EmitGameEventResponse>;
49
49
  /**
@@ -52,6 +52,11 @@ export declare class ServiceClient {
52
52
  * tracing — see `GameTrackingSessionDto`.
53
53
  */
54
54
  bootstrapTrackingSession(anonId?: string): Promise<GameTrackingSessionDto>;
55
+ /**
56
+ * Lightweight integration heartbeat for review/liveops. This intentionally
57
+ * does not record a view/play metric.
58
+ */
59
+ detectGameIntegration(gameKey: string): Promise<boolean>;
55
60
  private trackingHeaders;
56
61
  /** Public storefront (sections + offers) for the integration's game. Read-only. */
57
62
  getStore(gameKey: string): Promise<GameStoreDto>;
@@ -71,10 +76,4 @@ export declare class ServiceClient {
71
76
  getBalanceHistory(bearerToken: string, query?: Record<string, any>): Promise<PagingResponse<any>>;
72
77
  getMyProfile(bearerToken: string): Promise<any>;
73
78
  getMyBalance(bearerToken: string): Promise<any>;
74
- listReferrals(bearerToken: string, query?: Record<string, any>): Promise<PagingResponse<any>>;
75
- setReferral(bearerToken: string, body: Record<string, any>): Promise<boolean>;
76
- listTasks(bearerToken: string, query?: TaskListQuery): Promise<any[]>;
77
- listFinishedTasks(bearerToken: string, query?: TaskListQuery): Promise<any[]>;
78
- startTask(bearerToken: string, body: Record<string, any>): Promise<any>;
79
- claimTask(bearerToken: string, body: Record<string, any>): Promise<any>;
80
79
  }
@@ -59,8 +59,8 @@ export declare class LooplayIframeAuth {
59
59
  getClient(): ApiClient;
60
60
  /** Call once when the game view opens, before any play/match tracking. */
61
61
  trackView(): Promise<boolean>;
62
- /** Starts a new play attempt; call when the user presses Play. Returns the attempt id. */
63
- startAttempt(): string;
62
+ /** Starts a new play session; call when the user presses Play. Returns the play session id. */
63
+ startPlaySession(): string;
64
64
  trackPlay(playTimeSeconds?: number): Promise<boolean>;
65
65
  trackMatch(matchId: string, opts: TrackMatchOptions): Promise<boolean>;
66
66
  emitGameEvent(actionCode: GameEventKey | string, opts?: EmitGameEventOptions): Promise<EmitGameEventResponse | null>;
@@ -14,8 +14,8 @@ export declare class LooplaySDK {
14
14
  getMyProfile(): Promise<any>;
15
15
  /** Call once when the game view opens, before any play/match tracking. */
16
16
  trackView(): Promise<boolean>;
17
- /** Starts a new play attempt; call when the user presses Play. Returns the attempt id. */
18
- startAttempt(): string;
17
+ /** Starts a new play session; call when the user presses Play. Returns the play session id. */
18
+ startPlaySession(): string;
19
19
  trackPlay(playTimeSeconds?: number): Promise<boolean>;
20
20
  /**
21
21
  * Report that a match/round ended.
@@ -39,4 +39,5 @@ export declare class LooplaySDK {
39
39
  }): Promise<EmitGameEventResponse>;
40
40
  private assertInitialized;
41
41
  private verifyGameId;
42
+ private detectIntegration;
42
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@looplay/sdk",
3
- "version": "0.8.3",
3
+ "version": "0.8.4",
4
4
  "description": "LooplaySDK (auth + points) for game integrations",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",