0.1.0 • Published 4 years ago

@wildanalytics/wild-analytics v0.1.0

Weekly downloads
-
License
ISC
Repository
bitbucket
Last release
4 years ago

Wild Analytics

This package provides a library of utilities to allow connection of your application to Wild Analytics.

Installation

To install WildAnalytics, open your project in a terminal window and run one of the below:

npm i @wildanalytics/wild-analytics

or

yarn add @wildanalytics/wild-analytics

If you're not already using both of React Native's Async Storage and NetInfo modules in your project, you'll also need to install @react-native-community/async-storage and @reac-native-community/netinfo.

These allow WildAnalytics to store session event data on the user's device, provided they have an active network connection, in case the app is closed or minimised prior to events being sent to us, or if the app crashes.

You can install these using one of the below:

npm i @react-native-community/async-storage @react-native-community/netinfo

or

yarn add @react-native-community/async-storage @react-native-community/netinfo

Following installation, you will then need to link these modules to your application using one of the below:

For React Native >= 0.60
cd ios && pod install && cd ..
For React Native < 0.60
react-native link @react-native-community/async-storage @react-native-community/netinfo

Finally, you can then access the package from your JavaScript files using one of the below:

import WildAnalytics from '@wildanalytics/wild-analytics';    

or

var WildAnalytics = require('@wildanalytics/wild-analytics');    

Obtaining an app key

To obtain a unique app key, follow the instructions at the Getting Started section of our website.

Setup

Once you have obtained an app key, you can connect your application to Wild Analytics and start tracking events via the start method, passing in your app key and the React Native AppState API.

The React Native AppState API is required in order to allow WildAnalytics to monitor the application's foreground/background status and post session data once minimised.

// Import package    
import WildAnalytics from '@wildanalytics/wild-analytics';    

// Retrieve React Native AppState API
import { AppState } from 'react-native';
    
// Call 'start', replacing 'yourKey' with your previously-obtained unique app key    
WildAnalytics.start(yourKey, AppState);    

Usage

The Wild Analytics module consists of 3 additional methods;

setUserId(userId: string)

Sets a user's ID to be shown on the Wild Analytics web application.

Example:

setUserId('User1');    

trackEvent(eventName: string, properties?: string | number | boolean | object)

Logs any required event with provided name and optional properties in string, number, boolean or object format.

Examples:

trackEvent('Input change', {    
    label: 'User ID',    
    value: 'user1'    
});    
    
trackEvent('Button press', 'Sign In');    

trackScreen(screenName: string)

Logs an event following user navigation to screen and separates events logged via trackEvent.

Example:

trackScreen('Home');    
0.1.0

4 years ago

0.0.18

4 years ago

0.0.19

4 years ago

0.0.17

4 years ago

0.0.16

4 years ago

0.0.14

4 years ago

0.0.15

4 years ago

0.0.13

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.12

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago

1.0.0

4 years ago