All Projects → leoilab → React Native Analytics Segment Io

leoilab / React Native Analytics Segment Io

Licence: mit
A React Native module for Segment Analytics

Projects that are alternatives of or similar to React Native Analytics Segment Io

Typewriter
Type safety + intellisense for your Segment analytics
Stars: ✭ 146 (+102.78%)
Mutual labels:  analytics, segment
Analytics Vue
The hassle-free way to integrate analytics into your Vue application.
Stars: ✭ 87 (+20.83%)
Mutual labels:  analytics, segment
Analytics
UNMAINTAINED! - Complete Google Analytics, Mixpanel, KISSmetrics (and more) integration for Meteor
Stars: ✭ 211 (+193.06%)
Mutual labels:  analytics, segment
Analytics React
[DEPRECATED AND UNSUPPORTED] The hassle-free way to integrate analytics into your React application.
Stars: ✭ 146 (+102.78%)
Mutual labels:  analytics, segment
Redux Segment
Segment.io analytics integration for redux.
Stars: ✭ 517 (+618.06%)
Mutual labels:  analytics, segment
Monocle
Detect anomalies in your GitHub/Gerrit projects
Stars: ✭ 50 (-30.56%)
Mutual labels:  analytics
Eventql
Distributed "massively parallel" SQL query engine
Stars: ✭ 1,121 (+1456.94%)
Mutual labels:  analytics
Batchman
This library for Android will take any set of events and batch them up before sending it to the server. It also supports persisting the events on disk so that no event gets lost because of an app crash. Typically used for developing any in-house analytics sdk where you have to make a single api call to push events to the server but you want to optimize the calls so that the api call happens only once per x events, or say once per x minutes. It also supports exponential backoff in case of network failures
Stars: ✭ 50 (-30.56%)
Mutual labels:  analytics
Nsdb
Natural Series Database
Stars: ✭ 49 (-31.94%)
Mutual labels:  analytics
Sas Container Recipes
A collection of recipes and other resources for building containers that include SAS Viya software.
Stars: ✭ 71 (-1.39%)
Mutual labels:  analytics
Porcupine
Express parametrable, composable and portable data pipelines
Stars: ✭ 70 (-2.78%)
Mutual labels:  analytics
Dashboard Extension Webpage Item
⛔ DEPRECATED. This project was moved to a new repository. Visit https://github.com/DevExpress/dashboard-extensions to find an updated version.
Stars: ✭ 62 (-13.89%)
Mutual labels:  analytics
Ostrio
▲ Web services for JavaScript, Angular.js, React.js, Vue.js, Meteor.js, Node.js, and other JavaScript-based websites, web apps, single page applications (SPA), and progressive web applications (PWA). Our services: Pre-rendering, Monitoring, Web Analytics, WebSec, and Web-CRON
Stars: ✭ 52 (-27.78%)
Mutual labels:  analytics
Dashboard Extension Online Map Item
⛔ DEPRECATED. This project was moved to a new repository. Visit https://github.com/DevExpress/dashboard-extensions to find an updated version.
Stars: ✭ 65 (-9.72%)
Mutual labels:  analytics
Weeklypedia
A weekly email update of all the most popular wikipedia articles
Stars: ✭ 50 (-30.56%)
Mutual labels:  analytics
Conf
Go package for loading program configuration from multiple sources.
Stars: ✭ 70 (-2.78%)
Mutual labels:  segment
Amplify Js
A declarative JavaScript library for application development using cloud services.
Stars: ✭ 8,539 (+11759.72%)
Mutual labels:  analytics
Data Science Best Resources
Carefully curated resource links for data science in one place
Stars: ✭ 1,104 (+1433.33%)
Mutual labels:  analytics
Countly Sdk Cordova
Countly Product Analytics SDK for Cordova, Icenium and Phonegap
Stars: ✭ 69 (-4.17%)
Mutual labels:  analytics
Singular Skadnetwork App
Sample apps demonstrating the logic needed to implement SKAdNetwork as an ad network, publisher and advertiser.
Stars: ✭ 59 (-18.06%)
Mutual labels:  analytics

npm travis

IMPORTANT NOTE ⚠️

This package is deprecated and is here only for transparency. We recommend using https://github.com/segmentio/analytics-react-native

A React Native wrapper for Segment Analytics

Installation

yarn add react-native-analytics-segment-io
react-native link react-native-analytics-segment-io

iOS

Add Analytics framework to your Podfile.

pod 'Analytics'

Device-based integration components

To add an integration with a Device-based Connection Mode, you must manually add that integration’s dependencies to the Podfile.

pod 'Segment-Mixpanel'
pod 'Segment-GoogleAnalytics'

The wrapper will automatically register the added components in the configuration when the SDK is initialized.

Supported integrations:

Component Podfile
Taplytics pod 'Segment-Taplytics'
Adjust pod 'Segment-Adjust'
Google Analytics pod 'Segment-GoogleAnalytics'
ComScore pod 'Segment-ComScore'
Amplitude pod 'Segment-Amplitude'
Facebook App Events pod 'Segment-Facebook-App-Events'
Mixpanel pod 'Segment-Mixpanel'
Localytics pod 'Segment-Localytics'
Flurry pod 'Segment-Flurry'
Quantcast pod 'Segment-Quantcast'
Crittercism pod 'Segment-Crittercism'
Firebase pod 'Segment-Firebase'
AppsFlyer pod 'segment-appsflyer-ios'
Branch pod 'Segment-Branch'
Braze (formerly Appboy) pod 'Segment-Appboy'
Intercom pod 'Segment-Intercom'

Ensure build order

To be absolutely certain that your integrations will be correctly handled by the react-native-analytics-segment-io module, you have to make sure that the Pods target is built before the RNAnalyticsSegmentIO one.

  1. Open your project workspace <name_of_your_app>.xcworkspace located in the ios/ folder.

⚠️ we want to open the .xcworkspace file and NOT the .xcodeproj.

  1. Open the Edit Scheme… pane of your own app target main scheme.

Edit scheme

  1. Select Build in the phase list on the left.

Build list

  1. Make sure that the Parallelize build option is unchecked.

Parallelize build

  1. If the Pods-<name_of_your_app> target is not present in the list click the + button and select it in the list under the Pods project.

Pods target selection

  1. If the RNAnalyticsSegmentIO target is not present in the list click the + button and select it in the list under the RNAnalyticsSegmentIO project.

Module target selection

  1. Re-arrange the Targets list by dragging targets around to make sure that:
  • Both Pods-<name_of_your_app> and RNAnalyticsSegmentIO are placed after the React target and before the <name_of_your_app> target.
  • The RNAnalyticsSegmentIO target is placed after the Pods-<name_of_your_app> one.

Build order

Note: This setup is particularly relevant if your Podfile contains use_frameworks!

Android

Run react-native link react-native-analytics-segment-io to add the necessary lines to the build files. Alternatively, you can do this manually with the 2 following steps:

  1. Add a reference to the project in settings.gradle:
include ':react-native-analytics-segment-io'
project(':react-native-analytics-segment-io').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-analytics-segment-io/android')
  1. Add the dependency to the app's build.gradle file:
compile project(':react-native-analytics-segment-io')

When the build files are set up to include the library, add a dependency to the Segment SDK in the app's build.gradle file:

compile 'com.segment.analytics.android:analytics:x.x.x' // We have tested with version 4.2.6

Then sync Gradle, and add the analytics package to your Application class:

import com.leo_pharma.analytics.AnalyticsPackage;
...
@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
      new MainReactPackage(),
      new AnalyticsPackage()
  );
}

Your project is now ready to start calling functions on react-native-analytics-segment-io.

Why you need to add the Segment SDK manually

The Segment SDK is added to the library as a provided dependency, meaning that it is not included in the final build. That is why it is necessary to include the Segment SDK in the app's build.gradle file. This makes it easy to update the Segment SDK from the app, and it makes the app's build configuration the source of truth when it comes to Segment.

Minimum React Native version

It is required to use React Native v0.46.4 or higher. This is because we use a feature in Java on the passed maps (.toHashMap()) that is introduced in that version.

Device-based integration components

To add an integration with a Device-based destination, you have to manually add that integration as a dependency to the app's build.gradle file.

For example:

compile 'com.segment.analytics.android.integrations:firebase:1.1.0'
compile 'com.segment.analytics.android.integrations:mixpanel:1.1.0'

The wrapper will automatically register the added components in the configuration when the SDK is present.

Supported integrations:

