stock42-react-native-lib
v1.0.4
Published
Stock42 React Native Lib. Report all logs, actions and more from your backend and server applications.
Downloads
42
Readme
Stock42 React Native
Official library for integrating Stock42 Services into your React Native applications, beginning with our powerful analytics tools.
Installation
To install the Stock42 React Native library, run the following command:
$ npm install stock42-react-native-lib --save
Stock42 React Native lib Analytics
Initializing
To get started, obtain a valid application token by registering a new tenant and creating an application at Stock42.
import { Stock42 } from 'stock42-react-native-lib'
try {
const { track, screenshot } = await Stock42({
appVersion: '1.0', // your mobile app version
appName: 'Stock42Test', // your mobile app name
userAgent: 'stock42agent', // your app userAgent
applicationToken: 'bd23a6fb-02e6-4ac6-8e5c-2aa28bd83db2-FV2AH3', //get this using Stock42 Mobile Apps
deviceId: '1', //important: generate your own deviceId for each device
})
} catch (err) {
console.info('Fatal Hit Errors: ', err)
}
Additional Dependency for Screenshots
To enable the screenshot functionality, you must also install react-native-view-shot:
npm install react-native-view-shot --save
This library allows you to capture fully rendered screenshots of your app. For more details, visit the react-native-view-shot GitHub page.
Sending hits
To send analytics hits to Stock42, use the track.do
method as shown below:
track.do({
eventName: 'custom',
screenName: 'home',
functionName: `functionForSomeOne`,
data: {
msg: 'random msg',
},
})
Sending screenshot
Ensure you have installed react-native-view-shot and then use the screenshot.do
method:
screenshot.do({
screenName: 'screentesting',
base64: 'base64-encoded-image-string'
});
import { captureScreen } from 'react-native-view-shot';
captureScreen({
format: "jpg",
quality: 0.8
}).then(
uri => console.log("Image saved to", uri),
error => console.error("Oops, snapshot failed", error)
);
screenshot.do({
screenName: 'screentesting',
base64:
'iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAACClBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKDgUBAgEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAtEQcFFx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