launchdarkly-experiment-setup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLaunchDarkly Experiment Setup
LaunchDarkly 实验设置
You're using a skill that guides you through setting up and running experiments in LaunchDarkly. Your job is to design the experiment, create it with the right metrics, treatments, and flag config, start data collection, evolve the design between iterations when needed, and stop with a winner. Never create a metric or experiment until the user approves a complete design, never start an iteration until the user says to start, and never change a flag unless the user asks. See Before you create anything for required pieces, suggestions, and labels. See the workflow for gathering and approval, Step 1 for the event check, and Step 4 for starting.
你正在使用一项 skill,该 skill 会指导你在 LaunchDarkly 中设置并运行实验。你的工作是设计实验,使用正确的指标、Treatment 和 Flag 配置创建实验,启动数据收集,在需要时跨迭代演进设计,并以胜出方案结束。除非用户批准完整设计,否则绝不创建指标或实验;除非用户明确要求开始,否则绝不启动迭代;除非用户要求,否则绝不更改 Flag。参见“创建任何内容之前”了解必需项、建议项和标签。参见“工作流”了解信息收集和批准流程,参见“步骤 1”了解事件检查,参见“步骤 4”了解如何启动。
Prerequisites
前置条件
This skill requires the remotely hosted LaunchDarkly MCP server to be configured in your environment.
Required MCP tools:
- — create a new experiment with its initial iteration (hypothesis, metrics, treatments, flag config).
create-experiment - — begin collecting data for an experiment's current draft iteration.
start-experiment-iteration - — check experiment status, treatments, metrics, and current iteration.
get-experiment
Optional MCP tools:
- — browse existing experiments in the project.
list-experiments - — update fields on the experiment or its current iteration. Honours
update-experiment, so what's editable depends on whether the iteration ismutableFieldsByStatus,not_started, orrunning. Returns rejected inputs understopped.skipped - — the API-recommended way to change locked fields on a running experiment. Stops the current iteration, creates a new draft with the supplied field updates, and starts it in one call.
save-and-start-experiment-iteration - — stop the running iteration. You must declare a winner: pass the
stop-experiment-iteration(and awinningTreatmentId). If no variation outperformed, pick the baseline/control as the winner.winningReason - ,
list-metrics,create-metric— manage metrics referenced by the experiment.list-metric-events - — read one flag's targeting in an environment: whether it is on, the variation a rule serves, its off variation, and whether that rule is a percentage rollout.
get-flag - — search flags in a project by name or key.
list-flags - — create a feature flag in a project. It is off in every environment until turned on.
create-flag - — read a flag's status in each environment (
get-flag-status-across-envs,new,active, orlaunched).inactive - — find stored contexts in an environment by kind, to see which context kinds are in use.
search-contexts
此 skill 要求在环境中配置远程托管的 LaunchDarkly MCP 服务端(MCP server)。
必需的 MCP 工具:
- — 创建新实验及其初始迭代(假设、指标、Treatment、Flag 配置)。
create-experiment - — 开始为实验当前的草稿迭代收集数据。
start-experiment-iteration - — 检查实验状态、Treatment、指标和当前迭代。
get-experiment
可选的 MCP 工具:
- — 浏览项目中的现有实验。
list-experiments - — 更新实验或其当前迭代的字段。遵循
update-experiment,因此可编辑内容取决于迭代是mutableFieldsByStatus、not_started还是running。被拒绝的输入会在stopped下返回。skipped - — API 推荐的方式,用于更改运行中实验的锁定字段。通过一次调用停止当前迭代、创建应用所提供字段更新的新草稿并启动它。
save-and-start-experiment-iteration - — 停止正在运行的迭代。必须声明胜出者:传入
stop-experiment-iteration(以及winningTreatmentId)。如果没有哪个变体表现更优,则选择 baseline/control 作为胜出者。winningReason - 、
list-metrics、create-metric— 管理实验引用的指标。list-metric-events - — 读取某个环境中单个 Flag 的定位规则:Flag 是否开启、规则提供哪个变体、off variation 是哪个,以及该规则是否为百分比放量。
get-flag - — 按名称或 key 搜索项目中的 Flag。
list-flags - — 在项目中创建 Feature Flag。在开启之前,该 Flag 在所有环境中均处于关闭状态。
create-flag - — 读取 Flag 在各个环境中的状态(
get-flag-status-across-envs、new、active或launched)。inactive - — 按 kind 查找某个环境中存储的 context,以查看正在使用哪些 context kind。
search-contexts
Core Concepts
核心概念
What Are Experiments?
实验是什么?
Experiments in LaunchDarkly measure the impact of feature flag variations on key metrics. An experiment consists of:
- Treatments: the flag variations being compared (control vs. test). Each treatment has an ; the values across treatments should sum to 100.
allocationPercent - Metrics: what you're measuring (conversion rate, latency, revenue, etc.). One must be the primary metric.
- Flag config: the ,
flagKey, andruleIdof the targeting rule that drives the experiment.flagConfigVersion - Iteration: a single data-collection window. Created in status, becomes
not_startedwhen started, transitions torunningwhen ended.stopped - Holdout (optional): a project-level group of users excluded from the experiment for baseline measurement ().
holdoutId
LaunchDarkly 中的实验用于衡量 Feature Flag 变体对关键指标的影响。一个实验包括:
- Treatments(处理组):正在比较的 Flag 变体(对照与测试)。每个 Treatment 都有一个 ;所有 Treatment 的值应合计为 100。
allocationPercent - Metrics(指标):要衡量的内容(转化率、延迟、收入等)。其中必须有一个主要指标。
- Flag config(Flag 配置):驱动实验的定位规则所对应的 、
flagKey和ruleId。flagConfigVersion - Iteration(迭代):单个数据收集窗口。创建时状态为 ,启动后变为
not_started,结束后转为running。stopped - Holdout(保留组,可选):项目级用户组,被排除在实验之外以进行基线衡量()。
holdoutId
Experiment Lifecycle
实验生命周期
- Create the experiment with its first iteration ().
create-experiment - Start the iteration to begin data collection (), only after the user explicitly says to start.
start-experiment-iteration - Monitor results as data accumulates ().
get-experiment - Evolve the design mid-experiment if needed — change locked fields like ,
treatments, ormetricsby callingmethodology, which stops the current iteration, creates a new draft with your changes, and starts it. That call starts data collection, so make it only after the user explicitly says to start.save-and-start-experiment-iteration - Stop the iteration when you have a winner or a clear call ().
stop-experiment-iteration - Ship the winning variation.
- 使用 创建实验及其第一个迭代。
create-experiment - 启动迭代以开始收集数据(),且只能在用户明确要求开始后执行。
start-experiment-iteration - 随着数据积累监控结果()。
get-experiment - 如有必要,在实验中途调整设计——调用 更改
save-and-start-experiment-iteration、treatments或metrics等锁定字段。该调用会停止当前迭代、创建包含变更的新草稿并启动它。由于此调用会开始收集数据,因此只能在用户明确要求开始后执行。methodology - 获得胜出者或作出明确决定后,停止迭代()。
stop-experiment-iteration - 发布胜出的变体。
Core Principles
核心原则
- Metrics first: ensure the metrics you'll reference exist before creating the experiment.
- Clear hypothesis: every iteration requires a string from the user. See Before you create anything.
hypothesis - Proper controls: exactly one treatment must have .
baseline: true - Sufficient sample size: let iterations run long enough to support a decision. See Step 7.
- One change at a time: test one variable per experiment for clear attribution.
- 指标优先:创建实验前,确保将要引用的指标已经存在。
- 清晰的假设:每个迭代都需要用户提供一个 字符串。参见“创建任何内容之前”。
hypothesis - 适当的对照组:必须恰好有一个 Treatment 设置 。
baseline: true - 充足的样本量:让迭代运行足够长时间,以支持决策。参见“步骤 7”。
- 一次只更改一个变量:每个实验只测试一个变量,以确保归因清晰。
Before you create anything
创建任何内容之前
These three must come from the user. Never fill them in:
- Flag and variations: which flag to test, and which of its variations are in the experiment.
- Hypothesis: what they expect to improve, and by how much if they know.
- Primary metric: the single metric or funnel that decides the result.
If any of these three are missing, leave them blank until the user supplies them. They go in the gather message. See the workflow. Once the user names the flag, see Step 2.
Control variation: which of those variations is the baseline (). If the user named it, use that. If they did not:
baseline: true- Ask, and leave it blank, when the flag is brand new, the targeted rule serves a percentage rollout, or the flag is off and reports that environment as
get-flag-status-across-envs. A flag is brand new if you created it in this conversation, orinactivereports that environment asget-flag-status-across-envs: the flag was created fewer than seven days ago and has never been evaluated there. A percentage rollout is a targeted rule that splits traffic across variations instead of serving one.newshows which.get-flagmeans the flag has not been evaluated for at least seven days, so no one is currently being served the off variation.inactive - Otherwise suggest one. If the flag is on, suggest the variation the targeted rule serves today. If the flag is off, suggest its off variation.
Randomization unit: the context kind the experiment randomizes on. If the user named it, use that. If they did not, call for this project and environment. Suggest only when a of returns contexts and returns 0, so is the only context kind in use. If is unavailable, returns no contexts, or any other kind is stored, ask and leave it blank.
search-contextsuserkinduserfilterkind notEquals "user"totalCountusersearch-contextsLabel every suggested value in the design as suggested, with a one-line reason, for example . The user can change any suggestion before approving. Approving the design accepts the suggestions still shown in it.
Control (suggested, what users see today): Start free trialSettings the user did not mention can stay on LaunchDarkly's defaults. List each default you are using in the design:
- Traffic split: equal across the variations the user named (two variations is 50/50). The values must sum to 100.
allocationPercent - Statistics: LaunchDarkly default (frequentist, sequential testing). Do not send unless the user chooses one. If they choose one, send that value and show it here instead of this default. A Bayesian choice is
methodologymethodology."bayesian" - Data source:
dataSource."launchdarkly" - Reshuffle:
canReshuffleTraffic.true
Leave unset unless the user set it, and say that in the design. The randomization unit is never one of these defaults.
analysisConfig以下三项必须来自用户。绝不能自行填写:
- Flag 与变体:要测试哪个 Flag,以及实验包含该 Flag 的哪些变体。
- 假设:用户预期改善什么,以及如果知道的话,改善幅度是多少。
- 主要指标:决定实验结果的单一指标或漏斗。
如果这三项中任何一项缺失,应保持空白,直到用户提供后再填写。这些内容应包含在信息收集消息中。参见“工作流”。用户指定 Flag 后,参见“步骤 2”。
Control variation:哪个变体是 baseline()。如果用户已指定,则直接使用。如果没有指定:
baseline: true- 当 Flag 是全新创建的、目标规则提供百分比放量,或者 Flag 处于关闭状态且 报告该环境为
get-flag-status-across-envs时,应询问用户并保持空白。如果 Flag 是在本次对话中创建的,或者inactive报告该环境为get-flag-status-across-envs,则该 Flag 属于全新 Flag:它创建于不到七天前,并且从未在该环境中被评估过。百分比放量是指将流量拆分到不同变体、而不是只提供一个变体的目标规则,可通过new查看。get-flag表示 Flag 至少七天未经过评估,因此当前没有用户被提供 off variation。inactive - 在其他情况下,建议一个变体。如果 Flag 已开启,建议目标规则当前提供的变体;如果 Flag 已关闭,建议其 off variation。
Randomization unit(随机化单元):实验进行随机化所使用的 context kind。如果用户已指定,则直接使用。如果没有指定,则针对该项目和环境调用 。仅当 kind 为 的查询返回了 context,且筛选 返回的 为 0,从而表明 是唯一正在使用的 context kind 时,才建议使用 。如果 不可用、没有返回 context,或者存储了任何其他 kind,则询问用户并保持空白。
search-contextsuserkind notEquals "user"totalCountuserusersearch-contexts将设计中的每个建议值标记为“建议”,并附上一行原因,例如 。用户可以在批准前更改任何建议。批准设计即表示接受其中仍然显示的建议。
Control(建议,用户当前看到的版本):Start free trial用户未提及的设置可以保留 LaunchDarkly 默认值。在设计中列出正在使用的每个默认值:
- 流量分配:在用户指定的各变体之间平均分配 (两个变体时为 50/50)。这些值必须合计为 100。
allocationPercent - 统计方法:LaunchDarkly 默认值(频率主义、序贯检验)。除非用户选择其他方法,否则不要发送 。如果用户选择了其他方法,则改为发送该值,并在此显示,而不是显示默认值。Bayesian 选择为
methodologymethodology。"bayesian" - 数据源:
dataSource。"launchdarkly" - 重新分流:
canReshuffleTraffic。true
除非用户已设置 ,否则保持其未设置状态,并在设计中说明这一点。Randomization unit 绝不属于这些默认值。
analysisConfigWorkflow
工作流
If nothing is missing, skip the gather message and go straight to the design. Otherwise gather every missing piece in one message before you show any design, then wait:
- the flag and variations, the hypothesis, or the primary metric, when one is missing
- the named flag, when cannot find it: say so and offer three choices in one message: correct the key (list similar flags from
get-flag); create the flag themselves, then tell you to continue; or have you create it. For that last choice, propose the key, name, type, and variations from their design, say it will be created off, and wait for an explicit yes before callinglist-flags. Ifcreate-flagis installed, follow it for that step. After the flag exists, continue setup. Never create a flag unless they pick that choice and approve the details.launchdarkly-flag-create - the control or the randomization unit, when the rules above say to ask instead of suggest
- for a new primary metric, its kind (,
custom, orpageview), what it is based on (event key, URL match, or click selector), and how it is measured (share of units who converted, a total count, or an average), when the user has not already made that clearclick
list-metricsget-flagcreate-metriccreate-experimentIf the user's wording already makes one of these clear, do not ask about it. "The share of users who sent the event" already names the measure, the kind, and the event key.
cta-clickedShow the design only when nothing is blank. Never show a design with a missing value. Include every piece gathered above, the other treatments, flag config (, , ), and every default you are applying. Statistics reads unless the user chose a methodology, in which case show their choice. Label each suggested value. See Before you create anything.
flagKeyruleIdflagConfigVersionLaunchDarkly default (frequentist, sequential testing)STOP HERE until the user approves the design.
Create the metric and the experiment only after the user explicitly approves a complete design they have seen. If the user changes anything after seeing it, show the updated design and ask once more.
如果没有任何缺失项,则跳过信息收集消息,直接进入设计。否则,在展示任何设计之前,应在一条消息中收集所有缺失内容,然后等待:
- Flag 与变体、假设或主要指标缺失时,收集相应内容。
- 当 无法找到用户指定的 Flag 时,应说明情况,并在一条消息中提供三个选择:更正 key(通过
get-flag列出相似的 Flag);由用户自行创建 Flag,然后通知你继续;或者由你创建该 Flag。对于最后一种选择,应根据用户的设计提出 key、name、type 和 variations,并说明 Flag 创建后处于关闭状态,在调用list-flags前等待用户明确同意。如果已安装create-flag,则该步骤遵循该 skill。Flag 存在后继续设置。除非用户选择由你创建并批准具体详情,否则绝不创建 Flag。launchdarkly-flag-create - 当上述规则要求询问而不是建议时,收集 control 或 randomization unit。
- 对于新的主要指标,如果用户尚未明确说明,则收集其 kind(、
custom或pageview)、依据什么构建(event key、URL match 或 click selector),以及如何衡量(转化单元占比、总计数或平均值)。click
信息收集期间可以使用 和 ,但不能使用 和 。
list-metricsget-flagcreate-metriccreate-experiment如果用户的表述已经使其中某项内容足够明确,则不要询问。例如,“发送 事件的用户占比”已经明确了衡量方式、kind 和 event key。
cta-clicked仅当没有任何空白项时才展示设计。绝不展示存在缺失值的设计。设计中必须包含上面收集到的全部内容、其他 Treatments、Flag 配置(、、),以及正在应用的每一个默认值。除非用户选择了某种统计方法,否则统计方法显示为 ;如果用户选择了统计方法,则显示其选择。标记每一个建议值。参见“创建任何内容之前”。
flagKeyruleIdflagConfigVersionLaunchDarkly 默认值(频率主义、序贯检验)在此停止,直到用户批准设计。
仅当用户明确批准其看过的完整设计后,才创建指标和实验。如果用户在看过设计后更改了任何内容,应展示更新后的设计,并再次请求批准。
Step 1: Prepare Metrics
步骤 1:准备指标
- Use to find existing metrics. The user names the primary metric.
list-metrics - If it already exists, keep its name and key for the design review.
- If it does not exist, a miss only means the metric is new. The user has often named the metric and not its kind or event key. Gather those before the design. Until the user has said the kind and, for a custom event, the event key:
- Do not call .
list-metric-events - Do not check the metric name, or any other key the user did not give, as the event key.
- Do not skip the flow check by treating the metric as or
pageview.click - Do not block creation for an event you have not identified.
- Do not call
- See the gather rule for a new metric's kind, what it is based on, and how it is measured.
- After the user has said the new metric is and named its event key, call
customfor that event key. Either way, the metric goes in the design once nothing else is blank. If the event is not reaching LaunchDarkly, include a warning in that design: the event has not arrived in that environment yet. List at most 10 custom event keyslist-metric-eventsreturns for that environment, preferring keys similar to the one the user gave, so a typo is easy to spot. Say the user can correct the event key, or approve as is if the tracking is not deployed yet. If they correct the event key, that is a change: calllist-metric-eventsagain for the new key and show the updated design, per the approval rule. On approval, create the metric and the experiment as normal, even if the event has not arrived.list-metric-events - Pageview and click metrics have no custom event key. Skip only after the user has said the kind is
list-metric-eventsorpageview.click - Pass the user-named primary metric as or
primarySingleMetricKey.primaryFunnelKey
| Goal | Metric type | Example key |
|---|---|---|
| Conversion | Custom conversion | |
| Performance | Custom numeric | |
| Engagement | Custom conversion | |
| Revenue | Custom numeric | |
- 使用 查找现有指标。用户会指定主要指标。
list-metrics - 如果指标已经存在,在设计审查中保留其名称和 key。
- 如果指标不存在,查询未命中只表示该指标是新指标。用户通常会指定指标名称,但不会指定其 kind 或 event key。在展示设计前收集这些信息。在用户指定 kind,并且对于 custom 指标指定 event key 之前:
- 不要调用 。
list-metric-events - 不要将指标名称或用户未提供的任何其他 key 当作 event key 来检查。
- 不要跳过流程检查并将指标视为 或
pageview。click - 不要因为尚未识别事件而阻止创建。
- 不要调用
- 有关新指标的 kind、构建依据和衡量方式,参见收集规则。
- 用户指定新指标为 并给出 event key 后,针对该 event key 调用
custom。无论事件是否到达,只要其他内容没有空缺,该指标就会进入设计。如果事件尚未到达 LaunchDarkly,应在设计中加入警告:该事件尚未到达当前环境。列出list-metric-events针对该环境返回的最多 10 个 custom event key,并优先选择与用户提供的 key 相似的 key,以便发现拼写错误。告知用户可以更正 event key,也可以在埋点尚未部署时按当前内容批准。如果用户更正 event key,则属于设计变更:针对新 key 再次调用list-metric-events,并按照批准规则展示更新后的设计。获得批准后,即使事件尚未到达,也照常创建指标和实验。list-metric-events - Pageview 和 click 指标没有 custom event key。只有在用户明确指定 kind 为 或
pageview后,才跳过click。list-metric-events - 将用户指定的主要指标作为 或
primarySingleMetricKey传入。primaryFunnelKey
| 目标 | 指标类型 | 示例 key |
|---|---|---|
| 转化 | 自定义转化 | |
| 性能 | 自定义数值 | |
| 互动 | 自定义转化 | |
| 收入 | 自定义数值 | |
Step 2: Identify the Targeting Rule
步骤 2:确定定位规则
You need the and current of the flag rule that will drive the experiment. Use on the flag (or its environment-scoped status) to find them. The fallthrough rule's id is the string .
ruleIdflagConfigVersionget-flag"fallthrough"需要获取驱动实验的 Flag 规则所对应的 和当前 。对该 Flag(或其环境范围状态)使用 来查找。fallthrough 规则的 id 是字符串 。
ruleIdflagConfigVersionget-flag"fallthrough"Step 3: Create the Experiment
步骤 3:创建实验
See the gather and approval rule above, then call for a new metric and . See Step 1 for the event check.
create-metriccreate-experimentCall . The top-level fields describe the experiment; the nested object describes the first data-collection window. The values in the example below are the shape of the call, not values to copy. See Before you create anything for the randomization unit.
create-experimentiterationjson
{
"projectKey": "my-project",
"environmentKey": "production",
"key": "checkout-flow-v2-experiment",
"name": "Checkout Flow v2 Experiment",
"description": "Compare the redesigned checkout against the current flow.",
"tags": ["growth", "checkout"],
"iteration": {
"hypothesis": "The redesigned checkout will lift completion rate by 3%.",
"primarySingleMetricKey": "checkout-completed",
"metrics": [
{ "key": "checkout-completed" },
{ "key": "checkout-time-seconds" }
],
"treatments": [
{
"name": "Control",
"baseline": true,
"allocationPercent": 50,
"parameters": [
{ "flagKey": "checkout-flow-v2", "variationId": "variation-a-id" }
]
},
{
"name": "New Checkout",
"baseline": false,
"allocationPercent": 50,
"parameters": [
{ "flagKey": "checkout-flow-v2", "variationId": "variation-b-id" }
]
}
],
"flags": {
"checkout-flow-v2": {
"ruleId": "fallthrough",
"flagConfigVersion": 7
}
},
"randomizationUnit": "user"
}
}Omit unless the user chose one. When they did, set it to that value (, , or ).
methodology"bayesian""frequentist""export_only"Useful optional top-level fields:
- — attach an existing holdout.
holdoutId - —
dataSource(default),"launchdarkly", or"snowflake"."databricks" - — send only when the user chooses one:
methodology,"bayesian", or"frequentist". Omit it otherwise. LaunchDarkly's default is frequentist with sequential testing."export_only" - — set only the fields the user set. Leave it unset to keep sequential testing on.
analysisConfig
Useful optional iteration fields:
- — array of context attribute keys to slice results by (e.g.
attributes).["country", "device"] - — covariate CSV id for stratified sampling.
covariateId - — defaults to
canReshuffleTraffic; settrueto lock users to their initial variation when allocations change.false
参见上述信息收集和批准规则,然后为新指标调用 ,并调用 。有关事件检查,参见“步骤 1”。
create-metriccreate-experiment调用 。顶层字段描述实验,嵌套的 对象描述第一个数据收集窗口。下面示例中的值仅用于展示调用结构,不可直接复制。有关 randomization unit,参见“创建任何内容之前”。
create-experimentiterationjson
{
"projectKey": "my-project",
"environmentKey": "production",
"key": "checkout-flow-v2-experiment",
"name": "Checkout Flow v2 Experiment",
"description": "Compare the redesigned checkout against the current flow.",
"tags": ["growth", "checkout"],
"iteration": {
"hypothesis": "The redesigned checkout will lift completion rate by 3%.",
"primarySingleMetricKey": "checkout-completed",
"metrics": [
{ "key": "checkout-completed" },
{ "key": "checkout-time-seconds" }
],
"treatments": [
{
"name": "Control",
"baseline": true,
"allocationPercent": 50,
"parameters": [
{ "flagKey": "checkout-flow-v2", "variationId": "variation-a-id" }
]
},
{
"name": "New Checkout",
"baseline": false,
"allocationPercent": 50,
"parameters": [
{ "flagKey": "checkout-flow-v2", "variationId": "variation-b-id" }
]
}
],
"flags": {
"checkout-flow-v2": {
"ruleId": "fallthrough",
"flagConfigVersion": 7
}
},
"randomizationUnit": "user"
}
}除非用户选择了统计方法,否则省略 。如果用户已选择,则将其设为该值(、 或 )。
methodology"bayesian""frequentist""export_only"常用的可选顶层字段:
- — 关联现有 Holdout。
holdoutId - —
dataSource(默认值)、"launchdarkly"或"snowflake"。"databricks" - — 仅当用户选择一种方法时发送:
methodology、"bayesian"或"frequentist",否则省略。LaunchDarkly 默认使用频率主义和序贯检验。"export_only" - — 仅设置用户指定的字段。保持未设置状态可继续启用序贯检验。
analysisConfig
常用的可选迭代字段:
- — 用于按维度拆分结果的 context attribute key 数组,例如
attributes。["country", "device"] - — 用于分层抽样的 covariate CSV id。
covariateId - — 默认为
canReshuffleTraffic;设为true时,在分配比例发生变化后将用户锁定在其初始变体中。false
Step 4: Start Data Collection
步骤 4:启动数据收集
Creating the experiment leaves the iteration in . Call only after the user explicitly says to start. That same wait applies to any other call that starts an iteration.
not_startedstart-experiment-iterationjson
{
"projectKey": "my-project",
"environmentKey": "production",
"experimentKey": "checkout-flow-v2-experiment"
}Before starting, the API requires that:
- the flag is toggled on,
- the iteration has a , and
randomizationUnit - at least one treatment has a non-zero .
allocationPercent
If the primary metric is a custom event, call again right before starting. If the event is arriving, start as normal once the flag is on. If it still is not arriving, the experiment can start but results will stay empty until the event arrives, so ask whether to start anyway.
list-metric-eventsIf the flag is off in that environment when the user says to start, don't change the flag. Tell the user the flag must be on in that environment, and that turning it on starts serving its variations to users there. Ask whether they want to turn it on themselves or have you do it, and wait for an explicit answer before calling any tool that changes the flag. Once the flag is on, call again to get the current , update the draft to use it, and tell the user you did, before starting.
get-flagflagConfigVersionIf the flag is off and the custom event still is not arriving, raise both in one message, the flag question and whether to start anyway, and wait for that one answer. Do not ask them separately.
Pass if you're restarting after a prior iteration was stopped.
changeJustification创建实验后,迭代会处于 状态。只有在用户明确要求开始后,才调用 。同样的等待规则也适用于任何其他会启动迭代的调用。
not_startedstart-experiment-iterationjson
{
"projectKey": "my-project",
"environmentKey": "production",
"experimentKey": "checkout-flow-v2-experiment"
}启动前,API 要求:
- Flag 已切换为开启状态;
- 迭代具有 ;
randomizationUnit - 至少一个 Treatment 的 非零。
allocationPercent
如果主要指标是 custom 事件,请在启动前再次调用 。如果事件正在到达,并且 Flag 已开启,则照常启动。如果事件仍未到达,实验仍可启动,但在事件到达前结果会保持为空,因此应询问用户是否仍要启动。
list-metric-events如果用户要求启动时 Flag 在该环境中处于关闭状态,不要更改 Flag。告知用户必须开启该环境中的 Flag,开启后会开始向该环境中的用户提供其变体。询问用户希望自行开启,还是由你开启,并在调用任何更改 Flag 的工具前等待明确答复。Flag 开启后,再次调用 获取当前的 ,更新草稿以使用该版本,并告知用户已经完成更新,然后再启动。
get-flagflagConfigVersion如果 Flag 处于关闭状态,且 custom 事件仍未到达,应在一条消息中同时提出这两个问题:Flag 的处理方式,以及是否仍要启动。等待用户对这一个问题作出答复。不要分别询问。
如果在此前已停止的迭代之后重新启动,请传入 。
changeJustificationStep 5: Verify
步骤 5:验证
- After the user has asked you to start, call and confirm
get-experiment.currentIteration.status === "running" - Check that treatments are present with the expected allocations.
- Check the metric list and the primary metric.
- 用户要求开始后,调用 并确认
get-experiment。currentIteration.status === "running" - 检查 Treatments 是否存在,并且流量分配符合预期。
- 检查指标列表和主要指标。
Step 6: Evolve the Design Mid-Experiment (when needed)
步骤 6:在实验中途调整设计(如有需要)
Most structural fields (treatments, metrics, methodology, hypothesis, …) are locked while an iteration is . Two ways to change them:
running- Light edits while running — will let through anything
update-experimentpermits in themutableFieldsByStatusstate (typically just metadata likerunning,name,description,maintainerId, plus appendingtags/metrics). It surfaces rejected fields underattributeswith a reason.skipped - Real design changes — call . It stops the current iteration, creates a new draft with the supplied field updates applied, and starts it in one call. Inputs match
save-and-start-experiment-iteration, plusupdate-experiment. Mutability is checked againstchangeJustificationsince updates land on the new draft.not_started
save-and-start-experiment-iterationExample: swap the treatment allocation and add a metric in a single call.
json
{
"projectKey": "my-project",
"environmentKey": "production",
"experimentKey": "checkout-flow-v2-experiment",
"changeJustification": "Lowering control allocation now that variant looks safe.",
"treatments": [
{
"name": "Control",
"baseline": true,
"allocationPercent": 30,
"parameters": [{ "flagKey": "checkout-flow-v2", "variationId": "variation-a-id" }]
},
{
"name": "New Checkout",
"baseline": false,
"allocationPercent": 70,
"parameters": [{ "flagKey": "checkout-flow-v2", "variationId": "variation-b-id" }]
}
],
"metrics": [
{ "key": "checkout-completed" },
{ "key": "checkout-time-seconds" },
{ "key": "checkout-error-rate" }
]
}当迭代处于 状态时,大多数结构字段(、、、 等)均被锁定。有两种更改方式:
runningtreatmentsmetricsmethodologyhypothesis- 运行期间的轻量编辑 — 仅允许
update-experiment在mutableFieldsByStatus状态下允许修改的内容(通常包括running、name、description、maintainerId等元数据,以及追加tags/metrics)。被拒绝的字段会在attributes下返回,并附带原因。skipped - 实际设计变更 — 调用 。它会停止当前迭代、创建应用所提供字段更新的新草稿,并一次调用启动新迭代。输入参数与
save-and-start-experiment-iteration相同,另需提供update-experiment。由于更新会落到新草稿上,因此可变性针对changeJustification状态进行检查。not_started
save-and-start-experiment-iteration示例:一次调用中交换 Treatment 的流量分配并添加一个指标。
json
{
"projectKey": "my-project",
"environmentKey": "production",
"experimentKey": "checkout-flow-v2-experiment",
"changeJustification": "Lowering control allocation now that variant looks safe.",
"treatments": [
{
"name": "Control",
"baseline": true,
"allocationPercent": 30,
"parameters": [{ "flagKey": "checkout-flow-v2", "variationId": "variation-a-id" }]
},
{
"name": "New Checkout",
"baseline": false,
"allocationPercent": 70,
"parameters": [{ "flagKey": "checkout-flow-v2", "variationId": "variation-b-id" }]
}
],
"metrics": [
{ "key": "checkout-completed" },
{ "key": "checkout-time-seconds" },
{ "key": "checkout-error-rate" }
]
}Step 7: Stop the Iteration
步骤 7:停止迭代
When the results support a decision, or the user has made a call, stop the iteration. For a frequentist experiment that decision is statistical significance. For a Bayesian experiment it is the probability to beat baseline or the probability to be best. Quote only the statistic for the methodology in use. A winning treatment is required to stop — LaunchDarkly does not let you end an iteration without declaring a winner. Pass the winning treatment's id (returned in as on each treatment) plus a .
get-experiment_idwinningReasonIf the experiment was inconclusive or no variation beat the control, declare the baseline/control treatment as the winner and say so in (e.g. "Inconclusive — keeping control"). There is no "stop without a winner" path.
winningReasonjson
{
"projectKey": "my-project",
"environmentKey": "production",
"experimentKey": "checkout-flow-v2-experiment",
"winningTreatmentId": "treat-002",
"winningReason": "Two weeks of data, +4.1% lift on the primary metric."
}Name the decision statistic in . Frequentist: significance, or that it was not significant. Bayesian: probability to beat baseline or probability to be best. Do not quote a Bayesian probability, or a prior, on a frequentist experiment.
winningReasonReport results:
- Iteration stopped with the declared (the control/baseline if inconclusive).
winningTreatmentId - Lift on the primary metric, plus the decision statistic for the methodology in use.
- Next steps (ship the winner, roll back, or start a follow-up iteration).
当结果支持作出决定,或用户已经作出决定时,停止迭代。对于频率主义实验,该决定依据是统计显著性;对于 Bayesian 实验,该决定依据是胜出 baseline 的概率或成为最佳方案的概率。只能引用当前统计方法对应的统计量。停止时必须指定一个胜出的 Treatment — LaunchDarkly 不允许在不声明胜出者的情况下结束迭代。传入胜出 Treatment 的 id( 会通过每个 Treatment 上的 返回)以及 。
get-experiment_idwinningReason如果实验结果不确定,或没有任何变体优于 control,则将 baseline/control Treatment 声明为胜出者,并在 中说明(例如“Inconclusive — keeping control”)。不存在“停止但不选择胜出者”的方式。
winningReasonjson
{
"projectKey": "my-project",
"environmentKey": "production",
"experimentKey": "checkout-flow-v2-experiment",
"winningTreatmentId": "treat-002",
"winningReason": "Two weeks of data, +4.1% lift on the primary metric."
}在 中注明决策统计量。对于频率主义实验,注明显著性,或说明结果不显著;对于 Bayesian 实验,注明胜出 baseline 的概率或成为最佳方案的概率。不要在频率主义实验中引用 Bayesian 概率或先验概率。
winningReason报告结果:
- 迭代已停止,并声明了 (结果不确定时为 control/baseline)。
winningTreatmentId - 主要指标的提升幅度,以及当前统计方法对应的决策统计量。
- 后续步骤(发布胜出方案、回滚或启动后续迭代)。
Edge Cases
边界情况
| Situation | Action |
|---|---|
| A new primary metric's kind or event key is unknown | Gather them before the event check. See Step 1. |
| The new metric is a custom event and the user named its event key | Warn in the design if it has not arrived; still create on approval. See Step 1. |
| Flag, variations, hypothesis, or primary metric is missing | Ask, and leave them blank. See Before you create anything. |
| The named flag does not exist in the project | Offer to correct the key, have them create it, or create it after they approve the details. Never create a flag otherwise. See the gather rule. |
| User did not name the control, and the rules say to ask | Ask for the control; don't suggest one. See Before you create anything. |
| User did not name the control, and the rules say to suggest | Suggest the control and label it. See Before you create anything. |
| User did not name the randomization unit | Suggest or ask for the randomization unit. See Before you create anything. |
| Design not approved | Leave |
| User has not said to start | Leave the iteration in |
| Flag is off when the user says to start | Don't change the flag; ask first. See Step 4. |
| Flag has no variations to compare | Add variations only when the user explicitly asks. Otherwise say which variations exist and ask. |
You don't know the flag's | Use |
| Experiment already exists | Use |
| Need to change locked fields mid-experiment | Use |
| Inspect the |
| 情况 | 处理方式 |
|---|---|
| 新主要指标的 kind 或 event key 未知 | 在事件检查前收集这些信息。参见“步骤 1”。 |
| 新指标是 custom 事件,且用户已指定 event key | 如果事件尚未到达,在设计中加入警告;获得批准后仍可创建。参见“步骤 1”。 |
| 缺少 Flag、变体、假设或主要指标 | 询问用户并保持空白。参见“创建任何内容之前”。 |
| 指定的 Flag 不存在于项目中 | 提供更正 key、由用户创建,或在用户批准详情后由你创建的选择。否则绝不创建 Flag。参见收集规则。 |
| 用户未指定 control,且规则要求询问 | 询问 control,不要建议。参见“创建任何内容之前”。 |
| 用户未指定 control,且规则要求建议 | 建议 control 并标记为建议。参见“创建任何内容之前”。 |
| 用户未指定 randomization unit | 建议或询问 randomization unit。参见“创建任何内容之前”。 |
| 设计未获批准 | 不调用 |
| 用户尚未要求开始 | 让迭代保持 |
| 用户要求启动时 Flag 处于关闭状态 | 不要更改 Flag;先询问用户。参见“步骤 4”。 |
| Flag 没有可比较的变体 | 仅在用户明确要求时添加变体。否则说明现有变体并询问用户。 |
不知道 Flag 的 | 使用 |
| 实验已经存在 | 使用 |
| 需要在实验中途更改锁定字段 | 使用 |
| 检查响应中的 |
What NOT to Do
禁止事项
- Don't fill in a required piece yourself, or present a suggestion without labeling it as suggested. See Before you create anything.
- Don't call before Step 1 says to, or block creation because an event has not arrived. See Step 1.
list-metric-events - Don't call or
create-metricbefore the approval rule above is satisfied.create-experiment - Don't call or
start-experiment-iterationuntil the user explicitly says to start.save-and-start-experiment-iteration - Don't turn a flag on or off, or change its targeting, unless the user explicitly asks you to.
- Don't create a flag unless the user asks you to and approves the proposed key, name, type, and variations. See the gather rule.
- Don't omit on
iteration— it's required.create-experiment - Don't set on more than one treatment.
baseline: true - Don't let values fail to sum to 100 across treatments.
allocationPercent - Don't try to change locked iteration fields with while the iteration is
update-experiment— reach forrunninginstead.save-and-start-experiment-iteration - Don't stop iterations early — wait for a decision the methodology supports. See Step 7.
- Don't run multiple experiments on the same flag at the same time without a careful holdout design.
- 不要自行填写必需项,也不要展示未标记为建议的建议值。参见“创建任何内容之前”。
- 不要在“步骤 1”允许之前调用 ,也不要因为事件尚未到达而阻止创建。参见“步骤 1”。
list-metric-events - 不要在满足上述批准规则之前调用 或
create-metric。create-experiment - 不要在用户明确要求开始之前调用 或
start-experiment-iteration。save-and-start-experiment-iteration - 除非用户明确要求,否则不要开启或关闭 Flag,也不要更改其定位规则。
- 除非用户要求并批准提出的 key、name、type 和 variations,否则不要创建 Flag。参见收集规则。
- 不要在 中省略
create-experiment— 它是必需字段。iteration - 不要在多个 Treatment 上设置 。
baseline: true - 不要让各 Treatment 的 之和不等于 100。
allocationPercent - 当迭代处于 状态时,不要尝试使用
running更改锁定字段 — 应改用update-experiment。save-and-start-experiment-iteration - 不要过早停止迭代 — 应等待统计方法所支持的决策条件。参见“步骤 7”。
- 如果没有经过周密的 Holdout 设计,不要在同一 Flag 上同时运行多个实验。