EyeofcloudUserContext

云眼About 3 min

EyeofcloudUserContext

This topic describes the EyeofcloudUserContext Object which allows you to make flag decisions and track events for a user context.

🚧 重要

对象允许做出标帜决策并跟踪已使用创建用户上下文方法创建的用户上下文的事件。

云眼用户上下文变体

EyeofcloudUserContext 在 Eyeofcloud灰度发布 Android SDK v3.7 及更高版本上受支持。

强制决策方法变体

setForcedDecision() 、 和 方法在 v3.13 及更高版本中受支持。 getForcedDecision()``removeForcedDecision()``removeAllForcedDecisions()

云眼用户上下文定义

以下代码显示了 EyeofcloudUserContext 的对象定义:

KotlinJava

class EyeofcloudUserContext(eyeofcloud: Eyeofcloud, userId: String, attributes: Map<String, Any?>?) { val userId: String val attributes: MutableMap<String?, Any?> // set an attribute for the user fun setAttribute(key: String, value: Any?) // make a decision about which flag variation the user buckets into for the flag key fun decide(key: String, options: List<EyeofcloudDecideOption?>? = emptyList()): EyeofcloudDecision // make decisions about which flag variations the user buckets into for flag keys fun decideForKeys(keys: List<String?>?, options: List<EyeofcloudDecideOption?>? = emptyList()): Map<String, EyeofcloudDecision> // make decisions about which flag variations the user buckets into for all flags fun decideAll(options: List<EyeofcloudDecideOption?>? = emptyList()): Map<String, EyeofcloudDecision> // track user event fun trackEvent(eventName: String, eventTags: Map<String?, *>? = emptyMap<String?, Any>()) // sets a forced decision (variationKey) for a given decision context fun setForcedDecision(eyeofcloudDecisionContext: EyeofcloudDecisionContext, eyeofcloudForcedDecision: EyeofcloudForcedDecision): Boolean // returns the forced decision (variationKey) for a given decision context fun getForcedDecision(eyeofcloudDecisionContext: EyeofcloudDecisionContext): EyeofcloudForcedDecision? // removes the forced decision (variationKey) for a given decision context fun removeForcedDecision(eyeofcloudDecisionContext: EyeofcloudDecisionContext): Boolean // removes all the forced decisions (variationKeys) for the user context fun removeAllForcedDecisions(): Boolean }

public class EyeofcloudUserContext { public String getUserId() public Map<String, Object> getAttributes() public EyeofcloudUserContext(Eyeofcloud eyeofcloud, String userId, Map<String, Object> attributes) // set an attribute for the user public void setAttribute(String key, Object value) // make a decision about which flag variation the user buckets into for the flag key public EyeofcloudDecision decide(String key, List<EyeofcloudDecideOption> options) // make decisions about which flag variations the user buckets into for flag keys public Map<String, EyeofcloudDecision> decideForKeys(List<String> keys, List<EyeofcloudDecideOption> options) // make decisions about which flag variations the user buckets into for all flags public Map<String, EyeofcloudDecision> decideAll(List<EyeofcloudDecideOption> options) // track user event public void trackEvent(String eventName, Map<String, ?> eventTags) // sets a forced decision (variationKey) for a given decision context public Boolean setForcedDecision(EyeofcloudDecisionContext context, EyeofcloudForcedDecision decision) // returns the forced decision (variationKey) for a given decision context public EyeofcloudForcedDecision getForcedDecision(EyeofcloudDecisionContext context) // removes the forced decision (variationKey) for a given decision context public Boolean removeForcedDecision(EyeofcloudDecisionContext context) // removes all the forced decisions (variationKeys) for the user context public Boolean removeAllForcedDecisions() }

性能

下表显示了 EyeofcloudUserContext 对象的属性:

属性

类型

评论

用户标识

字符串

用户的 ID

(可选)属性

Map

自定义键值对的映射,用于指定用于受众群体定位的用户属性。创建用户时,可以使用用户 ID 传递映射。

方法

下表显示了 EyeofcloudUserContext 对象的方法:

方法

评论

设置属性

将自定义用户属性作为键值对传递给用户上下文。

决定

返回用户的标帜键的决策结果。决策结果在 EyeofcloudDecision 对象中返回,并包含传递标帜规则所需的所有数据。
请参阅分桶方法decide

决定全部

返回用户的所有活动(未存档)标帜的决策。
请参阅分桶方法decide

决定键

返回指定标帜键的标帜决策映射。
请参阅分桶方法decide

跟踪事件

跟踪用户的转化事件(即用户执行的操作)。如果指定的事件键与任何现有事件不匹配,则记录错误消息。
查看跟踪事件

设置强制决策

强制用户使用特定变体。
请参阅设置强制决策

getForcedDecision

返回用户被强制进入的变体。
请参阅获取强制决策

删除强制决策

从特定的强制变体中删除用户。
请参阅删除强制决策

删除所有强制决策

从所有强制变体中移除用户。
请参阅删除所有强制决策

源文件

包含 Android 实现的语言/平台源文件是 Eyeofcloud.javaopen in new window

Last update:
Contributors: zhangweixue,“zhangweixue”