feat: Add afterEventEnqueue hook execution for event enqueueing #134
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requirements
Related issues
This PR introduces a new
afterEventEnqueue
hook that allows developers to observe when events are enqueued for processing in the LaunchDarkly SDK.Describe the solution you've provided
New Feature: afterEventEnqueue Hook
This PR introduces a complete implementation of the
afterEventEnqueue
hook functionality, allowing developers to hook into the event enqueuing process for monitoring, analytics, and debugging purposes.Implementation Details
1. Hook Runner Implementation (
HookRunner.js
)AFTER_ENQUEUE_STAGE_NAME
constant for consistent stage namingexecuteAfterEnqueue()
function that executes hooks in reverse order (consistent with other "after" hooks)afterEventEnqueue()
method to the HookRunner interface with proper empty hooks handlingtryExecuteStage()
for robust exception handling2. SDK Integration (
index.js
)enqueueEvent()
function:hookRunner.afterEventEnqueue(event)
3. TypeScript Type Definitions (
typings.d.ts
)EventEnqueueContext
interface with comprehensive typing for all event types:identify
events: context, creationDatefeature
events: key, context, value, variation, version, default, reason, trackEvents, debugEventsUntilDatecustom
events: key, context, data, metricValue, url, contextKind, creationDatedebug
events: all feature event propertiesHook
interface to includeafterEventEnqueue?(hookContext: EventEnqueueContext): void
Usage Example
Additional context
This new hook provides developers with observability into the SDK's event processing pipeline. It's particularly useful for: