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
Copy file name to clipboardExpand all lines: src/connections/sources/catalog/libraries/mobile/react-native/classic.md
+39-40Lines changed: 39 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ hidden: true
6
6
> info "Analytics for React Native 2.0"
7
7
> Analytics for React Native 2.0 is available. For more information, see the [Analytics for React Native 2.0 GitHub repository](https://github.com/segmentio/analytics-react-native){:target="_blank"}.
8
8
9
-
Analytics for React Native makes it easy to send your data to any analytics or marketing tool without having to learn, test, or implement a new API every time.
9
+
Analytics for React Native makes it easy to send your data to any analytics or marketing tool without having to learn, test or implement a new API every time.
10
10
11
11
All of Segment's libraries are open-source, and you can [view Analytics for React Native on GitHub](https://github.com/segmentio/analytics-react-native){:target="_blank"}, or see a list of the other [Segment browser and server libraries](/docs/connections/sources/catalog/){:target="_blank"} too.
12
12
@@ -16,9 +16,9 @@ All of Segment's libraries are open-source, and you can [view Analytics for Reac
16
16
In cloud-mode, Analytics-React-Native functions as a normal Segment library. In device-mode it wraps the Segment [Analytics-iOS](/docs/connections/sources/catalog/libraries/mobile/ios/) and [Analytics-Android](/docs/connections/sources/catalog/libraries/mobile/android/) libraries, and loads the appropriate mobile library depending on the user's platform. Because of this, Analytics-React-Native includes the two mobile libraries as dependencies.
17
17
18
18
> warning ""
19
-
> When you bundle a destination’s device-mode SDK, the React Native library serves as a wrapper for the iOS or Android source libraries. To access the underlying destination code, it's necessary to write bridging code between the React Native wrapper and the destination’s SDK.
19
+
> When you bundle a destination’s device-mode SDK, the React Native library serves as a wrapper for the iOS or Android source libraries. To access the underlying destination code, it is necessary to write bridging code between the React Native wrapper, and the destination’s SDK.
20
20
>
21
-
> For example, to configure deep linking or retrieve the Appsflyer ID in Appsflyer, or configure in-app messages or push notifications in Braze, you must write code to specifically access these methods from the destination SDK.
21
+
> For example, if to configure deep linking or retrieve the Appsflyer ID in Appsflyer, or configure in-app messages or push notifications in Braze, you must write code to specifically access these methods from the destination SDK.
22
22
23
23
### Analytics-React-Native and Unique Identifiers
24
24
@@ -28,7 +28,7 @@ One of the most important parts of any analytics platform is the ability to cons
28
28
29
29
Apple restricts how you can generate and use unique IDs to help protect end-users' privacy. Segment generates IDs while remaining in compliance with Apple's policies.
30
30
31
-
Before iOS 5, developers had access to `uniqueIdentifier`, which was a hardware-specific serial number that was consistent across different apps, vendors, and installs. Starting with iOS 5, however, [Apple deprecated access to this identifier](https://developer.apple.com/news/?id=3212013a){:target="_blank"}. In iOS 6, Apple introduced the `identifierForVendor` which protects end-users from cross-app identification. In iOS 7, Apple [restricted access to the device’s MAC address](http://techcrunch.com/2013/06/14/ios-7-eliminates-mac-address-as-tracking-option-signaling-final-push-towards-apples-own-ad-identifier-technology/){:target="_blank"}, which many developers used as a workaround to get a similar device-specific serial number to replace `uniqueIdentifier`.
31
+
Before iOS 5 developers had access to `uniqueIdentifier`, which was a hardware-specific serial number that was consistent across different apps, vendors and installs. Starting with iOS 5, however, [Apple deprecated access to this identifier](https://developer.apple.com/news/?id=3212013a){:target="_blank"}. In iOS 6 Apple introduced the `identifierForVendor` which protects end-users from cross-app identification. In iOS 7 Apple [restricted access to the device’s MAC address](http://techcrunch.com/2013/06/14/ios-7-eliminates-mac-address-as-tracking-option-signaling-final-push-towards-apples-own-ad-identifier-technology/){:target="_blank"}, which many developers used as a workaround to get a similar device-specific serial number to replace `uniqueIdentifier`.
32
32
33
33
Segment’s iOS library supports iOS 7+ by generating a UUID and storing it on disk. This complies with Apple’s required privacy policies, maintains compatibility, and also enables correct tracking in situations where multiple people use the same device, since the UUID can be regenerated.
34
34
@@ -66,37 +66,36 @@ To add CocoaPods to your app, follow [these instructions](https://facebook.githu
66
66
67
67
### Install the SDK
68
68
69
-
Segment recommends that you use NPM to install Analytics for React Native. This allows you to create a build with specific destinations, and makes it much easier to install and upgrade the library and any components.
69
+
Segment recommends that you use NPM to install Analytics for React Native. This allows you to create a build with specific destinations, and makes it much easier to install and upgrade the library and any components. To install the SDK:
70
70
71
-
First, add the `@segment/analytics-react-native` dependency to your `dependencies` and link it using `react-native-cli`, using the example commands below.
71
+
1. Add the `@segment/analytics-react-native` dependency to your `dependencies` and link it using `react-native-cli`, using the example commands below.
72
72
73
-
```bash
74
-
$ yarn add @segment/analytics-react-native
75
-
$ yarn react-native link
76
-
```
73
+
```bash
74
+
$ yarn add @segment/analytics-react-native
75
+
$ yarn react-native link
76
+
```
77
77
78
-
Then in your application, set up the library as in the example below.
78
+
2. In your application, set up the library as in the example below.
79
79
80
-
```js
81
-
awaitanalytics.setup('YOUR_WRITE_KEY', {
82
-
// Record screen views automatically!
83
-
recordScreenViews:true,
84
-
// Record certain application events automatically!
85
-
trackAppLifecycleEvents:true
86
-
})
87
-
```
88
-
89
-
Next, make sure you import Analytics-React-Native in any files that you want to use it in. You can use an `import` statement like the example below.
80
+
```js
81
+
await analytics.setup('YOUR_WRITE_KEY', {
82
+
// Record screen views automatically!
83
+
recordScreenViews: true,
84
+
// Record certain application events automatically!
85
+
trackAppLifecycleEvents: true
86
+
})
87
+
```
88
+
3. Make sure you import Analytics-React-Native in any files that you use want to it in. You can use an `import` statement like the example below.
90
89
91
90
```js
92
91
import analytics from '@segment/analytics-react-native'
93
92
```
94
93
95
94
### Dynamic Framework for Manual Installation
96
95
97
-
Segment only supports sending data to bundled, device-mode destinations if you're using Cocoapods to manage your dependencies. Our Support staff cannot answer questions about, and are not responsible for, projects that do not use Cocoapods.
96
+
Segment only supports sending data to bundled, device-mode destinations if you are using Cocoapods to manage your dependencies. Our Support staff cannot answer questions about, and are not responsible for, projects that do not use Cocoapods.
98
97
99
-
If you absolutely cannot use Cocoapods, you can manually install our dynamic framework which allows you to send data to Segment, and have Segment send it on to enabled cloud-mode destinations.
98
+
If you can't use Cocoapods, you can manually install Segment's dynamic framework which allows you to send data to Segment, and have Segment send it on to enabled cloud-mode destinations.
100
99
101
100
To install Analytics-React-native manually:
102
101
@@ -105,12 +104,12 @@ To install Analytics-React-native manually:
> **Note**: if you choose not to use a dependency manager, you must keep all of the files up-to-date with regularly scheduled, manual updates.
107
+
>**Note**: If you choose not to use a dependency manager, you must keep all of the files up-to-date with regularly scheduled, manual updates.
109
108
110
109
111
110
### Packaging Destinations using Device-mode
112
111
113
-
By default, Analytics-React-Native sends all of your data first to the Segment servers, which forward the data on to any tools you enabled from the Segment web app. It doesn't package any external destination code by default. This is known as sending your data using "Cloud-mode", and it helps reduce the size of your project.
112
+
By default, Analytics-React-Native sends all of your data first to the Segment servers, which forward the data on to any tools you enabled from the Segment web app. It does not package any external destination code by default. This is known as sending your data using "Cloud-mode", and it helps reduce the size of your project.
114
113
115
114
However, some destinations require that you include code in your project that can be run on the user's device so that these tools can function correctly. These destinations send data directly to the destination's API endpoints, as well as sending a copy to the Segment servers forarchiving. This is known as sending datain"device-mode". Other destinations offer a device-mode SDK, but still work (with reduced features) in cloud-mode.
116
115
@@ -119,7 +118,7 @@ You can read [more about connection modes](/docs/connections/destinations/#conne
119
118
> success ""
120
119
>**Tip!** Segment recommends that you use Device-mode destinations only when necessary to use device-specific features, so you can reduce the size of your application.
121
120
122
-
To use a device-mode destination, you add the destination's SDK to the project. You can find information about these in the destination information pages in the Segment app. Any mobile destination with a Device-mode option includes information on how to bundle SDK.
121
+
To use a device-mode destination, add the destination's SDK to the project. You can find information about these in the destination information pages in the Segment app. Any mobile destination with a Device-mode option includes information on how to bundle SDK.
123
122
124
123
> warning ""
125
124
> **Good to know**: Not all destinations have a device-mode package available for use with React Native. [See the list below](#destinations-that-support-device-mode-for-react-native). If a destination you want to use doesn't offer a React Native SDK, you can usually still use it in cloud-mode instead.
> If you are bundling several device-mode destinations in your project, you might want to make a checklist to make sure you add the relevant dependencies and add import statements.
135
+
> If you are bundling several device-mode destinations in your project, you might want to make a checklist to make sure you add the relevant dependencies, and add import statements.
137
136
138
137
See the [device mode documentation in the React Native readme](https://github.com/segmentio/analytics-react-native/#packaging-device-mode-destination-sdks){:target="_blank"} for more details.
139
138
@@ -188,7 +187,7 @@ Now that the library is installed and some SDKs are set up, you're ready to lear
188
187
189
188
### Identify
190
189
191
-
The [Identify call](/docs/connections/spec/identify/) lets you tie a user to their actions and record traits about them. It includes a unique User ID and any optional traits you know about them.
190
+
The [Identify call](/docs/connections/spec/identify/) lets you tie a user to their actions, and record traits about them. It includes a unique User ID, and any optional traits you know about them.
192
191
193
192
Segment recommends that you make an Identify call when the user first creates an account, and when they update their information. If users can log out of your app, you should call `identify` when a user logs back in.
194
193
@@ -197,7 +196,7 @@ Analytics-React-Native works on its own background thread, so it never blocks th
197
196
> note ""
198
197
>**Note**: Segment automatically assigns an `anonymousId` to users before you identify them. The `userId` is what connects anonymous activities across devices.
199
198
200
-
The example Identify call below identifies a user by their unique User ID (the one you know them by in your database), and labels them with `name` and `email` traits.
199
+
The example Identify call below identifies a user by their unique User ID (the one you know them by in your database), and labels them with a `name` and `email` traits.
201
200
202
201
```js
203
202
analytics.identify("a user's id", {
@@ -270,7 +269,7 @@ You can read more about the Track call fields on [the Segment Spec page about th
270
269
271
270
The [Screen call](/docs/connections/spec/screen/) lets you you record whenever a user sees a screen of your mobile app, along with optional extra information about the page being viewed. This is very similar to the [Page call](/docs/connections/spec/page/) that you would use for non-mobile users.
272
271
273
-
Record a screen event whenever the user opens or navigates to a new screen in your app. This could be a view, fragment, dialog, or activity depending on your app.
272
+
Record a screen event an event whenever the user opens or navigates to a new screen in your app. This could be a view, fragment, dialog or activity depending on your app.
274
273
275
274
The example Screen call below shows a user viewed the Photo Feed, and that the page was private.
276
275
@@ -297,9 +296,9 @@ You can read more about the Screen call fields on [the Segment Spec page about t
297
296
298
297
### Group
299
298
300
-
The [Group call](/docs/connections/spec/group/) lets you associate an [identified user](#identify) user with a group. A group could be a company, organization, account, project, or team. The call also lets you record custom traits about the group, like industry or number of employees.
299
+
The [Group call](/docs/connections/spec/group/) lets you associate an [identified user](#identify) user with a group. A group could be a company, organization, account, project or team. The call also lets you record custom traits about the group, like industry or number of employees.
301
300
302
-
The Group call is useful for tools like [Intercom](/docs/connections/destinations/catalog/intercom/), [Preact](/docs/connections/destinations/catalog/preact/), and [Totango](/docs/connections/destinations/catalog/totango/), as it ties the user to a **group** of other users.
301
+
The Group call is useful for tools like [Intercom](/docs/connections/destinations/catalog/intercom/), [Preact](/docs/connections/destinations/catalog/preact/) and [Totango](/docs/connections/destinations/catalog/totango/), as it ties the user to a **group** of other users.
303
302
304
303
The example Group call below adds the current user to the `myGroup` group, and adds a name and description.
305
304
@@ -327,7 +326,7 @@ You can read more about the Group method, including the group call payload, in [
327
326
328
327
### Alias
329
328
330
-
You can use Alias calls to link one identity with another. This is an advanced method, but it's required to manage user identities correctly in *some* destinations.
329
+
You can use Alias calls to link one identity with another. This is an advanced method, but it is required to manage user identities correctly in *some* destinations.
331
330
332
331
In [Mixpanel](/docs/connections/destinations/catalog/mixpanel/#alias) it's used to associate an anonymous user with an identified user once they sign up. For [Kissmetrics](/docs/connections/destinations/catalog/kissmetrics/#alias), if your user switches IDs, you can use 'alias' to rename the 'userId'.
333
332
@@ -405,7 +404,7 @@ analytics.reset()
405
404
406
405
### Flush
407
406
408
-
By default, the library collects 20 events in the queue before flushing (sending) them, but you can modify this number.
407
+
By default, the library collects 20 events in the queue before flushing (sending) them, but you modify this number.
409
408
410
409
You can set`flushAt` to `1` to send events as they come in, and not in batches. This approach uses more battery.
In some cases, you might want to add information to [the `context` object](/docs/connections/spec/common/#context) in the Segment message payload. This can be useful for adding context or session data for an event that doesn't have another logical place to add it, such as in an Identify, Screen, or Group.
450
+
In some cases, you might want to add information to [the `context` object](/docs/connections/spec/common/#context) in the Segment message payload. This can be useful for adding context or session data for an event that doesn't have another logical place to add it, such as in an Identify, Screen or Group.
By default, events are delivered to any cloud-mode destinations currently enabled in the Segment web app. You can override this delivery by adding a list to exclude, as in the example above. In this example, the event doesn't reach the Mixpanel destination.
466
+
By default, events are delivered to any cloud-mode destinations currently enabled in the Segment web app. You can override this delivery by adding a list to exclude, as in the example above. In this example, the event does not reach the Mixpanel destination.
468
467
469
468
> success ""
470
-
> **Tip!** Items in the Integrations object are **case sensitive** and must match the actual destination name. Many destination documentation pages include a list of acceptable names when the correct name isn't clear.
469
+
>**Tip!** Items in the Integrations object are **case sensitive** and must match the actual destination name. Many destination documentation pages include a list of acceptable names when the correct name is not clear.
471
470
472
471
## Identity and privacy
473
472
@@ -487,7 +486,7 @@ If a user opts back in at a later date, you can re-enable data collection using
487
486
analytics.enable()
488
487
```
489
488
490
-
When you disable the Segment library, all data collection methods (`track`, `identify`, etc) stop running; however, it doesn't remove the initialized libraries. If you bundle device-mode SDKs which collect data automatically, or outside of Segment, those continue to operate. Segment recommends that you invoke a disable method in each of packaged SDK when a user opts-out, to ensure all automatic data collection stops.
489
+
When you disable the Segment library, all data collection methods (`track`, `identify`, etc) stop running; however, it does not remove the initialized libraries. If you bundle device-mode SDKs which collect data automatically, or outside of Segment, those continue to operate. Segment recommends that you invoke a disable method in each of packaged SDK when a user opts-out, to ensure all automatic data collection stops.
491
490
492
491
### Anonymizing IP
493
492
@@ -524,7 +523,7 @@ React Native doesn't provide an official JavaScript API to handle push notificat
524
523
525
524
### React Native push notifications on iOS
526
525
527
-
For services that send push notifications, you first want to [create a Push SSL certificate following these steps](https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/AddingCapabilities/AddingCapabilities.html){:target="_blank"}. You then want to configure your application delegate to look like the code below and replace your Segment source write key.
526
+
For services that send push notifications, you first want to [create a Push SSL certificate following these steps](https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/AddingCapabilities/AddingCapabilities.html){:target="_blank"}. You then want to configure your application delegate to look like the code below, and replace your Segment source write key.
0 commit comments