decord/source/modules/analytics_sessions/SessionAdGenerator.tsx

72 lines
2.6 KiB
TypeScript
Raw Normal View History

// Module ID: 7721
// Function ID: 7722
2026-07-29 08:29:29 +00:00
// Name: getOrRefreshAdSession
// Dependencies: [1090, 1256, 7471, 573, 1232, 2]
2026-07-29 08:29:29 +00:00
// Exports: clearAdSession, getCurrentAdSession, getOrRefreshAdSession, isAdSessionExpired
2026-07-20 16:05:17 +00:00
// Module 7721 (getOrRefreshAdSession)
import dispatcherDefault from "dispatcher" /* 573 */;
import setDefault from "set" /* 1090 */;
import _modDef1232 from "module_1232" /* 1232 */;
import v1 from "v1" /* 1256 */;
import result2 from "result" /* 7471 */;
2026-08-24 06:08:38 +00:00
require = arg1;
let closure_3 = 12 * setDefault.Millis.HOUR;
2026-07-23 10:11:24 +00:00
let c4 = null;
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/analytics_sessions/SessionAdGenerator.tsx");
2026-07-20 16:05:17 +00:00
export const getOrRefreshAdSession = function getOrRefreshAdSession(shouldExtendSession) {
let flag = shouldExtendSession;
if (shouldExtendSession === undefined) {
flag = false;
}
const timestamp = Date.now();
2026-07-23 10:11:24 +00:00
if (null != obj) {
2026-07-29 08:29:29 +00:00
const _Date = Date;
const timestamp1 = Date.now();
if (timestamp1 < obj.createdAtTimestamp) {
obj = _modDef1232;
2026-07-29 08:29:29 +00:00
obj = { category: "ad", message: null };
const _HermesInternal = HermesInternal;
obj[1] = "future facing timestamp Date.now(): " + timestamp1 + ", initialized timestamp: " + tmp11.createdAtTimestamp;
obj.addBreadcrumb(obj);
let flag2 = true;
} else {
const diff = timestamp1 - tmp11.lastUsedTimestamp;
2026-08-24 06:08:38 +00:00
flag2 = diff > result2.SESSION_IDLE_TIMEOUT_MILLIS || timestamp1 - tmp11.createdAtTimestamp > closure_3;
2026-07-29 08:29:29 +00:00
}
if (!flag2) {
2026-07-20 16:05:17 +00:00
if (flag) {
2026-07-23 10:11:24 +00:00
obj.lastUsedTimestamp = timestamp;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let tmp9 = obj;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp9;
2026-07-20 16:05:17 +00:00
}
2026-08-24 06:08:38 +00:00
obj = { uuid: v1.v4(), createdAtTimestamp: timestamp, lastUsedTimestamp: timestamp, version: result2.CLIENT_SESSION_STORAGE_VERSION };
const obj4 = v1;
dispatcherDefault.dispatch({ type: "AD_SESSION_RESET" });
2026-07-29 08:29:29 +00:00
tmp9 = obj;
2026-07-20 16:05:17 +00:00
};
export function clearAdSession() {
2026-08-24 06:08:38 +00:00
c4 = null;
2026-07-20 16:05:17 +00:00
}
export function getCurrentAdSession() {
2026-07-23 10:11:24 +00:00
return c4;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
export const isAdSessionExpired = function isAdSessionExpired(createdAtTimestamp) {
const timestamp = Date.now();
if (timestamp < createdAtTimestamp.createdAtTimestamp) {
let obj = _modDef1232;
2026-07-29 08:29:29 +00:00
obj = { category: "ad", message: null };
const _HermesInternal = HermesInternal;
obj[1] = "future facing timestamp Date.now(): " + timestamp + ", initialized timestamp: " + createdAtTimestamp.createdAtTimestamp;
obj.addBreadcrumb(obj);
return true;
} else {
const diff = timestamp - createdAtTimestamp.lastUsedTimestamp;
2026-08-24 06:08:38 +00:00
return diff > result2.SESSION_IDLE_TIMEOUT_MILLIS || timestamp - createdAtTimestamp.createdAtTimestamp > closure_3;
2026-07-29 08:29:29 +00:00
}
};