@ amplitude/plugin- 实验- 浏览器
振幅实验集成的官方浏览器 SDK 插件
安装
该软件包发布在国家预防机制登记册上,可用npm和纱线安装.
# npm
npm install @amplitude/plugin-experiment-browser
# yarn
yarn add @amplitude/plugin-experiment-browser
使用量
这个插件在Amplitude浏览器SDK上方工作并添加了Amplitude实验集成功能. 要使用此插件, 您需要安装 @amplitude/analytics-browser 版本 v2.17.5 或后会.
1. 进口宽度包
@amplitude/plugin-experiment-browser
import { experimentPlugin } from '@amplitude/plugin-experiment-browser';
2. 证据确凿的实验插件
该插件接受类型的可选参数 ExperimentPluginConfig 根据您的使用大小写配置插件.
const experiment = experimentPlugin({
deploymentKey: 'DEPLOYMENT_KEY', // Optional if using the same key as analytics
// Other experiment configuration options
});
选项
| 名称 | 类型 | 默认 | 说明 |
|---|---|---|---|
deploymentKey | string | undefined | 振幅实验的部署密钥。 如果不提供,插件将使用Amplitude API键. |
... | ExperimentConfig | {} | 所有其他配置选项来自 @amplitude/experiment-js-client。 。 。 . |
3. 安装插件到振幅 SDK
amplitude.add(experiment);
4. 振幅SDK初始化
amplitude.init('API_KEY');
实验一体化
此插件将振幅实验与振幅分析集成. 插件 :
- 使用振幅分析配置自动初始化实验客户端
- 为一致的用户身份设置实验和分析之间的连接
- 允许您使用实验客户端的所有特性,同时保持与分析器的连接
访问实验客户端
实验客户端可以通过插件实例访问 :
const plugin = experimentPlugin(config);
amplitude.add(plugin);
amplitude.init('API_KEY');
// Now you can access the Experiment client
const variant = await plugin.experiment.fetch();
学习更多
欲了解更多关于振幅实验的信息,请访问 正式文件。 。 。 .