expo-analytics-segment
provides access to https://segment.com/ mobile analytics. Wraps Segment's iOS and Android sources.Note: Session tracking may not work correctly when running Experiences in the main Expo app. It will work correctly if you create a standalone app.
Android Device | Android Emulator | iOS Device | iOS Simulator | Web |
---|---|---|---|---|
Pending |
expo install expo-analytics-segment
If you're installing this in a bare React Native app, you should also follow these additional installation instructions.
import * as Segment from 'expo-analytics-segment';
Segment.initialize()
but before other segment calls. See https://segment.com/docs/spec/identify/.null
.null
.null
.options
object would be:{ "integrations": { "Sentry": { "enabled": true } }, "context": { "ip": "0.0.0.0" } }
Promise
resolving to a boolean
indicating whether the method has been executed on the underlying Segment instance or not.null
.Depending on the audience for your app (e.g. children) or the countries where you sell your app (e.g. the EU), you may need to offer the ability for users to opt-out of analytics data collection inside your app. You can turn off forwarding to ALL destinations including Segment itself: (Source – Segment docs)
import * as Segment from 'expo-analytics-segment'; Segment.setEnabledAsync(false); // Or if they opt-back-in, you can re-enable data collection: Segment.setEnabledAsync(true);
Note: disabling the Segment SDK ensures that all data collection method invocations (eg.track
,identify
, etc) are ignored.
setEnabledAsync(false)
, Segment won't track the users even when the app restarts. To check whether tracking is enabled, use Segment.getEnabledAsync()
which returns a promise which should resolve to a boolean.