云眼用户上下文 - 强制决策

云眼About 3 min

云眼用户上下文 - 强制决策

本主题介绍云眼灰度发布(特性标帜)AB实验 Go SDK 的 EyeofcloudUserContext 对象,该对象允许做出标帜决策并跟踪用户上下文的事件。

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

云眼用户上下文变体

EyeofcloudUserContext 在 SDK v1.7.0 及更高版本上受支持。

强制决策方法变体

SetForcedDecision() 、 和 方法在 v1.8.0 及更高版本中受支持。 GetForcedDecision()``RemoveForcedDecision()``RemoveAllForcedDecisions()

云眼用户上下文定义

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

Go

type EyeofcloudUserContext struct { UserID string Attributes map[string]interface{} } // GetEyeofcloud returns eyeofcloud client instance for Eyeofcloud user context func (o EyeofcloudUserContext) GetEyeofcloud() *EyeofcloudClient // GetUserID returns userID for Eyeofcloud user context func (o EyeofcloudUserContext) GetUserID() string // GetUserAttributes returns user attributes for Eyeofcloud user context func (o EyeofcloudUserContext) GetUserAttributes() map[string]interface{} // SetAttribute sets an attribute for a given key. func (o *EyeofcloudUserContext) SetAttribute(key string, value interface{}) // Decide returns a decision result for a given flag key and a user context, which contains // all data required to deliver the flag or experiment. func (o *EyeofcloudUserContext) Decide(key string, options []decide.EyeofcloudDecideOptions) EyeofcloudDecision // DecideAll returns a key-map of decision results for all active flag keys with options. func (o *EyeofcloudUserContext) DecideAll(options []decide.EyeofcloudDecideOptions) map[string]EyeofcloudDecision // DecideForKeys returns a key-map of decision results for multiple flag keys and options. func (o *EyeofcloudUserContext) DecideForKeys(keys []string, options []decide.EyeofcloudDecideOptions) map[string]EyeofcloudDecision // TrackEvent generates a conversion event with the given event key if it exists and queues it up to be sent to the Eyeofcloud // log endpoint for results processing. func (o *EyeofcloudUserContext) TrackEvent(eventKey string, eventTags map[string]interface{}) (err error) // EyeofcloudDecisionContext type EyeofcloudDecisionContext struct { FlagKey string RuleKey string } // EyeofcloudForcedDecision type EyeofcloudForcedDecision struct { VariationKey string } // SetForcedDecision sets the forced decision (variation key) for a given decision context (flag key and optional rule key). // returns true if the forced decision has been set successfully. func (o *EyeofcloudUserContext) SetForcedDecision(context pkgDecision.EyeofcloudDecisionContext, decision pkgDecision.EyeofcloudForcedDecision) bool // GetForcedDecision returns the forced decision for a given flag and an optional rule func (o *EyeofcloudUserContext) GetForcedDecision(context pkgDecision.EyeofcloudDecisionContext) (pkgDecision.EyeofcloudForcedDecision, error) // RemoveForcedDecision removes the forced decision for a given flag and an optional rule. func (o *EyeofcloudUserContext) RemoveForcedDecision(context pkgDecision.EyeofcloudDecisionContext) bool // RemoveAllForcedDecisions removes all forced decisions bound to this user context. func (o *EyeofcloudUserContext) RemoveAllForcedDecisions() bool

性能

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

属性

类型

评论

用户标识

字符串

用户的 ID

(可选)属性

Map

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

方法

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

方法

评论

设置属性

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

获取用户属性

获取用户的属性

决定

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

决定全部

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

决定键

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

跟踪事件

查看跟踪事件

设置强制决策

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

获得强制决策

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

删除强制决策

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

删除所有强制决策

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

参见

创建用户上下文

源文件

包含 go 实现的语言/平台源文件是 client.goopen in new window

Last update:
Contributors: “zhangweixue”,zhangweixue