云眼用户上下文
云眼用户上下文
本主题介绍 EyeofcloudUserContext 对象,该对象允许做出标帜决策并跟踪用户上下文的事件。
对象允许做出标帜决策并跟踪已使用创建用户上下文方法创建的用户上下文的事件。
云眼用户上下文变体
EyeofcloudUserContext 在 SDK v3.7 及更高版本上受支持。
强制决策方法变体
setForcedDecision()
、getForcedDecision()
、removeForcedDecision()
和removeAllForcedDecisions()
方法在 v3.9.0 及更高版本中受支持。
云眼用户上下文定义
以下代码显示了 EyeofcloudUserContext 的对象定义:
.PHP
class EyeofcloudUserContext implements \JsonSerializable {
// Create an instance of the Eyeofcloud User Context. Pass in user id and optionally user attributes
public function __construct(Eyeofcloud $eyeofcloudClient, $userId, array $attributes = [], $forcedDecisions = null);
// get user id for the user
public function getUserId();
// set user attributes
public function setAttribute($key, $value);
// get user attributes
public function getAttributes();
// make a decision about which flag variation the user buckets into for the flag key
public function decide($key, array $options = []);
// make decisions about which flag variations the user buckets into for flag keys
public function decideForKeys(array $keys, array $options = []);
// make decisions about which flag variations the user buckets into for all flags
public function decideAll(array $options = []);
// track user event
public function trackEvent($eventKey, array $eventTags = []);
// Sets the forced decision (variationKey) for a given decision context
public function setForcedDecision($context, $decision);
// Returns the forced decision for a given decision context
public function getForcedDecision($context);
// Removes the forced decision for a given decision context
public function removeForcedDecision($context);
// Removes all forced decisions bound to this user context
public function removeAllForcedDecisions();
}
性能
下表显示了 EyeofcloudUserContext 对象的属性:
属性 | 类型 | 评论 |
---|---|---|
用户标识 | 字符串 | 用户的 ID |
(可选)属性 | Map | 自定义键值对的映射,用于指定用于受众群体定位的用户属性。创建用户时,可以使用用户 ID 传递映射。 |
方法
下表显示了 EyeofcloudUserContext 对象的方法:
方法 | 评论 |
---|---|
设置属性 | 将自定义用户属性作为键值对传递给用户上下文。 |
decide | Returns a decision result for a flag key for a user. The decision result is returned in an EyeofcloudDecision object, and contains all data required to deliver the flag rule. See Decide methods |
decideForKeys
Returns a map of flag decisions for specified flag keys.
See Decide methods
decideAll
Returns decisions for all active (unarchived) flags for a user.
See Decide methods
trackEvent
Tracks a conversion event (in other words, an action a user takes) for a user. Logs an error message if the specified event key doesn't match any existing events.
See Track Event
setForcedDecision
Forces a user into a specific variation.
See Set Forced Decision
getForcedDecision
Returns what variation the user was forced into.
See Get Forced Decision
removeForcedDecision
Removes a user from a specific forced variation.
See Remove Forced Decision
removeAllForcedDecisions
Removes a user from all forced variations.
See Remove All Forced Decisions
See Also
Source files
The language/platform source files containing the implementation for PHP is Eyeofcloud.php.