UNPKG

react-native-site24x7-rn

Version:

Monitor react native mobile applications with site24x7 Mobile RUM

50 lines (47 loc) 1.41 kB
import { NativeModules } from 'react-native'; import { Dimensions } from 'react-native'; import S24Utils from './site24x7Utils'; const { Site24x7Rn } = NativeModules; class site24x7RnScreenTracker{ constructor(){ this.ignoredScreens = []; } /** * Configuring screens to be ignored from tracking * * @param {Array} screens */ ignoreScreens(screens){ if(typeof screens == 'string'){ this.ignoredScreens.push(screens); }else{ this.ignoredScreens.concat(screens); } } /** * Static method to get current device orientaion (potrait|landscape) * * @return {string} */ static getDeviceOrientation(){ const dim = Dimensions.get('screen'); if(dim.height >= dim.width){ return 'potrait';//No I18N }else{ return 'landscape';//No I18N } } /** * Option to add screen manually with loadtime of the screen * * @param {string} screenName * @param {number} loadTime */ addScreen(screenName,loadTime){ S24Utils.setCurrentScreen(screenName); if(!S24Utils.shouldIgnoreFromList(screenName,this.ignoredScreens,false)){ Site24x7Rn.addScreen(screenName,site24x7RnScreenTracker.getDeviceOrientation(),Date.now().toString(),''+loadTime); } } } module.exports = site24x7RnScreenTracker;