-
Notifications
You must be signed in to change notification settings - Fork 200
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Summary
I'm trying to make a plugin which will update my store with the number events which are actually sent to Segment, ideally the count of successful uploads.
This plugin will be ran in our pre-release environment as part of an automation test suite, so we can ensure Segment events are being uploaded successfully before we release to production.
Here's the best I have come up with for now:
export class EventCounter extends Plugin {
type = PluginType.after;
execute(e: SegmentEvent) {
// if (production), return e; else:
useStore.setState(state => {
return {
...state,
e2eSegmentEventCount: state.e2eSegmentEventCount + 1,
};
});
return e;
}
}This does work at the moment, but it's just counting processed events, not ones that have actually been sent.
Proposed Solution
Perhaps some kind of onFlushed event:
export class EventCounter extends Plugin {
type = PluginType.after;
// New event here:
onFlushSuccess(e: SegmentEvent) {
// if (production), return e; else:
useStore.setState(state => {
return {
...state,
e2eSegmentEventCount: state.e2eSegmentEventCount + 1,
};
});
return e;
}
}
// Could even have:
// onFlushFailedOnce the event has passed through this plugin, it can be cleared from memory.
Thanks
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request