Code Monkey home page Code Monkey logo

react-native-adobe-analytics's Introduction

Unmaintainted repo

This repo is currently unmaintained. This organization will stop soon (beginning 2020) - If anybody wants to step in as maintainer let us know.

React Native Adobe Analytics

React Native bridge for Adobe Analytics.

Installation

Using npm

$ npm install react-native-adobe-analytics --save
$ react-native link react-native-adobe-analytics

Using CocoaPods (iOS only)

Add this to your Podfile and run pod install

$ pod 'RNAdobeAnalytics', :path => '../node_modules/react-native-adobe-analytics'

Consult the React Native documentation on how to install React Native using CocoaPods.

Configuration file

Get your ADBMobileConfig.json file from Adobe Mobile Services.

  • On iOS, add the ADBMobileConfig.json file to your XCode project so that it's accessible in your bundle.
  • On Android, the ADBMobileConfig.json file must be placed in the assets folder.

Android Configuration

Update MainApplication.java

You need to import this package into your MainApplication.java file as well as load that package in the getPackages method:

diff --git a/MainApplication.java b/MainApplication.java
index a209301..8ada6e5 100644
--- a/MainApplication.java
+++ b/MainApplication.java
@@ -7,6 +7,7 @@ import com.facebook.react.ReactNativeHost;
 import com.facebook.react.ReactPackage;
 import com.facebook.react.shell.MainReactPackage;
 import com.facebook.soloader.SoLoader;
+import be.smalltownheroes.adobe.analytics.RNAdobeAnalyticsPackage;
 
 import java.util.Arrays;
 import java.util.List;
@@ -22,7 +23,8 @@ public class MainApplication extends Application implements ReactApplication {
     @Override
     protected List<ReactPackage> getPackages() {
       return Arrays.<ReactPackage>asList(
-          new MainReactPackage()
+          new MainReactPackage(),
+          new RNAdobeAnalyticsPackage()
       );
     }

iOS Configuration

Install Adobe Mobile SDK

Add this to your Podfile and run pod install

pod 'AdobeMobileSDK', '~> 4.14.1'

When using !use_frameworks in your Podfile, add this to your didFinishLaunchingWithOptions function in AppDelegate.m

[ADBMobile overrideConfigPath:[[NSBundle mainBundle] pathForResource:@"ADBMobileConfig" ofType:@"json"]];

Usage

Javascript API

Import the javascript class:

import {AdobeAnalyticsAPI} from 'react-native-adobe-analytics'

AdobeAnalyticsAPI.init()

Static methods

init(debug)

Initializes Adobe Analytics

  • debug: Boolean

trackState(state, contextData)

Track a view or screen in your app

  • state: String
  • contextData: Object

trackAction(action, contextData)

Track an event or an action in your app

  • action: String
  • contextData: Object

React components

Initializes Adobe Analytics

<AdobeAnalytics debug={true} />

Track a view or screen in your app

<AdobeAnalyticsTrackState 
  state="Home screen"
  contextData={{...}}
/>

Track an event or an action in your app

<AdobeAnalyticsTrackAction 
  action="Logged in"
  contextData={{...}}
/>

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.