Skip to content

Commit c937344

Browse files
committed
Use 'manifest2' when 'manifest' does not exist
When using EAS Update, 'manifest' will be null and 'manifest2' is defined instead
1 parent 2f0c766 commit c937344

File tree

4 files changed

+30
-14
lines changed

4 files changed

+30
-14
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
### TBD
44

5+
### Fixed
6+
7+
- (expo): preliminary support for the Expo EAS Update. Please send us feedback on how we can improve our support! [kennethlynne](https://github.com/kennethlynne) [#1686](https://github.com/bugsnag/bugsnag-js/pull/1686) [#1695](https://github.com/bugsnag/bugsnag-js/pull/1695)
8+
59
### Changed
610

711
- (plugin-react-navigation): Allow React Navigation v6 as a peer dependency [#1691](https://github.com/bugsnag/bugsnag-js/pull/1691)

packages/expo/src/config.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@ const Constants = require('expo-constants').default
55

66
// If the developer property is not present in the manifest, it means the app is
77
// not connected to a development tool and is either a published app running in
8-
// the Expo client, or a standalone app (we also assume production for a missing
9-
// manifest, but that should never happen)
10-
const IS_PRODUCTION = !Constants.manifest || !Constants.manifest.developer
8+
// the Expo client, or a standalone app
9+
let IS_PRODUCTION = true
10+
11+
if (Constants.manifest) {
12+
IS_PRODUCTION = !Constants.manifest.developer
13+
} else if (Constants.manifest2) {
14+
IS_PRODUCTION = !Constants.manifest2?.extra?.expoGo?.developer
15+
}
1116

1217
// The app can still run in production "mode" in development environments, in which
1318
// cases the global boolean __DEV__ will be set to true

packages/expo/src/notifier.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,22 @@ const Bugsnag = {
4343
if (typeof opts === 'string') opts = { apiKey: opts }
4444
if (!opts) opts = {}
4545

46-
// attempt to fetch apiKey from app.json if we didn't get one explicitly passed
47-
if (!opts.apiKey &&
48-
Constants.manifest &&
49-
Constants.manifest.extra &&
50-
Constants.manifest.extra.bugsnag &&
51-
Constants.manifest.extra.bugsnag.apiKey) {
52-
opts.apiKey = Constants.manifest.extra.bugsnag.apiKey
46+
// read the api key from app.json if one is not explicitly passed
47+
if (!opts.apiKey) {
48+
if (Constants.manifest?.extra?.bugsnag?.apiKey) {
49+
opts.apiKey = Constants.manifest.extra.bugsnag.apiKey
50+
} else if (Constants.manifest2?.extra?.expoClient?.extra?.bugsnag?.apiKey) {
51+
opts.apiKey = Constants.manifest2.extra.expoClient.extra.bugsnag.apiKey
52+
}
5353
}
5454

55-
if (!opts.appVersion && Constants.manifest && Constants.manifest.version) {
56-
opts.appVersion = Constants.manifest.version
55+
// read the version from app.json if one is not explicitly passed
56+
if (!opts.appVersion) {
57+
if (Constants.manifest?.version) {
58+
opts.appVersion = Constants.manifest.version
59+
} else if (Constants.manifest2?.extra?.expoClient?.version) {
60+
opts.appVersion = Constants.manifest2.extra.expoClient.version
61+
}
5762
}
5863

5964
const bugsnag = new Client(opts, schema, internalPlugins, { name, version, url })

packages/plugin-expo-app/app.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = {
2929
}
3030

3131
client.addOnSession(session => {
32-
if (Constants.manifest.revisionId) {
32+
if (Constants.manifest?.revisionId) {
3333
session.app.codeBundleId = Constants.manifest.revisionId
3434
} else if (Constants.manifest2?.extra?.expoClient?.revisionId) {
3535
session.app.codeBundleId = Constants.manifest2.extra.expoClient.revisionId
@@ -49,8 +49,10 @@ module.exports = {
4949

5050
event.addMetadata('app', { nativeBundleVersion, nativeVersionCode })
5151

52-
if (Constants.manifest.revisionId) {
52+
if (Constants.manifest?.revisionId) {
5353
event.app.codeBundleId = Constants.manifest.revisionId
54+
} else if (Constants.manifest2?.extra?.expoClient?.revisionId) {
55+
event.app.codeBundleId = Constants.manifest2.extra.expoClient.revisionId
5456
}
5557
}, true)
5658
}

0 commit comments

Comments
 (0)