282 lines
16 KiB
TypeScript
282 lines
16 KiB
TypeScript
/* Metro module 4249; source: modules/experiments/createExperiment.tsx; dependencies: [57, 31, 1226, 4107, 4108, 4106, 4250, 4251, 2] */
|
|
import Module00057 from '../../by-id/module-00057.js'; /* Metro dependency 57 */
|
|
import AuthenticationStore from '../../stores/AuthenticationStore.tsx'; /* Metro dependency 1226 */
|
|
import ExperimentStore from './ExperimentStore.tsx'; /* Metro dependency 4107 */
|
|
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
|
|
import * as ReactModule from '../../by-id/module-00031-React.js'; /* Metro dependency 31 */
|
|
import * as ValidateTriggerPointModule from './trigger_points/validateTriggerPoint.tsx'; /* Metro dependency 4250 */
|
|
|
|
function _fun35293(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#35293, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4421:6, offset: 0x0106df1c, size: 228 bytes, params: 8, frame: 19
|
|
const env0_0 = require;
|
|
const getConfig_35295 = function(a0, a1, a2, a3) {
|
|
var r0;
|
|
if (a3 == null) {
|
|
r0 = a2.get(a1)?.config;
|
|
r0 = r0 ?? a0.defaultConfig;
|
|
} else if (a3.aaMode) {
|
|
r0 = a0.defaultConfig;
|
|
} else {
|
|
r0 = a2.get(a1)?.config;
|
|
r0 = r0 ?? a0.defaultConfig;
|
|
}
|
|
return r0;
|
|
};
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
let value = ReactModule;
|
|
const env0_4 = value.useState;
|
|
const env0_5 = value.useEffect;
|
|
value = require(4108) /* metro dependency 4108: ExperimentConstants */;
|
|
const env0_8 = value.ExperimentBuckets;
|
|
const env0_9 = value.ExposureTypes;
|
|
(FileImportTrackerModule).fileFinishedImporting('modules/experiments/createExperiment.tsx');
|
|
exports.default = createExperiment;
|
|
function getExperimentDescriptor(a0, a1, a2) { // fn#35294, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4421:213, offset: 0x0106e000, size: 63 bytes, params: 4, frame: 14
|
|
return a0 === 'guild' ? ExperimentStore.getGuildExperimentDescriptor(a1,
|
|
a2.guildId) : ExperimentStore.getUserExperimentDescriptor(a1);
|
|
}
|
|
|
|
function createExperiment(a0) { // fn#35296, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4421:572, offset: 0x0106e087, size: 465 bytes, params: 2, frame: 23
|
|
const env0_0 = a0;
|
|
const trackExposure_352982 = trackExposure_35298;
|
|
const subscribe_353002 = subscribe_35300;
|
|
var value;
|
|
ValidateTriggerPointModule.validateOneExperiment(a0.id, a0.label, a0.commonTriggerPoint);
|
|
const Map = global.Map;
|
|
const map = new Map();
|
|
let set = map.set;
|
|
const NOT_ELIGIBLE = ExperimentBuckets.NOT_ELIGIBLE;
|
|
Reflect.apply(set, map, [NOT_ELIGIBLE, {description: 'Not Eligible', config: a0.defaultConfig}]);
|
|
set = map.set;
|
|
const CONTROL = ExperimentBuckets.CONTROL;
|
|
Reflect.apply(set, map, [CONTROL, {description: 'Control Bucket', config: a0.defaultConfig}]);
|
|
a0.treatments.forEach(_fun35303);
|
|
const kind = a0.kind;
|
|
object = {};
|
|
object.id = a0.id;
|
|
object.title = a0.label;
|
|
object.commonTriggerPoint = a0.commonTriggerPoint;
|
|
const value4 = map.values();
|
|
const items3 = [];
|
|
arraySpread(items3, value4, 0, items3);
|
|
object.description = items3.map(function(a0) {
|
|
return a0.description;
|
|
});
|
|
const value5 = map.keys();
|
|
const items2 = [];
|
|
arraySpread(items2, value5, 0, items3);
|
|
object.buckets = items2;
|
|
if (kind === 'guild') {
|
|
value = require(4106) /* metro dependency 4106: ExperimentManager */;
|
|
value = value.registerGuildExperiment(object);
|
|
} else {
|
|
value = require(4106) /* metro dependency 4106: ExperimentManager */;
|
|
value = value.registerUserExperiment(object);
|
|
}
|
|
return {useExperiment: useExperiment, subscribe: subscribe_353002, trackExposure: trackExposure_352982,
|
|
getCurrentConfig: getCurrentConfig, definition: a0, isAAMode: isAAMode};
|
|
function trackAutoExposure(a0) { // fn#35297, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4421:1201, owner: createExperiment.trackAutoExposure, offset: 0x0106e258, size: 101 bytes, params: 2, frame: 17
|
|
let value = a1;
|
|
const value2 = a3;
|
|
const r3 = value !== undefined ? value : {};
|
|
const r2 = value2 !== undefined ? value2 : null;
|
|
value = environment.__proto__;
|
|
r3.exposureType = a2 ? ExposureTypes.AUTO_FALLBACK : ExposureTypes.AUTO;
|
|
r3.excluded = false;
|
|
if (r2 != null) {
|
|
trackExposureWithDescriptor(a0, r3, r2);
|
|
} else {
|
|
trackExposure_35298(a0, r3);
|
|
}
|
|
}
|
|
|
|
function createExperimentTrackExposure(a0) { // fn#35298, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4421:1361, owner: createExperiment.trackExposure, offset: 0x0106e2bd, size: 96 bytes, params: 2, frame: 17
|
|
let value = a1;
|
|
const r3 = value !== undefined ? value : {excluded: false, exposureType: ExposureTypes.MANUAL};
|
|
value = environment.__proto__;
|
|
const experimentDescriptor = getExperimentDescriptor(env0_0.kind, env0_2.id, a0);
|
|
if (experimentDescriptor != null) {
|
|
trackExposureWithDescriptor(a0, r3, experimentDescriptor);
|
|
}
|
|
}
|
|
|
|
function trackExposureWithDescriptor(a0, a1, a2) { // fn#35299, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4421:1514, owner: createExperiment.trackExposureWithDescriptor, offset: 0x0106e31d, size: 246 bytes, params: 4, frame: 23
|
|
var r10;
|
|
var excluded;
|
|
var value;
|
|
var MANUAL;
|
|
var value2;
|
|
var moduleValue;
|
|
var trackExposureToExperiment;
|
|
var id;
|
|
var object;
|
|
if (a2 != null) {
|
|
value = environment.__proto__;
|
|
MANUAL = ExposureTypes.MANUAL;
|
|
value2 = undefined;
|
|
moduleValue = require(4106) /* metro dependency 4106: ExperimentManager */;
|
|
trackExposureToExperiment = moduleValue.trackExposureToExperiment;
|
|
id = env0_2.id;
|
|
object = {};
|
|
r10 = (a0 == null ? value2 : a0.location) ?? 'unknown';
|
|
object.location = r10;
|
|
r10 = (a1 == null ? value2 : a1.analyticsLocations) ?? [];
|
|
object.analyticsLocations = r10;
|
|
r10 = (a1 == null ? value2 : a1.fingerprint) ?? AuthenticationStore.getFingerprint();
|
|
object.fingerprint = r10 ?? value2;
|
|
excluded = a1 == null ? value2 : a1.excluded;
|
|
excluded = !!excluded && excluded;
|
|
object.excluded = excluded;
|
|
object.exposureType = (a1 == null ? value2 : a1.exposureType) ?? MANUAL;
|
|
Reflect.apply(trackExposureToExperiment, moduleValue, [id, a2, object]);
|
|
}
|
|
}
|
|
|
|
function createExperimentSubscribe(a0, a1) { // fn#35300, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4421:1956, owner: createExperiment.subscribe, offset: 0x0106e413, size: 218 bytes, params: 3, frame: 23
|
|
var environment;
|
|
let value = a2;
|
|
const env0_0 = a0;
|
|
const env0_1 = a1;
|
|
const r1 = value !== undefined ? value : {};
|
|
const onStoreChange2 = onStoreChange;
|
|
let r5 = r1.disable != null && r1.disable;
|
|
value = environment.__proto__;
|
|
const getExperimentDescriptorBinding = getExperimentDescriptor;
|
|
const binding = env0_0;
|
|
const experimentDescriptorBinding = getExperimentDescriptorBinding(binding.kind, binding.id, a0);
|
|
r5 = experimentDescriptorBinding == null || r5 ? ExperimentBuckets.NOT_ELIGIBLE : experimentDescriptorBinding.bucket;
|
|
const env0_3 = r5;
|
|
a1(getConfig_35295(env0_0, env0_3, env0_1, experimentDescriptorBinding), env0_3,
|
|
experimentDescriptorBinding == null ? -1 : experimentDescriptorBinding.revision);
|
|
ExperimentStore.addReactChangeListener(onStoreChange2);
|
|
return function() {
|
|
ExperimentStore.removeReactChangeListener(onStoreChange);
|
|
};
|
|
function onStoreChange() { // fn#35301, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4421:2141, owner: createExperiment.subscribe.onStoreChange, offset: 0x0106e4ed, size: 157 bytes, params: 1, frame: 20
|
|
const getExperimentDescriptorBinding = getExperimentDescriptor;
|
|
const binding = env1_0;
|
|
const experimentDescriptorBinding = getExperimentDescriptorBinding(binding.kind, binding.id, env0_0);
|
|
const r3 = experimentDescriptorBinding == null || env0_2 ? ExperimentBuckets.NOT_ELIGIBLE : experimentDescriptorBinding.bucket;
|
|
const revision2 = experimentDescriptorBinding == null ? -1 : experimentDescriptorBinding.revision;
|
|
if (!(r3 === env0_3 && revision === revision2)) {
|
|
require(getConfig_35295(env1_0, r3, env1_1, experimentDescriptorBinding), r3, revision2);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
function _fun35303(a0) { // fn#35303, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4421:847, offset: 0x0106e5a7, size: 89 bytes, params: 2, frame: 20
|
|
const binding = env0_1;
|
|
binding.set(a0.id, {description: 'Treatment ' + a0.id + ': ' + a0.label, config: a0.config});
|
|
}
|
|
|
|
function useExperiment(a0) { // fn#35305, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4421:2448, owner: createExperiment.useExperiment, offset: 0x0106e60a, size: 378 bytes, params: 2, frame: 24
|
|
var r10;
|
|
var defaultImport;
|
|
let value = a1;
|
|
const value2 = undefined;
|
|
let r0 = value !== value2 ? value : {autoTrackExposure: true};
|
|
const disable = r0.disable;
|
|
const r6 = disable != null && disable;
|
|
const env0_0 = r6;
|
|
value = r0.autoTrackExposure !== false;
|
|
const getExperimentDescriptorBinding = getExperimentDescriptor;
|
|
let binding = env0_0;
|
|
const experimentDescriptorBinding = getExperimentDescriptorBinding(binding.kind, binding.id, a0);
|
|
if (r0.trackExposureOptions == null) {
|
|
r10 = value2;
|
|
} else {
|
|
defaultImport = importDefault(4251) /* metro dependency 4251 */;
|
|
r0 = r0.trackExposureOptions ?? ({});
|
|
r10 = defaultImport(r0);
|
|
}
|
|
const triggerDebuggingEnabled = experimentDescriptorBinding == null ? value2 : experimentDescriptorBinding.triggerDebuggingEnabled;
|
|
const r2 = triggerDebuggingEnabled != null && triggerDebuggingEnabled;
|
|
const value8 = useState(_fun35306);
|
|
binding = env1_3;
|
|
const value9 = binding(value8, 2);
|
|
const value10 = binding(value9[0], 3);
|
|
const property = value10[0];
|
|
const property2 = value10[1];
|
|
const property3 = value10[2];
|
|
const env0_5 = value9[1];
|
|
const value11 = (importDefault(4251) /* metro dependency 4251 */)(a0);
|
|
useEffect(_fun35307, [r6, value, value11, r10, property2, property3, r2]);
|
|
useEffect(_fun35308, [r6, value11]);
|
|
return property;
|
|
function _fun35306() { // fn#35306, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4421:2734, offset: 0x0106e784, size: 121 bytes, params: 1, frame: 19
|
|
const r1 = env0_2 == null || env0_0 ? ExperimentBuckets.NOT_ELIGIBLE : env0_2.bucket;
|
|
const items2 = [getConfig_35295(env1_0, r1, env1_1, env0_2), r1];
|
|
items2[2] = env0_2 == null ? -1 : env0_2.revision;
|
|
return items2;
|
|
}
|
|
|
|
function _fun35307() { // fn#35307, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4421:2906, offset: 0x0106e7fd, size: 93 bytes, params: 1, frame: 16
|
|
var value6;
|
|
let r1 = env0_0 || !env0_1 && !env0_4;
|
|
r1 = !r1 ? env1_0.commonTriggerPoint != null : r1;
|
|
if (!r1) {
|
|
value6 = environment.__proto__;
|
|
trackAutoExposure(env0_6, Module00057, env0_1 === false);
|
|
}
|
|
}
|
|
|
|
function _fun35308() { // fn#35308, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4421:3002, offset: 0x0106e85a, size: 43 bytes, params: 1, frame: 15
|
|
return subscribe_35300(env0_6, _fun35309, {disable: env0_0});
|
|
function _fun35309(a0, a1, a2) { // fn#35309, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4421:3019, offset: 0x0106e885, size: 44 bytes, params: 4, frame: 11
|
|
const env0_0 = a0;
|
|
const env0_1 = a1;
|
|
const env0_2 = a2;
|
|
env1_5(_fun35310);
|
|
function _fun35310(a0) { // fn#35310, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4421:3032, offset: 0x0106e8b1, size: 83 bytes, params: 2, frame: 4
|
|
const value = a0;
|
|
return value[0] !== env0_0 || value[1] !== require ? [env0_0, require,
|
|
importDefault] : value[2] === importDefault ? value : [env0_0, require, importDefault];
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function getCurrentConfig(a0) { // fn#35311, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4421:3167, owner: createExperiment.getCurrentConfig, offset: 0x0106e904, size: 199 bytes, params: 2, frame: 20
|
|
let value = a1;
|
|
const r3 = value !== undefined ? value : {autoTrackExposure: true};
|
|
value = environment.__proto__;
|
|
const getExperimentDescriptorBinding = getExperimentDescriptor;
|
|
const binding = env0_0;
|
|
const experimentDescriptorBinding = getExperimentDescriptorBinding(binding.kind, binding.id, a0);
|
|
if (experimentDescriptorBinding == null) {
|
|
return getConfig_35295(env0_0, ExperimentBuckets.NOT_ELIGIBLE, env0_1, experimentDescriptorBinding);
|
|
}
|
|
if (r3.disable) {
|
|
return getConfig_35295(env0_0, ExperimentBuckets.NOT_ELIGIBLE, env0_1, experimentDescriptorBinding);
|
|
}
|
|
if (r3.autoTrackExposure !== false) {
|
|
if (env0_0.commonTriggerPoint == null) {
|
|
trackAutoExposure(a0, r3.trackExposureOptions, r3.autoTrackExposure === false, experimentDescriptorBinding);
|
|
}
|
|
} else if (experimentDescriptorBinding.triggerDebuggingEnabled) {
|
|
if (env0_0.commonTriggerPoint == null) {
|
|
trackAutoExposure(a0, r3.trackExposureOptions, r3.autoTrackExposure === false, experimentDescriptorBinding);
|
|
}
|
|
}
|
|
return getConfig_35295(env0_0, experimentDescriptorBinding.bucket, env0_1, experimentDescriptorBinding);
|
|
}
|
|
|
|
function isAAMode(a0) { // fn#35312, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4421:3531, owner: createExperiment.isAAMode, offset: 0x0106e9cb, size: 59 bytes, params: 2, frame: 15
|
|
let value = environment.__proto__;
|
|
const getExperimentDescriptorBinding = getExperimentDescriptor;
|
|
const binding = env0_0;
|
|
value = getExperimentDescriptorBinding(binding.kind, binding.id, a0);
|
|
return !(value == null || !value.aaMode);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
global.__d(_fun35293, 4249, [57, 31, 1226, 4107, 4108, 4106, 4250, 4251,
|
|
2]) /* metro module 4249, dependencies: [57, 31, 1226, 4107, 4108, 4106, 4250, 4251, 2] */;
|