pvamplitudebridge

1.0.0 • Public • Published

React-Native-Amplitude

React-Native wrapper for the Amplitude SDK


Getting started

npm install pvamplitudebridge --save

Include the Amplitude SDK

Include the Amplitude SDK in your project to make it available to the wrapper (bridge) library. You can find instructions for installing the SDK here. We recommend installing the SDK as a POD for your iOS project. The PVAmplitudeBridge project will search for header files in the Pods directory.

Linking the project

You need to link the pvamplitudebridge project so that it will be reachable in your project.

$ react-native link pvamplitudebridge

Manual Installation

iOS
  1. In Xcode, use the project navigator to add files to the Libraries folder by right clicking on Add Files to [your project's name]
  2. Go to node_modules -> pvamplitudebridge and add PVAmplitudeBridge.xcodeproj
  3. In Xcode, select your project in the project navigator. Add the libPVAmplitudeBridge.a to your project's Build Phases -> Link Binary With Libraries
  4. Run your project (Cmd+R)

Usage

Initialize Amplitude

import PVAmplitude from 'pvamplitudebridge'
 
PVAmplitude.initializeApiKey("[Enter your Amplitude API key]")

Track an Event

PVAmplitude.logEvent("TestEvent-1")

Track an Event with Properties

let properties = {propA: "value A", propB: "value B"}
PVAmplitude.logEventWithProperties("EventWithProperties", properties)

Setting Event Properties

logEvent(eventName)
 
logEventWithProperties(eventName, eventPropertiesDictionary) 
 
logEventWithPropertiesAndSession(eventName, eventPropertiesDictionary, isOutOfSession) 
 
logEventWithGroups(eventName, eventPropertiesDictionary, groups)
 
logEventWithGroupsAndSession(eventName, eventPropertiesDictionary, groups, isOutofSession)

Tracking Sessions

trackSessions(shouldTrack)
 
minTimeBetweenSessionsMillis(timeInMillis) 
 
// returns a promise
getCurrentSessionId()
 
logOut()

Setting Custom User IDS and Setting User Properties

setUserId(userId)
 
identifySet(key, value)
 
identifySetOnce(key, value) 
  
identifyUnset(key)
 
identifyAdd(key, value)
 
identifyAppendArray(key, value)
 
identifyAppendDictionary(key, value)
 
identifyPrependArray(key, value) 
 
identifyPrependDictionary(key, value)
 
clearUserProperties() 

Readme

Keywords

Package Sidebar

Install

npm i pvamplitudebridge

Weekly Downloads

3

Version

1.0.0

License

ISC

Last publish

Collaborators

  • mrkeithelliott