332 lines
22 KiB
TypeScript
332 lines
22 KiB
TypeScript
/* Metro module 13090; source: modules/analytics_sessions/SessionAdManager.tsx; dependencies: [6, 7, 15, 17, 18, 1226, 661, 4876, 4041, 672, 1216, 7113, 683, 694, 4561, 2] */
|
|
import ClassCallCheck from '../../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */
|
|
import CreateClass from '../../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */
|
|
import PossibleConstructorReturn from '../../by-id/module-00015-PossibleConstructorReturn.js'; /* Metro dependency 15 */
|
|
import Module00017 from '../../by-id/module-00017.js'; /* Metro dependency 17 */
|
|
import Inherits from '../../by-id/module-00018-Inherits.js'; /* Metro dependency 18 */
|
|
import AuthenticationStore from '../../stores/AuthenticationStore.tsx'; /* Metro dependency 1226 */
|
|
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
|
|
import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */
|
|
import * as TimersModule from '../../external/discord_common/js/packages/timers/Timers.tsx'; /* Metro dependency 4041 */
|
|
import * as SessionForegroundUtilsNativeModule from './SessionForegroundUtils.native.tsx'; /* Metro dependency 4876 */
|
|
import * as SessionAdGeneratorModule from './SessionAdGenerator.tsx'; /* Metro dependency 7113 */
|
|
|
|
function _fun100027(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#100027, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13280:6, offset: 0x021dc14a, size: 338 bytes, params: 8, frame: 19
|
|
const env0_0 = require;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
let value = AuthenticationStore;
|
|
const env0_11 = value.getToken();
|
|
object = {DEFAULT: 'DEFAULT', USER_LOGOUT: 'USER_LOGOUT', WINDOW_FOCUS: 'WINDOW_FOCUS',
|
|
APP_STATE_UPDATE: 'APP_STATE_UPDATE'};
|
|
value = importDefault(4561) /* metro dependency 4561: LifecycleManager */;
|
|
value = _fun100031(value);
|
|
value = new value();
|
|
(FileImportTrackerModule).fileFinishedImporting('modules/analytics_sessions/SessionAdManager.tsx');
|
|
exports.default = value;
|
|
function _isNativeReflectConstruct_100028() { // fn#100028, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13280:201, offset: 0x021dc29c, size: 98 bytes, params: 1, frame: 18
|
|
var Boolean;
|
|
var prototype;
|
|
var valueOf;
|
|
var call;
|
|
var Reflect;
|
|
var construct;
|
|
var closure;
|
|
var value;
|
|
var error;
|
|
try {
|
|
Boolean = global.Boolean;
|
|
prototype = Boolean.prototype;
|
|
valueOf = prototype.valueOf;
|
|
call = valueOf.call;
|
|
Reflect = global.Reflect;
|
|
construct = Reflect.construct;
|
|
Boolean = global.Boolean;
|
|
closure = function() {
|
|
};
|
|
value = Reflect.apply(construct, Reflect, [Boolean, [], closure]);
|
|
value = Reflect.apply(call, valueOf, [value]);
|
|
var result = !value;
|
|
} catch (error) {
|
|
}
|
|
return (_isNativeReflectConstruct_100028_isNativeReflectConstruct = function() {
|
|
return !!result;
|
|
})();
|
|
}
|
|
|
|
function _fun100031(a0) { // fn#100031, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13280:573, offset: 0x021dc2fe, size: 97 bytes, params: 2, frame: 16
|
|
const SessionAdManager2 = SessionAdManager;
|
|
Inherits(SessionAdManager2, a0);
|
|
return CreateClass(SessionAdManager2, [{key: '_initialize', value: value_100044}, {key: '_terminate',
|
|
value: value_100045}]);
|
|
function SessionAdManager(a0) { // fn#100032, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13280:585, offset: 0x021dc35f, size: 371 bytes, params: 2, frame: 22
|
|
var r0;
|
|
var Reflect;
|
|
let value = copyRestArgs(0, undefined);
|
|
let binding = env1_3;
|
|
binding(this, SessionAdManager);
|
|
const items2 = [];
|
|
arraySpread(items2, value, 0, items2);
|
|
value = env1_6(SessionAdManager);
|
|
binding = env1_5;
|
|
if (_isNativeReflectConstruct_100028()) {
|
|
Reflect = global.Reflect;
|
|
value = Reflect.construct(value, items2, env1_6(this).constructor);
|
|
r0 = value;
|
|
} else {
|
|
value = value.apply(this, items2);
|
|
r0 = value;
|
|
}
|
|
value = binding(this, r0);
|
|
value.focusedOrForegrounded = (require(4876) /* metro dependency 4876: SessionForegroundUtilsNative */).isForegrounded();
|
|
const Interval = (TimersModule).Interval;
|
|
const value4 = Object.create(Interval.prototype, {constructor: {value: Interval}});
|
|
const interval = new Interval();
|
|
value.heartbeatInterval = interval instanceof Object ? interval : value4;
|
|
value.schedulerStarted = false;
|
|
value.lastHeartbeatTimestamp = 0;
|
|
value.maybeStartHeartbeat = maybeStartHeartbeat;
|
|
value.startAnalyticHeartbeat = startAnalyticHeartbeat;
|
|
value.trackHeartbeat = trackHeartbeat_100035;
|
|
value.stopAnalyticHeartbeat = stopAnalyticHeartbeat;
|
|
value.scheduleHeartbeatTracking = scheduleHeartbeatTracking_100037;
|
|
value.handleLogin = handleLogin_100038;
|
|
value.handleLogout = handleLogout_100039;
|
|
value.handleEnrollmentSuccess = handleEnrollmentSuccess;
|
|
value.handleWindowFocus = handleWindowFocus_100041;
|
|
value.handleAppStateUpdate = handleAppStateUpdate_100042;
|
|
value.handleAuthenticationChange = handleAuthenticationChange_100043;
|
|
return value;
|
|
function maybeStartHeartbeat() { // fn#100033, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13280:981, owner: SessionAdManager.maybeStartHeartbeat, offset: 0x021dc4d2, size: 111 bytes, params: 1, frame: 15
|
|
var binding;
|
|
var start;
|
|
var value;
|
|
let heartbeatInterval = env0_0.heartbeatInterval;
|
|
if (!heartbeatInterval.isStarted()) {
|
|
binding = env0_0;
|
|
binding.trackHeartbeat();
|
|
heartbeatInterval = binding.heartbeatInterval;
|
|
start = heartbeatInterval.start;
|
|
value = environment.__proto__.__proto__;
|
|
value = 5 * (importDefault(672) /* metro dependency 672: Durations */).Millis.MINUTE;
|
|
Reflect.apply(start, heartbeatInterval, [value, binding.trackHeartbeat]);
|
|
}
|
|
}
|
|
|
|
function startAnalyticHeartbeat() { // fn#100034, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13280:1134, owner: SessionAdManager.startAnalyticHeartbeat, offset: 0x021dc541, size: 92 bytes, params: 1, frame: 12
|
|
var binding;
|
|
var value;
|
|
if (!env0_0.schedulerStarted) {
|
|
binding = env0_0;
|
|
binding.schedulerStarted = true;
|
|
value = environment.__proto__.__proto__;
|
|
value = importDefault(1216) /* metro dependency 1216: SentryUtilsNative */;
|
|
value.addBreadcrumb({'category': 'ad', 'message': 'Starting ad session heartbeat'});
|
|
binding.maybeStartHeartbeat();
|
|
}
|
|
}
|
|
|
|
function SessionAdManagerTrackHeartbeat() { // fn#100035, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13280:1302, owner: SessionAdManager.trackHeartbeat, offset: 0x021dc59d, size: 309 bytes, params: 1, frame: 18
|
|
var value3;
|
|
var value4;
|
|
var value5;
|
|
var orRefreshAdSession;
|
|
var defaultImport2;
|
|
const value = a0;
|
|
const r6 = value !== undefined ? value : false;
|
|
if (env0_0.schedulerStarted) {
|
|
value3 = global.performance.now();
|
|
value4 = value3 - env0_0.lastHeartbeatTimestamp;
|
|
value5 = environment.__proto__.__proto__;
|
|
if (r6) {
|
|
orRefreshAdSession = (require(7113) /* metro dependency 7113: SessionAdGenerator */).getOrRefreshAdSession();
|
|
defaultImport2 = importDefault(683) /* metro dependency 683: AnalyticsUtils */;
|
|
defaultImport2.track(AnalyticEvents.CLIENT_AD_HEARTBEAT, {client_ad_session_id: orRefreshAdSession.uuid,
|
|
client_heartbeat_initialization_timestamp: orRefreshAdSession.createdAtTimestamp,
|
|
client_heartbeat_version: 3});
|
|
env0_0.lastHeartbeatTimestamp = value3;
|
|
} else if (env0_0.lastHeartbeatTimestamp > 0) {
|
|
if (!(value4 < 5 * (importDefault(672) /* metro dependency 672: Durations */).Millis.MINUTE)) {
|
|
orRefreshAdSession = (require(7113) /* metro dependency 7113: SessionAdGenerator */).getOrRefreshAdSession();
|
|
defaultImport2 = importDefault(683) /* metro dependency 683: AnalyticsUtils */;
|
|
defaultImport2.track(AnalyticEvents.CLIENT_AD_HEARTBEAT, {client_ad_session_id: orRefreshAdSession.uuid,
|
|
client_heartbeat_initialization_timestamp: orRefreshAdSession.createdAtTimestamp,
|
|
client_heartbeat_version: 3});
|
|
env0_0.lastHeartbeatTimestamp = value3;
|
|
}
|
|
} else {
|
|
orRefreshAdSession = (require(7113) /* metro dependency 7113: SessionAdGenerator */).getOrRefreshAdSession();
|
|
defaultImport2 = importDefault(683) /* metro dependency 683: AnalyticsUtils */;
|
|
defaultImport2.track(AnalyticEvents.CLIENT_AD_HEARTBEAT, {client_ad_session_id: orRefreshAdSession.uuid,
|
|
client_heartbeat_initialization_timestamp: orRefreshAdSession.createdAtTimestamp,
|
|
client_heartbeat_version: 3});
|
|
env0_0.lastHeartbeatTimestamp = value3;
|
|
}
|
|
} else {
|
|
if (r6) {
|
|
value3 = global.performance.now();
|
|
value4 = value3 - env0_0.lastHeartbeatTimestamp;
|
|
value5 = environment.__proto__.__proto__;
|
|
if (r6) {
|
|
orRefreshAdSession = (require(7113) /* metro dependency 7113: SessionAdGenerator */).getOrRefreshAdSession();
|
|
defaultImport2 = importDefault(683) /* metro dependency 683: AnalyticsUtils */;
|
|
defaultImport2.track(AnalyticEvents.CLIENT_AD_HEARTBEAT, {client_ad_session_id: orRefreshAdSession.uuid,
|
|
client_heartbeat_initialization_timestamp: orRefreshAdSession.createdAtTimestamp,
|
|
client_heartbeat_version: 3});
|
|
env0_0.lastHeartbeatTimestamp = value3;
|
|
} else if (env0_0.lastHeartbeatTimestamp > 0) {
|
|
if (!(value4 < 5 * (importDefault(672) /* metro dependency 672: Durations */).Millis.MINUTE)) {
|
|
orRefreshAdSession = (require(7113) /* metro dependency 7113: SessionAdGenerator */).getOrRefreshAdSession();
|
|
defaultImport2 = importDefault(683) /* metro dependency 683: AnalyticsUtils */;
|
|
defaultImport2.track(AnalyticEvents.CLIENT_AD_HEARTBEAT,
|
|
{client_ad_session_id: orRefreshAdSession.uuid,
|
|
client_heartbeat_initialization_timestamp: orRefreshAdSession.createdAtTimestamp,
|
|
client_heartbeat_version: 3});
|
|
env0_0.lastHeartbeatTimestamp = value3;
|
|
}
|
|
} else {
|
|
orRefreshAdSession = (require(7113) /* metro dependency 7113: SessionAdGenerator */).getOrRefreshAdSession();
|
|
defaultImport2 = importDefault(683) /* metro dependency 683: AnalyticsUtils */;
|
|
defaultImport2.track(AnalyticEvents.CLIENT_AD_HEARTBEAT, {client_ad_session_id: orRefreshAdSession.uuid,
|
|
client_heartbeat_initialization_timestamp: orRefreshAdSession.createdAtTimestamp,
|
|
client_heartbeat_version: 3});
|
|
env0_0.lastHeartbeatTimestamp = value3;
|
|
}
|
|
return undefined;
|
|
}
|
|
(importDefault(1216) /* metro dependency 1216: SentryUtilsNative */).addBreadcrumb({'category': 'ad',
|
|
'message': 'Ad heartbeat called but scheduler not started'});
|
|
env0_0.heartbeatInterval.stop();
|
|
}
|
|
}
|
|
|
|
function stopAnalyticHeartbeat() { // fn#100036, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13280:1842, owner: SessionAdManager.stopAnalyticHeartbeat, offset: 0x021dc6d2, size: 150 bytes, params: 1, frame: 16
|
|
var binding;
|
|
let value = a0;
|
|
if (env0_0.schedulerStarted) {
|
|
binding = env0_0;
|
|
binding.schedulerStarted = false;
|
|
binding.lastHeartbeatTimestamp = 0;
|
|
value = environment.__proto__.__proto__;
|
|
value = importDefault(1216) /* metro dependency 1216: SentryUtilsNative */;
|
|
value.addBreadcrumb({category: 'ad',
|
|
message: 'Stopping ad session heartbeat: ' + (value !== undefined ? value : env2_12.DEFAULT)});
|
|
binding.heartbeatInterval.stop();
|
|
}
|
|
}
|
|
|
|
function SessionAdManagerScheduleHeartbeatTracking() { // fn#100037, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13280:2068, owner: SessionAdManager.scheduleHeartbeatTracking, offset: 0x021dc768, size: 119 bytes, params: 1, frame: 14
|
|
var value2;
|
|
var binding;
|
|
var error;
|
|
let value = a0;
|
|
const r5 = value !== undefined ? value : env2_12.DEFAULT;
|
|
value = environment;
|
|
if (env0_0.focusedOrForegrounded) {
|
|
value2 = environment.__proto__.__proto__;
|
|
if (env2_11 != null) {
|
|
try {
|
|
binding = env0_0;
|
|
binding.startAnalyticHeartbeat();
|
|
} catch (error) {
|
|
value = importDefault(1216) /* metro dependency 1216: SentryUtilsNative */;
|
|
value.captureException(error);
|
|
}
|
|
} else {
|
|
env0_0.stopAnalyticHeartbeat(r5);
|
|
}
|
|
} else {
|
|
env0_0.stopAnalyticHeartbeat(r5);
|
|
}
|
|
}
|
|
|
|
function SessionAdManagerHandleLogin() { // fn#100038, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13280:2236, owner: SessionAdManager.handleLogin, offset: 0x021dc7df, size: 34 bytes, params: 1, frame: 11
|
|
const binding = env0_0;
|
|
binding.scheduleHeartbeatTracking();
|
|
binding.trackHeartbeat(true);
|
|
}
|
|
|
|
function SessionAdManagerHandleLogout() { // fn#100039, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13280:2308, owner: SessionAdManager.handleLogout, offset: 0x021dc801, size: 65 bytes, params: 1, frame: 12
|
|
const binding = env0_0;
|
|
const stopAnalyticHeartbeat = binding.stopAnalyticHeartbeat;
|
|
const value = environment.__proto__.__proto__;
|
|
const USER_LOGOUT = env2_12.USER_LOGOUT;
|
|
Reflect.apply(stopAnalyticHeartbeat, binding, [USER_LOGOUT]);
|
|
(SessionAdGeneratorModule).clearAdSession();
|
|
}
|
|
|
|
function handleEnrollmentSuccess() { // fn#100040, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13280:2405, owner: SessionAdManager.handleEnrollmentSuccess, offset: 0x021dc842, size: 40 bytes, params: 1, frame: 12
|
|
const value = environment.__proto__.__proto__;
|
|
(SessionAdGeneratorModule).getOrRefreshAdSession(true);
|
|
}
|
|
|
|
function SessionAdManagerHandleWindowFocus({focused}) { // fn#100041, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13280:2466, owner: SessionAdManager.handleWindowFocus, offset: 0x021dc86a, size: 50 bytes, params: 2, frame: 11
|
|
const binding = env0_0;
|
|
binding.focusedOrForegrounded = focused;
|
|
const scheduleHeartbeatTracking = binding.scheduleHeartbeatTracking;
|
|
const WINDOW_FOCUS = env2_12.WINDOW_FOCUS;
|
|
Reflect.apply(scheduleHeartbeatTracking, binding, [WINDOW_FOCUS]);
|
|
}
|
|
|
|
function SessionAdManagerHandleAppStateUpdate({state}) { // fn#100042, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13280:2576, owner: SessionAdManager.handleAppStateUpdate, offset: 0x021dc89c, size: 63 bytes, params: 2, frame: 12
|
|
const binding = env0_0;
|
|
const ACTIVE = AppStates.ACTIVE;
|
|
binding.focusedOrForegrounded = state === ACTIVE;
|
|
const scheduleHeartbeatTracking = binding.scheduleHeartbeatTracking;
|
|
const APP_STATE_UPDATE = env2_12.APP_STATE_UPDATE;
|
|
Reflect.apply(scheduleHeartbeatTracking, binding, [APP_STATE_UPDATE]);
|
|
}
|
|
|
|
function SessionAdManagerHandleAuthenticationChange() { // fn#100043, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13280:2705, owner: SessionAdManager.handleAuthenticationChange, offset: 0x021dc8db, size: 99 bytes, params: 1, frame: 11
|
|
const value = environment.__proto__.__proto__;
|
|
if (env2_11 !== authenticationStore.getToken()) {
|
|
(require(7113) /* metro dependency 7113: SessionAdGenerator */).clearAdSession();
|
|
env0_0.stopAnalyticHeartbeat();
|
|
}
|
|
env0_0.scheduleHeartbeatTracking();
|
|
}
|
|
|
|
}
|
|
|
|
function value_100044() { // fn#100044, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13280:2901, offset: 0x021dc93e, size: 239 bytes, params: 1, frame: 18
|
|
let value = environment.__proto__;
|
|
this.focusedOrForegrounded = SessionForegroundUtilsNativeModule.isForegrounded();
|
|
const authenticationStoreBinding = authenticationStore;
|
|
authenticationStoreBinding.addChangeListener(this.handleAuthenticationChange);
|
|
value = importDefault(694) /* metro dependency 694: Dispatcher */;
|
|
value.subscribe('WINDOW_FOCUS', this.handleWindowFocus);
|
|
value = importDefault(694) /* metro dependency 694: Dispatcher */;
|
|
value.subscribe('APP_STATE_UPDATE', this.handleAppStateUpdate);
|
|
value = importDefault(694) /* metro dependency 694: Dispatcher */;
|
|
value.subscribe('QUESTS_ENROLL_SUCCESS', this.handleEnrollmentSuccess);
|
|
value = importDefault(694) /* metro dependency 694: Dispatcher */;
|
|
value.subscribe('LOGIN_SUCCESS', this.handleLogin);
|
|
value = importDefault(694) /* metro dependency 694: Dispatcher */;
|
|
value.subscribe('LOGOUT', this.handleLogout);
|
|
this.scheduleHeartbeatTracking();
|
|
}
|
|
|
|
function value_100045() { // fn#100045, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:13280:3372, offset: 0x021dca2d, size: 207 bytes, params: 1, frame: 18
|
|
this.stopAnalyticHeartbeat();
|
|
let value = environment.__proto__;
|
|
const authenticationStoreBinding = authenticationStore;
|
|
authenticationStoreBinding.removeChangeListener(this.handleAuthenticationChange);
|
|
value = importDefault(694) /* metro dependency 694: Dispatcher */;
|
|
value.unsubscribe('WINDOW_FOCUS', this.handleWindowFocus);
|
|
value = importDefault(694) /* metro dependency 694: Dispatcher */;
|
|
value.unsubscribe('APP_STATE_UPDATE', this.handleAppStateUpdate);
|
|
value = importDefault(694) /* metro dependency 694: Dispatcher */;
|
|
value.unsubscribe('QUESTS_ENROLL_SUCCESS', this.handleEnrollmentSuccess);
|
|
value = importDefault(694) /* metro dependency 694: Dispatcher */;
|
|
value.unsubscribe('LOGIN_SUCCESS', this.handleLogin);
|
|
value = importDefault(694) /* metro dependency 694: Dispatcher */;
|
|
value.unsubscribe('LOGOUT', this.handleLogout);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
global.__d(_fun100027, 13090, [6, 7, 15, 17, 18, 1226, 661, 4876, 4041, 672, 1216, 7113, 683, 694, 4561,
|
|
2]) /* metro module 13090, dependencies: [6, 7, 15, 17, 18, 1226, 661, 4876, 4041, 672, 1216, 7113, 683, 694, 4561, 2] */;
|