react-native-amplitude
v1.0.1
Published
React Native wrapper for native iOS Facebook SDK login button and manager
Downloads
12
Readme
react-native-amplitude
Simple React Native wrapper for Amplitude (Android) tracking
Installation
npm install react-native-amplitude --save
Install Amplitude Android SDK more info here
Update Gradle settings
// file: android/settings.gradle
...
include ':RNAmplitude'
project(':RNAmplitude').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-amplitude/android')
- Update Gradle build
// file: android/app/build.gradle
...
dependencies {
...
compile project(':RNAmplitude');
}
- Register React Package
...
import com.threedot.reactnativeamplitude.ReactNativeAmplitudePackage; // import
public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {
private ReactInstanceManager mReactInstanceManager;
private ReactRootView mReactRootView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.setApplication(getApplication())
.setBundleAssetName("index.android.bundle")
.setJSMainModuleName("index.android")
.addPackage(new MainReactPackage())
// register package here
.addPackage(new ReactNativeAmplitudePackage(this,getApplication()))
.setUseDeveloperSupport(BuildConfig.DEBUG)
.setInitialLifecycleState(LifecycleState.RESUMED)
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "AwesomeProject", null);
setContentView(mReactRootView);
}
...
Usage
//Require the module
var Amplitude = require('react-native-amplitude');
//Init Mixpanel SDK with your project token
Amplitude.initialize(YOUR_PROJECT_TOKEN);
//Log an event
Amplitude.logEvent('appStart');