Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary file is not generated #122

Closed
arlyxiao opened this issue Dec 16, 2024 · 1 comment
Closed

Temporary file is not generated #122

arlyxiao opened this issue Dec 16, 2024 · 1 comment
Assignees

Comments

@arlyxiao
Copy link

arlyxiao commented Dec 16, 2024

The issue can be reopen
#121

Debug with the function RunningUpdate
https://github.com/segmentio/Analytics-CSharp/blob/main/Analytics-CSharp/Segment/Analytics/Plugins/StartupQueue.cs#L47

Here are the test steps:

  1. Close the network. Clear all previous test data with full clean test steps.
  2. Initialize segment with default config offline. Only use the write key as parameter for the segment constructor function.
  3. Wait for a few seconds, I can see the state.running is true from the function RunningUpdate, https://github.com/segmentio/Analytics-CSharp/blob/main/Analytics-CSharp/Segment/Analytics/Plugins/StartupQueue.cs#L47
  4. Then I call track event and wait for a few minutes without closing the app. Keep the app running.
  5. The temporary file is still not generated.

In conclusion, if the segment instance is initialized offline, even state.running = true, it will not generate the temporary file.

@wenxi-zeng
Copy link
Contributor

wenxi-zeng commented Dec 16, 2024

@arlyxiao as I have mentioned in the previous thread: if the network is turned off before initialization, then analytics won't be able to get the settings and will fallback to use cached settings. so there are two cases:

  • if the app has being initialized before with network, then it already has a cached validate settings to use. you should see events written to disk with no problem.
  • if the app is started fresh (i.e. all app directories are cleared) and network is off, then the SDK has no idea on what the settings are. the default value is just an empty object, and every destination is turned off by this check if it is not present in settings.integrations. if you definitely want to cover this case you need provide your default settings to defaultSettings in configuration:
var configuration = new Configuration("Your write key",
    defaultSettings: new Settings
    {
        Integrations = new JsonObject
        {
            ["Segment.io"] = new JsonObject
            {
                ["apiKey"] = "Your write key"
            }
        }
    });

make sure all analytics related directories are cleared before testing it again.

however, I do not recommend of doing this, because it leads to another edge case: your settings instruct the SDK to track events but your remote settings actually turned off segment.io as an destination. then when the network comes back, you will see cached events sending to your segment dashboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants