Skip to content

Improve Readme #186

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

Merged
merged 4 commits into from
Jun 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 27 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Analytics helps you measure your users, product, and business. It unlocks insigh
3. **Explore your data** by creating metrics (for example, new signups, retention cohorts, and revenue generation).
- The best Segment companies use retention cohorts to measure product market fit. Netflix has 70% paid retention after 12 months, 30% after 7 years.

[Segment](https://segment.com) collects analytics data and allows you to send it to more than 250 apps (such as Google Analytics, Mixpanel, Optimizely, Facebook Ads, Slack, Sentry) just by flipping a switch. You only need one Segment code snippet, and you can turn integrations on and off at will, with no additional code. [Sign up with Segment today](https://app.segment.com/signup).
[Segment](https://segment.com) collects analytics data and allows you to send it to more than 250 apps (such as Google Analytics, Mixpanel, Optimizely, Facebook Ads, Slack, Sentry) just by flipping a switch. You only need one Segment code snippet, and you can turn destinations on and off from the Segment web UI, with no additional code. [Sign up with Segment today](https://app.segment.com/signup).

### Why?

Expand Down Expand Up @@ -54,6 +54,10 @@ If you are part of a new startup (<$5M raised, <2 years since founding),

## Prerequisite

#### React-Native

- Version 0.62 or greater.

#### iOS

- CocoaPods (**recommended**)
Expand All @@ -71,15 +75,17 @@ $ yarn react-native link

See the [API docs](packages/core/docs/classes/analytics.client.md) for more details.

Additional examples of common usage patterns and how-to's can found at [Analytics for React-Native](https://segment.com/docs/connections/sources/catalog/libraries/mobile/react-native/).

<!-- prettier-ignore -->
```js
import analytics from '@segment/analytics-react-native'
import Mixpanel from '@segment/analytics-react-native-mixpanel'
import GoogleAnalytics from '@segment/analytics-react-native-google-analytics'
import mixpanel from '@segment/analytics-react-native-mixpanel'
import firebase from '@segment/analytics-react-native-firebase'

analytics
.setup('writeKey', {
using: [Mixpanel, GoogleAnalytics],
using: [mixpanel, firebase],
recordScreenViews: true,
trackAppLifecycleEvents: true,
trackAttributionData: true,
Expand Down Expand Up @@ -111,22 +117,22 @@ analytics.screen('Home')
There are two ways to send data to your analytics services through this library:

1. [Through the Segment servers](#cloud-based-connection-modes)
2. [Directly from the device using bundled SDK’s](#packaging-device-based-destination-sdks)
2. [Directly from the device using bundled SDK’s](#packaging-device-mode-destination-sdks)

**Note**: Refer to the specific destination’s docs to see if your tool must be bundled in the app or sent server-side.

#### Cloud-based Connection Modes

When an destination’s SDK is not packaged, but it is enabled via your dashboard, the request goes through the Segment REST API, and is routed to the service’s server-side API as [described here](https://segment.com/docs/integrations/#connection-modes).
When an destination’s SDK is not packaged, but it is enabled using the Segment web UI, the request goes through the Segment REST API, and is routed to the service’s server-side API as [described here](https://segment.com/docs/connections/destinations/#connection-modes).

#### Packaging Device-based destination SDKs
#### Packaging Device-mode Destination SDKs

By default, our `@segment/analytics-react-native` package does not contain any device-based destinations.

We recommend using device-based destinations on a need-to-use basis to reduce the size of your application, and avoid running into the dreaded 65k method limit on Android.
We recommend only using device-based destinations on a need-to-use basis to reduce the size of your application, and to avoid running into the dreaded 65k method limit on Android.

If you would like to package device-based destinations, first search for the dependency you need using [the list below](#integrations).
You'll need to run `react-native link` and add it in the `.using()` configuration method. Example using Firebase :
If you would like to package device-based destinations, first search for the dependency you need using [the list below](#supported-device-mode-destinations).
Then run `react-native link` and add it in the `.using()` configuration method. Example using Firebase :

```bash
$ yarn add @segment/analytics-react-native-firebase
Expand All @@ -143,14 +149,17 @@ await analytics.setup('writeKey', {
using: [firebase]
})
```
For IOS you will need to add the GoogleService-info.plist to your IOS folder. This file can be downloaded from your Firebase instance. Firebase takes up to 24 hours to show events. However, you can utilize the Firebase debug method to confirm your setup is sending data correctly. To do this add ```-FIRDebugEnabled``` in Xcode’s Scheme Settings.

In Xcode:
```Project -> Scheme -> Edit Scheme -> Arguments Passed On Launch```
For IOS you must add the GoogleService-info.plist to your iOS folder. This file can be downloaded from your Firebase instance. Firebase takes up to 24 hours to show events. However, you can utilize the Firebase debug method to confirm your setup is sending data correctly. To do this add `-FIRDebugEnabled` in Xcode’s Scheme Settings.

In Xcode:
`Project -> Scheme -> Edit Scheme -> Arguments Passed On Launch`

#### Supported Device-Mode Destinations
Copy link
Contributor

Choose a reason for hiding this comment

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

👍


#### Integrations
> All destinations have the same version as `@segment/analytics-react-native`

> All integrations have the same version as `@segment/analytics-react-native`
**Note**: Each device-mode destination has a different native setup procedure due to differences between the underlying SDK vendors. Please refer to the vendor documentation for configuring the native iOS and Android portions of a given destination. More information and links to vendor specific instructions and details can be found at [Connection Mode Comparisons](https://segment.com/docs/connections/destinations/cmodes-compare/).

<!-- AUTOGEN:INTEGRATIONS:BEGIN -->

Expand Down Expand Up @@ -187,7 +196,7 @@ In Xcode:

We **highly recommend** using Cocoapods.

However, if you cannot use Cocoapods, you can manually install our dynamic framework allowing you to send data to Segment and on to enabled cloud-mode destinations. We do not support sending data to bundled, device-mode integrations outside of Cocoapods.
However, if you cannot use Cocoapods, you can manually install our dynamic framework allowing you to send data to Segment and on to enabled cloud-mode destinations. We do not support sending data to bundled, device-mode destinations outside of Cocoapods.

Here are the steps for installing manually:

Expand All @@ -209,7 +218,7 @@ If you're using Cocoapods, check that your `ios/Podfile` file contains the right
```ruby
pod 'RNAnalytics', :path => '../node_modules/@segment/analytics-react-native'
```
- `Failed to load [...] integration native module`, look for the integration native module, example with Google Analytics:
- `Failed to load [...] integration native module`, look for the destination native module, example with Google Analytics:
```ruby
pod 'RNAnalyticsIntegration-Google-Analytics', :path => '../node_modules/@segment/analytics-react-native-google-analytics'
```
Expand Down Expand Up @@ -239,7 +248,7 @@ Check that `android/app/src/main/.../MainApplication.java` contains a reference
}
```

- `Failed to load [...] integration native module`, look for the integration native module, example with Google Analytics:
- `Failed to load [...] integration native module`, look for the destination native module, example with Google Analytics:

```java
import com.segment.analytics.reactnative.integration.google.analytics.RNAnalyticsIntegration_Google_AnalyticsPackage;
Expand Down