You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To use your own persistence layer you can use the storePersistor option when initializing the client. Make sure you always have a persistor (either by having AsyncStorage package installed or by explicitly passing a value), else you might get unexpected side effects like multiple 'Application Installed' events
50
+
To use your own persistence layer you can use the storePersistor option when initializing the client. Make sure you always have a persistor, either by having AsyncStorage package installed or by explicitly passing a value, or you might get unexpected side effects like multiple 'Application Installed' events.
51
51
52
52
4. If you're using iOS, install native modules with:
53
53
@@ -75,7 +75,7 @@ These are the options you can apply to configure the client:
The Reset method clears the internal state of the library for the current user and group. This is useful for apps where users can log in and out with different identities over time.
276
276
277
277
> warning ""
278
-
> Each time you call Reset, a new AnonymousId is generated automatically.
278
+
> **Note:** Each time you call Reset, Segment generates a new AnonymousId.
279
279
280
280
{% codeexample %}
281
281
{% codeexampletab Method signature %}
@@ -333,8 +333,9 @@ If you don't do this, the old client instance would still exist and retain the t
333
333
334
334
Ideally, you shouldn'thavetousethismethodandtheSegmentclientshouldbeinitializedonlyonceintheapplicationlifecycle.
>Ifyouimplementcustomflushpolicies, theyreplaceSegment's default Count and Timer policies. To incorporate custom policies, add your custom Timer and Count policies to the client'sFlushPoliciesconfiguration.
@@ -399,7 +401,8 @@ Your policies also have a `shouldFlush` observable boolean value. When this is s
399
401
export class FlushOnScreenEventsPolicy extends FlushPolicyBase {
400
402
onEvent(event: SegmentEvent): void {
401
403
// Only flush when a screen even happens
402
-
if (event.type === EventType.ScreenEvent) {
404
+
if (event.type \
405
+
EventType.ScreenEvent) {
403
406
this.shouldFlush.value = true;
404
407
}
405
408
}
@@ -414,6 +417,7 @@ export class FlushOnScreenEventsPolicy extends FlushPolicyBase {
414
417
## Automatic screen tracking
415
418
To avoid sending a Screen event with each navigation action, you can track navigation globally. The implementation depends on which navigation library you use. The two main navigation libraries for React Native are [React Navigation](https://reactnavigation.org/){:target="_blank"} and [React Native Navigation](https://wix.github.io/react-native-navigation/docs/before-you-start/){:target="_blank"}.
416
419
420
+
417
421
### React Navigation
418
422
When setting up React Navigation, find the root-level navigation container and call `screen()` whenever the user navigates to a new screen. Segment's [exampleapp](https://github.com/segmentio/analytics-react-native/tree/master/example){:target="_blank"} is set up with screen tracking using React Navigation, so you can use it as a guide.
419
423
@@ -457,7 +461,7 @@ To set up automatic screen tracking with React Navigation:
457
461
}
458
462
}}
459
463
>
460
-
```
464
+
```
461
465
462
466
### React Native Navigation
463
467
To set up automatic screen tracking while using [React Native Navigation](https://wix.github.io/react-native-navigation/docs/before-you-start/){:target="_blank"}:
@@ -482,19 +486,21 @@ Segment's plugin architecture lets you modify and augment how the events are pro
482
486
| `enrichment` | Executes as the first level of event processing. |
483
487
| `destination` | Executes as events begin to pass off to destinations. |
484
488
| `after` | Executes after all event processing is completed. You can use this to perform cleanup operations. |
485
-
| `utility` | Executes only with manual calls such as Logging. |
489
+
| `utility` | Executes only with manual calls like Logging. |
486
490
487
491
> info ""
488
-
> Plugins can have their own native code, such as the iOS-only [`IdfaPlugin`](https://github.com/segmentio/analytics-react-native/blob/829fc80bc8c4f59fa99dadd25083efa422d577f0/packages/plugins/plugin-idfa/README.md){:target="_blank"}, or wrap an underlying library, such as the [`FirebasePlugin`](https://www.npmjs.com/package/@segment/analytics-react-native-plugin-firebase){:target="_blank"} which uses `react-native-firebase`.
492
+
> Plugins can have their own native code (like the iOS-only [`IdfaPlugin`](https://github.com/segmentio/analytics-react-native/blob/829fc80bc8c4f59fa99dadd25083efa422d577f0/packages/plugins/plugin-idfa/README.md){:target="_blank"}) or wrap an underlying library (like the [`FirebasePlugin`](https://www.npmjs.com/package/@segment/analytics-react-native-plugin-firebase) which uses `react-native-firebase` under the hood).
489
493
490
494
### Destination plugins
491
-
Segment provides a `DestinationPlugin`. You can add additional destination plugins and upload events and data to them.
495
+
Segment is an out-of-the-box `DestinationPlugin`. You can add as many other destination plugins as you like and upload events and data to them.
496
+
492
497
493
498
If you don't want the Segment destination plugin, set `autoAddSegmentDestination=false` in the options when setting up your client. This prevents the `SegmentDestination` plugin from being added automatically.
494
499
495
500
### Adding plugins
496
501
You can add a plugin at any time using `segmentClient.add()`.
@@ -515,6 +521,7 @@ segmentClient.add({ plugin: new IdfaPlugin() });
515
521
### Writing your own plugins
516
522
Plugins implement as [ES6 classes](https://www.w3schools.com/react/react_es6_classes.asp){:target="_blank"}. To get started, familiarize yourself with the available classes in `/packages/core/src/plugin.ts`.
517
523
524
+
518
525
The available plugin classes are:
519
526
- `Plugin`
520
527
- `EventPlugin`
@@ -608,11 +615,12 @@ These are the example plugins you can use and alter to meet your tracking needs:
> Destination filters are only available to Business Tier customers.
614
622
>
615
-
> Destination filters on mobile device-mode destinations are in beta and only supports Analytics-React-Native 2.0, [Analytics-Swift](/docs/connections/sources/catalog/libraries/mobile/swift/) and [Analytics-Kotlin](/docs/connections/sources/catalog/libraries/mobile/kotlin-android/).
623
+
> Destination filters on mobile device-mode destinations are in beta and only support Analytics-React-Native 2.0, [Analytics-Swift](/docs/connections/sources/catalog/libraries/mobile/swift/) and [Analytics-Kotlin](/docs/connections/sources/catalog/libraries/mobile/kotlin-android/).
616
624
617
625
Use Analytics-React-Native 2.0 to set up [destination filters](/docs/connections/destinations/destination-filters/) on your mobile device-mode destinations.
618
626
@@ -649,6 +657,7 @@ To get started with destination filters on mobile device-mode destinations using
649
657
650
658
## Supported destinations
651
659
Segment supports a large number of [cloud-mode](/docs/connections/destinations/#connection-modes) destinations. Segment also supports the following destinations for Analytics React Native 2.0 in device-mode:
@@ -663,6 +672,8 @@ On Android, Segment's React Native library generates a unique ID by using the DR
663
672
To collect the Android Advertising ID provided by Play Services, Segment provides a [plugin](https://github.com/segmentio/analytics-react-native/tree/master/packages/plugins/plugin-advertising-id){:target="_blank"} that can be used to collect that value. This value is set to `context.device.advertisingId`. For iOS, this [plugin](https://github.com/segmentio/analytics-react-native/tree/master/packages/plugins/plugin-idfa){:target="_blank"} can be used to set the IDFA `context.device.advertisingId` property.
664
673
665
674
## FAQs
675
+
Find answers to common Analytics React Native questions.
676
+
666
677
#### Can I use the catalog of device-mode destinations from Segment's 1.X.X React-Native release?
667
678
No, only the plugins [listed](#plugin-types) are supported in device-mode for Analytics React Native 2.0.
668
679
#### Will I still see device-mode integrations listed as `false` in the integrations object?
The `instanceId` was introduced in [v2.10.1](https://github.com/segmentio/analytics-react-native/releases/tag/%40segment%2Fanalytics-react-native-v2.10.1) and correlates events to a particular instance of the client in a scenario when you might have multiple instances on a single app.
687
699
700
+
688
701
#### How do I interact with the Integrations object?
689
702
The Integrations object is no longer part of the Segment events method signature. To access the Integrations object and control what destinations the event reaches, you can use a plugin:
690
703
@@ -711,8 +724,10 @@ import {
711
724
}
712
725
}
713
726
```
727
+
714
728
#### How do I add to the Context object?
715
729
You need to use a plugin to access and modify the Context object. For example, to add `context.groupId` to every Track call, create a plugin like this:
730
+
716
731
```js
717
732
//in AddToContextPlugin.js
718
733
import {
@@ -740,12 +755,14 @@ import { AddToContextPlugin } from './AddToContextPlugin'
#### I've upgraded to React Native 2.0, but I'm still getting warnings in the Google Play Store that my app is not compliant. Why is this?
744
-
The React Native 2.0 library is compliant with Google Play Store policies. However, Segment recommends that you check to see if there are any old and inactive [tracks on the Google Play Store](https://developers.google.com/android-publisher/tracks){:target="_blank"} that are not updated to the latest build. If this is the case, we recommend updating those tracks to resolve the issue.
758
+
### I've upgraded to React Native 2.0, but I am still getting warnings in the Google Play Store that my app is not compliant. Why is this?
759
+
The React Native 2.0 library is compliant with Google Play Store policies. However, Segment recommends that you check to see if there are any old and inactive [tracks on the Google Play Store](https://developers.google.com/android-publisher/tracks){:target="_blank"} that are not updated to the latest build. If this is the case, Segment recommends updating those tracks to resolve the issue.
760
+
745
761
746
762
#### Can I set `inlineRequires` to false in my `metro.config.js` file?
747
763
Segment requires the `inlineRequires` value in your `metro.config.js` value to be set to `true`. To disable `inlineRequires` for certain modules, you can specify this using a [blockList](https://facebook.github.io/metro/docs/configuration/#:~:text=If%20inlineRequires%20is%20an%20object){:target="_blank"}.
748
764
765
+
749
766
#### Can I clear user traits without calling the Reset method?
750
767
The Reset method on `userInfo` can accept a function that receives the current state and returns a modified desired state. Using this method, you can return the current traits, delete any traits you no longer wish to track, and persist the new trait set.
0 commit comments