Skip to content

Commit

Permalink
deps: Upgrade @sentry/react-native to 5.9.2, the latest
Browse files Browse the repository at this point in the history
Our hope here is to fix the Android crashes in zulip#5757. If it works
(as it seems to in internal testing!), it would support the theory
that the Sentry Native SDK at 0.4.12 (and from others' reports, also
0.5.4) has a bad interaction with something in Google's Play
Services system update on 2023-08-01 -- and that the interaction is
not present with Sentry Native 0.6.5 (its current latest).

Those Sentry Native SDK versions are deduced from Sentry *React
Native* SDK versions (3.4.3, 5.1.1, and 5.9.2, respectively), using
a process I wrote down:
  https://chat.zulip.org/#narrow/stream/48-mobile/topic/Android.20crashes/near/1643817

See a React Native issue:
  facebook/react-native#39505

and an issue in a Google tracker:
  https://issuetracker.google.com/issues/300840851?pli=1

and an issue in the Sentry Unity tracker:
  https://github.com/getsentry/sentry-unity/issues/1444

Done by following the upgrade guide at
  https://docs.sentry.io/platforms/react-native/migration/
starting in the "From 3.x to 4.x" section and working up through
"From 4.x to 5.x".

Not many declared breaking changes relevant to our app:
- The `Severity` enum is removed in favor of string literals
- The Sentry CLI had a big upgrade with declared breaking changes
  to handle in our iOS build

We want to get this out to Android users quickly, so we postpone a
few things for now:
- Any testing on iOS
- Flow types generated from the TypeScript using TsFlower. (We have
  a hand-translated libdef, but it's likely to be misleading because
  it's now outdated by two major versions. I've ripped it out here.)

See our long debugging thread on CZO:
  https://chat.zulip.org/#narrow/stream/48-mobile/topic/.40sentry.2Freact-native.20to.20latest/near/1643986
  • Loading branch information
chrisbobbe committed Sep 21, 2023
1 parent 73ff2c6 commit 19b0955
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 470 deletions.
16 changes: 9 additions & 7 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -436,14 +436,14 @@ PODS:
- RNScreens (3.25.0):
- React-Core
- React-RCTImage
- RNSentry (3.4.3):
- RNSentry (5.9.2):
- React-Core
- Sentry (= 7.11.0)
- Sentry/HybridSDK (= 8.11.0)
- RNVectorIcons (9.2.0):
- React-Core
- Sentry (7.11.0):
- Sentry/Core (= 7.11.0)
- Sentry/Core (7.11.0)
- Sentry/HybridSDK (8.11.0):
- SentryPrivate (= 8.11.0)
- SentryPrivate (8.11.0)
- SocketRocket (0.6.0)
- Toast (4.0.0)
- Yoga (1.14.0)
Expand Down Expand Up @@ -554,6 +554,7 @@ SPEC REPOS:
- libevent
- OpenSSL-Universal
- Sentry
- SentryPrivate
- SocketRocket
- Toast
- YogaKit
Expand Down Expand Up @@ -757,9 +758,10 @@ SPEC CHECKSUMS:
RNGestureHandler: c0d04458598fcb26052494ae23dda8f8f5162b13
RNReanimated: e7d8afaf8fed4b3bf1a46e06adb2e04a2b248f1c
RNScreens: 85d3880b52d34db7b8eeebe2f1a0e807c05e69fa
RNSentry: 85f6525b5fe8d2ada065858026b338605b3c09da
RNSentry: da8111ddd855157a9e21294153156b85ae5d6be4
RNVectorIcons: fcc2f6cb32f5735b586e66d14103a74ce6ad61f8
Sentry: 0c5cd63d714187b4a39c331c1f0eb04ba7868341
Sentry: 39d57e691e311bdb73bc1ab5bbebbd6bc890050d
SentryPrivate: 48712023cdfd523735c2edb6b06bedf26c4730a3
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
Yoga: 0bc4b37c3b8a345336ff601e2cf7d9704bab7e93
Expand Down
4 changes: 2 additions & 2 deletions ios/ZulipMobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [[ $USE_SENTRY != \"YES\" ]]; then\necho [Bundle React Native code and images] Skipping sentry\n../node_modules/react-native/scripts/react-native-xcode.sh\nelse\nexport SENTRY_PROPERTIES=sentry.properties\nexport NODE_BINARY=node\n../node_modules/@sentry/cli/bin/sentry-cli react-native xcode ../node_modules/react-native/scripts/react-native-xcode.sh\nfi\n";
shellScript = "if [[ $USE_SENTRY != \"YES\" ]]; then\necho [Bundle React Native code and images] Skipping sentry\n../node_modules/react-native/scripts/react-native-xcode.sh\nelse\nexport SENTRY_PROPERTIES=sentry.properties\nexport EXTRA_PACKAGER_ARGS=\"--sourcemap-output $DERIVED_FILE_DIR/main.jsbundle.map\"\nexport NODE_BINARY=node\n../node_modules/@sentry/cli/bin/sentry-cli react-native xcode ../node_modules/react-native/scripts/react-native-xcode.sh\nfi\n";
};
52F8B8FD88489D79CA92AA16 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
Expand Down Expand Up @@ -298,7 +298,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [[ $USE_SENTRY != \"YES\" ]]; then\necho [Upload Debug Symbols to Sentry] Skipping sentry\nelse\nexport SENTRY_PROPERTIES=sentry.properties\n../node_modules/@sentry/cli/bin/sentry-cli upload-dsym\nfi\n";
shellScript = "if [[ $USE_SENTRY != \"YES\" ]]; then\necho [Upload Debug Symbols to Sentry] Skipping sentry\nelse\nexport SENTRY_PROPERTIES=sentry.properties\n\n[[ $SENTRY_INCLUDE_NATIVE_SOURCES == \"true\" ]] && INCLUDE_SOURCES_FLAG=\"--include-sources\" || INCLUDE_SOURCES_FLAG=\"\"\nSENTRY_CLI=\"../node_modules/@sentry/cli/bin/sentry-cli\"\n$SENTRY_CLI debug-files upload \"$INCLUDE_SOURCES_FLAG\" \"$DWARF_DSYM_FOLDER_PATH\"\nfi\n";
};
8BC51697242D4EF80019892C /* Start Metro */ = {
isa = PBXShellScriptBuildPhase;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@react-navigation/material-top-tabs": "^5.2.19",
"@react-navigation/native": "^5.7.6",
"@react-navigation/stack": "npm:@zulip/react-navigation-stack@5.14.10-0.zulip.1",
"@sentry/react-native": "^3.1.1",
"@sentry/react-native": "^5.9.2",
"@zulip/shared": "0.0.18",
"base-64": "^1.0.0",
"blueimp-md5": "^2.10.0",
Expand Down
7 changes: 5 additions & 2 deletions src/__tests__/sentry-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// @flow
/*
* @flow strict-local
*/

// $FlowFixMe[untyped-import]
import * as Sentry from '@sentry/react-native';
import { isSentryActive } from '../sentry';

Expand All @@ -13,7 +16,7 @@ describe('sentry', () => {
expect(isSentryActive()).toBeFalse();
Sentry.addBreadcrumb({
message: 'test message',
level: Sentry.Severity.Debug,
level: 'debug',
});
expect(isSentryActive()).toBeFalse();
});
Expand Down
1 change: 1 addition & 0 deletions src/api/apiFetch.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* @flow strict-local */
// $FlowFixMe[untyped-import]
import * as Sentry from '@sentry/react-native';

import type { UrlParams } from '../utils/url';
Expand Down
1 change: 1 addition & 0 deletions src/events/eventActions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* @flow strict-local */
// $FlowFixMe[untyped-import]
import { addBreadcrumb } from '@sentry/react-native';
// $FlowFixMe[untyped-import]
import isEqual from 'lodash.isequal';
Expand Down
8 changes: 5 additions & 3 deletions src/sentry.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* @flow strict-local */
// $FlowFixMe[untyped-import]
import * as Sentry from '@sentry/react-native';
import type { Breadcrumb, BreadcrumbHint } from '@sentry/react-native';
import { nativeApplicationVersion } from 'expo-application';
// $FlowFixMe[untyped-import]
import md5 from 'blueimp-md5';
Expand All @@ -12,6 +12,10 @@ import { getIdentities } from './account/accountsSelectors';
import { sentryKey } from './sentryConfig';
import { isUrlOnRealm } from './utils/url';

// TODO import from @sentry/react-native libdef
type Breadcrumb = $FlowFixMe;
type BreadcrumbHint = $FlowFixMe;

export const isSentryActive = (): boolean => {
// Hub#getClient() is documented as possibly returning undefined, but the
// significance of `undefined` is not. In practice, it appears to be
Expand Down Expand Up @@ -122,8 +126,6 @@ function scrubUrl(unscrubbedUrl: void | string): void | string {
function scrubBreadcrumb(breadcrumb: Breadcrumb, hint?: BreadcrumbHint): Breadcrumb {
switch (breadcrumb.type) {
case 'http': {
// $FlowIgnore[incompatible-indexer] | We assume it's an
// $FlowIgnore[incompatible-type] | HttpBreadcrumb; see jsdoc.
const httpBreadcrumb: HttpBreadcrumb = breadcrumb;
return {
...httpBreadcrumb,
Expand Down
1 change: 1 addition & 0 deletions src/utils/internalLinks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* @flow strict-local */
// $FlowFixMe[untyped-import]
import { addBreadcrumb } from '@sentry/react-native';
import * as internal_url from '@zulip/shared/lib/internal_url';
import { makeUserId } from '../api/idTypes';
Expand Down
14 changes: 10 additions & 4 deletions src/utils/logging.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/* @flow strict-local */
import type { Scope, SeverityType } from '@sentry/react-native';
import {
// $FlowFixMe[untyped-import]
captureException,
// $FlowFixMe[untyped-import]
captureMessage,
// $FlowFixMe[untyped-import]
configureScope,
Severity,
// $FlowFixMe[untyped-import]
withScope as withScopeImpl,
} from '@sentry/react-native';

Expand All @@ -16,6 +18,10 @@ import config from '../config';
/** Type of "extras" intended for Sentry. */
export type Extras = {| +[key: string]: JSONable |};

// TODO import from @sentry/react-native libdef
type Scope = $FlowFixMe;
type SeverityType = $FlowFixMe;

/**
* `Error`, but subclass instances have the name of the subclass at `.name`
*
Expand Down Expand Up @@ -183,7 +189,7 @@ const makeLogFunction = ({ consoleMethod, severity }: LogParams): LogFunction =>
*/
export const error: (event: string | Error, extras?: Extras) => void = makeLogFunction({
consoleMethod: console.error,
severity: Severity.Error,
severity: 'error',
});

/**
Expand All @@ -208,7 +214,7 @@ export const error: (event: string | Error, extras?: Extras) => void = makeLogFu
*/
export const warn: (event: string | Error, extras?: Extras) => void = makeLogFunction({
consoleMethod: console.warn,
severity: Severity.Warning,
severity: 'warning',
});

/**
Expand Down

0 comments on commit 19b0955

Please sign in to comment.