feat(experiments): 发布多组方案配置界面 #10
@@ -227,3 +227,5 @@ pnpm build
|
|||||||
比例统一按百分比输入,50代表50%,保留0.01%精度;既有用户分组保持不变。
|
比例统一按百分比输入,50代表50%,保留0.01%精度;既有用户分组保持不变。
|
||||||
|
|
||||||
后台统一隐藏原生及 Element Plus 自绘内部滚动条;表格、弹窗、抽屉和下拉选项仍支持触摸、鼠标和键盘滚动。叙事预设编辑与后端预算、下架回退及方案快照行为保持一致。
|
后台统一隐藏原生及 Element Plus 自绘内部滚动条;表格、弹窗、抽屉和下拉选项仍支持触摸、鼠标和键盘滚动。叙事预设编辑与后端预算、下架回退及方案快照行为保持一致。
|
||||||
|
|
||||||
|
实验方案分组支持 A~Z(最多26组),每组自行设置返回值和比例,合计必须100%。两组比例自动互补,多组显示总和并支持平均分配、补足剩余;0%组保留配置供人工验收。不再提供默认方案选择,未入组及暂停时使用类型默认返回值。用户管理按当前方案动态展示可指定的组,结束实验也可选择任意已配置组。
|
||||||
|
|||||||
+8
-10
@@ -1154,7 +1154,9 @@ export type Entry = {
|
|||||||
caseSensitive: boolean;
|
caseSensitive: boolean;
|
||||||
scanDepth: number;
|
scanDepth: number;
|
||||||
};
|
};
|
||||||
/** 测试方案:A/B 的返回值遵循已注册类型的数据契约。 */
|
/** 组比例以万分比保存,key使用A至Z,0%组仍可用于人工指定。 */
|
||||||
|
export type ExperimentGroup = { key: string; weight: number; value: unknown };
|
||||||
|
/** 测试方案:动态分组的返回值遵循已注册类型的数据契约。 */
|
||||||
export type Experiment = {
|
export type Experiment = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
@@ -1168,13 +1170,9 @@ export type Experiment = {
|
|||||||
cutoff?: string;
|
cutoff?: string;
|
||||||
accounts: string[];
|
accounts: string[];
|
||||||
traffic: number;
|
traffic: number;
|
||||||
weightB: number;
|
groups: ExperimentGroup[];
|
||||||
baseline: "A" | "B";
|
winner?: string;
|
||||||
winner?: "A" | "B";
|
|
||||||
presetA?: string;
|
|
||||||
presetB?: string;
|
|
||||||
description: string;
|
description: string;
|
||||||
values?: { A: unknown; B: unknown };
|
|
||||||
typeRevision?: number;
|
typeRevision?: number;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -1213,16 +1211,16 @@ export type ExperimentUser = {
|
|||||||
status: string;
|
status: string;
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
decision: null | {
|
decision: null | {
|
||||||
variant: "A" | "B";
|
variant: string | null;
|
||||||
reason: string;
|
reason: string;
|
||||||
value: unknown;
|
value: unknown;
|
||||||
revision: number;
|
revision: number;
|
||||||
};
|
};
|
||||||
override: null | {
|
override: null | {
|
||||||
variant: "A" | "B";
|
variant: string;
|
||||||
reason: string;
|
reason: string;
|
||||||
expiresAt: string;
|
expiresAt: string;
|
||||||
bypassAudience: number;
|
bypassAudience: number;
|
||||||
};
|
};
|
||||||
assignment: null | { variant: "A" | "B"; createdAt: string };
|
assignment: null | { variant: string; createdAt: string };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,13 +35,12 @@ const availablePlans = computed(() =>
|
|||||||
);
|
);
|
||||||
const form = ref({
|
const form = ref({
|
||||||
account: "",
|
account: "",
|
||||||
variant: "B" as "A" | "B",
|
variant: "",
|
||||||
reason: "",
|
reason: "",
|
||||||
bypassAudience: false,
|
bypassAudience: false,
|
||||||
expiresAt: new Date(Date.now() + 86400000).toISOString()
|
expiresAt: new Date(Date.now() + 86400000).toISOString()
|
||||||
});
|
});
|
||||||
const reasons: Record<string, string> = {
|
const reasons: Record<string, string> = {
|
||||||
baseline: "默认组",
|
|
||||||
default: "无运行方案",
|
default: "无运行方案",
|
||||||
finished: "最终方案",
|
finished: "最终方案",
|
||||||
override: "人工指定",
|
override: "人工指定",
|
||||||
@@ -49,8 +48,8 @@ const reasons: Record<string, string> = {
|
|||||||
sticky: "已保存的稳定分组",
|
sticky: "已保存的稳定分组",
|
||||||
outside_traffic: "未进入实验流量",
|
outside_traffic: "未进入实验流量",
|
||||||
allocated: "按规则预计分组(未写入)",
|
allocated: "按规则预计分组(未写入)",
|
||||||
paused: "方案暂停,使用默认组",
|
paused: "方案暂停,使用类型默认值",
|
||||||
draft: "草稿,使用默认组"
|
draft: "草稿,使用类型默认值"
|
||||||
};
|
};
|
||||||
const states: Record<string, string> = {
|
const states: Record<string, string> = {
|
||||||
draft: "草稿",
|
draft: "草稿",
|
||||||
@@ -102,7 +101,8 @@ function open(row: ExperimentUser) {
|
|||||||
detail.value = row;
|
detail.value = row;
|
||||||
form.value = {
|
form.value = {
|
||||||
account: row.account,
|
account: row.account,
|
||||||
variant: row.override?.variant ?? "B",
|
variant:
|
||||||
|
row.override?.variant ?? selected.value.config.groups[0]?.key ?? "",
|
||||||
reason: "",
|
reason: "",
|
||||||
bypassAudience: !!row.override?.bypassAudience,
|
bypassAudience: !!row.override?.bypassAudience,
|
||||||
expiresAt: new Date(Date.now() + 86400000).toISOString()
|
expiresAt: new Date(Date.now() + 86400000).toISOString()
|
||||||
@@ -202,7 +202,7 @@ onMounted(async () => {
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<el-alert
|
<el-alert
|
||||||
title="分组预览只读,不会给用户入组或记录曝光。先选择测试方案,再查人、指定 A/B 或恢复自动;草稿和暂停时使用方案默认组。"
|
title="分组预览只读,不会给用户入组或记录曝光。先选择测试方案,再查人、指定任意配置组或恢复自动;草稿和暂停时使用类型默认返回值。"
|
||||||
:closable="false"
|
:closable="false"
|
||||||
type="info"
|
type="info"
|
||||||
/>
|
/>
|
||||||
@@ -236,8 +236,12 @@ onMounted(async () => {
|
|||||||
{{ typeName(selected.scope) }} / {{ selected.name }}
|
{{ typeName(selected.scope) }} / {{ selected.name }}
|
||||||
<el-tag>{{ states[selected.state] }}</el-tag
|
<el-tag>{{ states[selected.state] }}</el-tag
|
||||||
><span>
|
><span>
|
||||||
流量 {{ selected.config.traffic / 100 }}% · B 组
|
实验流量 {{ selected.config.traffic / 100 }}% ·
|
||||||
{{ selected.config.weightB / 100 }}%</span
|
{{
|
||||||
|
selected.config.groups
|
||||||
|
.map(g => `${g.key} ${g.weight / 100}%`)
|
||||||
|
.join(" / ")
|
||||||
|
}}</span
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
<el-table v-loading="loading" :data="items"
|
<el-table v-loading="loading" :data="items"
|
||||||
@@ -258,7 +262,11 @@ onMounted(async () => {
|
|||||||
><el-table-column label="分组预览 / 返回值" min-width="200"
|
><el-table-column label="分组预览 / 返回值" min-width="200"
|
||||||
><template #default="{ row }"
|
><template #default="{ row }"
|
||||||
><template v-if="row.decision"
|
><template v-if="row.decision"
|
||||||
><strong>{{ row.decision.variant }} 组</strong>
|
><strong>{{
|
||||||
|
row.decision.variant
|
||||||
|
? row.decision.variant + " 组"
|
||||||
|
: "未入组 · 类型默认值"
|
||||||
|
}}</strong>
|
||||||
<p class="secondary">
|
<p class="secondary">
|
||||||
{{ reasons[row.decision.reason] ?? row.decision.reason }}
|
{{ reasons[row.decision.reason] ?? row.decision.reason }}
|
||||||
</p>
|
</p>
|
||||||
@@ -339,8 +347,12 @@ onMounted(async () => {
|
|||||||
></el-form-item
|
></el-form-item
|
||||||
><el-form-item label="指定分组"
|
><el-form-item label="指定分组"
|
||||||
><el-radio-group v-model="form.variant"
|
><el-radio-group v-model="form.variant"
|
||||||
><el-radio value="A">A 组</el-radio
|
><el-radio
|
||||||
><el-radio value="B">B 组</el-radio></el-radio-group
|
v-for="group in selected?.config.groups ?? []"
|
||||||
|
:key="group.key"
|
||||||
|
:value="group.key"
|
||||||
|
>{{ group.key }} 组({{ group.weight / 100 }}%)</el-radio
|
||||||
|
></el-radio-group
|
||||||
></el-form-item
|
></el-form-item
|
||||||
><el-form-item label="有效期(最多 30 天)"
|
><el-form-item label="有效期(最多 30 天)"
|
||||||
><el-date-picker
|
><el-date-picker
|
||||||
@@ -360,7 +372,7 @@ onMounted(async () => {
|
|||||||
><el-checkbox v-model="form.bypassAudience"
|
><el-checkbox v-model="form.bypassAudience"
|
||||||
>明确允许此账号越过人群限制</el-checkbox
|
>明确允许此账号越过人群限制</el-checkbox
|
||||||
><el-alert
|
><el-alert
|
||||||
title="人工指定优先于流量和稳定分组。方案未运行时仍使用默认组;恢复自动后保留原稳定分组,所有操作记录审计。"
|
title="人工指定优先于流量和稳定分组。方案未运行时使用类型默认返回值;恢复自动后保留原稳定分组,所有操作记录审计。"
|
||||||
:closable="false"
|
:closable="false"
|
||||||
class="content" /></el-form
|
class="content" /></el-form
|
||||||
><template #footer
|
><template #footer
|
||||||
@@ -381,8 +393,12 @@ onMounted(async () => {
|
|||||||
new Date(detail.createdAt).toLocaleString()
|
new Date(detail.createdAt).toLocaleString()
|
||||||
}}</el-descriptions-item
|
}}</el-descriptions-item
|
||||||
><el-descriptions-item label="当前预览"
|
><el-descriptions-item label="当前预览"
|
||||||
>{{ detail.decision?.variant }} 组 ·
|
>{{
|
||||||
{{ reasons[detail.decision?.reason ?? ""] }}</el-descriptions-item
|
detail.decision?.variant
|
||||||
|
? detail.decision.variant + " 组"
|
||||||
|
: "未入组 · 类型默认值"
|
||||||
|
}}
|
||||||
|
· {{ reasons[detail.decision?.reason ?? ""] }}</el-descriptions-item
|
||||||
><el-descriptions-item label="返回值">
|
><el-descriptions-item label="返回值">
|
||||||
<pre>{{
|
<pre>{{
|
||||||
JSON.stringify(detail.decision?.value, null, 2)
|
JSON.stringify(detail.decision?.value, null, 2)
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
digital,
|
digital,
|
||||||
type Content,
|
type Content,
|
||||||
type Experiment,
|
type Experiment,
|
||||||
|
type ExperimentGroup,
|
||||||
type ExperimentType
|
type ExperimentType
|
||||||
} from "@/api/access";
|
} from "@/api/access";
|
||||||
type Account = { account: string; name: string; createdAt: string };
|
type Account = { account: string; name: string; createdAt: string };
|
||||||
@@ -50,9 +51,8 @@ type Details = {
|
|||||||
const guideVisible = ref(false);
|
const guideVisible = ref(false);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const scenes = ref<ExperimentType[]>([]);
|
const scenes = ref<ExperimentType[]>([]);
|
||||||
const validA = ref(true),
|
const groupValid = ref<Record<string, boolean>>({});
|
||||||
validB = ref(true),
|
const filterType = ref("");
|
||||||
filterType = ref("");
|
|
||||||
const filtered = computed(() =>
|
const filtered = computed(() =>
|
||||||
list.value.filter(e => !filterType.value || e.scope === filterType.value)
|
list.value.filter(e => !filterType.value || e.scope === filterType.value)
|
||||||
);
|
);
|
||||||
@@ -98,12 +98,53 @@ const trafficPercent = computed({
|
|||||||
if (edit.value) edit.value.config.traffic = Math.round((value ?? 0) * 100);
|
if (edit.value) edit.value.config.traffic = Math.round((value ?? 0) * 100);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const weightBPercent = computed({
|
const groupTotal = computed(
|
||||||
get: () => (edit.value?.config.weightB ?? 0) / 100,
|
() => edit.value?.config.groups.reduce((sum, g) => sum + g.weight, 0) ?? 0
|
||||||
set: (value: number | undefined) => {
|
);
|
||||||
if (edit.value) edit.value.config.weightB = Math.round((value ?? 0) * 100);
|
const groupKeys = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
|
||||||
|
/** 两组时自动互补;更多组由用户显式填写,不悄悄改动其他组。 */
|
||||||
|
function setWeight(group: ExperimentGroup, percentage: number | undefined) {
|
||||||
|
if (!edit.value) return;
|
||||||
|
group.weight = Math.round((percentage ?? 0) * 100);
|
||||||
|
if (edit.value.config.groups.length === 2) {
|
||||||
|
const other = edit.value.config.groups.find(g => g.key !== group.key)!;
|
||||||
|
other.weight = 10000 - group.weight;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
function addGroup() {
|
||||||
|
if (!edit.value || !editingType.value) return;
|
||||||
|
const key = groupKeys.find(
|
||||||
|
k => !edit.value!.config.groups.some(g => g.key === k)
|
||||||
|
);
|
||||||
|
if (key)
|
||||||
|
edit.value.config.groups.push({
|
||||||
|
key,
|
||||||
|
weight: 0,
|
||||||
|
value: JSON.parse(JSON.stringify(editingType.value.defaultValue))
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function removeGroup(key: string) {
|
||||||
|
if (!edit.value || edit.value.config.groups.length <= 1) return;
|
||||||
|
edit.value.config.groups = edit.value.config.groups.filter(
|
||||||
|
g => g.key !== key
|
||||||
|
);
|
||||||
|
delete groupValid.value[key];
|
||||||
|
}
|
||||||
|
function distributeEvenly() {
|
||||||
|
if (!edit.value) return;
|
||||||
|
const groups = edit.value.config.groups;
|
||||||
|
const each = Math.floor(10000 / groups.length),
|
||||||
|
extra = 10000 % groups.length;
|
||||||
|
groups.forEach((g, i) => {
|
||||||
|
g.weight = each + (i < extra ? 1 : 0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function fillRemaining(group: ExperimentGroup) {
|
||||||
|
group.weight = Math.max(0, 10000 - (groupTotal.value - group.weight));
|
||||||
|
}
|
||||||
|
function groupSummary(item: Experiment) {
|
||||||
|
return item.config.groups.map(g => `${g.key} ${g.weight / 100}%`).join(" · ");
|
||||||
|
}
|
||||||
const editingType = computed(() =>
|
const editingType = computed(() =>
|
||||||
scenes.value.find(s => s.id === edit.value?.scope)
|
scenes.value.find(s => s.id === edit.value?.scope)
|
||||||
);
|
);
|
||||||
@@ -112,23 +153,21 @@ const presetOptions = computed(() =>
|
|||||||
? presets.value.map(p => ({ label: p.name, value: p.id }))
|
? presets.value.map(p => ({ label: p.name, value: p.id }))
|
||||||
: undefined
|
: undefined
|
||||||
);
|
);
|
||||||
/** 类型切换时重新初始化值,编辑历史方案时兼容旧预设字段。 */
|
/** 类型切换只重置返回值,不改变用户已经配置的组别和比例。 */
|
||||||
function initializeValues(reset = false) {
|
function initializeValues(reset = false) {
|
||||||
if (!edit.value || !editingType.value) return;
|
if (!edit.value || !editingType.value) return;
|
||||||
const t = editingType.value,
|
const type = editingType.value;
|
||||||
c = edit.value.config;
|
for (const group of edit.value.config.groups) {
|
||||||
c.values = JSON.parse(
|
if (reset || group.value === undefined)
|
||||||
|
group.value = JSON.parse(
|
||||||
JSON.stringify(
|
JSON.stringify(
|
||||||
t.contract.fixedValues ??
|
type.valueType === "boolean" && group.key === "B"
|
||||||
(!reset && c.values
|
? !type.defaultValue
|
||||||
? c.values
|
: type.defaultValue
|
||||||
: t.contract.optionsSource === "presets"
|
|
||||||
? { A: c.presetA ?? "", B: c.presetB ?? "" }
|
|
||||||
: { A: t.defaultValue, B: t.defaultValue })
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
validA.value = true;
|
}
|
||||||
validB.value = true;
|
groupValid.value = {};
|
||||||
}
|
}
|
||||||
function users(item: Experiment) {
|
function users(item: Experiment) {
|
||||||
router.push({
|
router.push({
|
||||||
@@ -173,11 +212,14 @@ function open(item?: Experiment) {
|
|||||||
audience: "all",
|
audience: "all",
|
||||||
accounts: [],
|
accounts: [],
|
||||||
traffic: 10000,
|
traffic: 10000,
|
||||||
weightB: 5000,
|
groups: [
|
||||||
baseline: "A",
|
{ key: "A", weight: 5000, value: undefined },
|
||||||
|
{ key: "B", weight: 5000, value: undefined }
|
||||||
|
],
|
||||||
description: ""
|
description: ""
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
edit.value.config.groups.sort((a, b) => a.key.localeCompare(b.key));
|
||||||
initializeValues();
|
initializeValues();
|
||||||
editor.value = true;
|
editor.value = true;
|
||||||
}
|
}
|
||||||
@@ -188,9 +230,11 @@ function createTrial() {
|
|||||||
edit.value.config.audience = "specified";
|
edit.value.config.audience = "specified";
|
||||||
edit.value.config.accounts = [];
|
edit.value.config.accounts = [];
|
||||||
edit.value.config.traffic = 10000;
|
edit.value.config.traffic = 10000;
|
||||||
edit.value.config.weightB = 10000;
|
edit.value.config.groups.forEach(g => {
|
||||||
|
g.weight = g.key === "B" ? 10000 : 0;
|
||||||
|
});
|
||||||
edit.value.config.description =
|
edit.value.config.description =
|
||||||
"选择你创建并接入的实验类型,只选择自己的账号;在指定用户中切换A/B对照,验收完成后另建正式方案。";
|
"选择你创建并接入的实验类型,只选择自己的账号;在指定用户中切换各组对照,验收完成后另建正式方案。";
|
||||||
initializeValues(true);
|
initializeValues(true);
|
||||||
guideVisible.value = false;
|
guideVisible.value = false;
|
||||||
}
|
}
|
||||||
@@ -207,8 +251,10 @@ async function save() {
|
|||||||
!edit.value.config.accounts.length
|
!edit.value.config.accounts.length
|
||||||
)
|
)
|
||||||
return ElMessage.warning("请选择至少一个入组账号,验收时先选择自己");
|
return ElMessage.warning("请选择至少一个入组账号,验收时先选择自己");
|
||||||
if (!validA.value || !validB.value)
|
if (groupTotal.value !== 10000)
|
||||||
return ElMessage.warning("请修正 A/B 返回值的 JSON 格式");
|
return ElMessage.warning("所有分组比例合计必须为 100%");
|
||||||
|
if (Object.values(groupValid.value).some(valid => !valid))
|
||||||
|
return ElMessage.warning("请修正分组返回值的 JSON 格式");
|
||||||
saving.value = true;
|
saving.value = true;
|
||||||
try {
|
try {
|
||||||
await digital(`experiments/${edit.value.id}`, "put", edit.value);
|
await digital(`experiments/${edit.value.id}`, "put", edit.value);
|
||||||
@@ -224,15 +270,15 @@ async function save() {
|
|||||||
async function move(
|
async function move(
|
||||||
item: Experiment,
|
item: Experiment,
|
||||||
state: "running" | "paused" | "finished",
|
state: "running" | "paused" | "finished",
|
||||||
winner?: "A" | "B"
|
winner?: string
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
await ElMessageBox.confirm(
|
await ElMessageBox.confirm(
|
||||||
state === "running"
|
state === "running"
|
||||||
? `启动「${item.name}」?启动后人群、比例和方案将冻结。`
|
? `启动「${item.name}」?启动后人群、比例和方案将冻结。`
|
||||||
: state === "paused"
|
: state === "paused"
|
||||||
? "暂停后用户回到默认方案,已有分组保留。"
|
? "暂停后用户使用类型默认返回值,已有分组保留。"
|
||||||
: `结束后所有用户采用 ${winner} 方案,实验不能重新启动。`,
|
: `结束后所有用户采用 ${winner} 组返回值,实验不能重新启动。`,
|
||||||
state === "finished" ? "结束实验" : "确认状态变更",
|
state === "finished" ? "结束实验" : "确认状态变更",
|
||||||
{ type: "warning", confirmButtonText: "确认", cancelButtonText: "取消" }
|
{ type: "warning", confirmButtonText: "确认", cancelButtonText: "取消" }
|
||||||
);
|
);
|
||||||
@@ -312,7 +358,7 @@ onMounted(load);
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<el-alert
|
<el-alert
|
||||||
title="同一类型消费标识只允许一个未结束方案。新老用户以账号创建时间与显式分界判定;暂停回默认方案,结束后固化最终方案。"
|
title="同一类型消费标识只允许一个未结束方案。新老用户以账号创建时间与显式分界判定;暂停使用类型默认返回值,结束后保留所选组的返回值。"
|
||||||
type="info"
|
type="info"
|
||||||
:closable="false"
|
:closable="false"
|
||||||
style="margin-bottom: 20px"
|
style="margin-bottom: 20px"
|
||||||
@@ -368,8 +414,9 @@ onMounted(load);
|
|||||||
><template #default="{ row }"
|
><template #default="{ row }"
|
||||||
><div>{{ audienceNames[row.config.audience] }}</div>
|
><div>{{ audienceNames[row.config.audience] }}</div>
|
||||||
<small class="secondary"
|
<small class="secondary"
|
||||||
>流量 {{ row.config.traffic / 100 }}% · B组
|
>实验流量 {{ row.config.traffic / 100 }}%<br />{{
|
||||||
{{ row.config.weightB / 100 }}%</small
|
groupSummary(row)
|
||||||
|
}}</small
|
||||||
></template
|
></template
|
||||||
></el-table-column
|
></el-table-column
|
||||||
><el-table-column label="操作" min-width="260" fixed="right"
|
><el-table-column label="操作" min-width="260" fixed="right"
|
||||||
@@ -402,9 +449,11 @@ onMounted(load);
|
|||||||
><el-button link type="danger">结束实验</el-button
|
><el-button link type="danger">结束实验</el-button
|
||||||
><template #dropdown
|
><template #dropdown
|
||||||
><el-dropdown-menu
|
><el-dropdown-menu
|
||||||
><el-dropdown-item command="A">保留 A 方案</el-dropdown-item
|
><el-dropdown-item
|
||||||
><el-dropdown-item command="B"
|
v-for="group in row.config.groups"
|
||||||
>保留 B 方案</el-dropdown-item
|
:key="group.key"
|
||||||
|
:command="group.key"
|
||||||
|
>保留 {{ group.key }} 组</el-dropdown-item
|
||||||
></el-dropdown-menu
|
></el-dropdown-menu
|
||||||
></template
|
></template
|
||||||
></el-dropdown
|
></el-dropdown
|
||||||
@@ -422,14 +471,16 @@ onMounted(load);
|
|||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="editor"
|
v-model="editor"
|
||||||
title="测试方案草稿"
|
title="测试方案草稿"
|
||||||
width="min(720px,95vw)"
|
class="experiment-dialog"
|
||||||
|
top="5vh"
|
||||||
|
width="min(880px,95vw)"
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
destroy-on-close
|
destroy-on-close
|
||||||
><el-form v-if="edit" label-position="top"
|
><el-form v-if="edit" label-position="top">
|
||||||
><el-form-item label="名称" required
|
<div class="form-grid">
|
||||||
|
<el-form-item label="名称" required
|
||||||
><el-input v-model="edit.name" maxlength="120"
|
><el-input v-model="edit.name" maxlength="120"
|
||||||
/></el-form-item>
|
/></el-form-item>
|
||||||
<div class="form-grid">
|
|
||||||
<el-form-item label="实验类型"
|
<el-form-item label="实验类型"
|
||||||
><el-select
|
><el-select
|
||||||
v-model="edit.scope"
|
v-model="edit.scope"
|
||||||
@@ -440,19 +491,14 @@ onMounted(load);
|
|||||||
:key="s.id"
|
:key="s.id"
|
||||||
:value="s.id"
|
:value="s.id"
|
||||||
:label="s.name"
|
:label="s.name"
|
||||||
:disabled="!s.enabled" /></el-select></el-form-item
|
:disabled="!s.enabled" /></el-select
|
||||||
><el-form-item label="默认方案"
|
|
||||||
><el-select v-model="edit.config.baseline"
|
|
||||||
><el-option label="A 方案" value="A" /><el-option
|
|
||||||
label="B 方案"
|
|
||||||
value="B" /></el-select
|
|
||||||
></el-form-item>
|
></el-form-item>
|
||||||
</div>
|
</div>
|
||||||
<el-form-item label="实验目标与验收指标"
|
<el-form-item label="实验目标与验收指标"
|
||||||
><el-input
|
><el-input
|
||||||
v-model="edit.config.description"
|
v-model="edit.config.description"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
:rows="3"
|
:rows="2"
|
||||||
placeholder="例如:观察首次聊天转化和用户反馈,确认新版交互是否改善体验。" /></el-form-item
|
placeholder="例如:观察首次聊天转化和用户反馈,确认新版交互是否改善体验。" /></el-form-item
|
||||||
><el-divider content-position="left">实验人群</el-divider
|
><el-divider content-position="left">实验人群</el-divider
|
||||||
><el-form-item label="入组范围"
|
><el-form-item label="入组范围"
|
||||||
@@ -496,60 +542,122 @@ onMounted(load);
|
|||||||
:label="`${a.name} (${a.account})`"
|
:label="`${a.name} (${a.account})`"
|
||||||
:value="a.account" /></el-select
|
:value="a.account" /></el-select
|
||||||
></el-form-item>
|
></el-form-item>
|
||||||
<div class="form-grid">
|
<el-form-item label="进入实验的流量(%)">
|
||||||
<el-form-item label="进入实验的流量(%)"
|
<el-input-number
|
||||||
><el-input-number
|
|
||||||
v-model="trafficPercent"
|
v-model="trafficPercent"
|
||||||
:min="0"
|
:min="0"
|
||||||
:max="100"
|
:max="100"
|
||||||
:precision="2"
|
:precision="2"
|
||||||
:step="1"
|
:step="1"
|
||||||
/><small>{{ edit.config.traffic / 100 }}%</small></el-form-item
|
/>
|
||||||
><el-form-item label="入组后 B 组比例(%)"
|
<p class="secondary">
|
||||||
><el-input-number
|
目标人群中有多少人参与实验;未参与的用户使用类型默认返回值。
|
||||||
v-model="weightBPercent"
|
</p>
|
||||||
|
</el-form-item>
|
||||||
|
<section class="group-config" aria-label="分组配置">
|
||||||
|
<div class="group-heading">
|
||||||
|
<strong>分组配置</strong>
|
||||||
|
<el-tag
|
||||||
|
:type="groupTotal === 10000 ? 'success' : 'danger'"
|
||||||
|
role="status"
|
||||||
|
>合计 {{ (groupTotal / 100).toFixed(2) }}% / 100%</el-tag
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<p class="secondary">
|
||||||
|
默认 A、B 两组,可添加到 Z。0%
|
||||||
|
组不会自动分流,仍可人工指定;返回值不因比例改变。
|
||||||
|
</p>
|
||||||
|
<el-table :data="edit.config.groups" row-key="key">
|
||||||
|
<el-table-column label="组别" width="70"
|
||||||
|
><template #default="{ row }"
|
||||||
|
><el-tag type="info">{{ row.key }}</el-tag></template
|
||||||
|
></el-table-column
|
||||||
|
>
|
||||||
|
<el-table-column label="分流比例(%)" width="200"
|
||||||
|
><template #default="{ row }">
|
||||||
|
<el-input-number
|
||||||
|
:model-value="row.weight / 100"
|
||||||
|
:aria-label="`${row.key}组分流比例`"
|
||||||
:min="0"
|
:min="0"
|
||||||
:max="100"
|
:max="100"
|
||||||
:precision="2"
|
:precision="2"
|
||||||
:step="1"
|
:step="1"
|
||||||
/><small
|
@update:model-value="v => setWeight(row, v)"
|
||||||
>A {{ (10000 - edit.config.weightB) / 100 }}% / B
|
/>
|
||||||
{{ edit.config.weightB / 100 }}%</small
|
<el-button
|
||||||
></el-form-item
|
v-if="groupTotal < 10000"
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="fillRemaining(row)"
|
||||||
|
>补足剩余</el-button
|
||||||
>
|
>
|
||||||
</div>
|
</template></el-table-column
|
||||||
<template v-if="editingType && edit.config.values">
|
|
||||||
<el-divider content-position="left">A/B 返回值</el-divider>
|
|
||||||
<div class="form-grid">
|
|
||||||
<el-form-item
|
|
||||||
v-for="group in ['A', 'B'] as const"
|
|
||||||
:key="group"
|
|
||||||
:label="`${group} 组${editingType.contract.labels?.[group] ? ' · ' + editingType.contract.labels[group] : ''}`"
|
|
||||||
required
|
|
||||||
>
|
>
|
||||||
|
<el-table-column label="返回值" min-width="220"
|
||||||
|
><template #default="{ row }">
|
||||||
<ExperimentValue
|
<ExperimentValue
|
||||||
:key="editingType.id + group"
|
v-if="editingType"
|
||||||
v-model="edit.config.values[group]"
|
:key="editingType.id + row.key"
|
||||||
|
v-model="row.value"
|
||||||
:kind="editingType.valueType"
|
:kind="editingType.valueType"
|
||||||
:options="presetOptions"
|
:options="presetOptions"
|
||||||
:disabled="!!editingType.contract.fixedValues"
|
@valid="v => (groupValid[row.key] = v)"
|
||||||
@valid="v => (group === 'A' ? (validA = v) : (validB = v))"
|
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
<span v-else class="secondary">请先选择实验类型</span>
|
||||||
|
</template></el-table-column
|
||||||
|
>
|
||||||
|
<el-table-column label="操作" width="85"
|
||||||
|
><template #default="{ row }"
|
||||||
|
><el-button
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
:disabled="edit.config.groups.length <= 1"
|
||||||
|
:aria-label="`删除${row.key}组`"
|
||||||
|
@click="removeGroup(row.key)"
|
||||||
|
>删除</el-button
|
||||||
|
></template
|
||||||
|
></el-table-column
|
||||||
|
>
|
||||||
|
</el-table>
|
||||||
|
<div class="group-actions">
|
||||||
|
<el-button
|
||||||
|
:disabled="!editingType || edit.config.groups.length >= 26"
|
||||||
|
@click="addGroup"
|
||||||
|
>添加分组</el-button
|
||||||
|
><el-button @click="distributeEvenly">平均分配</el-button
|
||||||
|
><span class="secondary"
|
||||||
|
>{{ edit.config.groups.length }} / 26 组</span
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
<el-alert
|
<el-alert
|
||||||
v-if="editingType.integrationState !== 'confirmed'"
|
v-if="groupTotal !== 10000"
|
||||||
type="warning"
|
type="error"
|
||||||
title="该类型还未完成应用接入验收,可以保存草稿;请到「实验类型 → 接入与验收」完成后再启动。"
|
|
||||||
:closable="false"
|
:closable="false"
|
||||||
|
title="请调整各组比例,合计达到 100% 后才能保存。"
|
||||||
/>
|
/>
|
||||||
</template>
|
</section>
|
||||||
|
<el-alert
|
||||||
|
v-if="editingType && editingType.integrationState !== 'confirmed'"
|
||||||
|
type="warning"
|
||||||
|
title="该类型尚未完成应用接入验收,可以保存草稿;完成接入与验收后才能启动。"
|
||||||
|
:closable="false" />
|
||||||
|
<p v-if="editingType" class="secondary">
|
||||||
|
未参与实验或实验暂停时,返回类型默认值:{{
|
||||||
|
JSON.stringify(editingType.defaultValue)
|
||||||
|
}},不属于任何实验组。
|
||||||
|
</p>
|
||||||
<el-alert
|
<el-alert
|
||||||
title="启动前请核对人群和比例。启动后规则冻结,需要新规则时创建下一条实验。"
|
title="启动前请核对人群和比例。启动后规则冻结,需要新规则时创建下一条实验。"
|
||||||
:closable="false" /></el-form
|
:closable="false" /></el-form
|
||||||
><template #footer
|
><template #footer
|
||||||
><el-button @click="editor = false">取消</el-button
|
><el-button @click="editor = false">取消</el-button
|
||||||
><el-button type="primary" :loading="saving" @click="save"
|
><el-button
|
||||||
|
type="primary"
|
||||||
|
:loading="saving"
|
||||||
|
:disabled="
|
||||||
|
groupTotal !== 10000 || Object.values(groupValid).some(v => !v)
|
||||||
|
"
|
||||||
|
@click="save"
|
||||||
>保存草稿</el-button
|
>保存草稿</el-button
|
||||||
></template
|
></template
|
||||||
></el-dialog
|
></el-dialog
|
||||||
@@ -565,13 +673,26 @@ onMounted(load);
|
|||||||
><span>{{ sceneName(selected.scope) }}</span
|
><span>{{ sceneName(selected.scope) }}</span
|
||||||
><small>版本 {{ selected.revision }}</small>
|
><small>版本 {{ selected.revision }}</small>
|
||||||
</div>
|
</div>
|
||||||
|
<el-table :data="selected.config.groups" class="group-details">
|
||||||
|
<el-table-column prop="key" label="组别" width="80" />
|
||||||
|
<el-table-column label="分流比例" width="120"
|
||||||
|
><template #default="{ row }"
|
||||||
|
>{{ row.weight / 100 }}%</template
|
||||||
|
></el-table-column
|
||||||
|
>
|
||||||
|
<el-table-column label="返回值"
|
||||||
|
><template #default="{ row }"
|
||||||
|
><code>{{ JSON.stringify(row.value) }}</code></template
|
||||||
|
></el-table-column
|
||||||
|
>
|
||||||
|
</el-table>
|
||||||
<el-tabs v-model="detailTab"
|
<el-tabs v-model="detailTab"
|
||||||
><el-tab-pane label="效果概览" name="metrics"
|
><el-tab-pane label="效果概览" name="metrics"
|
||||||
><el-alert
|
><el-alert
|
||||||
title="只统计实际入组流量,人工指定单列。曝光在可见页面渲染后记录,漏斗按服务端决策归因;仅作描述性统计。"
|
title="只统计实际入组流量,人工指定单列。曝光在可见页面渲染后记录,漏斗按服务端决策归因;仅作描述性统计。"
|
||||||
type="info"
|
type="info"
|
||||||
:closable="false" /><el-table :data="details?.metrics ?? []"
|
:closable="false" /><el-table :data="details?.metrics ?? []"
|
||||||
><el-table-column prop="variant" label="方案" /><el-table-column
|
><el-table-column prop="variant" label="组别" /><el-table-column
|
||||||
label="人群"
|
label="人群"
|
||||||
><template #default="{ row }">{{
|
><template #default="{ row }">{{
|
||||||
row.cohort === "manual" ? "人工指定" : "规则分组"
|
row.cohort === "manual" ? "人工指定" : "规则分组"
|
||||||
@@ -590,7 +711,7 @@ onMounted(load);
|
|||||||
description="尚无决策记录" />
|
description="尚无决策记录" />
|
||||||
<h3 style="margin: 24px 0 12px">使用漏斗</h3>
|
<h3 style="margin: 24px 0 12px">使用漏斗</h3>
|
||||||
<el-table :data="details?.funnel ?? []"
|
<el-table :data="details?.funnel ?? []"
|
||||||
><el-table-column prop="variant" label="方案" /><el-table-column
|
><el-table-column prop="variant" label="组别" /><el-table-column
|
||||||
label="人群"
|
label="人群"
|
||||||
><template #default="{ row }">{{
|
><template #default="{ row }">{{
|
||||||
row.cohort === "manual" ? "人工指定" : "规则分组"
|
row.cohort === "manual" ? "人工指定" : "规则分组"
|
||||||
@@ -637,31 +758,31 @@ onMounted(load);
|
|||||||
<li>
|
<li>
|
||||||
<strong>测试方案:定义怎么测</strong>
|
<strong>测试方案:定义怎么测</strong>
|
||||||
<p>
|
<p>
|
||||||
选择类型,配置 A/B 返回值、人群与百分比。100% 流量、B 组 50%
|
选择类型,配置 A~Z 各组的返回值、分流比例与人群。各组比例合计必须为
|
||||||
表示所有入组用户 A/B
|
100%;A 100%、B 0% 时,自动流量全部进入
|
||||||
各一半。保存只是草稿,启动才生效;启动后规则冻结。
|
A。保存只是草稿,启动才生效;启动后规则冻结。
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<strong>用户管理:查看与指定谁</strong>
|
<strong>用户管理:查看与指定谁</strong>
|
||||||
<p>
|
<p>
|
||||||
从方案行点击「用户管理」,搜索账号,查看只读分组预览。点击「指定分组」可指定
|
从方案行点击「用户管理」,搜索账号,查看只读分组预览。点击「指定分组」可指定
|
||||||
A/B、有效期与原因;「恢复自动」取消人工指定,回到原稳定分组。预览本身不会分配用户或产生曝光。
|
任意配置组、有效期与原因;「恢复自动」取消人工指定,回到原稳定分组。预览本身不会分配用户或产生曝光。
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<strong>先自己验收,再正式分流</strong>
|
<strong>先自己验收,再正式分流</strong>
|
||||||
<p>
|
<p>
|
||||||
选择你已接入的类型,指定名单只选自己,流量 100%、B 组
|
选择你已接入的类型,指定名单只选自己,流量 100%、B 组
|
||||||
100%,启动后在应用检查 B 组效果。再到用户管理指定 A/B
|
100%,启动后在应用检查 B 组效果。再到用户管理指定不同组
|
||||||
对照。其他账号按默认组。验收完成另建正式方案。
|
对照。其他账号使用类型默认返回值。验收完成另建正式方案。
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<strong>效果、暂停与结束</strong>
|
<strong>效果、暂停与结束</strong>
|
||||||
<p>
|
<p>
|
||||||
在「效果与审计」查看决策、曝光、漏斗和操作记录。暂停回方案默认组,恢复保留原分组;结束时选择最终
|
在「效果与审计」查看决策、曝光、漏斗和操作记录。暂停回类型默认返回值,恢复保留原分组;结束时选择最终
|
||||||
A/B,之后对所有用户长期生效。新类型须在消费者实际展示后调用曝光接口,不能把决策请求当作曝光。
|
任意组,之后对所有用户长期生效。新类型须在消费者实际展示后调用曝光接口,不能把决策请求当作曝光。
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
@@ -678,6 +799,42 @@ onMounted(load);
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
:global(.experiment-dialog) {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
max-height: 90vh;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.experiment-dialog .el-dialog__body) {
|
||||||
|
min-height: 0;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-details {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-config {
|
||||||
|
margin: 8px 0 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-heading,
|
||||||
|
.group-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-heading {
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-actions {
|
||||||
|
margin: 16px 0;
|
||||||
|
}
|
||||||
|
|
||||||
.workflow-guide {
|
.workflow-guide {
|
||||||
padding-left: 22px;
|
padding-left: 22px;
|
||||||
line-height: 1.8;
|
line-height: 1.8;
|
||||||
|
|||||||
Reference in New Issue
Block a user