Coder Social home page Coder Social logo

stevehollaar / react-native-segment-analytics Goto Github PK

View Code? Open in Web Editor NEW

This project forked from charlires/react-native-segment-analytics

0.0 1.0 0.0 25 KB

Segment Analytics library for React Native (Android & IOS)

License: MIT License

Java 62.76% JavaScript 5.65% Ruby 12.60% Objective-C 18.99%

react-native-segment-analytics's Introduction

react-native-segment-analytics

Install

$ npm install react-native-segment-analytics --save

IOS (CocoaPods)

pod 'Analytics'
pod 'React', :path => '../node_modules/react-native'
pod 'SegmentAnalytics', :path => '../node_modules/react-native-segment-analytics/ios'

Install the Cocoapods dependencies:

$ pod install
Headsup

Make sure that you have libAnalytics.a and libSegmentAnalytics.a in your Linked Frameworks and Libraries You may have to import them manually.

image

Android

Add in android/settings.gradle

include ':react-native-segment-analytics'
project(':react-native-segment-analytics').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-segment-analytics/android')

Add in android/app/build.gradle

dependencies {
    ......
    compile project(':react-native-segment-analytics')

}

If you're on RN > 29 apply these changes in MainApplication.java, otherwise in MainActivity.java

import com.charlires.segmentanalytics.SegmentAnalyticsPackage;
...
@Override
protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new SegmentAnalyticsPackage() // <----- Register the module
    );
}

Usage

Import the module

import RNSegmentIO from 'react-native-segment-analytics';

Set it up just ones inside your project

RNSegmentIO.setup("YOUR-SEGMENT-KEY");

Use it

RNSegmentIO.setup(configKey: string)

RNSegmentIO.identify(userId: string, traits: Object)

RNSegmentIO.track(trackText: string, properties: Object)

RNSegmentIO.screen(screenName: string, properties: Object)

RNSegmentIO.alias(newId: string)

Note: remember to import it in every file you are going to use it.

react-native-segment-analytics's People

Contributors

charlires avatar felixclack avatar fmauquie avatar idris avatar jlo1 avatar xchat avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.