
Event listeners for lightweight integrations
We’ve made it possible to easily integrate Bucket with other systems through event listeners in the Bucket SDKs. Event listeners are useful for debugging and logging, but they really shine when you want to make Bucket data available in other systems.
For example, when debugging sessions in Datadog Session Replay, it’s useful to know which feature flags were enabled for the user. Sending feature flag checks to Datadog now only takes a few lines of code in the Bucket React SDK:
import { datadogRum } from "@datadog/browser-rum";
import { useClient } from "@bucketco/react-sdk";
function DatadogFlagEvalIntegration() {
const client = useClient();
useEffect(() => {
return client?.on("check", (check) => {
datadogRum.addFeatureFlagEvaluation(check.key, check.value);
});
}, [client]);
return null;
}
Similarly, If you’re using Bucket track()
to monitor feature usage, you can now send these events to Amplitude easily:
import { amplitude } from "@amplitude/analytics-node";
import { useClient } from "@bucketco/react-sdk";
function AmplitudeTrackIntegration() {
const client = useClient();
useEffect(() => {
return client?.on("track", (trackEvent) => {
amplitude.track(trackEvent.eventName);
});
}, [client]);
return null;
}
See the full documentation for more information