Ensure all events are sent before application exit:
// Flush all pending eventsawait analytics.closeAndFlush()// With timeoutawait analytics.closeAndFlush({ timeout: 5000 })// Good practice: flush on process exitprocess.on('SIGTERM', async () => { await analytics.closeAndFlush() process.exit(0)})