Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle null Constants.expoConfig and Constants.expoGoConfig #145

Merged
merged 3 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/expo/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const stringWithLength = require('@bugsnag/core/lib/validators/string-with-lengt
// If the developer property is not present it means the app is
// not connected to a development tool and is either a published app running in
// the Expo client, or a standalone app
const IS_PRODUCTION = !Constants.expoConfig.developer && !Constants.expoGoConfig.developer
const IS_PRODUCTION = !Constants.expoConfig?.developer && !Constants.expoGoConfig?.developer

// The app can still run in production "mode" in development environments, in which
// cases the global boolean __DEV__ will be set to true
Expand Down
6 changes: 3 additions & 3 deletions packages/expo/src/notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const internalPlugins = [
require('@bugsnag/plugin-expo-device'),
require('@bugsnag/plugin-expo-app'),
require('@bugsnag/plugin-console-breadcrumbs'),
require('@bugsnag/plugin-network-breadcrumbs')([NET_INFO_REACHABILITY_URL, Constants.expoConfig.logUrl || Constants.expoGoConfig?.logUrl]),
require('@bugsnag/plugin-network-breadcrumbs')([NET_INFO_REACHABILITY_URL, Constants.expoConfig?.logUrl || Constants.expoGoConfig?.logUrl]),
require('@bugsnag/plugin-expo-app-state-breadcrumbs'),
require('@bugsnag/plugin-expo-connectivity-breadcrumbs'),
require('@bugsnag/plugin-react-native-orientation-breadcrumbs'),
Expand All @@ -45,12 +45,12 @@ const Bugsnag = {

// read the api key from app.json if one is not explicitly passed
if (!opts.apiKey) {
opts.apiKey = Constants.expoConfig.extra?.bugsnag?.apiKey
opts.apiKey = Constants.expoConfig?.extra?.bugsnag?.apiKey
}

// read the version from app.json if one is not explicitly passed
if (!opts.appVersion) {
opts.appVersion = Constants.expoConfig.version
opts.appVersion = Constants.expoConfig?.version
}

const bugsnag = new Client(opts, schema, internalPlugins, { name, version, url })
Expand Down
12 changes: 6 additions & 6 deletions packages/expo/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ jest.mock('expo-constants', () => ({
default: {
platform: {},
expoConfig: {},
expoGoConfig: {}
expoGoConfig: null
}
}))

jest.mock('../../plugin-expo-device/node_modules/expo-constants', () => ({
default: {
platform: {},
expoConfig: {},
expoGoConfig: {}
expoGoConfig: null
}
}))

Expand All @@ -22,7 +22,7 @@ jest.mock('../../plugin-expo-app/node_modules/expo-constants', () => ({
default: {
platform: {},
expoConfig: {},
expoGoConfig: {}
expoGoConfig: null
}
}))

Expand Down Expand Up @@ -244,7 +244,7 @@ describe('expo notifier', () => {
default: {
platform: {},
expoConfig: {},
expoGoConfig: {}
expoGoConfig: null
}
}))

Expand All @@ -256,7 +256,7 @@ describe('expo notifier', () => {
jest.mock('expo-constants', () => ({
default: {
platform: {},
expoConfig: {},
expoConfig: null,
expoGoConfig: {
developer: {
tool: 'expo-cli'
Expand All @@ -279,7 +279,7 @@ describe('expo notifier', () => {
tool: 'expo-cli'
}
},
expoGoConfig: {}
expoGoConfig: null
}
}))

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-expo-device/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = {
runtimeVersions: {
reactNative: rnVersion,
expoApp: Constants.expoVersion,
expoSdk: Constants.expoConfig.sdkVersion,
expoSdk: Constants.expoConfig?.sdkVersion,
androidApiLevel: Constants.platform.android ? String(Platform.Version) : undefined
},
totalMemory: Device.totalMemory
Expand Down
Loading