38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
import environment from '../components/environment.js';
|
|
import axios from 'axios';
|
|
import store from '../redux/store';
|
|
import Theme from '../components/theme.style';
|
|
import { getAppVersion, getOS, getOSVersion, getUniqueID } from './device.js';
|
|
import { getModel } from 'react-native-device-info';
|
|
|
|
export const callLogs = async (error, status, type, subject, action) => {
|
|
const name = Theme.formatter.NAME(store.getState().appUserInfoReducer.userinfo.data);
|
|
const data = {
|
|
"project": environment.PROJECT_CODE,
|
|
"user": name || "Guest",
|
|
"source": type || "frontend",
|
|
"type": status,
|
|
"subject": subject || "Screen",
|
|
"action": action || "Render",
|
|
"errors": status === "success" ? undefined : {
|
|
"error": JSON.stringify(error)
|
|
},
|
|
"values": {
|
|
"app_version": getAppVersion(),
|
|
"device_unique_id": getUniqueID(),
|
|
"device_os_version": getOSVersion(),
|
|
"device_os": getOS(),
|
|
"device_model": getModel()
|
|
}
|
|
}
|
|
|
|
await axios({
|
|
url: `${environment.LOGS_URL}/create`,
|
|
method: "POST",
|
|
data: data,
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
"Project-Key": environment.PROJECT_KEY
|
|
}
|
|
})
|
|
} |