- Custom events, described in Send flag evaluations as custom events. The plugin sends each flag evaluation to Fullstory as its own event. Because each event carries the flag key, the variation, and the context, you can build Fullstory segments and metrics that compare behavior across variations. We recommend this approach.
- Page properties, described in Send flag evaluations as page properties. The plugin attaches the set of evaluated flags to the current Fullstory page. Because this groups all flags into a single property, it supports less precise analysis than custom events. However, it makes the accumulated set of evaluated flags visible on pages where your application evaluates flags.
LaunchDarkly also offers its own session replayIf you are evaluating options rather than extending an existing Fullstory implementation, the LaunchDarkly session replay plugin records end-user sessions and correlates them with flag evaluations without any custom code. To learn more, read Session replay.
Prerequisites
To build either integration, you need:- A Fullstory account with the Fullstory browser snippet installed and using the V2 browser API.
- The JavaScript SDK version 3.7 or later, or the React Web SDK version 3.7 or later. These versions introduced plugin support.
Send flag evaluations as custom events
In this approach, the plugin uses theafterEvaluation hook stage to send one Fullstory custom event per flag evaluation. Fullstory indexes the event properties, so you can then segment sessions by flag key and variation.
Understand the event properties
The example plugin sends an event namedfeature_flag.evaluation with the following properties. This name aligns with the feature_flag events that LaunchDarkly session replay records automatically:
| Property | Description |
|---|---|
feature_flag.key | The key of the evaluated flag |
feature_flag.provider_name | Set to LaunchDarkly |
feature_flag.context_id | The fully-qualified key of the LaunchDarkly context that received the variation |
feature_flag.variation_index | The zero-based index of the variation the context received |
feature_flag.value | The string representation of the variation value |
feature_flag.evaluation_reason | The kind of the evaluation reason, for example RULE_MATCH or FALLTHROUGH |
feature_flag object rather than passing them as flat, dotted property names. Fullstory property names may only contain letters, numbers, underscores, and hyphens, and must begin with a letter, so a name such as feature_flag.key is invalid. Fullstory joins nested property names with dots when it builds its schema, which produces the names in the table above. To learn more, read Fullstory’s Client API requirements.
Create the plugin
The plugin below sends one event per flag evaluation, and skips the call when a flag returns the same value it returned the last time your application evaluated it for the same context. Your application may callvariation many times per page, and Fullstory limits custom events to 60 calls per user per page per minute, with a burst limit of 40 calls per second. Without deduplication, a single page render can exhaust that budget.
Modify this code to fit your setup. To use it as written, save it as fullstoryPlugin.ts:
Register the plugin
To send the events, pass the plugin to the SDK in theplugins configuration option when you initialize the client:
feature_flag.evaluation event appears in Fullstory. To confirm the integration is working, search your Fullstory sessions for that event. To learn more, read Fullstory’s Analytics events.
Send flag evaluations as page properties
In this approach, the plugin collects the flags your application evaluates and attaches them to the current Fullstory page as a singleldflags property. Fullstory page properties apply from the time of the setProperties call until the URL host or path changes, so pages where your application evaluates flags show the accumulated set of flags evaluated so far in the session.
Because Fullstory allows a maximum of 50 unique properties per page and 500 unique properties across all pages, the plugin sends the flags as one array property rather than one property per flag.
Fullstory must finish starting before getSession returns a value
FS('getSession') returns null or undefined until Fullstory capture has started. The example plugin skips the call in that case. If your application evaluates flags before Fullstory is ready, use FS('observe') or FS('getSessionAsync') to wait for capture to begin. To learn more, read Fullstory’s Get session details documentation.setProperties only when a flag value actually changes. Modify this code to fit your setup. To use it as written, save it as fullstoryPagePropertiesPlugin.ts:
plugins configuration option, in the same way you register the custom events plugin. To send both custom events and page properties, pass both plugins: