0.0.6 • Published 7 years ago

cryptid-react-native v0.0.6

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

cryptid-react-native

Javascript react-native client to cryptid analytics.

This library should be used to integrate Cryptid Analytics into react-native applications.

For browser-based javascript projects (including React, Vue, etc.), use cryptid, which will gather browser information rather than device information.

Install

First, install the package to your React Native project

npm install cryptid-react-native --save

This should install the module along with its main dependency, react-native-device-info. You'll then need to follow the configuration instructions of react-native-device-info, available at the preceding link but reproduced here.

react-native link react-native-device-info

Note: The above command works for recent versions of RN. If you need to deal with an older version of the framework or if you desire to manually link the dependency into your application, please follow the directions here.

Configure

Create a new Tracker using the trackerId of the property you're tracking.

import Tracker from 'cryptid-react-native';

const tracker = new Tracker('mobile|C8BB8D97-CA6E-49B7-89A3-56EB0A671480');

You may also supply additional options as a second argument. These will be passed through to the underlying fetch call.

There are also two callbacks you may define: beforeFetch, which is passed the url and options that will be used in the fetch, and afterFetch which is passed the response.

import Tracker from 'cryptid-react-native';

const tracker = new Tracker('mobile|C8BB8D97-CA6E-49B7-89A3-56EB0A671480', {
  beforeFetch: (url, options) => console.log('before', url, options),
  afterFetch: (response) => console.log('response', response),
});

Use

Tracker has one method: send, which is used to send an event to the cryptid service. When you call send the library gathers device metadata to include with the event data you supply. All of this metadata may be overridden by fields you include on the event object (see the Events section below.)

Simple example:

tracker.send({eventValue: 'login-successful'});

More complex:

tracker.send({
  eventCategory: 'authentication',
  eventAction: 'signup',
  eventLabel: 'signup-method',
  eventValue: 'facebook',
  timezone: '',
  latitude: '',
  logintude: '',
  elevation: ''
});

Events

List of fields that can be included in the event object.

FieldDescriptionRequired?Example
eventCategoryCategory of the eventNoauthentication
eventActionAction or workflow the event occured duringNologin
eventLabelLabel of the eventNoform-submission
eventValueValue of the eventYesbutton-click or enter-key
customField_1Custom dataNo
customField_2Custom dataNo
customField_3Custom dataNo
customField_4Custom dataNo
customField_5Custom dataNo
timezoneTimezone the device resides inNoAmerica/Chicago
latitudeLatitude of the deviceNo43.0731
longitudeLongitude of the deviceNo89.4012
elevationElevation of the deviceNo741

You may use the Category, Action, Label and Value event fields any way that you'd like in your application; they exist merely to allow for an event taxonomy that works for you. The simplest way to use them is to only supply an event value such as login-successful. If you don't need anything more complicated, you may omit the rest of the fields.

Likewise, the customField values are there to log supplemental application information that may bes useful to you, but are not required by the send event or the service.

Note that the geospatial data is NOT collected automatically by the library. This is because different platforms require specific permission to be given to collect such information, and it's not up to cryptid whether you enable the collection (and thus user opt-in) for this data. Therefore, if you already have these permissions or choose to enable them then this data can be included in the event payload.

List of device metadata fields that are automatically collected and may be overridden by including them in the event object:

FieldDescriptionExammple
deviceManufacturerDevice manufacturerApple
deviceBrandDevice brandApple, htc, Xiaomi
deviceModelDevice modeliPhone 6
deviceIdDevice IDiPhone7,2
deviceLocaleDevice localeen-US
deviceCountryDevice countryUS
deviceNameDevice nameZach's iPhone 6
systemNameSystem nameiPhone OS
systemVersionSystem version9.0
bundleIdBundle IDcom.cardiganapp
buildNumberBuild number89
appVersionApplicatino version1.1.0
appVersionReadableApplication version1.1.0.89
appInstanceIdApplication instance ID(Android only)
userAgentUser agentDalvik/2.1.0 (Linux; U; Android 5.1; Google Nexus 4 - 5.1.0 - API 22 - 768x1280 Build/LMY47D)
isEmulatorIs the app running in an emulator?true
isTabletIs the app running on a tabletfalse
0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago