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

feat: adds support for setting offline mode #635

Closed
wants to merge 3 commits into from

Conversation

kevinpagtakhan
Copy link
Collaborator

This PR introduces online/offline mode support for the Amplitude SDK. Online mode indicates that the platform has an active connection to the network, while offline mode indicates that the platform does not have an active connection to the network. During online mode, the SDK works as usual and sends events at the configured time interval, while during offline mode, the SDK does not send events at all, but stores unsent events to the configured storage. Events persisted in the configured storage are available to be sent at a later time. The SDK by default is set to online mode, unless explicitly set through initialization options or the setOffline() API. Note that the online/offline mode support does not include automatic toggles between modes. The mode must explicitly be set by the instrumenter.

To set Amplitude SDK to offline mode

  • via initialization options
amplitude.init(apiKey, {
  offline: true,
});
  • via setOffline() API
amplitude.setOffline(true)

To set Amplitude SDK to online mode

  • via initialization options (unnecessary because offline mode is false by default)
amplitude.init(apiKey, {
  offline: false,
});
  • via setOffline() API
amplitude.setOffline(false)

Summary

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?:

Copy link
Contributor

@justin-fiedler justin-fiedler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kevinpagtakhan !

@kevinpagtakhan kevinpagtakhan changed the title feat: adds supports for setting offline mode feat: adds support for setting offline mode Dec 18, 2023
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

Successfully merging this pull request may close these issues.

3 participants