zence-marketing-react
Version:
zence-marketing-react is a React Native Android SDK designed to streamline event tracking and notifications for mobile applications. This SDK enables seamless integration with Android / iOS apps, capturing user actions like clicks, add-to-cart, purchases,
260 lines (191 loc) • 6.92 kB
Markdown
# zence-marketing-react
## Description
zence-marketing-react is a React Native Android SDK designed to streamline event tracking and notifications for mobile applications. This SDK enables seamless integration with Android / iOS apps, capturing user actions like clicks, add-to-cart, purchases, and more, and sending relevant notifications in real-time. It is built with flexibility in mind, allowing for dynamic configuration and easy integration with other platforms.
## Features:
### Event Tracking:
Capture key user events such as clicks, installs, and purchases.
### Real-Time Notifications:
Trigger notifications based on user behavior in real time.
### Easy Integration:
Quickly integrate with your Android and iOS app using simple React Native commands.
Customizable: Configure event-based journeys and notifications tailored to your app's needs.
### Scalable:
Built to handle large-scale data capture and notification delivery.
## Installation
```bash
npm install zence-marketing-react
```
### Supporting Library, Please install this package
```bash
npm install @react-native-community/async-storage axios
```
### For iOS,
```bash
cd ios
pod install
cd ..
```
## Usage
### Import
```js
import zenceMarketing from "zence-marketing-react";
```
### Example of predefined events call
```js
zenceMarketing.trigger("event-name", data);
```
### Example of custom events call
```js
zenceMarketing.event("event-name", data);
```
## Predefined events
To enhance the performance of our app, we are tracking several important predefined events. Below is the list of these events for your review. Please take a moment to read through them and implement them in your project accordingly.
### initialize() :
In the initialize() event, please ensure that you pass your app's FCM token, device ID, application ID, application secret, web site url and application name to register your app with our package.
## Configuration
### Note:
The `appId`, `appSecret`, and `programCode` should be obtained from your vendor.
The `url_type` should be `'Android'` or `'Ios'`, depending on your platform
The `webSiteUrl` should be your App ID for Android and your Bundle ID for iOS.
### Additional Device Information:
The following device-related details are included in the update:
#### OS Information:
- **`osVersion`**: Operating system version
- **`osName`**: Name of the operating system
- **`sdkVersion`**: SDK version
#### Device Information:
- **`deviceModel`**: Model of the device
- **`manufacturer`**: Device manufacturer
- **`screenResolution`**: Screen resolution
- **`timeZone`**: Device time zone
- **`locale`**: Device locale
- **`networkType`**: Type of network connection (Wi-Fi, Mobile, etc.)
- **`carrierName`**: Mobile carrier name
- **`isRooted`**: `true` if the device is rooted, otherwise `false`
#### App & Installation Details:
- **`installTime`**: Timestamp of when the app was installed
- **`appVersion`**: Current version of the app
#### Permissions Status:
- **`permissions.location`**: Location permission status (`granted`/`denied`)
- **`permissions.notifications`**: Notifications permission status (`granted`/`denied`)
- **`permissions.camera`**: Camera permission status (`granted`/`denied`)
#### Device Storage:
- **`deviceStorage.totalStorageMB`**: Total device storage in MB
- **`deviceStorage.availableStorageMB`**: Available device storage in MB
#### Battery Information:
- **`batteryLevel`**: Current battery percentage
- **`isCharging`**: `true` if the device is charging, otherwise `false`
#### Network & Connectivity:
- **`connectionInfo.ipAddress`**: Device IP address
- **`connectionInfo.macAddress`**: Device MAC address
Ensure that these values are fetched dynamically from the device environment.
```js
Please note, this is an important event and should be considered the start of the project.
```
```js
zenceMarketing.trigger("initialize", {
fcmToken: value,
deviceId: value,
appId: value,
appSecret: value,
appName: value,
programCode: value,
url_type: Android or Ios,
webSiteUrl : value,
osVersion: value,
osName: value,
sdkVersion: value,
deviceModel: value,
manufacturer: value,
screenResolution: value,
timeZone: value,
locale: value,
networkType: value,
carrierName: value,
isRooted: true or false,
installTime: value,
appVersion: value,
permissions: {
location: value,
notifications: value,
camera: value
},
deviceStorage: {
totalStorageMB: value,
availableStorageMB: value
},
batteryLevel: value,
isCharging: true or false,
connectionInfo: {
ipAddress: value,
macAddress: value
}
});
```
### login() :
We kindly request that you use the login() event to track user activity within the application. The userId and userName are required, and additional values can be passed as well. The userName may be an email, phone number, or username.
```js
zenceMarketing.trigger("login", {
userId: value,
userName: value,
name: value,
data: { ... },
timestamp: value,
deviceId: value,
appId: value,
appName: value,
webSiteUrl : value,
});
```
### register() :
We kindly ask you to implement the register() event to capture essential user registration details within the application. The userId and userName are required, and additional values can be passed as well. The userName may be an email, phone number, or username.
```js
zenceMarketing.trigger("register", {
userId: value,
userName: value,
name: value,
data: { ... },
timestamp: value,
deviceId: value,
appId: value,
appName: value,
webSiteUrl : value,
});
```
### logout() :
We kindly request that you implement the logout event to capture when users exit the application. This event should help us track user engagement and improve our overall service.
```js
zenceMarketing.trigger("logout", {
userId: value,
userName: value,
name: value,
timestamp: value,
deviceId: value,
appId: value,
appName: value,
webSiteUrl: value,
});
```
## Custom events
With custom events, you have the flexibility to pass any event name along with its parameters.
### Sample Event:
```js
zenceMarketing.event("button-clicked", {
userId: value,
userName: value,
name: value,
data: { ... },
timestamp: value,
deviceId: value,
appId: value,
appName: value,
webSiteUrl : value,
});
```
With custom events, you have the flexibility to pass any event name along with its parameters.
By utilizing custom events, you can tailor the tracking to meet your specific needs and gain valuable insights into user interactions within the application.
## Notification click events
If you want to trigger an event when a notification is clicked or when an in-app notification is received, you need to call the "notification-click" event and pass the data received in the notification body.
```js
zenceMarketing.event("notification-click", data);
```