Files
discord-decomp/utils/ExperimentUtils.tsx
T
2026-11-01 12:12:55 +02:00

87 lines
2.8 KiB
TypeScript

// Metro module 7879 (f7880).
import ExperimentStore from "../modules/experiments/ExperimentStore";
import { ExperimentBuckets, ExperimentTypes } from "../modules/experiments/ExperimentConstants";
import { trackExposureToExperiment } from "../modules/experiments/ExperimentManager";
import Module12 from "../_bundle/Module12";
const getFirstEligibleUserExperiment = function getFirstEligibleUserExperiment(a0) {
for (const item of a0) {
const userExperimentDescriptor = ExperimentStore.getUserExperimentDescriptor(item);
if (userExperimentDescriptor == null) {
continue;
}
return [item, userExperimentDescriptor];
}
return null;
};
const r22 = {
getFirstEligibleUserExperiment,
isInExperimentBucket: function isInExperimentBucket(a0, a1) {
return ExperimentStore.getUserExperimentBucket(a0) === a1;
},
experimentDescriptorEquals: function experimentDescriptorEquals(a0, a1) {
if (a0 == null && a1 == null) {
return true;
}
if (a0 === a1) {
return true;
}
if (a0 == null && a1 != null) {
return false;
}
if (a0 != null && a1 == null) {
return false;
}
if (a0 != null && a1 != null) {
if (a0.type !== a1.type) {
return false;
}
if (a0.bucket !== a1.bucket) {
return false;
}
if (a0.revision !== a1.revision) {
return false;
}
if (a0.type === ExperimentTypes.USER && a1.type === ExperimentTypes.USER) {
return Module12.isEqual(a0.context, a1.context);
}
}
return true;
},
trackExposureToFirstEligibleUserExperiment: function trackExposureToFirstEligibleUserExperiment(a0) {
const firstEligibleUserExperiment = getFirstEligibleUserExperiment(a0);
if (firstEligibleUserExperiment != null) {
const [r6, r10] = firstEligibleUserExperiment;
trackExposureToExperiment(r6, r10);
return r10;
}
},
getExperimentBucketName: function getExperimentBucketName(a0) {
return a0 !== ExperimentBuckets.CONTROL ? a0 !== ExperimentBuckets.NOT_ELIGIBLE ? `Treatment ${a0}` : "Not Eligible" : "Control";
},
getRecentExperimentBuckets: function getRecentExperimentBuckets(a0, c16074_0) {
return Object.entries(a0).reduce((acc, item) => {
const [r24, r25] = item;
if ((function isRecentExperiment(a0, a1) {
let r34;
L4: {
try {
const [r17, r18] = a0.split("-");
if (r18 == null) {
break L4;
}
r34 = new Date(`${r17}-${r18.slice(0, 2)}-01`) > a1;
} catch ($e) {
return false;
}
return r34;
}
return false;
})(r24, c16074_0) && r25 > ExperimentBuckets.CONTROL) {
acc[r24] = r25;
}
return acc;
}, {});
}
};
export default r22;