Component Dependency
Braze (formerly Appboy) com.appboy:appboy-segment-integration:2.1.1
AppsFlyer com.appsflyer:segment-android-integration:1.9
Adjust com.segment.analytics.android.integrations:adjust:0.3.1
Amplitude com.segment.analytics.android.integrations:amplitude:1.2.1
Bugsnag com.segment.analytics.android.integrations:bugsnag:1.0.0
ComScore com.segment.analytics.android.integrations:comscore:3.0.0
Countly com.segment.analytics.android.integrations:countly:1.0.0
Crittercism com.segment.analytics.android.integrations:crittercism:1.0.0
Firebase com.segment.analytics.android.integrations:firebase:1.1.0
Flurry com.segment.analytics.android.integrations:flurry:3.0.0
Google Analytics com.segment.analytics.android.integrations:google-analytics:2.0.0
Intercom com.segment.analytics.android.integrations:intercom:1.1.0-beta
Localytics com.segment.analytics.android.integrations:Localytics
Mixpanel com.segment.analytics.android.integrations:mixpanel:1.1.0
NielsenDCR com.segment.analytics.android.integrations:nielsendcr:1.0.0-Beta
Quantcast com.segment.analytics.android.integrations:quantcast:1.0.1
Tapstream com.segment.analytics.android.integrations:tapstream:1.0.0
Branch io.branch.segment.analytics.android.integrations:branch:1.0.2-RELEASE

Extra repositories

Some integrations require you to add an extra Maven repository to your app's build.gradle file. These are all of those dependencies with their repository:

repositories {
  ...
  maven { url "http://appboy.github.io/appboy-android-sdk/sdk" } // Required for Braze (formerly Appboy)
  maven { url 'https://comscore.bintray.com/Analytics' } // Required for Comscore
  maven { url 'http://dl.bintray.com/countly/maven' } // Required for Countly
  maven { url 'https://maven.google.com' } // Required for Firebase
  maven { url 'http://maven.localytics.com/public' } // Required for Localytics
}

Usage

import Analytics, { AnalyticsConstants } from 'react-native-analytics-segment-io'

setup: function (key, options = {})

Initial framework setup

const options = { option: value, option: value }
Analytics.setup('segment_write_key', options)

Where options is an object that contains the options mentioned in the table below. There are constants available for all the options, using [AnalyticsConstants.optionName], e.g. [AnalyticsConstants.trackApplicationLifecycleEvents]: true. If an option is not set in the options object, its default value is used (see table below).

setup() returns a promise to indicate whether the initialization was successful or not.

Supported options:

Options Type Default iOS Android Description
enableAdvertisingTracking Bool true Whether the analytics client should track advertising info.
flushAt Integer 20 The number of queued events that the analytics client should flush at. Setting this to 1 will not queue any events and will use more battery.
recordScreenViews Bool false Whether the analytics client should automatically make a screen call when a view controller is added to a view hierarchy.
shouldUseBluetooth Bool false Whether the analytics client should record bluetooth information.
shouldUseLocationServices Bool false Whether the analytics client should use location services.
trackApplicationLifecycleEvents Bool false Whether the analytics client should automatically make a track call for application lifecycle events, such as "Application Installed", "Application Updated" and "Application Opened".
trackAttributionData Bool false Whether the analytics client should automatically track attribution data from enabled providers using the mobile service.
trackDeepLinks Bool false Whether the analytics client should automatically track deep links.
debug Bool false Whether the analytics client should log everything to the console (only enable this during development).

identify: function (userId, traits = {})

Tie a user to their actions and record traits about them

Analytics.identify('user_id', { email: 'user_email' })

Futher explanation can be found on Segments own page.

track: function (event, properties = {})

Record the actions your users performs

Analytics.track('Weapon Bought', { weapon: 'sword' })

Futher explanation can be found on Segments own page.

screen: function (name, properties = {})

Record whenever a user sees a screen

Analytics.screen('Photo Screen', { feed: 'private' })

Futher explanation can be found on Segments own page.

group: function (groupId, traits = {})

Associate an identified user user with a group

Analytics.group('Group123', {name: 'Bob Group', description: 'Accounting Awesome'})

Futher explanation can be found on Segments own page.

alias: function (newId)

Associate one user identity with another

Analytics.alias('new_id')

Futher explanation can be found on Segments own page.

reset: function ()

Clears the SDK’s internal stores for the current user and group

Analytics.reset()

Futher explanation can be found on Segments own page.

flush: function ()

Manually flush the queue

Analytics.flush()

Futher explanation can be found on Segments own page.

enable: function ()

You may need to offer the ability for users to opt-out of analytics

Analytics.enable()

Futher explanation can be found on Segments own page.

disable: function ()

You may need to offer the ability for users to opt-out of analytics

Analytics.disable()

Futher explanation can be found on Segments own page.

Example

To run the iOS example:

git clone [email protected]:leoilab/react-native-analytics-segment-io.git
cd react-native-analytics-segment-io
cd example
yarn install
cd ios
pod install
cd ..
react-native run-ios

To run the Android example:

git clone [email protected]:leoilab/react-native-analytics-segment-io.git
cd react-native-analytics-segment-io
cd example
yarn install
react-native run-android

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].