From 6938ed6f1872155b1ac46eaf5ba24f8496e2796f Mon Sep 17 00:00:00 2001 From: Taylor Dixon Date: Mon, 29 Apr 2024 12:57:47 -0600 Subject: [PATCH] PLAT-14519: Resolving issue with segment library hanging CLI --- scripts/analytics/wrapper.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/analytics/wrapper.js b/scripts/analytics/wrapper.js index 94131e8..1bde68f 100644 --- a/scripts/analytics/wrapper.js +++ b/scripts/analytics/wrapper.js @@ -36,7 +36,12 @@ class AnalyticsWrapper { try { this.analytics = new Analytics({ - writeKey: token + writeKey: token, + // Segment node library was built for long running node processes like express. + // Maintain a lower values for flush than library defaults, so that segment does not + // hang CLI node process while waiting for queue to flush. + flushAt: 3, + flushInterval: 100 }); } catch { // Ignore errors during initialization - TODO: log to sentry