0.0.1 • Published 4 months ago

react-native-lytics v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Lytics SDK for React Native

Installation

Install the SDK:

yarn add react-native-lytics

Android

Add the following permissions to your AndroidManifest.xml file:

<uses-permission android:name="android.permission.INTERNET" />

This permission is required to send events to the Lytics API.

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

This permission is technically optional but highly recommended to allow the library to determine the best time to send events to the API.

iOS

Install native modules:

npx pod-install

Configuration

You must initialize the Lytics SDK with your API token before using it.

import { start } from 'react-native-lytics';

start({
  apiToken: 'xxxxxx',
  ...
});

Sending Data

Identity Events

Tracking identity events provides an interface for updating the current user's properties stored on device as well as emitting an identify event to the downstream collections API.

import { identify } from 'react-native-lytics';

identify({ identifiers: { email: 'jdoe@email.com' } });

Consent Events

Consent events provide an interface for configuring and emitting a special event that represents an app users explicit consent. This event does everything a normal event does in addition to providing a special payload for consent details at the discretion of the developer.

import { consent } from 'react-native-lytics';

consent({
  consent: {
    documents: ['terms_aug_2022', 'privacy_may_2022'],
    consented: true,
  },
});

Track Custom Events

Track custom events provides an interface for configuring and emitting a custom event at the customers discretion throughout their application (e.g. made a purchase or logged in).

import { track } from 'react-native-lytics';

track({ name: 'Event_Tap', properties: { event: 'Event_Tap' } });

Screen Events

Screen events provide an interface for configuring and emitting a special event that represents a screen or page view. It should be seen as an extension of the track method.

import { screen } from 'react-native-lytics';

screen({
  name: 'Event_Detail',
  properties: { artistID: 123, eventID: 345 },
});

Advertising ID

Android

To support collecting the Android Advertising ID, add the following to the application's gradle dependencies:

implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'

Additionally, declare a Google Play services normal permission in the manifest file as follows:

<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

After confirming with the user and getting their consent, enable Advertiser ID collection via Lytics.enableGAID().

The user's Android Advertising ID will be sent with each event's identifiers.

Note, the user can disable or change the Advertising ID via the Android system privacy settings.

iOS

Before collecting the IDFA you must first add a NSUserTrackingUsageDescription to your app's Info.plist. You can then call requestTrackingAuthorization() to have iOS request authorization to access the IDFA. Note that the alert will not be displayed if the user has turned off “Allow Apps to Request to Track” in the system privacy settings and that authorization can be revoked at any time.

Usage

import { requestTrackingAuthorization } from 'react-native-lytics';

requestTrackingAuthorization();
0.0.1

4 months ago