找物源码导读Cocos Creator 3.8 · assets/scripts
0%
已读 0 / 424
目录— 个文件
目录加载中…
…/bridge/ab/ABDefine.ts
1import type { ABExperimentDef } from "../../framework/module/ab/ABFrameDefine";
2
3/** 稳定实验 key(落盘用,改名等于新实验)。 */
4export const ABExperimentKey = {
5 Achievement: "achievement",
6 /** 主线关卡首期实验:A 组使用原关卡,B 组使用 findConfig_1。 */
7 MainlineLevelV1: "mainline_level_v1",
8 /** 热点配置实验:A 使用原配置,B 使用 HotspotConfig_1。 */
9 HotspotLevelV1: "hotspot_level_v1",
10} as const;
11
12export type ABExperimentKeyType = (typeof ABExperimentKey)[keyof typeof ABExperimentKey];
13
14/**
15 * 本版在测清单。
16 * - 在清单里:参与 AB,首次分桶并固化
17 * - 不在清单:不测,IsOpen 恒为 true
18 * 下版不测某个功能时从这里删掉即可。
19 */
20export const AB_ACTIVE_EXPERIMENTS: ABExperimentDef[] = [
21 { key: ABExperimentKey.HotspotLevelV1, openRatio: 50 },
22 { key: ABExperimentKey.MainlineLevelV1, openRatio: 50 },
23 // { key: ABExperimentKey.Achievement, openRatio: 50 },
24];
讲解25 行
AB 实验定义人工通读

ABDefine.ts

定义项目侧 AB 实验的稳定 key 与当前在测清单。key 会写入存档做分桶,清单决定哪些实验参与分流;GameEntry.ConfigureAB 读取清单后再按发行包开关做二次过滤,最后交给框架 AB 模块。

先看 ABExperimentKey 的取值与落盘约定,再看 AB_ACTIVE_EXPERIMENTS 中哪些实验被注释掉、哪些仍开放。

特殊处理与易错点

4注释稳定实验 key(落盘用,改名等于新实验)。
7注释主线关卡首期实验:A 组使用原关卡,B 组使用 findConfig_1。
9注释热点配置实验:A 使用原配置,B 使用 HotspotConfig_1。
20注释本版在测清单。 - 在清单里:参与 AB,首次分桶并固化 - 不在清单:不测,IsOpen 恒为 true 下版不测某个功能时从这里删掉即可。