Objective
This article explains how to confirm the delivery of events sent using the Segment Node.js SDK and outlines best practices for detecting and handling missing events. It covers the use of SDK event listeners, flush methods, and error handling to ensure reliable event processing and delivery.
Product
Segment
Environment
Segment Console
Procedure
- Register event listeners using the SDK’s
on()andoff()methods fortrack,identify, anderrorevents. - When sending events, use the per-event callback parameter to detect delivery errors for each event.
- After queuing events, call
flush()to submit all pending events to Segment. Wait for the flush to complete before proceeding. - For process shutdown, use
flush({ close: true })to ensure all events are sent before termination. - Monitor the
errorevent listener to capture and handle any delivery failures. - If needed, implement retry logic for transient failures, leveraging the SDK’s built-in exponential backoff and additional custom retries if needed.
Additional Information
- Keep in mind that the Source Debugger provides a sample of ingested events and is not a complete record.
- For critical workflows, consider sending events to a Warehouse or S3 destination for end-to-end validation, as the Source Debugger is not exhaustive.
- For large-scale or critical data backfills, validate event delivery at the destination system when possible.
- For more details, refer to the Segment Node.js SDK documentation.