The Amp Devcenter Test Developer Hub

Welcome to the Amp Devcenter Test developer hub. You'll find comprehensive guides and documentation to help you start working with Amp Devcenter Test as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

React Native

Amplitude React Native SDK Installation & Quick Start

If you’re familiar with instrumenting Amplitude in your web apps with the JavaScript SDK, you’ll find using the SDK in React Native to be a nearly identical experience. On the web, you may have been using the JavaScript snippet in your HTML to asynchronously load the SDK. For React Native you’ll have to embed the SDK directly into your application, just as you would any other JavaScript package. You can find the package on npm.

Installation

  1. Install the SDK directly into your application:
npm install amplitude-js
  1. Import amplitude-js
    After installing the package you would import amplitude-js like any other node module.
const amplitude = require('amplitude-js');
amplitude.getInstance().init("API_KEY");
  1. Instrument events to Amplitude through JS SDK methods:
    And now you can instrument Amplitude by logging events in your app exactly as you would in your web applications. Please find instructions on how to send events, set userID, etc through our JS SDK documentation. An example of what an event call will look like is as follows:
amplitude.getInstance().setUserId('0cc82db6-3677');
amplitude.getInstance().logEvent("view dashboard", {
  "dashboard id": "id",
  "dashboard load time ms": 200,
  "is owner": false,
});

Caveats

  • Device IDs are randomly generated and not based on idfv/adid
  • With v 5.5, pull react-native device identifier from device info when possible
  • IDFA/IDFV/ADID is not tracked through JS SDK. If you are planning to send attribution data through one of our Attribution Partners, please see note #3 on our Attribution API doc.
  • As of SDK version 5.10, Library field for event will include amplitude-react-native when using SDK in React Native. In SDK versions prior to 5.10, the "Library" field for event will be "JS SDK."
  • If you use expo in your React native project then use https://docs.expo.io/versions/latest/sdk/amplitude/

Additional Dependencies

There are two additional react native dependencies that aren't referenced in the package.json file. You will have to manually install these.

  • @react-native-device-info Tested with version 3.1.4
  • @react-native-community/async-storage Tested with version 1.6.2

Usage & Examples

Please see the SDK Usage & Examples page.

Need Help?

If you have any problems or issues over our SDK, feel free to create a github issue or submit a request on Amplitude Help.

Usage & Examples

Please see the SDK Usage & Examples page.

Need Help?

If you have any problems or issues over our SDK, feel free to create a github issue or submit a request on Amplitude Help.

Updated 18 days ago


React Native


Amplitude React Native SDK Installation & Quick Start

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.