@thestatic-tv/dcl-sdk 1.0.1 → 1.0.2

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.
package/dist/index.d.mts CHANGED
@@ -84,6 +84,26 @@ interface InteractionResponse {
84
84
  alreadyExists: boolean;
85
85
  version: string;
86
86
  }
87
+ /**
88
+ * Scene stats for display in-world
89
+ */
90
+ interface SceneStats {
91
+ date: string;
92
+ totalSessions: number;
93
+ uniqueVisitors: number;
94
+ totalMinutes: number;
95
+ visitorNumber: number | null;
96
+ isFirstVisitor: boolean;
97
+ }
98
+ /**
99
+ * Scene stats response from the API
100
+ */
101
+ interface SceneStatsResponse {
102
+ success: boolean;
103
+ stats: SceneStats;
104
+ sceneName: string | null;
105
+ version: string;
106
+ }
87
107
 
88
108
  /**
89
109
  * Guide module - fetch channel lineup from thestatic.tv
@@ -160,6 +180,11 @@ declare class SessionModule {
160
180
  * Check if a session is currently active
161
181
  */
162
182
  isSessionActive(): boolean;
183
+ /**
184
+ * Get scene stats (visitors, sessions, etc.)
185
+ * Useful for displaying metrics in-world
186
+ */
187
+ getStats(): Promise<SceneStatsResponse['stats'] | null>;
163
188
  }
164
189
 
165
190
  /**
@@ -294,4 +319,4 @@ declare class StaticTVClient {
294
319
  destroy(): Promise<void>;
295
320
  }
296
321
 
297
- export { type Channel, GuideModule, type GuideResponse, HeartbeatModule, type HeartbeatResponse, type InteractionResponse, InteractionsModule, KEY_TYPE_CHANNEL, KEY_TYPE_SCENE, SessionModule, type SessionResponse, StaticTVClient, type StaticTVConfig, type Vod };
322
+ export { type Channel, GuideModule, type GuideResponse, HeartbeatModule, type HeartbeatResponse, type InteractionResponse, InteractionsModule, KEY_TYPE_CHANNEL, KEY_TYPE_SCENE, type SceneStats, type SceneStatsResponse, SessionModule, type SessionResponse, StaticTVClient, type StaticTVConfig, type Vod };
package/dist/index.d.ts CHANGED
@@ -84,6 +84,26 @@ interface InteractionResponse {
84
84
  alreadyExists: boolean;
85
85
  version: string;
86
86
  }
87
+ /**
88
+ * Scene stats for display in-world
89
+ */
90
+ interface SceneStats {
91
+ date: string;
92
+ totalSessions: number;
93
+ uniqueVisitors: number;
94
+ totalMinutes: number;
95
+ visitorNumber: number | null;
96
+ isFirstVisitor: boolean;
97
+ }
98
+ /**
99
+ * Scene stats response from the API
100
+ */
101
+ interface SceneStatsResponse {
102
+ success: boolean;
103
+ stats: SceneStats;
104
+ sceneName: string | null;
105
+ version: string;
106
+ }
87
107
 
88
108
  /**
89
109
  * Guide module - fetch channel lineup from thestatic.tv
@@ -160,6 +180,11 @@ declare class SessionModule {
160
180
  * Check if a session is currently active
161
181
  */
162
182
  isSessionActive(): boolean;
183
+ /**
184
+ * Get scene stats (visitors, sessions, etc.)
185
+ * Useful for displaying metrics in-world
186
+ */
187
+ getStats(): Promise<SceneStatsResponse['stats'] | null>;
163
188
  }
164
189
 
