diff options
| author | rxliuli <rxliuli@gmail.com> | 2025-11-04 05:03:50 +0800 |
|---|---|---|
| committer | rxliuli <rxliuli@gmail.com> | 2025-11-04 05:03:50 +0800 |
| commit | bce557cc2dc767628bed6aac87301a1be7c5431b (patch) | |
| tree | b51a051228d01fe3306cd7626d4a96768aadb944 /node_modules/@jet-app/app-store/tmp/src/foundation/experimentation/experiment-cache.js | |
init commit
Diffstat (limited to 'node_modules/@jet-app/app-store/tmp/src/foundation/experimentation/experiment-cache.js')
| -rw-r--r-- | node_modules/@jet-app/app-store/tmp/src/foundation/experimentation/experiment-cache.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/node_modules/@jet-app/app-store/tmp/src/foundation/experimentation/experiment-cache.js b/node_modules/@jet-app/app-store/tmp/src/foundation/experimentation/experiment-cache.js new file mode 100644 index 0000000..c0384ea --- /dev/null +++ b/node_modules/@jet-app/app-store/tmp/src/foundation/experimentation/experiment-cache.js @@ -0,0 +1,63 @@ +import { makeMetatype } from "@jet/environment/util/metatype"; +import { ExperimentAreaId } from "./experiment-area-id"; +export class ExperimentCache { + constructor() { + this.cachedTreatments = {}; + this.cachedRawTreatments = {}; + } + async loadTreatments(objectGraph) { + const experimentAreas = this.experimentAreasForPlatform(objectGraph); + if (experimentAreas.length > 0) { + try { + this.cachedRawTreatments = await objectGraph.treatmentStore.treatmentsForAreas(experimentAreas); + for (const [experimentAreaId, treatment] of Object.entries(this.cachedRawTreatments)) { + /// AMS Adds some debug metadata after the treatment identifier in internal builds we do not want this + /// for app store usage + const rawIdentifier = treatment.identifier; + this.cachedTreatments[experimentAreaId] = { + ...treatment, + identifier: rawIdentifier.split(":")[0], + }; + } + } + catch (error) { + objectGraph.console.error("Failed to load treatments", error); + } + } + } + currentTreatmentForExperiment(experimentAreaId) { + return this.cachedTreatments[experimentAreaId]; + } + createAb2Data() { + const ab2Data = []; + for (const [experimentAreaId, treatment] of Object.entries(this.cachedRawTreatments)) { + ab2Data.push({ + areaId: experimentAreaId, + bucket: -2, + treatmentId: treatment.identifier, + }); + } + return ab2Data; + } + experimentAreasForPlatform(objectGraph) { + const experimentAreas = []; + switch (objectGraph.client.deviceType) { + case "phone": + case "pad": + experimentAreas.push(...[ + ExperimentAreaId.ArcadeDownloadPackOnboarding, + ExperimentAreaId.CondensedTodayAds, + ExperimentAreaId.ProductPagePreloading, + ExperimentAreaId.ProductPageVariants, + ExperimentAreaId.ProductPageYMALRowCount, + ExperimentAreaId.SearchLandingPage, + ]); + break; + default: + break; + } + return experimentAreas; + } +} +ExperimentCache.metatype = makeMetatype("app-store:experimentCache"); +//# sourceMappingURL=experiment-cache.js.map
\ No newline at end of file |
