react-native-module-sample
v1.1.9
Published
Downloads
12
Readme
imqa-react-native-agent
Getting started
$ npm install imqa-react-native-agent --save
Usage
Measure screen rendering time
import MpmAgent from ‘imqa-react-native-agent’;
class ParentsComponent extends React.Component {
...
componentDidMount() {
MpmAgent?.setBehaviorData("MyComponent");
MpmAgent?.startReactNativeRender("MyComponent", true);
...
MpmAgent?.endReactNativeRender("MyComponent", true);
}
}
}
import MpmAgent from 'imqa-react-native-agent';
class ChildComponent extends React.Component {
...
componentDidMount() {
MpmAgent?.startReactNativeRender("MyChildComponent", false);
...
MpmAgent?.endReactNativeRender("MyChildComponent", false);
}
}
Measuring Network Time
Axios
const axiosInstance = axios.create({
baseURL:"http://sample-api"
});
axiosInstance.interceptors.request.use(
(config) => {
try{
MpmAgent?.startReactNativeNetwork(
config.baseURL?.toString(),
config.url?.toString(),
config.method?.toString(),
config.baseURL?.split('://')[0]
);
}catch(e){
console.error(e);
}
return config;
},
error => {
MpmAgent?.endReactNativeNetwork("500");
}
);
axiosInstance.interceptors.response.use( response => {
MpmAgent?.endReactNativeNetwork(response.status.toString());
return response;
});
Fetch
let url = "http://sample-api";
MpmAgent?.startReactNativeNetwork(url, "/sample", "post", url?.split('://')[0]);
fetch(url)
.then(response => {
MpmAgent?.endReactNativeNetwork(response.status.toString());
return response;
})
.catch(error => {
MpmAgent?.endReactNativeNetwork("500");
});