Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
> make sure you follow our [migration guide](https://docs.sentry.io/platforms/react-native/migration/) first.
<!-- prettier-ignore-end -->

## Unreleased

### Changes

- Remove deprecated `appOwnership` constant use in Expo Go detection ([#4893](https://github.com/getsentry/sentry-react-native/pull/4893))

## 7.0.0-beta.0

### Upgrading from 6.x to 7.0
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/js/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Profiler } from '@sentry/react';
import type * as React from 'react';
import { Platform } from 'react-native';
import type { TouchEventBoundaryProps } from './touchevents';
import { getExpoConstants } from './utils/expomodules';
import { isExpoGo } from './utils/environment';

type ProfilerProps = React.ComponentProps<typeof Profiler>;
type BrowserTransportOptions = Parameters<typeof makeFetchTransport>[0];
Expand Down Expand Up @@ -315,8 +315,7 @@ export function shouldEnableNativeNagger(userOptions: unknown): boolean {
return false;
}

const expoConstants = getExpoConstants();
if (expoConstants && expoConstants.appOwnership === 'expo') {
if (isExpoGo()) {
// If the app is running in Expo Go, we don't want to nag
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/js/utils/environment.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Platform } from 'react-native';
import { RN_GLOBAL_OBJ } from '../utils/worldwide';
import { getExpoConstants } from './expomodules';
import { getExpoConstants, getExpoGo } from './expomodules';
import { ReactNativeLibraries } from './rnlibraries';

/** Checks if the React Native Hermes engine is running */
Expand Down Expand Up @@ -34,8 +34,8 @@ export function isExpo(): boolean {

/** Check if JS runs in Expo Go */
export function isExpoGo(): boolean {
const expoConstants = getExpoConstants();
return expoConstants?.appOwnership === 'expo';
const expoGo = getExpoGo();
return !!expoGo;
}

/** Check Expo Go version if available */
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/js/utils/expoglobalobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* https://github.com/expo/expo/blob/b51b5139f2caa2a9495e4132437d7ca612276158/packages/expo-manifests/src/Manifests.ts
*/
export interface ExpoConstants {
appOwnership?: 'standalone' | 'expo' | 'guest';
/**
* Deprecated. But until removed we can use it as user ID to match the native SDKs.
*/
Expand Down Expand Up @@ -65,10 +64,13 @@ export interface ExpoUpdates {
createdAt?: Date | null;
}

export type ExpoGo = unknown;

export interface ExpoGlobalObject {
modules?: {
ExponentConstants?: ExpoConstants;
ExpoDevice?: ExpoDevice;
ExpoUpdates?: ExpoUpdates;
ExpoGo?: ExpoGo;
};
}
9 changes: 8 additions & 1 deletion packages/core/src/js/utils/expomodules.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ExpoConstants, ExpoDevice, ExpoUpdates } from './expoglobalobject';
import type { ExpoConstants, ExpoDevice, ExpoGo, ExpoUpdates } from './expoglobalobject';
import { RN_GLOBAL_OBJ } from './worldwide';

/**
Expand All @@ -21,3 +21,10 @@ export function getExpoDevice(): ExpoDevice | undefined {
export function getExpoUpdates(): ExpoUpdates | undefined {
return RN_GLOBAL_OBJ.expo?.modules?.ExpoUpdates ?? undefined;
}

/**
* Returns the Expo Go module if present
*/
export function getExpoGo(): ExpoGo | undefined {
return RN_GLOBAL_OBJ.expo?.modules?.ExpoGo ?? undefined;
}
7 changes: 2 additions & 5 deletions samples/expo/app/(tabs)/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Button, StyleSheet } from 'react-native';
import Constants from 'expo-constants';
import * as Sentry from '@sentry/react-native';
import { reloadAppAsync } from 'expo';
import { reloadAppAsync, isRunningInExpoGo } from 'expo';
import * as DevClient from 'expo-dev-client';

import { Text, View } from '@/components/Themed';
Expand All @@ -11,8 +10,6 @@ import * as WebBrowser from 'expo-web-browser';
import { useUpdates } from 'expo-updates';
import { isWeb } from '../../utils/isWeb';

const isRunningInExpoGo = Constants.appOwnership === 'expo';

export default function TabOneScreen() {
const { currentlyRunning } = useUpdates();
return (
Expand Down Expand Up @@ -65,7 +62,7 @@ export default function TabOneScreen() {
<Button
title="Native Crash"
onPress={() => {
if (isRunningInExpoGo) {
if (isRunningInExpoGo()) {
console.warn('Not supported in Expo Go. Build the application to test this feature.');
return;
}
Expand Down
Loading