From 67be1b05ed93640b28804115a806ca2c57411e3c Mon Sep 17 00:00:00 2001 From: Mantri Ramkishor Date: Mon, 11 Nov 2024 16:25:08 +0530 Subject: [PATCH 01/12] NTP-11577 | Cybertron Changes (#1003) Co-authored-by: Varnit Goyal Co-authored-by: varnit goyal --- .github/workflows/codePush.yml | 42 +++- .github/workflows/newBuild.yml | 43 +++- App.tsx | 49 ++++- RN-UI-LIB | 2 +- android/app/build.gradle | 5 +- android/sentry.properties | 7 + config/qa/config.js | 10 +- ios/AVAPP.xcodeproj/project.pbxproj | 17 +- ios/sentry.properties | 7 + metro.config.js | 8 +- package.json | 6 +- src/common/BlockerScreen.tsx | 6 +- src/components/utlis/apiHelper.ts | 4 +- src/components/utlis/errorUtils.ts | 18 +- src/constants/config.js | 10 +- src/screens/Profile/index.tsx | 2 +- src/screens/allCases/CasesListScreen.tsx | 9 +- yarn.lock | 261 ++++++++++++++++------- 18 files changed, 384 insertions(+), 122 deletions(-) create mode 100644 android/sentry.properties create mode 100644 ios/sentry.properties diff --git a/.github/workflows/codePush.yml b/.github/workflows/codePush.yml index 2501732a..372da6d7 100644 --- a/.github/workflows/codePush.yml +++ b/.github/workflows/codePush.yml @@ -63,8 +63,11 @@ jobs: generate_source_map: needs: generate + outputs: + package_version: ${{ needs.generate.outputs.package_version }} + build_number: ${{ needs.generate.outputs.build_number }} runs-on: [default] - if: success() && (github.event.inputs.environment == 'Prod') # Only create source map for Prod releases + if: success() && (github.event.inputs.environment != 'Prod') # Only create source map for Prod releases steps: - name: Checkout uses: actions/checkout@v2 @@ -95,6 +98,43 @@ jobs: with: name: source-map path: index.android.bundle.map + + + + + upload_sourcemap_cybertron: + needs: generate_source_map + runs-on: [default] + if: success() && (github.event.inputs.environment != 'Prod') + steps: + - name: Download Source Map + uses: actions/download-artifact@v3 + with: + name: source-map + path: ./artifacts # Specify the folder to store the downloaded artifact + + - name: 'create release' + run: | + cd artifacts + ls -lh + echo creating release + response=$(curl --location --request POST '${{secrets.CYBERTRON_BASE_URL}}/api/v1/release' \ + --header 'Content-Type: application/json' \ + --data '{ + "releaseVersion": "${{ needs.generate_source_map.outputs.package_version }}", + "projectReferenceId": "${{ secrets.CYBERTRON_PROJECT_ID }}" + }') + echo $response + + - name: 'create presigned url' + run: | + presigned_url_source_map='${{secrets.CYBERTRON_BASE_URL}}/api/v1/get-sourcemap-upload-url?project_id=${{secrets.CYBERTRON_PROJECT_ID}}&release_id=${{ needs.generate_source_map.outputs.package_version }}&file_name=index.android.bundle.map' + response=$(curl --location $presigned_url_source_map) + echo "$response" + upload_url=$(echo "$response" | jq -r .url) + echo $upload_url + curl --location --request PUT --progress-bar --header "Content-Type: application/octet-stream" $upload_url --upload-file artifacts/index.android.bundle.map + create_release_tag: needs: generate_source_map diff --git a/.github/workflows/newBuild.yml b/.github/workflows/newBuild.yml index 2b6686e2..e8501bf9 100644 --- a/.github/workflows/newBuild.yml +++ b/.github/workflows/newBuild.yml @@ -44,6 +44,9 @@ on: jobs: generate: runs-on: [ default ] + outputs: + package_version: ${{ github.event.inputs.version_name }} + build_number: ${{ github.event.inputs.version_code }} steps: - name: Checkout uses: actions/checkout@v2 @@ -166,7 +169,10 @@ jobs: generate_source_map: needs: generate runs-on: [default] - if: success() && (github.event.inputs.environment == 'Prod') && (github.event.inputs.releaseType == 'HARD_RELEASE' || inputs.releaseType == 'HARD_RELEASE') # Only create source map for Prod releases and not for test builds + outputs: + package_version: ${{ needs.generate.outputs.package_version }} + build_number: ${{ needs.generate.outputs.build_number }} + # if: success() && (github.event.inputs.environment != 'Prod') && (github.event.inputs.releaseType == 'HARD_RELEASE' || inputs.releaseType == 'HARD_RELEASE') # Only create source map for Prod releases and not for test builds steps: - name: Checkout uses: actions/checkout@v2 @@ -225,6 +231,41 @@ jobs: name: source-map path: index.android.bundle.map + + upload_sourcemap_cybertron: + needs: generate_source_map + runs-on: [default] + if: success() && (github.event.inputs.environment != 'Prod') + steps: + - name: Download Source Map + uses: actions/download-artifact@v3 + with: + name: source-map + path: ./artifacts # Specify the folder to store the downloaded artifact + + - name: 'create release' + run: | + cd artifacts + ls -lh + echo creating release + response=$(curl --location --request POST '${{secrets.CYBERTRON_BASE_URL}}/api/v1/release' \ + --header 'Content-Type: application/json' \ + --data '{ + "releaseVersion": "${{ needs.generate_source_map.outputs.package_version }}", + "projectReferenceId": "${{ secrets.CYBERTRON_PROJECT_ID }}" + }') + echo $response + + - name: 'create presigned url' + run: | + presigned_url_source_map='${{secrets.CYBERTRON_BASE_URL}}/api/v1/get-sourcemap-upload-url?project_id=${{secrets.CYBERTRON_PROJECT_ID}}&release_id=${{ needs.generate_source_map.outputs.package_version }}&file_name=index.android.bundle.map' + response=$(curl --location $presigned_url_source_map) + echo "$response" + upload_url=$(echo "$response" | jq -r .url) + echo $upload_url + curl --location --request PUT --progress-bar --header "Content-Type: application/octet-stream" $upload_url --upload-file artifacts/index.android.bundle.map + + create_release_tag: needs: generate_source_map runs-on: [default] diff --git a/App.tsx b/App.tsx index cf74001a..4da40b94 100644 --- a/App.tsx +++ b/App.tsx @@ -21,10 +21,10 @@ import { PersistGate } from 'redux-persist/integration/react'; import store, { persistor } from './src/store/store'; import FullScreenLoader from './RN-UI-LIB/src/components/FullScreenLoader'; -import { toastConfigs, ToastContainer } from './RN-UI-LIB/src/components/toast'; +import { toast, toastConfigs, ToastContainer } from './RN-UI-LIB/src/components/toast'; import { navigationRef } from './src/components/utlis/navigationUtlis'; -import { sendDeviceDetailsToClickstream } from '@components/utlis/commonFunctions'; +import { getAppVersion, sendDeviceDetailsToClickstream } from '@components/utlis/commonFunctions'; import { linkingConf } from '@components/utlis/deeplinkingUtils'; import { getBuildFlavour } from '@components/utlis/DeviceUtils'; import { setGlobalBuildFlavour } from '@constants/Global'; @@ -48,6 +48,51 @@ import { setJsErrorHandler } from './src/services/exception-handler.service'; import fetchUpdatedRemoteConfig from './src/services/firebaseFetchAndUpdate.service'; import { StorageKeys } from './src/types/storageKeys'; import CodePushLoadingModal, { CodePushLoadingModalRef } from './CodePushModal'; +import { createTransport } from '@sentry/core'; +import * as Sentry from '@sentry/react-native'; + +function makeFetchTransport(options: any): any { + function makeRequest(request: any) { + const requestOptions: RequestInit = { + body: request.body, + method: 'POST', + referrerPolicy: 'origin', + headers: options.headers, + ...options.fetchOptions, + }; + + return fetch(options.url, requestOptions).then((response) => { + console.log({ options, requestOptions, response }); + toast({ type: 'success', text1: options?.url }); + return { + statusCode: response.status, + headers: { + 'x-sentry-rate-limits': response.headers.get('X-Sentry-Rate-Limits'), + 'retry-after': response.headers.get('Retry-After'), + }, + }; + }); + } + + return createTransport(options, makeRequest); +} + +Sentry.init({ + dsn: 'https://98c6621b8fa4447389ea43c67172154d@o4508256125911040.ingest.us.sentry.io/4508256126107648', + transport: makeFetchTransport, + tunnel: 'https://qa-sa.navi.com/cybertron/api/4/envelope?sentry_key=', + beforeSend(event) { + event.extra = { + ...event.extra, + release_id: getAppVersion(), + alfredSessionId: '', + metadata: {}, + }; + return event; + }, + // uncomment the line below to enable Spotlight (https://spotlightjs.com) + // enableSpotlight: __DEV__, +}); if (ENV !== 'prod') { // mockApiServer(); diff --git a/RN-UI-LIB b/RN-UI-LIB index 019bc50b..a4253115 160000 --- a/RN-UI-LIB +++ b/RN-UI-LIB @@ -1 +1 @@ -Subproject commit 019bc50b015b464438047e37c6253cb41af4bf68 +Subproject commit a42531156f3a00362bc97ecc8f41166df509ae2a diff --git a/android/app/build.gradle b/android/app/build.gradle index d02d6761..c3ba274c 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -134,9 +134,10 @@ def reactNativeArchitectures() { return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"] } -def VERSION_CODE = 212 -def VERSION_NAME = "2.14.12" +def VERSION_CODE = 213 +def VERSION_NAME = "2.14.13" +apply from: new File(["node", "--print", "require.resolve('@sentry/react-native/package.json')"].execute().text.trim(), "../sentry.gradle") android { ndkVersion rootProject.ext.ndkVersion diff --git a/android/sentry.properties b/android/sentry.properties new file mode 100644 index 00000000..af69fca5 --- /dev/null +++ b/android/sentry.properties @@ -0,0 +1,7 @@ + +auth.token=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 + +defaults.org=navi-l1 +defaults.project=react-native + +defaults.url=https://sentry.io/ diff --git a/config/qa/config.js b/config/qa/config.js index df82b252..fa45a329 100644 --- a/config/qa/config.js +++ b/config/qa/config.js @@ -1,15 +1,15 @@ import { MILLISECONDS_IN_A_MINUTE, MINUTES_IN_AN_HOUR } from '../../RN-UI-LIB/src/utlis/common'; -export const BASE_AV_APP_URL = 'https://qa-longhorn-portal.np.navi-tech.in/field-app'; +export const BASE_AV_APP_URL = 'https://qa-longhorn-server.np.navi-ppl.in/field-app'; export const SENTRY_DSN = - 'https://acef93c884c1424cacc4ec899562e203@qa-longhorn-portal.np.navi-tech.in/glitchtip-events/173'; -export const JANUS_SERVICE_URL = 'https://qa-longhorn-portal.np.navi-tech.in/api/events/json'; + 'https://acef93c884c1424cacc4ec899562e203@qa-longhorn-server.np.navi-ppl.in/glitchtip-events/173'; +export const JANUS_SERVICE_URL = 'https://qa-longhorn-server.np.navi-ppl.in/api/events/json'; export const ENV = 'qa'; export const IS_SSO_ENABLED = true; export const APM_APP_NAME = 'cosmos-app'; -export const APM_BASE_URL = 'https://qa-longhorn-portal.np.navi-tech.in/apm-events'; +export const APM_BASE_URL = 'https://qa-longhorn-server.np.navi-ppl.in/apm-events'; export const IS_DATA_SYNC_REQUIRED = true; export const DATA_SYNC_TIME_INTERVAL = 2 * MINUTES_IN_AN_HOUR * MILLISECONDS_IN_A_MINUTE; // 2hr export const GOOGLE_SSO_CLIENT_ID = '60755663443-40k0fbrbbqv4ci4hrjlbrphab5fj387b.apps.googleusercontent.com'; -export const MS_CLARITY_PROJECT_ID = ''; \ No newline at end of file +export const MS_CLARITY_PROJECT_ID = ''; diff --git a/ios/AVAPP.xcodeproj/project.pbxproj b/ios/AVAPP.xcodeproj/project.pbxproj index f4270e79..7482cc60 100644 --- a/ios/AVAPP.xcodeproj/project.pbxproj +++ b/ios/AVAPP.xcodeproj/project.pbxproj @@ -184,6 +184,7 @@ 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, 00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */, E235C05ADACE081382539298 /* [CP] Copy Pods Resources */, + 20788EEE27084AE2A60AD608 /* Upload Debug Symbols to Sentry */, ); buildRules = ( ); @@ -264,7 +265,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "set -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT $REACT_NATIVE_XCODE\"\n"; + shellScript = "set -e\n\nWITH_ENVIRONMENT=\"../node_modules/react-native/scripts/xcode/with-environment.sh\"\nREACT_NATIVE_XCODE=\"../node_modules/react-native/scripts/react-native-xcode.sh\"\n\n/bin/sh -c \"$WITH_ENVIRONMENT \\\"/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode.sh $REACT_NATIVE_XCODE\\\"\"\n"; }; 00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; @@ -397,6 +398,20 @@ shellScript = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../node_modules/react-native/scripts/.packager.env\"\nif [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then\n if ! curl -s \"http://localhost:${RCT_METRO_PORT}/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open \"$SRCROOT/../node_modules/react-native/scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi\n"; showEnvVarsInLog = 0; }; + 20788EEE27084AE2A60AD608 /* Upload Debug Symbols to Sentry */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + name = "Upload Debug Symbols to Sentry"; + inputPaths = ( + ); + outputPaths = ( + ); + shellPath = /bin/sh; + shellScript = "/bin/sh ../node_modules/@sentry/react-native/scripts/sentry-xcode-debug-files.sh"; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/ios/sentry.properties b/ios/sentry.properties new file mode 100644 index 00000000..af69fca5 --- /dev/null +++ b/ios/sentry.properties @@ -0,0 +1,7 @@ + +auth.token=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 + +defaults.org=navi-l1 +defaults.project=react-native + +defaults.url=https://sentry.io/ diff --git a/metro.config.js b/metro.config.js index 13a96421..8a5628af 100644 --- a/metro.config.js +++ b/metro.config.js @@ -1,3 +1,7 @@ +const { + withSentryConfig +} = require("@sentry/react-native/metro"); + /** * Metro configuration for React Native * https://github.com/facebook/react-native @@ -5,7 +9,7 @@ * @format */ -module.exports = { +module.exports = withSentryConfig({ transformer: { getTransformOptions: async () => ({ transform: { @@ -14,4 +18,4 @@ module.exports = { }, }), }, -}; +}); \ No newline at end of file diff --git a/package.json b/package.json index 468f55a8..e7a04cc3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "AV_APP", - "version": "2.14.12", - "buildNumber": "212", + "version": "2.14.13", + "buildNumber": "213", "private": true, "scripts": { "android:dev": "yarn move:dev && react-native run-android", @@ -56,7 +56,7 @@ "@react-navigation/native": "6.1.4", "@react-navigation/native-stack": "6.9.4", "@reduxjs/toolkit": "1.9.1", - "@sentry/react-native": "5.5.0", + "@sentry/react-native": "^5.35.0", "@shopify/flash-list": "1.4.3", "@supersami/rn-foreground-service": "^2.1.0", "appcenter": "^4.4.5", diff --git a/src/common/BlockerScreen.tsx b/src/common/BlockerScreen.tsx index 51553f2f..324386c7 100644 --- a/src/common/BlockerScreen.tsx +++ b/src/common/BlockerScreen.tsx @@ -200,9 +200,9 @@ const BlockerScreen = (props: IBlockerScreen) => { // Higher Priotrity to Post Operative Hours if (!withinOperativeHours && isLoggedIn && !GLOBAL.IS_IMPERSONATED) return ; - if (shouldUpdate.newApkCachedUrl) { - return ; - } + // if (shouldUpdate.newApkCachedUrl) { + // return ; + // } if (shouldUpdate.switchToFallback) { const { heading, instructions } = BLOCKER_SCREEN_DATA.UNINSTALL_APP; diff --git a/src/components/utlis/apiHelper.ts b/src/components/utlis/apiHelper.ts index 4593cc42..3511bda7 100644 --- a/src/components/utlis/apiHelper.ts +++ b/src/components/utlis/apiHelper.ts @@ -359,7 +359,7 @@ axiosInstance.interceptors.response.use( if ([API_STATUS_CODE.UNAUTHORIZED, API_STATUS_CODE.FORBIDDEN].includes(response.status)) { // Reset user info - dispatch(handleLogout()); + // dispatch(handleLogout()); } // Blocking cosmos after operative hours @@ -368,7 +368,7 @@ axiosInstance.interceptors.response.use( dispatch(setWithinOperativeHours(false)); } } - + return Promise.reject(error); } config.retry -= 1; diff --git a/src/components/utlis/errorUtils.ts b/src/components/utlis/errorUtils.ts index f64f42b2..32dd8fbd 100644 --- a/src/components/utlis/errorUtils.ts +++ b/src/components/utlis/errorUtils.ts @@ -2,15 +2,15 @@ import * as Sentry from '@sentry/react-native'; import { GLOBAL } from '../../constants/Global'; export const logError = (error: Error, extraInfo = '') => { - if(__DEV__) { - // Disable sentry in development mode - return; - } - // Sentry.setTag('agentId', GLOBAL.AGENT_ID || 'not-logged-in'); - // Sentry.captureException(error, (scope) => { - // scope.setExtra('ExtraInfo', extraInfo); - // return scope; - // }); + // if(__DEV__) { + // // Disable sentry in development mode + // return; + // } + Sentry.setTag('agentId', GLOBAL.AGENT_ID || 'not-logged-in'); + Sentry.captureException(error, (scope) => { + scope.setExtra('ExtraInfo', extraInfo); + return scope; + }); }; export const sentryCaptureMessage = (errorStr: string, extraInfo = '') => { diff --git a/src/constants/config.js b/src/constants/config.js index df82b252..fa45a329 100644 --- a/src/constants/config.js +++ b/src/constants/config.js @@ -1,15 +1,15 @@ import { MILLISECONDS_IN_A_MINUTE, MINUTES_IN_AN_HOUR } from '../../RN-UI-LIB/src/utlis/common'; -export const BASE_AV_APP_URL = 'https://qa-longhorn-portal.np.navi-tech.in/field-app'; +export const BASE_AV_APP_URL = 'https://qa-longhorn-server.np.navi-ppl.in/field-app'; export const SENTRY_DSN = - 'https://acef93c884c1424cacc4ec899562e203@qa-longhorn-portal.np.navi-tech.in/glitchtip-events/173'; -export const JANUS_SERVICE_URL = 'https://qa-longhorn-portal.np.navi-tech.in/api/events/json'; + 'https://acef93c884c1424cacc4ec899562e203@qa-longhorn-server.np.navi-ppl.in/glitchtip-events/173'; +export const JANUS_SERVICE_URL = 'https://qa-longhorn-server.np.navi-ppl.in/api/events/json'; export const ENV = 'qa'; export const IS_SSO_ENABLED = true; export const APM_APP_NAME = 'cosmos-app'; -export const APM_BASE_URL = 'https://qa-longhorn-portal.np.navi-tech.in/apm-events'; +export const APM_BASE_URL = 'https://qa-longhorn-server.np.navi-ppl.in/apm-events'; export const IS_DATA_SYNC_REQUIRED = true; export const DATA_SYNC_TIME_INTERVAL = 2 * MINUTES_IN_AN_HOUR * MILLISECONDS_IN_A_MINUTE; // 2hr export const GOOGLE_SSO_CLIENT_ID = '60755663443-40k0fbrbbqv4ci4hrjlbrphab5fj387b.apps.googleusercontent.com'; -export const MS_CLARITY_PROJECT_ID = ''; \ No newline at end of file +export const MS_CLARITY_PROJECT_ID = ''; diff --git a/src/screens/Profile/index.tsx b/src/screens/Profile/index.tsx index 124ac8f6..340619fa 100644 --- a/src/screens/Profile/index.tsx +++ b/src/screens/Profile/index.tsx @@ -121,7 +121,7 @@ const Profile: React.FC = () => { ]} > {hideUploadImageBtn ? null : } - {getNavigationLinks()?.map((link, index) => { + {getNavigationLinks().tmp.data.map((link, index) => { if (!link.isVisible) return null; return ( diff --git a/src/screens/allCases/CasesListScreen.tsx b/src/screens/allCases/CasesListScreen.tsx index 788ec0f3..402f8dad 100644 --- a/src/screens/allCases/CasesListScreen.tsx +++ b/src/screens/allCases/CasesListScreen.tsx @@ -4,7 +4,7 @@ import { setCommitmentOpenBottomSheet } from '@reducers/commitmentTrackerSlice'; import { COLORS } from '@rn-ui-lib/colors'; import DailyCommitmentIcon from '@rn-ui-lib/icons/DailyCommitmentIcon'; import React, { useEffect } from 'react'; -import { StyleSheet } from 'react-native'; +import {Button, StyleSheet} from 'react-native'; import CasesList from './CasesList'; import { setSelectedFilters } from '@reducers/filtersSlice'; import { parseJsonWithFallback } from '@utils/commonFunctions'; @@ -25,6 +25,10 @@ const CasesListScreen = (props: IAllCasesListScreenProps) => { const pinnedList = useAppSelector((state) => state.allCases.pinnedList); const completedList = useAppSelector((state) => state.allCases.completedList); const isCallActive = useAppSelector((state) => state?.activeCall?.activeCallDetails?.callActive); + const onCrashClick = ()=> { + const a = undefined; + console.log(a.varnit); + }; const isCommitmentFormVisible = useAppSelector( (state) => state.commitmentTracker.isCommitmentFormVisible @@ -65,6 +69,7 @@ const CasesListScreen = (props: IAllCasesListScreenProps) => { textStyle={styles.titleText} /> ) : null} +