@thestatic-tv/dcl-sdk 2.0.1 → 2.0.3
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 +9 -4
- package/dist/index.d.ts +9 -4
- package/dist/index.js +45 -13
- package/dist/index.mjs +45 -13
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -536,10 +536,11 @@ declare class StaticTVClient {
|
|
|
536
536
|
private config;
|
|
537
537
|
private baseUrl;
|
|
538
538
|
private _keyType;
|
|
539
|
+
private _disabled;
|
|
539
540
|
/** Guide module - fetch channel lineup (channel keys only) */
|
|
540
541
|
readonly guide: GuideModule | null;
|
|
541
|
-
/** Session module - track visitor sessions (all keys) */
|
|
542
|
-
readonly session: SessionModule;
|
|
542
|
+
/** Session module - track visitor sessions (all keys, null when disabled) */
|
|
543
|
+
readonly session: SessionModule | null;
|
|
543
544
|
/** Heartbeat module - track video watching (channel keys only) */
|
|
544
545
|
readonly heartbeat: HeartbeatModule | null;
|
|
545
546
|
/** Interactions module - like/follow channels (channel keys only) */
|
|
@@ -569,9 +570,13 @@ declare class StaticTVClient {
|
|
|
569
570
|
*/
|
|
570
571
|
constructor(config: StaticTVConfig);
|
|
571
572
|
/**
|
|
572
|
-
* Get the key type (channel or
|
|
573
|
+
* Get the key type (channel, scene, or null if disabled)
|
|
573
574
|
*/
|
|
574
|
-
get keyType(): 'channel' | 'scene';
|
|
575
|
+
get keyType(): 'channel' | 'scene' | null;
|
|
576
|
+
/**
|
|
577
|
+
* Check if tracking is disabled (no valid API key)
|
|
578
|
+
*/
|
|
579
|
+
get isDisabled(): boolean;
|
|
575
580
|
/**
|
|
576
581
|
* Check if this is a lite (scene-only) client
|
|
577
582
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -536,10 +536,11 @@ declare class StaticTVClient {
|
|
|
536
536
|
private config;
|
|
537
537
|
private baseUrl;
|
|
538
538
|
private _keyType;
|
|
539
|
+
private _disabled;
|
|
539
540
|
/** Guide module - fetch channel lineup (channel keys only) */
|
|
540
541
|
readonly guide: GuideModule | null;
|
|
541
|
-
/** Session module - track visitor sessions (all keys) */
|
|
542
|
-
readonly session: SessionModule;
|
|
542
|
+
/** Session module - track visitor sessions (all keys, null when disabled) */
|
|
543
|
+
readonly session: SessionModule | null;
|
|
543
544
|
/** Heartbeat module - track video watching (channel keys only) */
|
|
544
545
|
readonly heartbeat: HeartbeatModule | null;
|
|
545
546
|
/** Interactions module - like/follow channels (channel keys only) */
|
|
@@ -569,9 +570,13 @@ declare class StaticTVClient {
|
|
|
569
570
|
*/
|
|
570
571
|
constructor(config: StaticTVConfig);
|
|
571
572
|
/**
|
|
572
|
-
* Get the key type (channel or
|
|
573
|
+
* Get the key type (channel, scene, or null if disabled)
|
|
573
574
|
*/
|
|
574
|
-
get keyType(): 'channel' | 'scene';
|
|
575
|
+
get keyType(): 'channel' | 'scene' | null;
|
|
576
|
+
/**
|
|
577
|
+
* Check if tracking is disabled (no valid API key)
|
|
578
|
+
*/
|
|
579
|
+
get isDisabled(): boolean;
|
|
575
580
|
/**
|
|
576
581
|
* Check if this is a lite (scene-only) client
|
|
577
582
|
*/
|
package/dist/index.js
CHANGED
|
@@ -453,7 +453,7 @@ var HeartbeatModule = class {
|
|
|
453
453
|
async sendHeartbeat() {
|
|
454
454
|
if (!this.currentChannel || !this.isWatching) return;
|
|
455
455
|
try {
|
|
456
|
-
const sessionId = this.client.session
|
|
456
|
+
const sessionId = this.client.session?.getSessionId();
|
|
457
457
|
await this.client.request("/heartbeat", {
|
|
458
458
|
method: "POST",
|
|
459
459
|
body: JSON.stringify({
|
|
@@ -2121,16 +2121,8 @@ var StaticTVClient = class {
|
|
|
2121
2121
|
* ```
|
|
2122
2122
|
*/
|
|
2123
2123
|
constructor(config) {
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
}
|
|
2127
|
-
if (config.apiKey.startsWith("dclk_")) {
|
|
2128
|
-
this._keyType = KEY_TYPE_CHANNEL;
|
|
2129
|
-
} else if (config.apiKey.startsWith("dcls_")) {
|
|
2130
|
-
this._keyType = KEY_TYPE_SCENE;
|
|
2131
|
-
} else {
|
|
2132
|
-
throw new Error("StaticTVClient: invalid apiKey format. Must start with dclk_ or dcls_");
|
|
2133
|
-
}
|
|
2124
|
+
this._keyType = null;
|
|
2125
|
+
this._disabled = false;
|
|
2134
2126
|
this.config = {
|
|
2135
2127
|
autoStartSession: true,
|
|
2136
2128
|
sessionHeartbeatInterval: 3e4,
|
|
@@ -2139,6 +2131,34 @@ var StaticTVClient = class {
|
|
|
2139
2131
|
...config
|
|
2140
2132
|
};
|
|
2141
2133
|
this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
|
|
2134
|
+
if (!config.apiKey) {
|
|
2135
|
+
console.log("[StaticTV] No apiKey provided - tracking disabled. Scene will load normally.");
|
|
2136
|
+
this._disabled = true;
|
|
2137
|
+
this._keyType = null;
|
|
2138
|
+
this.session = null;
|
|
2139
|
+
this.guide = null;
|
|
2140
|
+
this.heartbeat = null;
|
|
2141
|
+
this.interactions = null;
|
|
2142
|
+
this.guideUI = null;
|
|
2143
|
+
this.chatUI = null;
|
|
2144
|
+
return;
|
|
2145
|
+
}
|
|
2146
|
+
if (config.apiKey.startsWith("dclk_")) {
|
|
2147
|
+
this._keyType = KEY_TYPE_CHANNEL;
|
|
2148
|
+
} else if (config.apiKey.startsWith("dcls_")) {
|
|
2149
|
+
this._keyType = KEY_TYPE_SCENE;
|
|
2150
|
+
} else {
|
|
2151
|
+
console.log("[StaticTV] Invalid apiKey format (must start with dclk_ or dcls_) - tracking disabled. Scene will load normally.");
|
|
2152
|
+
this._disabled = true;
|
|
2153
|
+
this._keyType = null;
|
|
2154
|
+
this.session = null;
|
|
2155
|
+
this.guide = null;
|
|
2156
|
+
this.heartbeat = null;
|
|
2157
|
+
this.interactions = null;
|
|
2158
|
+
this.guideUI = null;
|
|
2159
|
+
this.chatUI = null;
|
|
2160
|
+
return;
|
|
2161
|
+
}
|
|
2142
2162
|
this.session = new SessionModule(this);
|
|
2143
2163
|
if (this._keyType === KEY_TYPE_CHANNEL) {
|
|
2144
2164
|
this.guide = new GuideModule(this);
|
|
@@ -2168,11 +2188,17 @@ var StaticTVClient = class {
|
|
|
2168
2188
|
this.log(`StaticTVClient initialized (${this._keyType} mode)`);
|
|
2169
2189
|
}
|
|
2170
2190
|
/**
|
|
2171
|
-
* Get the key type (channel or
|
|
2191
|
+
* Get the key type (channel, scene, or null if disabled)
|
|
2172
2192
|
*/
|
|
2173
2193
|
get keyType() {
|
|
2174
2194
|
return this._keyType;
|
|
2175
2195
|
}
|
|
2196
|
+
/**
|
|
2197
|
+
* Check if tracking is disabled (no valid API key)
|
|
2198
|
+
*/
|
|
2199
|
+
get isDisabled() {
|
|
2200
|
+
return this._disabled;
|
|
2201
|
+
}
|
|
2176
2202
|
/**
|
|
2177
2203
|
* Check if this is a lite (scene-only) client
|
|
2178
2204
|
*/
|
|
@@ -2214,13 +2240,19 @@ var StaticTVClient = class {
|
|
|
2214
2240
|
* Cleanup when done (call before scene unload)
|
|
2215
2241
|
*/
|
|
2216
2242
|
async destroy() {
|
|
2243
|
+
if (this._disabled) {
|
|
2244
|
+
this.log("StaticTVClient destroyed (was disabled)");
|
|
2245
|
+
return;
|
|
2246
|
+
}
|
|
2217
2247
|
if (this.heartbeat) {
|
|
2218
2248
|
this.heartbeat.stopWatching();
|
|
2219
2249
|
}
|
|
2220
2250
|
if (this.chatUI) {
|
|
2221
2251
|
this.chatUI.destroy();
|
|
2222
2252
|
}
|
|
2223
|
-
|
|
2253
|
+
if (this.session) {
|
|
2254
|
+
await this.session.endSession();
|
|
2255
|
+
}
|
|
2224
2256
|
this.log("StaticTVClient destroyed");
|
|
2225
2257
|
}
|
|
2226
2258
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -413,7 +413,7 @@ var HeartbeatModule = class {
|
|
|
413
413
|
async sendHeartbeat() {
|
|
414
414
|
if (!this.currentChannel || !this.isWatching) return;
|
|
415
415
|
try {
|
|
416
|
-
const sessionId = this.client.session
|
|
416
|
+
const sessionId = this.client.session?.getSessionId();
|
|
417
417
|
await this.client.request("/heartbeat", {
|
|
418
418
|
method: "POST",
|
|
419
419
|
body: JSON.stringify({
|
|
@@ -2081,16 +2081,8 @@ var StaticTVClient = class {
|
|
|
2081
2081
|
* ```
|
|
2082
2082
|
*/
|
|
2083
2083
|
constructor(config) {
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
}
|
|
2087
|
-
if (config.apiKey.startsWith("dclk_")) {
|
|
2088
|
-
this._keyType = KEY_TYPE_CHANNEL;
|
|
2089
|
-
} else if (config.apiKey.startsWith("dcls_")) {
|
|
2090
|
-
this._keyType = KEY_TYPE_SCENE;
|
|
2091
|
-
} else {
|
|
2092
|
-
throw new Error("StaticTVClient: invalid apiKey format. Must start with dclk_ or dcls_");
|
|
2093
|
-
}
|
|
2084
|
+
this._keyType = null;
|
|
2085
|
+
this._disabled = false;
|
|
2094
2086
|
this.config = {
|
|
2095
2087
|
autoStartSession: true,
|
|
2096
2088
|
sessionHeartbeatInterval: 3e4,
|
|
@@ -2099,6 +2091,34 @@ var StaticTVClient = class {
|
|
|
2099
2091
|
...config
|
|
2100
2092
|
};
|
|
2101
2093
|
this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
|
|
2094
|
+
if (!config.apiKey) {
|
|
2095
|
+
console.log("[StaticTV] No apiKey provided - tracking disabled. Scene will load normally.");
|
|
2096
|
+
this._disabled = true;
|
|
2097
|
+
this._keyType = null;
|
|
2098
|
+
this.session = null;
|
|
2099
|
+
this.guide = null;
|
|
2100
|
+
this.heartbeat = null;
|
|
2101
|
+
this.interactions = null;
|
|
2102
|
+
this.guideUI = null;
|
|
2103
|
+
this.chatUI = null;
|
|
2104
|
+
return;
|
|
2105
|
+
}
|
|
2106
|
+
if (config.apiKey.startsWith("dclk_")) {
|
|
2107
|
+
this._keyType = KEY_TYPE_CHANNEL;
|
|
2108
|
+
} else if (config.apiKey.startsWith("dcls_")) {
|
|
2109
|
+
this._keyType = KEY_TYPE_SCENE;
|
|
2110
|
+
} else {
|
|
2111
|
+
console.log("[StaticTV] Invalid apiKey format (must start with dclk_ or dcls_) - tracking disabled. Scene will load normally.");
|
|
2112
|
+
this._disabled = true;
|
|
2113
|
+
this._keyType = null;
|
|
2114
|
+
this.session = null;
|
|
2115
|
+
this.guide = null;
|
|
2116
|
+
this.heartbeat = null;
|
|
2117
|
+
this.interactions = null;
|
|
2118
|
+
this.guideUI = null;
|
|
2119
|
+
this.chatUI = null;
|
|
2120
|
+
return;
|
|
2121
|
+
}
|
|
2102
2122
|
this.session = new SessionModule(this);
|
|
2103
2123
|
if (this._keyType === KEY_TYPE_CHANNEL) {
|
|
2104
2124
|
this.guide = new GuideModule(this);
|
|
@@ -2128,11 +2148,17 @@ var StaticTVClient = class {
|
|
|
2128
2148
|
this.log(`StaticTVClient initialized (${this._keyType} mode)`);
|
|
2129
2149
|
}
|
|
2130
2150
|
/**
|
|
2131
|
-
* Get the key type (channel or
|
|
2151
|
+
* Get the key type (channel, scene, or null if disabled)
|
|
2132
2152
|
*/
|
|
2133
2153
|
get keyType() {
|
|
2134
2154
|
return this._keyType;
|
|
2135
2155
|
}
|
|
2156
|
+
/**
|
|
2157
|
+
* Check if tracking is disabled (no valid API key)
|
|
2158
|
+
*/
|
|
2159
|
+
get isDisabled() {
|
|
2160
|
+
return this._disabled;
|
|
2161
|
+
}
|
|
2136
2162
|
/**
|
|
2137
2163
|
* Check if this is a lite (scene-only) client
|
|
2138
2164
|
*/
|
|
@@ -2174,13 +2200,19 @@ var StaticTVClient = class {
|
|
|
2174
2200
|
* Cleanup when done (call before scene unload)
|
|
2175
2201
|
*/
|
|
2176
2202
|
async destroy() {
|
|
2203
|
+
if (this._disabled) {
|
|
2204
|
+
this.log("StaticTVClient destroyed (was disabled)");
|
|
2205
|
+
return;
|
|
2206
|
+
}
|
|
2177
2207
|
if (this.heartbeat) {
|
|
2178
2208
|
this.heartbeat.stopWatching();
|
|
2179
2209
|
}
|
|
2180
2210
|
if (this.chatUI) {
|
|
2181
2211
|
this.chatUI.destroy();
|
|
2182
2212
|
}
|
|
2183
|
-
|
|
2213
|
+
if (this.session) {
|
|
2214
|
+
await this.session.endSession();
|
|
2215
|
+
}
|
|
2184
2216
|
this.log("StaticTVClient destroyed");
|
|
2185
2217
|
}
|
|
2186
2218
|
};
|
package/package.json
CHANGED