amplitude / analytics-go

Go Amplitude Analytics SDK
MIT License
12 stars 7 forks source link

fix: avoid lost of events on transmission failure #56

Closed gilbertsoft closed 1 year ago

gilbertsoft commented 1 year ago

Summary

This PR addresses an issue with events get lost when marked for retry e.g. because of a transmission failure. If such events remain after processing, they will be returned back to storage using the ReturnBack method for later handling.

In our case we use a special storage which caches hundreds of events and delivers them once a day or if a number of events in the cache has reached. During our tests we reached the limits and the events which could not be delivered were lost in the end because of the missing handling of this case in the code. It should also be possible to reproduce this problem with the default storage by reaching the limits or cover it by a test which tests the case of a http status 429 returned by the API.

It's maybe a rare case but would be good it could be addressed to avoid the lost of any event.

Checklist

rfay commented 1 year ago

Ping - We're having to use a fork for this right now. Could you take a look please? Thanks!

rfay commented 1 year ago

Yay, thanks!

justin-fiedler commented 1 year ago

Hey @gilbertsoft just saw that the test coverage is failing. Can you please fix the tests? Otherwise we will take a look next week. Thanks!

gilbertsoft commented 1 year ago

Hey @gilbertsoft just saw that the test coverage is failing. Can you please fix the tests? Otherwise we will take a look next week. Thanks!

Sure, will have a look...

falconandy commented 1 year ago

Hi @gilbertsoft @justin-fiedler I fixed tests.

gilbertsoft commented 1 year ago

Hi @gilbertsoft @justin-fiedler I fixed tests.

Thanks for the update. Just started to debug.

gilbertsoft commented 1 year ago

Hi @gilbertsoft @justin-fiedler I fixed tests.

I left you a comment on the PR, the Return(nil) is not needed here.

justin-fiedler commented 1 year ago

Thanks @gilbertsoft and @falconandy! Fix is released in v1.0.1.