Add notes on usage in serverless environments #5380
Merged
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.
.track
calls in aPromise
in these environments, which isn't mentioned in this doc.Proposed changes
Added some documentation here in hopes of saving other developers the several hours I unfortunately spent thinking that just calling
await closeAndFlush()
would suffice for serverless environments—I needed to do the combination of both:analytics.track
calls in aPromise
andawait
ing itanalytics()
— otherwise my big batch of events just never getting sent despite callingcloseAndFlush()
and having that return. I didn't add this to the documentation since I'm not sure if I'm doing this correctly— any feedback would be appreciated. Happy to update the documentation with this additional information if this is actually necessary. The README seems to suggest it's only necessary if using plugins.Merge timing
ASAP to prevent any other developers upgrading from the deprecated
analytics-node
to this library that use it in a serverless environment and previously depended onawait analytics.flush()
.Related issues (optional)
flush
does not guarantee that all inflight messages are sent analytics-node#309