segmentio / Analytics-CSharp

The hassle-free way to add Segment analytics to your C# written app (.Net/Xamarin/Unity).
MIT License
21 stars 8 forks source link

Why does the function PendingUpload unsent events #112

Closed arlyxiao closed 1 month ago

arlyxiao commented 1 month ago

The function PendingUpload will be called when initialized analytics. And then remove the file without sending the events.

1727580004498

Why not send the events when initialize analytics? If it only removes files without sending events. These events will be lost. This doesn't make sense.

In my use case, It should flush all old temporary before purge whatever the scenario is.

wenxi-zeng commented 1 month ago

hi @arlyxiao, these two functions PendingUploads and PurgeStorage are utility functions for people who wanna control the storage themselves. the SDK itself does not use these two functions for flush. if you want to flush the events before purge, simple do

    analytics.Flush();  // flush events
    analytics.PurgeStorage();  // remove damaged files that can't be flushed

the functions only do what it intends to do. Flush for flushing. Purge for cleaning.

if you want to flush at app launch, see this StartupPolicy for example.