NTP-51553 | Added cybertron logger (#1125)
This commit is contained in:
2
.npmrc
Normal file
2
.npmrc
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
@cybertron:registry=https://nexus.cmd.navi-tech.in/repository/npm-packages/
|
||||||
|
//https://nexus.cmd.navi-tech.in/repository/npm-packages/:_authToken=NpmToken.1a3d3462-fb82-364c-bc64-0051e24635b3
|
||||||
@@ -9,4 +9,5 @@ export const APM_BASE_URL = 'https://dev-longhorn-portal.np.navi-tech.in/apm-eve
|
|||||||
export const GOOGLE_SSO_CLIENT_ID =
|
export const GOOGLE_SSO_CLIENT_ID =
|
||||||
'60755663443-40k0fbrbbqv4ci4hrjlbrphab5fj387b.apps.googleusercontent.com';
|
'60755663443-40k0fbrbbqv4ci4hrjlbrphab5fj387b.apps.googleusercontent.com';
|
||||||
export const COSMOS_DIALER_PACKAGE_NAME = 'org.fossify.phone';
|
export const COSMOS_DIALER_PACKAGE_NAME = 'org.fossify.phone';
|
||||||
|
export const CYBERTRON_LOGS_URL = 'https://dev-longhorn-portal.np.navi-tech.in/cybertron-logs';
|
||||||
export const CODEPUSH_KEY = 'test-get';
|
export const CODEPUSH_KEY = 'test-get';
|
||||||
|
|||||||
@@ -15,4 +15,5 @@ export const DATA_SYNC_TIME_INTERVAL = 2 * MINUTES_IN_AN_HOUR * MILLISECONDS_IN_
|
|||||||
export const GOOGLE_SSO_CLIENT_ID =
|
export const GOOGLE_SSO_CLIENT_ID =
|
||||||
'136591056725-ev8db4hrlud2m23n0o03or3cmmp3a3cq.apps.googleusercontent.com';
|
'136591056725-ev8db4hrlud2m23n0o03or3cmmp3a3cq.apps.googleusercontent.com';
|
||||||
export const COSMOS_DIALER_PACKAGE_NAME = 'org.fossify.phone';
|
export const COSMOS_DIALER_PACKAGE_NAME = 'org.fossify.phone';
|
||||||
|
export const CYBERTRON_LOGS_URL = 'https://longhorn.navi.com/cybertron-logs';
|
||||||
export const CODEPUSH_KEY = 'tfzYXgI3bnNdaIe';
|
export const CODEPUSH_KEY = 'tfzYXgI3bnNdaIe';
|
||||||
|
|||||||
@@ -14,3 +14,6 @@ export const GOOGLE_SSO_CLIENT_ID =
|
|||||||
'60755663443-40k0fbrbbqv4ci4hrjlbrphab5fj387b.apps.googleusercontent.com';
|
'60755663443-40k0fbrbbqv4ci4hrjlbrphab5fj387b.apps.googleusercontent.com';
|
||||||
export const COSMOS_DIALER_PACKAGE_NAME = 'org.fossify.phone';
|
export const COSMOS_DIALER_PACKAGE_NAME = 'org.fossify.phone';
|
||||||
export const CODEPUSH_KEY = 'test-get';
|
export const CODEPUSH_KEY = 'test-get';
|
||||||
|
export const CYBERTRON_LOGS_URL = 'https://qa-longhorn-portal.np.navi-ppl.in/cybertron-logs';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
"export-android": "mkdir -p android/output && react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/output/index.android.bundle --assets-dest android/output && cd android && find output -type f | zip index.android.bundle.zip -@ && cd .. && rm -rf android/output"
|
"export-android": "mkdir -p android/output && react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/output/index.android.bundle --assets-dest android/output && cd android && find output -type f | zip index.android.bundle.zip -@ && cd .. && rm -rf android/output"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@cybertron/logger": "1.0.108",
|
||||||
"@bam.tech/react-native-image-resizer": "3.0.5",
|
"@bam.tech/react-native-image-resizer": "3.0.5",
|
||||||
"@notifee/react-native": "7.8.2",
|
"@notifee/react-native": "7.8.2",
|
||||||
"@nozbe/with-observables": "1.4.1",
|
"@nozbe/with-observables": "1.4.1",
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ import { ToastMessages } from '../../screens/allCases/constants';
|
|||||||
import { alfredHandleSWWEvent } from './DeviceUtils';
|
import { alfredHandleSWWEvent } from './DeviceUtils';
|
||||||
import { setWithinOperativeHours } from '@reducers/userSlice';
|
import { setWithinOperativeHours } from '@reducers/userSlice';
|
||||||
import store from '@store';
|
import store from '@store';
|
||||||
|
import logger from './logger';
|
||||||
|
import { getKeyByValue } from './commonFunctions';
|
||||||
|
|
||||||
export enum ApiKeys {
|
export enum ApiKeys {
|
||||||
GENERATE_OTP = 'GENERATE_OTP',
|
GENERATE_OTP = 'GENERATE_OTP',
|
||||||
@@ -353,7 +355,20 @@ axiosInstance.interceptors.response.use(
|
|||||||
const start = response?.config?.headers['request-start-time'];
|
const start = response?.config?.headers['request-start-time'];
|
||||||
const end = Date.now();
|
const end = Date.now();
|
||||||
const milliseconds = end - Number(start);
|
const milliseconds = end - Number(start);
|
||||||
|
const url = response?.config?.url;
|
||||||
|
const apiKey = getKeyByValue(url, API_URLS);
|
||||||
sendApiToClickstreamEvent(response, milliseconds, false);
|
sendApiToClickstreamEvent(response, milliseconds, false);
|
||||||
|
logger({
|
||||||
|
msg: 'api response error',
|
||||||
|
extras: {
|
||||||
|
type: 'API_ERROR',
|
||||||
|
timeTaken: String(milliseconds),
|
||||||
|
statusCode: response?.status,
|
||||||
|
endpoint: API_URLS[apiKey as keyof typeof API_URLS],
|
||||||
|
method: response?.config?.method || '',
|
||||||
|
},
|
||||||
|
type: 'error'
|
||||||
|
});
|
||||||
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_API_FAILED, {
|
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_API_FAILED, {
|
||||||
statusCode: response?.status,
|
statusCode: response?.status,
|
||||||
url: response?.config?.url,
|
url: response?.config?.url,
|
||||||
|
|||||||
29
src/components/utlis/logger.ts
Normal file
29
src/components/utlis/logger.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { GLOBAL } from '@constants/Global';
|
||||||
|
import { ENV } from '@constants/config';
|
||||||
|
import cybertronLogger, { Message } from '@cybertron/logger/lib/main';
|
||||||
|
|
||||||
|
const logger = (payload: Message | string) => {
|
||||||
|
if (ENV === 'qa') return;
|
||||||
|
let transformedPayload: Message = {
|
||||||
|
msg: '',
|
||||||
|
};
|
||||||
|
if (typeof payload === 'string') {
|
||||||
|
transformedPayload.msg = payload;
|
||||||
|
} else {
|
||||||
|
transformedPayload = payload;
|
||||||
|
}
|
||||||
|
if (!transformedPayload?.extras) {
|
||||||
|
transformedPayload.extras = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
cybertronLogger.log({
|
||||||
|
msg: transformedPayload.msg || '',
|
||||||
|
extras: {
|
||||||
|
...transformedPayload.extras,
|
||||||
|
agentId: GLOBAL.AGENT_ID,
|
||||||
|
},
|
||||||
|
type: transformedPayload.type || 'log',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default logger;
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
import * as Sentry from '@sentry/react-native';
|
import * as Sentry from '@sentry/react-native';
|
||||||
import { SENTRY_DSN, TUNNEL_URL } from '../../constants/config';
|
import { CYBERTRON_LOGS_URL, ENV, SENTRY_DSN, TUNNEL_URL } from '../../constants/config';
|
||||||
import { addClickstreamEvent } from '../../services/clickstreamEventService';
|
import { addClickstreamEvent } from '../../services/clickstreamEventService';
|
||||||
import { CLICKSTREAM_EVENT_NAMES } from '../../common/Constants';
|
import { CLICKSTREAM_EVENT_NAMES } from '../../common/Constants';
|
||||||
import { getAppVersion } from './commonFunctions';
|
import { getAppVersion } from './commonFunctions';
|
||||||
import { createTransport } from '@sentry/core';
|
import { createTransport } from '@sentry/core';
|
||||||
import { GLOBAL } from '@constants/Global';
|
import { GLOBAL } from '@constants/Global';
|
||||||
|
import CybertronLogs, { ClientType } from '@cybertron/logger/lib/main';
|
||||||
|
|
||||||
function makeFetchTransport(options: any): any {
|
function makeFetchTransport(options: any): any {
|
||||||
function makeRequest(request: any) {
|
function makeRequest(request: any) {
|
||||||
@@ -51,6 +52,16 @@ export async function initSentry() {
|
|||||||
return event;
|
return event;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
CybertronLogs.setOptions({
|
||||||
|
appName: 'cosmos',
|
||||||
|
env: ENV,
|
||||||
|
baseUrl: CYBERTRON_LOGS_URL,
|
||||||
|
sessionId: GLOBAL?.AGENT_ID || 'cosmos-session',
|
||||||
|
teamName: 'collections',
|
||||||
|
threshold: 10,
|
||||||
|
clientType: ClientType.APP,
|
||||||
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_SENTRY_INTEGRATION_FAILED);
|
addClickstreamEvent(CLICKSTREAM_EVENT_NAMES.FA_SENTRY_INTEGRATION_FAILED);
|
||||||
console.error('Sentry initialization failed');
|
console.error('Sentry initialization failed');
|
||||||
|
|||||||
@@ -13,4 +13,5 @@ export const DATA_SYNC_TIME_INTERVAL = 2 * MINUTES_IN_AN_HOUR * MILLISECONDS_IN_
|
|||||||
export const GOOGLE_SSO_CLIENT_ID =
|
export const GOOGLE_SSO_CLIENT_ID =
|
||||||
'60755663443-40k0fbrbbqv4ci4hrjlbrphab5fj387b.apps.googleusercontent.com';
|
'60755663443-40k0fbrbbqv4ci4hrjlbrphab5fj387b.apps.googleusercontent.com';
|
||||||
export const COSMOS_DIALER_PACKAGE_NAME = 'org.fossify.phone';
|
export const COSMOS_DIALER_PACKAGE_NAME = 'org.fossify.phone';
|
||||||
|
export const CYBERTRON_LOGS_URL = 'https://qa-longhorn-portal.np.navi-ppl.in/cybertron-logs';
|
||||||
export const CODEPUSH_KEY = 'test-get';
|
export const CODEPUSH_KEY = 'test-get';
|
||||||
|
|||||||
@@ -139,13 +139,20 @@ export const sendApiToClickstreamEvent = (
|
|||||||
) => {
|
) => {
|
||||||
const url = response?.config?.url;
|
const url = response?.config?.url;
|
||||||
const statusCode = response?.status;
|
const statusCode = response?.status;
|
||||||
|
const method = response?.config?.method;
|
||||||
if (url) {
|
if (url) {
|
||||||
const apiKey = getKeyByValue(url, API_URLS);
|
const apiKey = getKeyByValue(url, API_URLS);
|
||||||
if (apiKey && DISABLE_API_EVENTS_URL.indexOf(apiKey) === -1) {
|
if (apiKey && DISABLE_API_EVENTS_URL.indexOf(apiKey) === -1) {
|
||||||
const eventName = getEventNameFromAPIKey(apiKey, isSuccess);
|
const eventName = getEventNameFromAPIKey(apiKey, isSuccess);
|
||||||
addClickstreamEvent(
|
addClickstreamEvent(
|
||||||
{ name: eventName, description: eventName },
|
{ name: eventName, description: eventName },
|
||||||
{ timeTaken: milliseconds, statusCode, response: statusCode === 400 ? response : '' }
|
{
|
||||||
|
timeTaken: milliseconds,
|
||||||
|
statusCode,
|
||||||
|
method,
|
||||||
|
endpoint: API_URLS[apiKey as keyof typeof API_URLS],
|
||||||
|
response: statusCode === 400 ? response : '',
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user