Notification listeners
This topic describes what notification listeners are and lists which methods or lifecycle events trigger notification listeners in Optimizely.
Notification listeners allow you to programmatically observe and act on various events that occur within the SDK. Notification listeners:
- Give you flexibility in implementing custom integrations with analytics provider.
- Enable integrations by passing data to external services.
Here are a few examples for using notification listeners:
- Send data to an analytics service and report feature flag decision data, for example, report that user_123 was assigned to variation A.
- Use SDK events to send alerts to data monitoring tools like New Relic and Datadog to better visualize how A/B tests affect service-level metrics.
- Pass all events to an external data tier, like a data warehouse, for additional processing and to leverage business intelligence tools.
- Re-initialize your SDK to retrieve updated feature flag configuration data for your business-critical features.
The listeners work by triggering a callback function that you define and provide at runtime.
The following methods or lifecycle events trigger notification listeners if you have implemented the listener:
Method | Notification listener invoked |
---|---|
Activate | In SDKs released Feb 2019 and earlier: Invokes the ACTIVATE notification listener if the user is included in an active A/B test. In SDKs released after Feb 2019: Invokes the DECISION notification listener if this listener is enabled. |
Get Feature Variable | In SDKs v3.1 and later: Invokes the DECISION notification listener if this listener is enabled. |
Track | Invokes the TRACK notification listener if this listener is enabled. Important! This method won't call the TRACK notification listener when the specified event key is invalid |
Get all feature variables | Invokes the DECISION notification listener if this listener is enabled. |
Get variation | Invokes the DECISION notification listener if this listener is enabled. |
Is Feature Enabled | Invokes the DECISION notification listener if this listener is enabled. Also invokes the ACTIVATE notification listener if the decision is the result of the visitor being included in an active feature test, and if this listener is enabled. |
Lifecycle event | Notification listener invoked |
---|---|
event batch flushed | Invokes the LOGEVENT notification listener if this listener is enabled |
new datafile retrieved | Invokes the OPTIMIZELYCONFIGUPDATE notification listener if this listener is enabled. |
Updated almost 3 years ago
For more information about each listener type, see: