Skip to content

Commit

Permalink
CP-7069: Upgrade sentry sdk (#911)
Browse files Browse the repository at this point in the history
  • Loading branch information
onghwan authored Sep 12, 2023
1 parent fce0b50 commit d205a79
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 297 deletions.
3 changes: 2 additions & 1 deletion app/ContextApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { TopLevelErrorFallback } from 'components/TopLevelErrorFallback'
import { GestureHandlerRootView } from 'react-native-gesture-handler'
import FlipperAsyncStorage from 'rn-flipper-async-storage-advanced'
import { ReactQueryProvider } from 'contexts/ReactQueryProvider'
import SentryService from 'services/sentry/SentryService'

function setToast(toast: Toast) {
global.toast = toast
Expand Down Expand Up @@ -79,4 +80,4 @@ const JailBrokenCheck: FC = ({ children }) => {
return <>{children}</>
}

export default Sentry.wrap(ContextApp)
export default SentryService.isAvailable ? Sentry.wrap(ContextApp) : ContextApp
72 changes: 36 additions & 36 deletions app/services/sentry/SentryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,43 @@ import * as Sentry from '@sentry/react-native'
import { DefaultSampleRate } from 'services/sentry/SentryWrapper'
import { scrub } from 'utils/data/scrubber'

class SentryService {
init = () => {
if (Config.SENTRY_DSN && !__DEV__) {
Sentry.init({
dsn: Config.SENTRY_DSN,
environment: Config.ENVIRONMENT,
debug: false,
beforeSend: event => {
/**
* eliminating breadcrumbs. This should eliminate
* a massive amount of the data leaks into sentry. If we find that console
* is leaking data, suspected that it might, than we can review the leak and
* see if we can modify the data before it is recorded. This can be
* done in the sentry options beforeBreadcrumbs function.
*/
delete event?.user?.email
delete event?.user?.ip_address
delete event.contexts?.device?.name
const isAvailable = Config.SENTRY_DSN !== undefined && !__DEV__

try {
const eventStr = JSON.stringify(event)
const scrubbedEventStr = scrub(eventStr)
return JSON.parse(scrubbedEventStr)
} catch (error) {
return event
}
},
beforeBreadcrumb: () => {
return null
},
tracesSampler: samplingContext => {
return samplingContext.sampleRate ?? DefaultSampleRate
},
integrations: []
})
}
const init = () => {
if (isAvailable) {
Sentry.init({
dsn: Config.SENTRY_DSN,
environment: Config.ENVIRONMENT,
debug: false,
beforeSend: event => {
/**
* eliminating breadcrumbs. This should eliminate
* a massive amount of the data leaks into sentry. If we find that console
* is leaking data, suspected that it might, than we can review the leak and
* see if we can modify the data before it is recorded. This can be
* done in the sentry options beforeBreadcrumbs function.
*/
delete event?.user?.email
delete event?.user?.ip_address
delete event.contexts?.device?.name

try {
const eventStr = JSON.stringify(event)
const scrubbedEventStr = scrub(eventStr)
return JSON.parse(scrubbedEventStr)
} catch (error) {
return event
}
},
beforeBreadcrumb: () => {
return null
},
tracesSampler: samplingContext => {
return samplingContext.sampleRate ?? DefaultSampleRate
},
integrations: []
})
}
}

export default new SentryService()
export default { init, isAvailable }
6 changes: 2 additions & 4 deletions app/services/sentry/Span.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SpanContext } from '@sentry/types/types/span'
import { SpanStatus } from '@sentry/tracing'
import { Transaction } from '@sentry/types'
import { OpName } from 'services/sentry/types'

Expand Down Expand Up @@ -33,11 +32,10 @@ export class Span {
const span = this.transaction?.startChild(this.spanContext)
try {
const result = await f()
// Do something
span?.setStatus(SpanStatus.Ok)
span?.setStatus('ok')
return result
} catch (err) {
span?.setStatus(SpanStatus.UnknownError)
span?.setStatus('unknown_error')
throw err
} finally {
span?.finish()
Expand Down
18 changes: 10 additions & 8 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,9 @@ PODS:
- React-RCTImage
- RNSensors (7.3.5):
- React-Core
- RNSentry (4.8.0):
- RNSentry (5.9.1):
- React-Core
- Sentry (= 7.29.0)
- Sentry/HybridSDK (= 8.10.0)
- RNSVG (13.8.0):
- React-Core
- RNVectorIcons (8.1.0):
Expand All @@ -510,9 +510,9 @@ PODS:
- SDWebImageWebPCoder (0.8.5):
- libwebp (~> 1.0)
- SDWebImage/Core (~> 5.10)
- Sentry (7.29.0):
- Sentry/Core (= 7.29.0)
- Sentry/Core (7.29.0)
- Sentry/HybridSDK (8.10.0):
- SentryPrivate (= 8.10.0)
- SentryPrivate (8.10.0)
- SocketRocket (0.6.0)
- Yoga (1.14.0)
- YogaKit (1.18.1):
Expand Down Expand Up @@ -642,6 +642,7 @@ SPEC REPOS:
- SDWebImage
- SDWebImageWebPCoder
- Sentry
- SentryPrivate
- SocketRocket
- YogaKit

Expand Down Expand Up @@ -891,16 +892,17 @@ SPEC CHECKSUMS:
RNReanimated: 0a5f87ec1da472cca3e835333fdebe51d983c411
RNScreens: f3230dd008a7d0ce5c0a8bc78ff12cf2315bda24
RNSensors: e74c8bd9606400c1048ab67af7f41eb2091cb2fc
RNSentry: db7fd7b66efda28885e4e904a8b5e7349aec61c1
RNSentry: 0a1daa8ee81e2776f977ae8c66e67c8d85587828
RNSVG: c1e76b81c76cdcd34b4e1188852892dc280eb902
RNVectorIcons: 31cebfcf94e8cf8686eb5303ae0357da64d7a5a4
SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d
SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d
Sentry: 4272663eb0eda312024d795ca3f5a562a8ce5e18
Sentry: 71cd4427146ac56eab6e70401ac7a24384c3d3b5
SentryPrivate: 9334613897c85a9e30f2c9d7a331af8aaa4fe71f
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
Yoga: 99caf8d5ab45e9d637ee6e0174ec16fbbb01bcfc
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: 813e8258c2f6020d5fd16151cddb17023263f060
PODFILE CHECKSUM: 1200f06fb217f7e34765cfbc333ab8a27f790217

COCOAPODS: 1.11.3
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@react-navigation/native-stack": "6.9.2",
"@react-navigation/stack": "6.3.2",
"@reduxjs/toolkit": "1.8.1",
"@sentry/react-native": "4.8.0",
"@sentry/react-native": "5.9.1",
"@shopify/flash-list": "1.4.3",
"@shopify/react-native-performance": "4.1.2",
"@shopify/react-native-skia": "0.1.183",
Expand Down
Loading

0 comments on commit d205a79

Please sign in to comment.