fix(experiments): 接通自建新老 UI 类型与行为归因
- bootstrap 使用可配置的 ui-new-old 类型,布尔返回值控制新老 UI - UI 行为归因与消费者保持一致,并补充两账号分组及暂停回退回归测试 - README 记录真实接入流程,不创建任何预置实验数据
This commit is contained in:
@@ -21,6 +21,11 @@ const envSchema = z.object({
|
||||
DB_NAME: z.string().min(1),
|
||||
DB_CONNECTION_LIMIT: z.coerce.number().int().positive().default(10),
|
||||
|
||||
// 显式业务接入:引用运营创建的类型,不创建或预置任何实验记录。
|
||||
DIGITAL_UI_TYPE_KEY: z
|
||||
.string()
|
||||
.regex(/^[a-z][a-z0-9_-]{1,63}$/)
|
||||
.default("ui-new-old"),
|
||||
DEEPSEEK_API_KEY: z.string().min(1).optional(),
|
||||
JWT_SECRET: z.string().min(32),
|
||||
JWT_EXPIRES_IN: z.string().min(1).default("2h"),
|
||||
|
||||
@@ -94,9 +94,11 @@ export async function digitalRoutes(app: FastifyInstance) {
|
||||
"SELECT body FROM dh_profiles WHERE account=?",
|
||||
[r.user.sub],
|
||||
),
|
||||
decide(r.user.sub, "ui", { value: "old" }),
|
||||
decide(r.user.sub, env.DIGITAL_UI_TYPE_KEY, { value: "old" }),
|
||||
]);
|
||||
const publicDecision = {
|
||||
typeKey: decision.typeKey,
|
||||
reason: decision.reason,
|
||||
variant: decision.variant,
|
||||
value: decision.value,
|
||||
fallbackValue: decision.fallbackValue,
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
hasExperimentGroup,
|
||||
type ExperimentConfig,
|
||||
} from "./digital.experiment-groups";
|
||||
import { env } from "../../config/env";
|
||||
import { createHash, randomUUID } from "node:crypto";
|
||||
import type { PoolConnection } from "mysql2/promise";
|
||||
import type { z } from "zod";
|
||||
@@ -400,13 +401,14 @@ export async function trackUiEvent(
|
||||
`INSERT IGNORE INTO dh_events(experiment_id,decision_id,account,variant,cohort,event_name,conversation_id,request_id)
|
||||
SELECT d.experiment_id,d.id,d.account,d.variant,IF(d.reason='override','manual','random'),?,?,?
|
||||
FROM dh_decisions d JOIN dh_experiments e ON e.id=d.experiment_id JOIN dh_scenes s ON s.id=e.scope
|
||||
WHERE d.id=? AND d.account=? AND s.consumer_key='ui' AND d.reason IN ('allocated','sticky','override') AND ${validity}`,
|
||||
WHERE d.id=? AND d.account=? AND s.consumer_key=? AND d.reason IN ('allocated','sticky','override') AND ${validity}`,
|
||||
[
|
||||
event,
|
||||
conversationId,
|
||||
requestId,
|
||||
decisionId,
|
||||
account,
|
||||
env.DIGITAL_UI_TYPE_KEY,
|
||||
...(completion ? [requestId] : []),
|
||||
],
|
||||
c,
|
||||
|
||||
Reference in New Issue
Block a user