stormcloud-video-player 0.6.7 → 0.6.9
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/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +239 -182
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +23 -2
- package/lib/index.d.ts +23 -2
- package/lib/index.js +239 -182
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +239 -182
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +6 -1
- package/lib/players/HlsPlayer.cjs +239 -182
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +239 -182
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/vastAdLayer.cjs +1 -26
- package/lib/sdk/vastAdLayer.cjs.map +1 -1
- package/lib/sdk/vastAdLayer.d.cts +1 -1
- package/lib/sdk/vastManager.d.cts +1 -1
- package/lib/{types-BYwfSJb5.d.cts → types-DSKC4ySr.d.cts} +5 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +239 -182
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/tracking.cjs +179 -150
- package/lib/utils/tracking.cjs.map +1 -1
- package/lib/utils/tracking.d.cts +11 -6
- package/package.json +1 -1
|
@@ -994,7 +994,6 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
994
994
|
var tornDown = false;
|
|
995
995
|
var trackingFired = createEmptyTrackingState();
|
|
996
996
|
var adStallTimerId;
|
|
997
|
-
var savedContentVideoStyles;
|
|
998
997
|
var currentAdEventHandlers;
|
|
999
998
|
var preloadSlots = /* @__PURE__ */ new Map();
|
|
1000
999
|
function emit(event, payload) {
|
|
@@ -1111,7 +1110,7 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1111
1110
|
video.style.top = "0";
|
|
1112
1111
|
video.style.width = "100%";
|
|
1113
1112
|
video.style.height = "100%";
|
|
1114
|
-
video.style.objectFit = "
|
|
1113
|
+
video.style.objectFit = "contain";
|
|
1115
1114
|
video.style.backgroundColor = "#000";
|
|
1116
1115
|
video.playsInline = true;
|
|
1117
1116
|
video.muted = false;
|
|
@@ -1226,31 +1225,12 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1226
1225
|
delete contentVideo.dataset.stormcloudAdPlaying;
|
|
1227
1226
|
}
|
|
1228
1227
|
}
|
|
1229
|
-
function applyContentVideoAdCoverStyles() {
|
|
1230
|
-
if (!singleElementMode) return;
|
|
1231
|
-
savedContentVideoStyles = {
|
|
1232
|
-
objectFit: contentVideo.style.objectFit,
|
|
1233
|
-
width: contentVideo.style.width,
|
|
1234
|
-
height: contentVideo.style.height
|
|
1235
|
-
};
|
|
1236
|
-
contentVideo.style.objectFit = "cover";
|
|
1237
|
-
contentVideo.style.width = "100%";
|
|
1238
|
-
contentVideo.style.height = "100%";
|
|
1239
|
-
}
|
|
1240
|
-
function restoreContentVideoStyles() {
|
|
1241
|
-
if (!singleElementMode || !savedContentVideoStyles) return;
|
|
1242
|
-
contentVideo.style.objectFit = savedContentVideoStyles.objectFit;
|
|
1243
|
-
contentVideo.style.width = savedContentVideoStyles.width;
|
|
1244
|
-
contentVideo.style.height = savedContentVideoStyles.height;
|
|
1245
|
-
savedContentVideoStyles = void 0;
|
|
1246
|
-
}
|
|
1247
1228
|
function handleAdComplete() {
|
|
1248
1229
|
if (tornDown) return;
|
|
1249
1230
|
clearAdStallTimer();
|
|
1250
1231
|
if (debug) console.log("".concat(LOG, " Handling ad completion"));
|
|
1251
1232
|
adPlaying = false;
|
|
1252
1233
|
setAdPlayingFlag(false);
|
|
1253
|
-
restoreContentVideoStyles();
|
|
1254
1234
|
if (adContainerEl) {
|
|
1255
1235
|
adContainerEl.style.display = "none";
|
|
1256
1236
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -1265,7 +1245,6 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1265
1245
|
if (debug) console.log("".concat(LOG, " Handling ad error"));
|
|
1266
1246
|
adPlaying = false;
|
|
1267
1247
|
setAdPlayingFlag(false);
|
|
1268
|
-
restoreContentVideoStyles();
|
|
1269
1248
|
if (adContainerEl) {
|
|
1270
1249
|
adContainerEl.style.display = "none";
|
|
1271
1250
|
adContainerEl.style.pointerEvents = "none";
|
|
@@ -1436,7 +1415,6 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1436
1415
|
];
|
|
1437
1416
|
contentVideo.style.visibility = "visible";
|
|
1438
1417
|
contentVideo.style.opacity = "1";
|
|
1439
|
-
applyContentVideoAdCoverStyles();
|
|
1440
1418
|
emit("content_pause");
|
|
1441
1419
|
setupAdEventListeners();
|
|
1442
1420
|
adVolume2 = originalMutedState ? 1 : originalVolume;
|
|
@@ -1675,7 +1653,6 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1675
1653
|
];
|
|
1676
1654
|
contentVideo.style.visibility = "visible";
|
|
1677
1655
|
contentVideo.style.opacity = "1";
|
|
1678
|
-
applyContentVideoAdCoverStyles();
|
|
1679
1656
|
emit("content_pause");
|
|
1680
1657
|
setupAdEventListeners();
|
|
1681
1658
|
adVolume2 = originalMutedState ? 1 : originalVolume;
|
|
@@ -1826,7 +1803,6 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1826
1803
|
if (debug) console.log("".concat(LOG, " Stopping ad"));
|
|
1827
1804
|
adPlaying = false;
|
|
1828
1805
|
setAdPlayingFlag(false);
|
|
1829
|
-
restoreContentVideoStyles();
|
|
1830
1806
|
contentVideo.muted = originalMutedState;
|
|
1831
1807
|
contentVideo.volume = originalMutedState ? 0 : originalVolume;
|
|
1832
1808
|
contentVideo.style.visibility = "visible";
|
|
@@ -1865,7 +1841,6 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1865
1841
|
destroyed = true;
|
|
1866
1842
|
adPlaying = false;
|
|
1867
1843
|
setAdPlayingFlag(false);
|
|
1868
|
-
restoreContentVideoStyles();
|
|
1869
1844
|
contentVideo.muted = originalMutedState;
|
|
1870
1845
|
contentVideo.volume = originalVolume;
|
|
1871
1846
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
@@ -2218,24 +2193,30 @@ function getBrowserID(clientInfo) {
|
|
|
2218
2193
|
});
|
|
2219
2194
|
})();
|
|
2220
2195
|
}
|
|
2221
|
-
var
|
|
2196
|
+
var PLAYER_TRACKING_BASE_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking";
|
|
2197
|
+
var TRACK_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/metrics/ingest");
|
|
2198
|
+
var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
|
|
2199
|
+
var IMPRESSIONS_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/impressions/ingest");
|
|
2200
|
+
function buildHeaders(licenseKey) {
|
|
2201
|
+
var headers = {
|
|
2202
|
+
"Content-Type": "application/json"
|
|
2203
|
+
};
|
|
2204
|
+
if (licenseKey) {
|
|
2205
|
+
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2206
|
+
}
|
|
2207
|
+
return headers;
|
|
2208
|
+
}
|
|
2222
2209
|
function sendTrackRequest(licenseKey, body) {
|
|
2223
2210
|
return _async_to_generator(function() {
|
|
2224
|
-
var
|
|
2211
|
+
var response;
|
|
2225
2212
|
return _ts_generator(this, function(_state) {
|
|
2226
2213
|
switch(_state.label){
|
|
2227
2214
|
case 0:
|
|
2228
|
-
headers = {
|
|
2229
|
-
"Content-Type": "application/json"
|
|
2230
|
-
};
|
|
2231
|
-
if (licenseKey) {
|
|
2232
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2233
|
-
}
|
|
2234
2215
|
return [
|
|
2235
2216
|
4,
|
|
2236
2217
|
fetch(TRACK_URL, {
|
|
2237
2218
|
method: "POST",
|
|
2238
|
-
headers:
|
|
2219
|
+
headers: buildHeaders(licenseKey),
|
|
2239
2220
|
body: JSON.stringify(body)
|
|
2240
2221
|
})
|
|
2241
2222
|
];
|
|
@@ -2257,14 +2238,86 @@ function sendTrackRequest(licenseKey, body) {
|
|
|
2257
2238
|
});
|
|
2258
2239
|
})();
|
|
2259
2240
|
}
|
|
2260
|
-
function
|
|
2241
|
+
function postJson(url, licenseKey, body) {
|
|
2261
2242
|
return _async_to_generator(function() {
|
|
2262
|
-
var
|
|
2243
|
+
var response;
|
|
2244
|
+
return _ts_generator(this, function(_state) {
|
|
2245
|
+
switch(_state.label){
|
|
2246
|
+
case 0:
|
|
2247
|
+
return [
|
|
2248
|
+
4,
|
|
2249
|
+
fetch(url, {
|
|
2250
|
+
method: "POST",
|
|
2251
|
+
headers: buildHeaders(licenseKey),
|
|
2252
|
+
body: JSON.stringify(body)
|
|
2253
|
+
})
|
|
2254
|
+
];
|
|
2255
|
+
case 1:
|
|
2256
|
+
response = _state.sent();
|
|
2257
|
+
if (!response.ok) {
|
|
2258
|
+
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2259
|
+
}
|
|
2260
|
+
return [
|
|
2261
|
+
4,
|
|
2262
|
+
response.json()
|
|
2263
|
+
];
|
|
2264
|
+
case 2:
|
|
2265
|
+
_state.sent();
|
|
2266
|
+
return [
|
|
2267
|
+
2
|
|
2268
|
+
];
|
|
2269
|
+
}
|
|
2270
|
+
});
|
|
2271
|
+
})();
|
|
2272
|
+
}
|
|
2273
|
+
function buildPlayerMetricEvent(_0) {
|
|
2274
|
+
return _async_to_generator(function(licenseKey) {
|
|
2275
|
+
var context, flags, _flags_captureAt, clientInfo, browserId, captureAt;
|
|
2276
|
+
var _arguments = arguments;
|
|
2277
|
+
return _ts_generator(this, function(_state) {
|
|
2278
|
+
switch(_state.label){
|
|
2279
|
+
case 0:
|
|
2280
|
+
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2281
|
+
clientInfo = getClientInfo();
|
|
2282
|
+
return [
|
|
2283
|
+
4,
|
|
2284
|
+
getBrowserID(clientInfo)
|
|
2285
|
+
];
|
|
2286
|
+
case 1:
|
|
2287
|
+
browserId = _state.sent();
|
|
2288
|
+
captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
|
|
2289
|
+
return [
|
|
2290
|
+
2,
|
|
2291
|
+
{
|
|
2292
|
+
player_id: browserId,
|
|
2293
|
+
browserId: browserId,
|
|
2294
|
+
device_type: clientInfo.deviceType,
|
|
2295
|
+
deviceType: clientInfo.deviceType,
|
|
2296
|
+
input_stream_type: context.inputStreamType,
|
|
2297
|
+
os: clientInfo.os,
|
|
2298
|
+
ad_loaded: flags.adLoaded,
|
|
2299
|
+
ad_detect: flags.adDetect,
|
|
2300
|
+
license_key: licenseKey,
|
|
2301
|
+
capture_at: captureAt,
|
|
2302
|
+
timestamp: captureAt
|
|
2303
|
+
}
|
|
2304
|
+
];
|
|
2305
|
+
}
|
|
2306
|
+
});
|
|
2307
|
+
}).apply(this, arguments);
|
|
2308
|
+
}
|
|
2309
|
+
function sendInitialTracking(_0) {
|
|
2310
|
+
return _async_to_generator(function(licenseKey) {
|
|
2311
|
+
var context, clientInfo, browserId, trackingData, error;
|
|
2312
|
+
var _arguments = arguments;
|
|
2263
2313
|
return _ts_generator(this, function(_state) {
|
|
2264
2314
|
switch(_state.label){
|
|
2265
2315
|
case 0:
|
|
2316
|
+
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2317
|
+
_state.label = 1;
|
|
2318
|
+
case 1:
|
|
2266
2319
|
_state.trys.push([
|
|
2267
|
-
|
|
2320
|
+
1,
|
|
2268
2321
|
4,
|
|
2269
2322
|
,
|
|
2270
2323
|
5
|
|
@@ -2274,34 +2327,29 @@ function sendInitialTracking(licenseKey) {
|
|
|
2274
2327
|
4,
|
|
2275
2328
|
getBrowserID(clientInfo)
|
|
2276
2329
|
];
|
|
2277
|
-
case
|
|
2330
|
+
case 2:
|
|
2278
2331
|
browserId = _state.sent();
|
|
2279
2332
|
trackingData = _object_spread({
|
|
2280
2333
|
browserId: browserId
|
|
2281
2334
|
}, clientInfo);
|
|
2282
|
-
headers = {
|
|
2283
|
-
"Content-Type": "application/json"
|
|
2284
|
-
};
|
|
2285
|
-
if (licenseKey) {
|
|
2286
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2287
|
-
}
|
|
2288
2335
|
return [
|
|
2289
2336
|
4,
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2337
|
+
sendTrackRequest(licenseKey, {
|
|
2338
|
+
events: [
|
|
2339
|
+
{
|
|
2340
|
+
player_id: browserId,
|
|
2341
|
+
device_type: clientInfo.deviceType,
|
|
2342
|
+
input_stream_type: context.inputStreamType,
|
|
2343
|
+
os: clientInfo.os,
|
|
2344
|
+
ad_loaded: false,
|
|
2345
|
+
ad_detect: false,
|
|
2346
|
+
license_key: licenseKey,
|
|
2347
|
+
capture_at: /* @__PURE__ */ new Date().toISOString()
|
|
2348
|
+
}
|
|
2349
|
+
],
|
|
2350
|
+
trackingData: trackingData
|
|
2294
2351
|
})
|
|
2295
2352
|
];
|
|
2296
|
-
case 2:
|
|
2297
|
-
response = _state.sent();
|
|
2298
|
-
if (!response.ok) {
|
|
2299
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2300
|
-
}
|
|
2301
|
-
return [
|
|
2302
|
-
4,
|
|
2303
|
-
response.json()
|
|
2304
|
-
];
|
|
2305
2353
|
case 3:
|
|
2306
2354
|
_state.sent();
|
|
2307
2355
|
return [
|
|
@@ -2321,36 +2369,30 @@ function sendInitialTracking(licenseKey) {
|
|
|
2321
2369
|
];
|
|
2322
2370
|
}
|
|
2323
2371
|
});
|
|
2324
|
-
})();
|
|
2372
|
+
}).apply(this, arguments);
|
|
2325
2373
|
}
|
|
2326
|
-
function sendAdDetectTracking(
|
|
2327
|
-
return _async_to_generator(function() {
|
|
2328
|
-
var
|
|
2374
|
+
function sendAdDetectTracking(_0, _1) {
|
|
2375
|
+
return _async_to_generator(function(licenseKey, adDetectInfo) {
|
|
2376
|
+
var context, error;
|
|
2377
|
+
var _arguments = arguments;
|
|
2329
2378
|
return _ts_generator(this, function(_state) {
|
|
2330
2379
|
switch(_state.label){
|
|
2331
2380
|
case 0:
|
|
2381
|
+
context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2382
|
+
_state.label = 1;
|
|
2383
|
+
case 1:
|
|
2332
2384
|
_state.trys.push([
|
|
2333
|
-
|
|
2385
|
+
1,
|
|
2334
2386
|
3,
|
|
2335
2387
|
,
|
|
2336
2388
|
4
|
|
2337
2389
|
]);
|
|
2338
|
-
clientInfo = getClientInfo();
|
|
2339
2390
|
return [
|
|
2340
2391
|
4,
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
trackingData = _object_spread({
|
|
2346
|
-
browserId: browserId
|
|
2347
|
-
}, clientInfo);
|
|
2348
|
-
return [
|
|
2349
|
-
4,
|
|
2350
|
-
sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
|
|
2351
|
-
licenseKey: licenseKey,
|
|
2352
|
-
adDetectInfo: adDetectInfo
|
|
2353
|
-
}))
|
|
2392
|
+
sendHeartbeat(licenseKey, context, {
|
|
2393
|
+
adDetect: true,
|
|
2394
|
+
captureAt: adDetectInfo.timestamp
|
|
2395
|
+
})
|
|
2354
2396
|
];
|
|
2355
2397
|
case 2:
|
|
2356
2398
|
_state.sent();
|
|
@@ -2371,36 +2413,30 @@ function sendAdDetectTracking(licenseKey, adDetectInfo) {
|
|
|
2371
2413
|
];
|
|
2372
2414
|
}
|
|
2373
2415
|
});
|
|
2374
|
-
})();
|
|
2416
|
+
}).apply(this, arguments);
|
|
2375
2417
|
}
|
|
2376
|
-
function sendAdLoadedTracking(
|
|
2377
|
-
return _async_to_generator(function() {
|
|
2378
|
-
var
|
|
2418
|
+
function sendAdLoadedTracking(_0, _1) {
|
|
2419
|
+
return _async_to_generator(function(licenseKey, adLoadedInfo) {
|
|
2420
|
+
var context, error;
|
|
2421
|
+
var _arguments = arguments;
|
|
2379
2422
|
return _ts_generator(this, function(_state) {
|
|
2380
2423
|
switch(_state.label){
|
|
2381
2424
|
case 0:
|
|
2425
|
+
context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2426
|
+
_state.label = 1;
|
|
2427
|
+
case 1:
|
|
2382
2428
|
_state.trys.push([
|
|
2383
|
-
|
|
2429
|
+
1,
|
|
2384
2430
|
3,
|
|
2385
2431
|
,
|
|
2386
2432
|
4
|
|
2387
2433
|
]);
|
|
2388
|
-
clientInfo = getClientInfo();
|
|
2389
|
-
return [
|
|
2390
|
-
4,
|
|
2391
|
-
getBrowserID(clientInfo)
|
|
2392
|
-
];
|
|
2393
|
-
case 1:
|
|
2394
|
-
browserId = _state.sent();
|
|
2395
|
-
trackingData = _object_spread({
|
|
2396
|
-
browserId: browserId
|
|
2397
|
-
}, clientInfo);
|
|
2398
2434
|
return [
|
|
2399
2435
|
4,
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
})
|
|
2436
|
+
sendHeartbeat(licenseKey, context, {
|
|
2437
|
+
adLoaded: true,
|
|
2438
|
+
captureAt: adLoadedInfo.timestamp
|
|
2439
|
+
})
|
|
2404
2440
|
];
|
|
2405
2441
|
case 2:
|
|
2406
2442
|
_state.sent();
|
|
@@ -2421,103 +2457,95 @@ function sendAdLoadedTracking(licenseKey, adLoadedInfo) {
|
|
|
2421
2457
|
];
|
|
2422
2458
|
}
|
|
2423
2459
|
});
|
|
2424
|
-
})();
|
|
2460
|
+
}).apply(this, arguments);
|
|
2425
2461
|
}
|
|
2426
|
-
function sendAdImpressionTracking(
|
|
2427
|
-
return _async_to_generator(function() {
|
|
2428
|
-
var
|
|
2462
|
+
function sendAdImpressionTracking(_0, _1) {
|
|
2463
|
+
return _async_to_generator(function(licenseKey, adImpressionInfo) {
|
|
2464
|
+
var context, metricEvent, error;
|
|
2465
|
+
var _arguments = arguments;
|
|
2429
2466
|
return _ts_generator(this, function(_state) {
|
|
2430
2467
|
switch(_state.label){
|
|
2431
2468
|
case 0:
|
|
2469
|
+
context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2470
|
+
_state.label = 1;
|
|
2471
|
+
case 1:
|
|
2432
2472
|
_state.trys.push([
|
|
2433
|
-
|
|
2434
|
-
|
|
2473
|
+
1,
|
|
2474
|
+
4,
|
|
2435
2475
|
,
|
|
2436
|
-
|
|
2476
|
+
5
|
|
2437
2477
|
]);
|
|
2438
|
-
clientInfo = getClientInfo();
|
|
2439
2478
|
return [
|
|
2440
2479
|
4,
|
|
2441
|
-
|
|
2480
|
+
buildPlayerMetricEvent(licenseKey, context, {
|
|
2481
|
+
captureAt: adImpressionInfo.timestamp
|
|
2482
|
+
})
|
|
2442
2483
|
];
|
|
2443
|
-
case
|
|
2444
|
-
|
|
2445
|
-
trackingData = _object_spread({
|
|
2446
|
-
browserId: browserId
|
|
2447
|
-
}, clientInfo);
|
|
2484
|
+
case 2:
|
|
2485
|
+
metricEvent = _state.sent();
|
|
2448
2486
|
return [
|
|
2449
2487
|
4,
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2488
|
+
Promise.all([
|
|
2489
|
+
postJson(HEARTBEAT_URL, licenseKey, metricEvent),
|
|
2490
|
+
postJson(IMPRESSIONS_URL, licenseKey, {
|
|
2491
|
+
events: [
|
|
2492
|
+
{
|
|
2493
|
+
player_id: metricEvent.player_id,
|
|
2494
|
+
ad_played_count: 1,
|
|
2495
|
+
ad_url: adImpressionInfo.adUrl,
|
|
2496
|
+
license_key: licenseKey,
|
|
2497
|
+
capture_at: adImpressionInfo.timestamp
|
|
2498
|
+
}
|
|
2499
|
+
]
|
|
2500
|
+
})
|
|
2501
|
+
])
|
|
2454
2502
|
];
|
|
2455
|
-
case
|
|
2503
|
+
case 3:
|
|
2456
2504
|
_state.sent();
|
|
2457
2505
|
return [
|
|
2458
2506
|
3,
|
|
2459
|
-
|
|
2507
|
+
5
|
|
2460
2508
|
];
|
|
2461
|
-
case
|
|
2509
|
+
case 4:
|
|
2462
2510
|
error = _state.sent();
|
|
2463
2511
|
console.error("[StormcloudVideoPlayer] Error sending ad impression tracking:", error);
|
|
2464
2512
|
return [
|
|
2465
2513
|
3,
|
|
2466
|
-
|
|
2514
|
+
5
|
|
2467
2515
|
];
|
|
2468
|
-
case
|
|
2516
|
+
case 5:
|
|
2469
2517
|
return [
|
|
2470
2518
|
2
|
|
2471
2519
|
];
|
|
2472
2520
|
}
|
|
2473
2521
|
});
|
|
2474
|
-
})();
|
|
2522
|
+
}).apply(this, arguments);
|
|
2475
2523
|
}
|
|
2476
|
-
function sendHeartbeat(
|
|
2477
|
-
return _async_to_generator(function() {
|
|
2478
|
-
var
|
|
2524
|
+
function sendHeartbeat(_0) {
|
|
2525
|
+
return _async_to_generator(function(licenseKey) {
|
|
2526
|
+
var context, flags, heartbeatData, error;
|
|
2527
|
+
var _arguments = arguments;
|
|
2479
2528
|
return _ts_generator(this, function(_state) {
|
|
2480
2529
|
switch(_state.label){
|
|
2481
2530
|
case 0:
|
|
2531
|
+
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2532
|
+
_state.label = 1;
|
|
2533
|
+
case 1:
|
|
2482
2534
|
_state.trys.push([
|
|
2483
|
-
|
|
2535
|
+
1,
|
|
2484
2536
|
4,
|
|
2485
2537
|
,
|
|
2486
2538
|
5
|
|
2487
2539
|
]);
|
|
2488
|
-
clientInfo = getClientInfo();
|
|
2489
2540
|
return [
|
|
2490
2541
|
4,
|
|
2491
|
-
|
|
2492
|
-
];
|
|
2493
|
-
case 1:
|
|
2494
|
-
browserId = _state.sent();
|
|
2495
|
-
heartbeatData = {
|
|
2496
|
-
browserId: browserId,
|
|
2497
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
2498
|
-
};
|
|
2499
|
-
headers = {
|
|
2500
|
-
"Content-Type": "application/json"
|
|
2501
|
-
};
|
|
2502
|
-
if (licenseKey) {
|
|
2503
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2504
|
-
}
|
|
2505
|
-
return [
|
|
2506
|
-
4,
|
|
2507
|
-
fetch("https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/heartbeat", {
|
|
2508
|
-
method: "POST",
|
|
2509
|
-
headers: headers,
|
|
2510
|
-
body: JSON.stringify(heartbeatData)
|
|
2511
|
-
})
|
|
2542
|
+
buildPlayerMetricEvent(licenseKey, context, flags)
|
|
2512
2543
|
];
|
|
2513
2544
|
case 2:
|
|
2514
|
-
|
|
2515
|
-
if (!response.ok) {
|
|
2516
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2517
|
-
}
|
|
2545
|
+
heartbeatData = _state.sent();
|
|
2518
2546
|
return [
|
|
2519
2547
|
4,
|
|
2520
|
-
|
|
2548
|
+
postJson(HEARTBEAT_URL, licenseKey, heartbeatData)
|
|
2521
2549
|
];
|
|
2522
2550
|
case 3:
|
|
2523
2551
|
_state.sent();
|
|
@@ -2538,7 +2566,7 @@ function sendHeartbeat(licenseKey) {
|
|
|
2538
2566
|
];
|
|
2539
2567
|
}
|
|
2540
2568
|
});
|
|
2541
|
-
})();
|
|
2569
|
+
}).apply(this, arguments);
|
|
2542
2570
|
}
|
|
2543
2571
|
// src/utils/polyfills.ts
|
|
2544
2572
|
function polyfillURLSearchParams() {
|
|
@@ -3553,17 +3581,62 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3553
3581
|
return "vast";
|
|
3554
3582
|
}
|
|
3555
3583
|
},
|
|
3584
|
+
{
|
|
3585
|
+
key: "getInputStreamType",
|
|
3586
|
+
value: function getInputStreamType() {
|
|
3587
|
+
var src = this.config.src.toLowerCase();
|
|
3588
|
+
if (src.includes(".m3u8")) return "hls";
|
|
3589
|
+
if (src.includes(".mpd")) return "dash";
|
|
3590
|
+
if (src.includes(".mp4")) return "mp4";
|
|
3591
|
+
return this.isLiveStream ? "live" : "vod";
|
|
3592
|
+
}
|
|
3593
|
+
},
|
|
3594
|
+
{
|
|
3595
|
+
key: "getAnalyticsContext",
|
|
3596
|
+
value: function getAnalyticsContext() {
|
|
3597
|
+
return {
|
|
3598
|
+
inputStreamType: this.getInputStreamType()
|
|
3599
|
+
};
|
|
3600
|
+
}
|
|
3601
|
+
},
|
|
3602
|
+
{
|
|
3603
|
+
key: "getAdUrlFromBids",
|
|
3604
|
+
value: function getAdUrlFromBids(bids) {
|
|
3605
|
+
var _bids_;
|
|
3606
|
+
return bids === null || bids === void 0 ? void 0 : (_bids_ = bids[0]) === null || _bids_ === void 0 ? void 0 : _bids_.vastUrl;
|
|
3607
|
+
}
|
|
3608
|
+
},
|
|
3609
|
+
{
|
|
3610
|
+
key: "trackAdLoaded",
|
|
3611
|
+
value: function trackAdLoaded(bids) {
|
|
3612
|
+
if (!this.config.licenseKey) return;
|
|
3613
|
+
var adUrl = this.getAdUrlFromBids(bids);
|
|
3614
|
+
if (adUrl) {
|
|
3615
|
+
this.lastServedAdUrl = adUrl;
|
|
3616
|
+
}
|
|
3617
|
+
sendAdLoadedTracking(this.config.licenseKey, _object_spread_props(_object_spread({
|
|
3618
|
+
source: this.getAdSource()
|
|
3619
|
+
}, adUrl ? {
|
|
3620
|
+
vastUrl: adUrl
|
|
3621
|
+
} : {}), {
|
|
3622
|
+
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
3623
|
+
}), this.getAnalyticsContext());
|
|
3624
|
+
}
|
|
3625
|
+
},
|
|
3556
3626
|
{
|
|
3557
3627
|
key: "attachAdLayerEventListeners",
|
|
3558
3628
|
value: function attachAdLayerEventListeners() {
|
|
3559
3629
|
var _this = this;
|
|
3560
3630
|
this.adLayer.on("ad_impression", function() {
|
|
3561
3631
|
if (_this.config.licenseKey) {
|
|
3562
|
-
sendAdImpressionTracking(_this.config.licenseKey, {
|
|
3632
|
+
sendAdImpressionTracking(_this.config.licenseKey, _object_spread_props(_object_spread({
|
|
3563
3633
|
source: _this.getAdSource(),
|
|
3564
|
-
adIndex: _this.currentAdIndex
|
|
3634
|
+
adIndex: _this.currentAdIndex
|
|
3635
|
+
}, _this.lastServedAdUrl ? {
|
|
3636
|
+
adUrl: _this.lastServedAdUrl
|
|
3637
|
+
} : {}), {
|
|
3565
3638
|
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
3566
|
-
});
|
|
3639
|
+
}), _this.getAnalyticsContext());
|
|
3567
3640
|
}
|
|
3568
3641
|
});
|
|
3569
3642
|
this.adLayer.on("ad_error", function(errorPayload) {
|
|
@@ -3657,6 +3730,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3657
3730
|
_this.isInAdTransition = false;
|
|
3658
3731
|
if (!_this.inAdBreak) return;
|
|
3659
3732
|
_this.currentAdIndex++;
|
|
3733
|
+
_this.trackAdLoaded();
|
|
3660
3734
|
_this.adLayer.playPreloaded(token).catch(function(err) {
|
|
3661
3735
|
if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playPreloaded failed:", err);
|
|
3662
3736
|
_this.handleAdFailure();
|
|
@@ -3686,6 +3760,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3686
3760
|
var freshBids = (_this_pendingNextAdBids = _this.pendingNextAdBids) !== null && _this_pendingNextAdBids !== void 0 ? _this_pendingNextAdBids : bids;
|
|
3687
3761
|
_this.pendingNextAdBids = null;
|
|
3688
3762
|
_this.currentAdIndex++;
|
|
3763
|
+
_this.trackAdLoaded(freshBids);
|
|
3689
3764
|
_this.adLayer.playAd(freshBids).catch(function(err) {
|
|
3690
3765
|
if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playAd(pending) failed:", err);
|
|
3691
3766
|
_this.handleAdFailure();
|
|
@@ -4065,7 +4140,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4065
4140
|
}, ((_this_pendingAdBreak1 = this.pendingAdBreak) === null || _this_pendingAdBreak1 === void 0 ? void 0 : _this_pendingAdBreak1.detectedAtFragmentSn) != null && {
|
|
4066
4141
|
detectedAtFragmentSn: this.pendingAdBreak.detectedAtFragmentSn
|
|
4067
4142
|
});
|
|
4068
|
-
sendAdDetectTracking(this.config.licenseKey, adDetectInfo);
|
|
4143
|
+
sendAdDetectTracking(this.config.licenseKey, adDetectInfo, this.getAnalyticsContext());
|
|
4069
4144
|
}
|
|
4070
4145
|
var isManifestMarker = this.isManifestBasedMarker(marker);
|
|
4071
4146
|
var forceImmediate = (_this_config_immediateManifestAds = this.config.immediateManifestAds) !== null && _this_config_immediateManifestAds !== void 0 ? _this_config_immediateManifestAds : true;
|
|
@@ -4134,6 +4209,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4134
4209
|
var bids = this.pendingNextAdBids;
|
|
4135
4210
|
this.pendingNextAdBids = null;
|
|
4136
4211
|
this.currentAdIndex++;
|
|
4212
|
+
this.trackAdLoaded(bids);
|
|
4137
4213
|
this.adLayer.playAd(bids).catch(function() {
|
|
4138
4214
|
return _this.handleAdFailure();
|
|
4139
4215
|
});
|
|
@@ -4388,7 +4464,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4388
4464
|
key: "initializeTracking",
|
|
4389
4465
|
value: function initializeTracking() {
|
|
4390
4466
|
var _this = this;
|
|
4391
|
-
sendInitialTracking(this.config.licenseKey).then(function() {
|
|
4467
|
+
sendInitialTracking(this.config.licenseKey, this.getAnalyticsContext()).then(function() {
|
|
4392
4468
|
_this.heartbeatInterval = window.setInterval(function() {
|
|
4393
4469
|
_this.sendHeartbeatIfNeeded();
|
|
4394
4470
|
}, 5e3);
|
|
@@ -4409,7 +4485,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4409
4485
|
var now = Date.now();
|
|
4410
4486
|
if (!this.lastHeartbeatTime || now - this.lastHeartbeatTime > 3e4) {
|
|
4411
4487
|
this.lastHeartbeatTime = now;
|
|
4412
|
-
sendHeartbeat(this.config.licenseKey).catch(function(error) {
|
|
4488
|
+
sendHeartbeat(this.config.licenseKey, this.getAnalyticsContext()).catch(function(error) {
|
|
4413
4489
|
if (_this.config.debugAdTiming) {
|
|
4414
4490
|
console.warn("[StormcloudVideoPlayer] Failed to send heartbeat:", error);
|
|
4415
4491
|
}
|
|
@@ -4802,12 +4878,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4802
4878
|
10
|
|
4803
4879
|
];
|
|
4804
4880
|
_this.currentAdIndex++;
|
|
4805
|
-
|
|
4806
|
-
sendAdLoadedTracking(_this.config.licenseKey, {
|
|
4807
|
-
source: _this.getAdSource(),
|
|
4808
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
4809
|
-
});
|
|
4810
|
-
}
|
|
4881
|
+
_this.trackAdLoaded(bids1);
|
|
4811
4882
|
return [
|
|
4812
4883
|
4,
|
|
4813
4884
|
_this.adLayer.playAd(bids1)
|
|
@@ -4912,12 +4983,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4912
4983
|
];
|
|
4913
4984
|
case 18:
|
|
4914
4985
|
_this.currentAdIndex++;
|
|
4915
|
-
|
|
4916
|
-
sendAdLoadedTracking(_this.config.licenseKey, {
|
|
4917
|
-
source: _this.getAdSource(),
|
|
4918
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
4919
|
-
});
|
|
4920
|
-
}
|
|
4986
|
+
_this.trackAdLoaded(bids2);
|
|
4921
4987
|
return [
|
|
4922
4988
|
4,
|
|
4923
4989
|
_this.adLayer.playAd(bids2)
|
|
@@ -5076,12 +5142,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5076
5142
|
6
|
|
5077
5143
|
];
|
|
5078
5144
|
this.currentAdIndex++;
|
|
5079
|
-
|
|
5080
|
-
sendAdLoadedTracking(this.config.licenseKey, {
|
|
5081
|
-
source: this.getAdSource(),
|
|
5082
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
5083
|
-
});
|
|
5084
|
-
}
|
|
5145
|
+
this.trackAdLoaded();
|
|
5085
5146
|
_state.label = 1;
|
|
5086
5147
|
case 1:
|
|
5087
5148
|
_state.trys.push([
|
|
@@ -5275,12 +5336,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5275
5336
|
5
|
|
5276
5337
|
];
|
|
5277
5338
|
case 3:
|
|
5278
|
-
|
|
5279
|
-
sendAdLoadedTracking(this.config.licenseKey, {
|
|
5280
|
-
source: this.getAdSource(),
|
|
5281
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
5282
|
-
});
|
|
5283
|
-
}
|
|
5339
|
+
this.trackAdLoaded(bids);
|
|
5284
5340
|
return [
|
|
5285
5341
|
4,
|
|
5286
5342
|
this.adLayer.playAd(bids)
|
|
@@ -5426,6 +5482,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5426
5482
|
,
|
|
5427
5483
|
7
|
|
5428
5484
|
]);
|
|
5485
|
+
this.trackAdLoaded(bids);
|
|
5429
5486
|
return [
|
|
5430
5487
|
4,
|
|
5431
5488
|
this.adLayer.playAd(bids)
|