Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
7 changes: 7 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

### Fixes

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

## 6.15.0

### Features
Expand Down Expand Up @@ -45,6 +51,7 @@
- Fixes Feedback Widget accessibility issue on iOS ([#4739](https://github.com/getsentry/sentry-react-native/pull/4739))
- Measuring TTID or TTFD could cause a crash when `parentSpanId` was removed ([#4881](https://github.com/getsentry/sentry-react-native/pull/4881))


### Dependencies

- Bump Bundler Plugins from v3.4.0 to v3.5.0 ([#4850](https://github.com/getsentry/sentry-react-native/pull/4850))
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 @@ -5,7 +5,7 @@ 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 @@ -308,8 +308,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,7 +1,7 @@
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 @@ -35,8 +35,8 @@ export function isExpo(): boolean {

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

/** Check Expo Go version if available */
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/js/utils/expoglobalobject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* https://github.com/expo/expo/blob/b51b5139f2caa2a9495e4132437d7ca612276158/packages/expo-manifests/src/Manifests.ts
*/
export interface ExpoConstants {
/** @deprecated use [Constants.executionEnvironment](https://docs.expo.dev/versions/latest/sdk/constants/#executionenvironment) instead */
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 +66,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