React Native
Requirements
- Edit permission to your source code.
- React-Native development environment is setup.
Use Cases
- Track user identity and behavior on your React-Native mobile applications.
Guideline
Installation
- Use
yarn
:
yarn add @react-native-async-storage/async-storage react-native-device-info react-native-uuid filum-react-native
- Use
npm
:
npm install --save @react-native-async-storage/async-storage react-native-device-info react-native-uuid filum-react-native
Usage
Initialization
Create a separated analytics
file to initialize the tracking instance:
let Analytics = require('filum-react-native');
export const filumAnalytics = new Analytics(
'WRITEKEY',
{
host: 'https://event.filum.ai',
},
);
Identify
identify() should be called before track() to incorporate your user_id in any upcoming track calls.
Use this method right after user has just sign in/sign up or anytime a trait of an user is updated (Eg: profile update).
import { filumAnalytics } from './analytics';
if (<conditions>) { // user password/credentials check is successful
...
filumAnalytics.identify(user_id, {
Email: "example@com.vn",
Name: "Harry Potter",
Gender: "Male",
});
}
Track event
Use a string to represent the event name and a JSON object to contain all additional properties.
filumAnalytics.track('Transaction Completed',
{
'Transaction ID': "#001",
'Total Value': 1000000,
}
);
Reset
Use this method right after the user has just logged out. It will clear the user_id
of the currently logged in user and generate new anonymous_id
for a new user.
filumAnalytics.reset();
Example App
You can refer to the example repo Filum React Native Sample App
Make sure to update the host
and WRITEKEY
in filumAnalytics.load()
before running.