From 6d73ed96e1d6bccfa60113727571411f06a2b172 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 8 Sep 2023 16:47:01 +0100 Subject: [PATCH] Make Sentry optional (#1416) * Move app.json -> app.config.js * Make Sentry optional --- app.config.js | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++ app.json | 109 ----------------------------------------------- docs/build.md | 16 +++---- 3 files changed, 122 insertions(+), 117 deletions(-) create mode 100644 app.config.js delete mode 100644 app.json diff --git a/app.config.js b/app.config.js new file mode 100644 index 00000000..4e519381 --- /dev/null +++ b/app.config.js @@ -0,0 +1,114 @@ +module.exports = function () { + const hasSentryToken = !!process.env.SENTRY_AUTH_TOKEN + return { + expo: { + name: 'Bluesky', + slug: 'bluesky', + scheme: 'bluesky', + owner: 'blueskysocial', + version: '1.49.0', + runtimeVersion: { + policy: 'appVersion', + }, + orientation: 'portrait', + icon: './assets/icon.png', + userInterfaceStyle: 'automatic', + splash: { + image: './assets/cloud-splash.png', + resizeMode: 'cover', + backgroundColor: '#ffffff', + }, + ios: { + buildNumber: '1', + supportsTablet: false, + bundleIdentifier: 'xyz.blueskyweb.app', + config: { + usesNonExemptEncryption: false, + }, + infoPlist: { + UIBackgroundModes: ['remote-notification'], + NSCameraUsageDescription: + 'Used for profile pictures, posts, and other kinds of content.', + NSMicrophoneUsageDescription: + 'Used for posts and other kinds of content.', + NSPhotoLibraryAddUsageDescription: + 'Used to save images to your library.', + NSPhotoLibraryUsageDescription: + 'Used for profile pictures, posts, and other kinds of content', + }, + associatedDomains: ['applinks:bsky.app', 'applinks:staging.bsky.app'], + }, + androidStatusBar: { + barStyle: 'dark-content', + backgroundColor: '#ffffff', + }, + android: { + versionCode: 36, + adaptiveIcon: { + foregroundImage: './assets/adaptive-icon.png', + backgroundColor: '#ffffff', + }, + googleServicesFile: './google-services.json', + package: 'xyz.blueskyweb.app', + intentFilters: [ + { + action: 'VIEW', + autoVerify: true, + data: [ + { + scheme: 'https', + host: 'bsky.app', + }, + ], + category: ['BROWSABLE', 'DEFAULT'], + }, + ], + }, + web: { + favicon: './assets/favicon.png', + }, + updates: { + enabled: true, + fallbackToCacheTimeout: 1000, + url: 'https://u.expo.dev/55bd077a-d905-4184-9c7f-94789ba0f302', + }, + plugins: [ + 'expo-localization', + hasSentryToken && 'sentry-expo', + [ + 'expo-build-properties', + { + android: { + compileSdkVersion: 34, + targetSdkVersion: 34, + buildToolsVersion: '34.0.0', + kotlinVersion: '1.8.0', + }, + }, + ], + [ + 'expo-updates', + { + username: 'blueskysocial', + }, + ], + ].filter(Boolean), + extra: { + eas: { + projectId: '55bd077a-d905-4184-9c7f-94789ba0f302', + }, + }, + hooks: { + postPublish: [ + { + file: 'sentry-expo/upload-sourcemaps', + config: { + organization: 'blueskyweb', + project: 'react-native', + }, + }, + ], + }, + }, + } +} diff --git a/app.json b/app.json deleted file mode 100644 index 9acc7120..00000000 --- a/app.json +++ /dev/null @@ -1,109 +0,0 @@ -{ - "expo": { - "name": "Bluesky", - "slug": "bluesky", - "scheme": "bluesky", - "owner": "blueskysocial", - "version": "1.49.0", - "runtimeVersion": { - "policy": "appVersion" - }, - "orientation": "portrait", - "icon": "./assets/icon.png", - "userInterfaceStyle": "automatic", - "splash": { - "image": "./assets/cloud-splash.png", - "resizeMode": "cover", - "backgroundColor": "#ffffff" - }, - "ios": { - "buildNumber": "1", - "supportsTablet": false, - "bundleIdentifier": "xyz.blueskyweb.app", - "config": { - "usesNonExemptEncryption": false - }, - "infoPlist": { - "UIBackgroundModes": [ - "remote-notification" - ], - "NSCameraUsageDescription": "Used for profile pictures, posts, and other kinds of content.", - "NSMicrophoneUsageDescription": "Used for posts and other kinds of content.", - "NSPhotoLibraryAddUsageDescription": "Used to save images to your library.", - "NSPhotoLibraryUsageDescription": "Used for profile pictures, posts, and other kinds of content" - }, - "associatedDomains": ["applinks:bsky.app", "applinks:staging.bsky.app"] - }, - "androidStatusBar": { - "barStyle": "dark-content", - "backgroundColor": "#ffffff" - }, - "android": { - "versionCode": 36, - "adaptiveIcon": { - "foregroundImage": "./assets/adaptive-icon.png", - "backgroundColor": "#ffffff" - }, - "googleServicesFile": "./google-services.json", - "package": "xyz.blueskyweb.app", - "intentFilters": [ - { - "action": "VIEW", - "autoVerify": true, - "data": [ - { - "scheme": "https", - "host": "bsky.app" - } - ], - "category": ["BROWSABLE", "DEFAULT"] - } - ] - }, - "web": { - "favicon": "./assets/favicon.png" - }, - "updates": { - "enabled": true, - "fallbackToCacheTimeout": 1000, - "url": "https://u.expo.dev/55bd077a-d905-4184-9c7f-94789ba0f302" - }, - "plugins": [ - "expo-localization", - "sentry-expo", - [ - "expo-build-properties", - { - "android": { - "compileSdkVersion": 34, - "targetSdkVersion": 34, - "buildToolsVersion": "34.0.0", - "kotlinVersion": "1.8.0" - } - } - ], - [ - "expo-updates", - { - "username": "blueskysocial" - } - ] - ], - "extra": { - "eas": { - "projectId": "55bd077a-d905-4184-9c7f-94789ba0f302" - } - }, - "hooks": { - "postPublish": [ - { - "file": "sentry-expo/upload-sourcemaps", - "config": { - "organization": "blueskyweb", - "project": "react-native" - } - } - ] - } - } -} diff --git a/docs/build.md b/docs/build.md index 73ffde7b..c76f7c3e 100644 --- a/docs/build.md +++ b/docs/build.md @@ -26,20 +26,20 @@ - Run once: `yarn e2e:build` - Each test run: `yarn e2e:run` - Tips - - Make sure you copy the `.env.example` to `.env` and add the appropriate tokens (e.g. `SENTRY_AUTH_TOKEN` can be created on the Sentry dashboard using [these instructions](https://docs.expo.dev/guides/using-sentry/#sign-up-for-a-sentry-account-and-create-a-project)). If this is not required, you can remove it from `eas.json` and `package.json`, as well as any mentions in the code. Please check the section below on how to remove Sentry from the codebase + - Make sure to copy the `.env.example` to `.env` and fill in any necessary tokens. (The Sentry token is NOT required; see instructions below if you want to enable Sentry.) - If you want to use Expo EAS on your own builds without ejecting from Expo, make sure to change the `owner` as well as `extra.eas.projectId` properties. If you do not have an Expo account, you may remove these properties. - `npx react-native info` Checks what has been installed. - The android simulator won't be able to access localhost services unless you run `adb reverse tcp:{PORT} tcp:{PORT}` - For instance, the locally-hosted dev-wallet will need `adb reverse tcp:3001 tcp:3001` - For some reason, the typescript compiler chokes on platform-specific files (e.g. `foo.native.ts`) but only when compiling for Web thus far. Therefore we always have one version of the file which doesn't use a platform specifier, and that should be the Web version. ([More info](https://stackoverflow.com/questions/44001050/platform-specific-import-component-in-react-native-with-typescript).) -### Removing Sentry -If you are part of the Bluesky team, you should have access to our Sentry dashboard, and you shouldn't need to remove Sentry. Even if you are not part of the Bluesky team, you can create your own Sentry account and add the `SENTRY_AUTH_TOKEN` env var and add your sentry account detials to `app.json` to make the app build and run successfully. However, if that is not possible, follow these steps to remove Sentry from the project (please don't commit this code in any PR): -- `yarn remove sentry-expo @sentry/react-native` -- Remove `sentry-expo` plugin in `app.json` and also remove the `postPublish` hook in `app.json` -- Remove any mentions of `sentry` from the `App.native.tsx`, `App.web.tsx` and `Navigation.tsx` files. Also, delete `sentry.ts` -- Run `rm -rf ios android` or delete the existing `android` and `ios` folders in the project (don't worry! `yarn prebuild` gets these back) -- Run `yarn prebuild` and `yarn ios` and build the app! +### Adding Sentry + +Adding Sentry is NOT required. You can keep `SENTRY_AUTH_TOKEN=` in `.env` which will build the app without Sentry. + +However, if you're a part of the Bluesky team and want to enable Sentry, fill in `SENTRY_AUTH_TOKEN` in your `.env`. It can be created on the Sentry dashboard using [these instructions](https://docs.expo.dev/guides/using-sentry/#sign-up-for-a-sentry-account-and-create-a-project). + +If you change `SENTRY_AUTH_TOKEN`, you need to do `yarn prebuild` before running `yarn ios` or `yarn android` again. ## Go-Server Build