165
190
  /**
@@ -294,4 +319,4 @@ declare class StaticTVClient {
294
319
  destroy(): Promise<void>;
295
320
  }
296
321
 
297
- export { type Channel, GuideModule, type GuideResponse, HeartbeatModule, type HeartbeatResponse, type InteractionResponse, InteractionsModule, KEY_TYPE_CHANNEL, KEY_TYPE_SCENE, SessionModule, type SessionResponse, StaticTVClient, type StaticTVConfig, type Vod };
322
+ export { type Channel, GuideModule, type GuideResponse, HeartbeatModule, type HeartbeatResponse, type InteractionResponse, InteractionsModule, KEY_TYPE_CHANNEL, KEY_TYPE_SCENE, type SceneStats, type SceneStatsResponse, SessionModule, type SessionResponse, StaticTVClient, type StaticTVConfig, type Vod };
package/dist/index.js CHANGED
@@ -99,7 +99,7 @@ var GuideModule = class {
99
99
  // src/utils/identity.ts
100
100
  function getPlayerWallet() {
101
101
  try {
102
- const { getPlayer } = require("@dcl/sdk/src/players");
102
+ const { getPlayer } = require("@dcl/sdk/players");
103
103
  const player = getPlayer();
104
104
  return player?.userId ?? null;
105
105
  } catch {
@@ -108,7 +108,7 @@ function getPlayerWallet() {
108
108
  }
109
109
  function getPlayerDisplayName() {
110
110
  try {
111
- const { getPlayer } = require("@dcl/sdk/src/players");
111
+ const { getPlayer } = require("@dcl/sdk/players");
112
112
  const player = getPlayer();
113
113
  return player?.name ?? null;
114
114
  } catch {
@@ -228,6 +228,28 @@ var SessionModule = class {
228
228
  isSessionActive() {
229
229
  return this.isActive;
230
230
  }
231
+ /**
232
+ * Get scene stats (visitors, sessions, etc.)
233
+ * Useful for displaying metrics in-world
234
+ */
235
+ async getStats() {
236
+ try {
237
+ const wallet = getPlayerWallet();
238
+ const queryParam = wallet ? `?wallet=${wallet}` : "";
239
+ const response = await this.client.request(
240
+ `/scene-stats${queryParam}`,
241
+ { method: "GET" }
242
+ );
243
+ if (response.success && response.stats) {
244
+ this.client.log("Stats fetched:", response.stats);
245
+ return response.stats;
246
+ }
247
+ return null;
248
+ } catch (error) {
249
+ this.client.log(`Failed to fetch stats: ${error}`);
250
+ return null;
251
+ }
252
+ }
231
253
  };
232
254
 
233
255
  // src/modules/heartbeat.ts
package/dist/index.mjs CHANGED
@@ -74,7 +74,7 @@ var GuideModule = class {
74
74
  // src/utils/identity.ts
75
75
  function getPlayerWallet() {
76
76
  try {
77
- const { getPlayer } = __require("@dcl/sdk/src/players");
77
+ const { getPlayer } = __require("@dcl/sdk/players");
78
78
  const player = getPlayer();
79
79
  return player?.userId ?? null;
80
80
  } catch {
@@ -83,7 +83,7 @@ function getPlayerWallet() {
83
83
  }
84
84
  function getPlayerDisplayName() {
85
85
  try {
86
- const { getPlayer } = __require("@dcl/sdk/src/players");
86
+ const { getPlayer } = __require("@dcl/sdk/players");
87
87
  const player = getPlayer();
88
88
  return player?.name ?? null;
89
89
  } catch {
@@ -203,6 +203,28 @@ var SessionModule = class {
203
203
  isSessionActive() {
204
204
  return this.isActive;
205
205
  }
206
+ /**
207
+ * Get scene stats (visitors, sessions, etc.)
208
+ * Useful for displaying metrics in-world
209
+ */
210
+ async getStats() {
211
+ try {
212
+ const wallet = getPlayerWallet();
213
+ const queryParam = wallet ? `?wallet=${wallet}` : "";
214
+ const response = await this.client.request(
215
+ `/scene-stats${queryParam}`,
216
+ { method: "GET" }
217
+ );
218
+ if (response.success && response.stats) {
219
+ this.client.log("Stats fetched:", response.stats);
220
+ return response.stats;
221
+ }
222
+ return null;
223
+ } catch (error) {
224
+ this.client.log(`Failed to fetch stats: ${error}`);
225
+ return null;
226
+ }
227
+ }
206
228
  };
207
229
 
208
230
  // src/modules/heartbeat.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thestatic-tv/dcl-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Connect your Decentraland scene to thestatic.tv - full channel lineup, metrics tracking, and interactions",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",