Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 11a18c8

Browse files
baseline implementation of notif listener rolllout
1 parent 6a3c9a5 commit 11a18c8

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

packages/optimizely-sdk/lib/optimizely/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,9 @@ Optimizely.prototype.isFeatureEnabled = function (featureKey, userId, attributes
521521
// got a variation from the exp, so we track the impression
522522
this._sendImpressionEvent(decision.experiment.key, decision.variation.key, userId, attributes);
523523
}
524+
if (decision.decisionSource === DECISION_SOURCES.ROLLOUT) {
525+
this._sendFeatureRolloutNotification(feature, userId, attributes, variation.featureEnabled);
526+
}
524527
if (variation.featureEnabled === true) {
525528
this.logger.log(LOG_LEVEL.INFO, sprintf(LOG_MESSAGES.FEATURE_ENABLED_FOR_USER, MODULE_NAME, featureKey, userId));
526529
return true;
@@ -535,6 +538,20 @@ Optimizely.prototype.isFeatureEnabled = function (featureKey, userId, attributes
535538
}
536539
};
537540

541+
Optimizely.prototype._sendFeatureRolloutNotification = function (feature, userId, attributes, featureEnabled) {
542+
var isEnabled = featureEnabled ? "Enabled" : "Disabled";
543+
544+
this.notificationCenter.sendNotifications(
545+
enums.NOTIFICATION_TYPES.FEATURE_ROLLOUT,
546+
{
547+
feature: feature,
548+
userId: userId,
549+
attributes: attributes,
550+
variation: isEnabled
551+
}
552+
);
553+
}
554+
538555
/**
539556
* Returns an Array containing the keys of all features in the project that are
540557
* enabled for the given user.

packages/optimizely-sdk/lib/utils/enums/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ exports.NODE_CLIENT_VERSION = '2.1.1';
164164
exports.NOTIFICATION_TYPES = {
165165
ACTIVATE: 'ACTIVATE:experiment, user_id,attributes, variation, event',
166166
TRACK: 'TRACK:event_key, user_id, attributes, event_tags, event',
167+
FEATURE_ROLLOUT: 'FEATURE_ROLLOUT:feature, user_id, attributes, variation',
167168
};
168169

169170
/*

0 commit comments

Comments
 (0)