decord/alpha/source/modules/analytics_sessions/SessionAdManager.tsx

175 lines
7.5 KiB
TypeScript
Raw Permalink Normal View History

2026-10-13 12:43:34 +00:00
// Module ID: 15138
// Function ID: 15139
// Name: SessionAdManager
2026-10-12 06:59:38 +00:00
// Dependencies: [502, 1085, 2002, 7185, 2060, 584, 1102, 1255, 7410, 1265, 2]
2026-07-20 16:05:17 +00:00
2026-10-13 12:43:34 +00:00
// Module 15138 (SessionAdManager)
2026-10-03 08:58:59 +00:00
import DispatcherDefault from "Dispatcher" /* 584 */;
import DurationsDefault from "Durations" /* 1102 */;
2026-10-09 10:00:15 +00:00
import SentryUtilsDefault from "SentryUtils" /* 1255 */;
import AnalyticsUtilsDefault from "AnalyticsUtils" /* 1265 */;
2026-10-10 08:08:14 +00:00
import Timers from "Timers" /* 2060 */;
2026-10-12 06:59:38 +00:00
import react_native from "react-native" /* 7185 */;
import SessionAdGenerator from "SessionAdGenerator" /* 7410 */;
import AuthenticationStore from "AuthenticationStore" /* 502 */;
2026-10-03 08:58:59 +00:00
import Constants from "Constants" /* 1085 */;
2026-10-09 10:00:15 +00:00
import LifecycleManager from "LifecycleManager" /* 2002 */;
2026-10-03 08:58:59 +00:00
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-10-03 08:58:59 +00:00
let closure_4;
let hasOwnProperty;
({ AnalyticEvents: closure_4, AppStates: hasOwnProperty } = Constants);
2026-07-29 08:29:29 +00:00
const ad = "ad";
let token = AuthenticationStore.getToken();
2026-07-29 08:29:29 +00:00
let closure_8 = { DEFAULT: "DEFAULT", USER_LOGOUT: "USER_LOGOUT", WINDOW_FOCUS: "WINDOW_FOCUS", APP_STATE_UPDATE: "APP_STATE_UPDATE" };
2026-10-03 08:58:59 +00:00
class SessionAdManager extends LifecycleManager {
2026-07-29 08:29:29 +00:00
constructor() {
2026-10-03 08:58:59 +00:00
const applyArgumentsResult = HermesBuiltin.applyArguments(this, new.target);
require = applyArgumentsResult;
let obj = react_native;
2026-07-29 08:29:29 +00:00
applyArgumentsResult.focusedOrForegrounded = obj.isForegrounded();
2026-10-03 08:58:59 +00:00
const interval = new Timers.Interval();
2026-07-29 08:29:29 +00:00
applyArgumentsResult.heartbeatInterval = interval;
applyArgumentsResult.schedulerStarted = false;
applyArgumentsResult.lastHeartbeatTimestamp = 0;
applyArgumentsResult.maybeStartHeartbeat = function maybeStartHeartbeat() {
2026-10-03 08:58:59 +00:00
const heartbeatInterval = require.heartbeatInterval;
2026-07-29 08:29:29 +00:00
if (!heartbeatInterval.isStarted()) {
2026-10-03 08:58:59 +00:00
require.trackHeartbeat();
2026-07-29 08:29:29 +00:00
const heartbeatInterval2 = obj.heartbeatInterval;
2026-10-03 08:58:59 +00:00
heartbeatInterval2.start(5 * DurationsDefault.Millis.MINUTE, require.trackHeartbeat);
2026-07-29 08:29:29 +00:00
}
};
applyArgumentsResult.startAnalyticHeartbeat = function startAnalyticHeartbeat() {
2026-10-03 08:58:59 +00:00
if (!require.schedulerStarted) {
require.schedulerStarted = true;
const obj3 = { category: ad, message: "Starting ad session heartbeat" };
2026-10-03 08:58:59 +00:00
const obj2 = SentryUtilsDefault;
obj2.addBreadcrumb(obj3);
require.maybeStartHeartbeat();
2026-07-29 08:29:29 +00:00
}
};
applyArgumentsResult.trackHeartbeat = function trackHeartbeat() {
let flag = arg0;
if (arg0 === undefined) {
flag = false;
}
2026-10-03 08:58:59 +00:00
if (!require.schedulerStarted) {
2026-07-29 08:29:29 +00:00
if (!flag) {
const obj2 = { category: ad, message: "Ad heartbeat called but scheduler not started" };
2026-10-03 08:58:59 +00:00
const obj = SentryUtilsDefault;
obj.addBreadcrumb(obj2);
2026-07-29 08:29:29 +00:00
const heartbeatInterval = tmp.heartbeatInterval;
heartbeatInterval.stop();
}
}
const nowResult = performance.now();
const diff = nowResult - tmp.lastHeartbeatTimestamp;
2026-10-03 08:58:59 +00:00
const obj3 = SessionAdGenerator;
const orRefreshAdSession = obj3.getOrRefreshAdSession();
const obj4 = AnalyticsUtilsDefault;
const obj5 = { client_ad_session_id: orRefreshAdSession.uuid, client_heartbeat_initialization_timestamp: orRefreshAdSession.createdAtTimestamp, client_heartbeat_version: 3 };
obj4.track(constants.CLIENT_AD_HEARTBEAT, obj5);
require.lastHeartbeatTimestamp = nowResult;
2026-07-29 08:29:29 +00:00
};
applyArgumentsResult.stopAnalyticHeartbeat = function stopAnalyticHeartbeat(DEFAULT) {
if (DEFAULT === undefined) {
DEFAULT = constants.DEFAULT;
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
if (require.schedulerStarted) {
require.schedulerStarted = false;
require.lastHeartbeatTimestamp = 0;
2026-07-29 08:29:29 +00:00
const _HermesInternal = HermesInternal;
2026-10-03 08:58:59 +00:00
const obj = { category: ad, message: "Stopping ad session heartbeat: " + DEFAULT };
const addBreadcrumb = SentryUtilsDefault.addBreadcrumb;
SentryUtilsDefault;
addBreadcrumb(obj);
2026-07-29 08:29:29 +00:00
const heartbeatInterval = tmp2.heartbeatInterval;
heartbeatInterval.stop();
}
};
applyArgumentsResult.scheduleHeartbeatTracking = function scheduleHeartbeatTracking(DEFAULT) {
if (DEFAULT === undefined) {
DEFAULT = constants.DEFAULT;
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
if (require.focusedOrForegrounded) {
2026-08-24 06:08:38 +00:00
if (null != token) {
2026-07-29 08:29:29 +00:00
try {
const result = obj.startAnalyticHeartbeat();
2026-10-03 08:58:59 +00:00
} catch (tmp6) {
const obj2 = SentryUtilsDefault;
obj2.captureException(tmp6);
2026-07-29 08:29:29 +00:00
}
}
}
const result1 = obj.stopAnalyticHeartbeat(DEFAULT);
};
applyArgumentsResult.handleLogin = function handleLogin() {
2026-10-03 08:58:59 +00:00
const result = require.scheduleHeartbeatTracking();
require.trackHeartbeat(true);
2026-07-29 08:29:29 +00:00
};
applyArgumentsResult.handleLogout = function handleLogout() {
2026-10-03 08:58:59 +00:00
const result = require.stopAnalyticHeartbeat(constants.USER_LOGOUT);
const obj = SessionAdGenerator;
obj.clearAdSession();
2026-07-29 08:29:29 +00:00
};
applyArgumentsResult.handleEnrollmentSuccess = function handleEnrollmentSuccess() {
2026-10-03 08:58:59 +00:00
const obj = SessionAdGenerator;
const orRefreshAdSession = obj.getOrRefreshAdSession(true);
2026-07-29 08:29:29 +00:00
};
applyArgumentsResult.handleWindowFocus = function handleWindowFocus(focused) {
2026-10-03 08:58:59 +00:00
require.focusedOrForegrounded = focused.focused;
const result = require.scheduleHeartbeatTracking(constants.WINDOW_FOCUS);
2026-07-29 08:29:29 +00:00
};
applyArgumentsResult.handleAppStateUpdate = function handleAppStateUpdate(state) {
2026-10-03 08:58:59 +00:00
require.focusedOrForegrounded = state.state === hasOwnProperty.ACTIVE;
const result = require.scheduleHeartbeatTracking(constants.APP_STATE_UPDATE);
2026-07-29 08:29:29 +00:00
};
applyArgumentsResult.handleAuthenticationChange = function handleAuthenticationChange() {
token = AuthenticationStore.getToken();
2026-08-24 06:08:38 +00:00
if (token !== token) {
2026-10-03 08:58:59 +00:00
const obj = SessionAdGenerator;
obj.clearAdSession();
const result = require.stopAnalyticHeartbeat();
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
const result1 = require.scheduleHeartbeatTracking();
2026-07-29 08:29:29 +00:00
};
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
_initialize() {
const obj = react_native;
this.focusedOrForegrounded = obj.isForegrounded();
AuthenticationStore.addChangeListener(this.handleAuthenticationChange);
const obj2 = DispatcherDefault;
const subscription = obj2.subscribe("WINDOW_FOCUS", this.handleWindowFocus);
const obj3 = DispatcherDefault;
const subscription1 = obj3.subscribe("APP_STATE_UPDATE", this.handleAppStateUpdate);
const obj4 = DispatcherDefault;
const subscription2 = obj4.subscribe("QUESTS_ENROLL_SUCCESS", this.handleEnrollmentSuccess);
const obj5 = DispatcherDefault;
const subscription3 = obj5.subscribe("LOGIN_SUCCESS", this.handleLogin);
const obj6 = DispatcherDefault;
const subscription4 = obj6.subscribe("LOGOUT", this.handleLogout);
const result = this.scheduleHeartbeatTracking();
}
_terminate() {
const result = this.stopAnalyticHeartbeat();
AuthenticationStore.removeChangeListener(this.handleAuthenticationChange);
const obj = DispatcherDefault;
obj.unsubscribe("WINDOW_FOCUS", this.handleWindowFocus);
const obj2 = DispatcherDefault;
obj2.unsubscribe("APP_STATE_UPDATE", this.handleAppStateUpdate);
const obj3 = DispatcherDefault;
obj3.unsubscribe("QUESTS_ENROLL_SUCCESS", this.handleEnrollmentSuccess);
const obj4 = DispatcherDefault;
obj4.unsubscribe("LOGIN_SUCCESS", this.handleLogin);
const obj5 = DispatcherDefault;
obj5.unsubscribe("LOGOUT", this.handleLogout);
}
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const prototype = SessionAdManager.prototype;
const sessionAdManager = new SessionAdManager();
let result = size.fileFinishedImporting("modules/analytics_sessions/SessionAdManager.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default sessionAdManager;