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

[Flask] bitrise pipelines #6645

Merged
merged 39 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
99710ef
basic pipeline scaffold
owencraston Jun 20, 2023
f621274
flask release ios
owencraston Jun 20, 2023
95fda8a
android release scripts
owencraston Jun 20, 2023
018ff06
check for sentry props on flask build
owencraston Jun 20, 2023
3e0e16e
bitrise certificate
owencraston Jun 20, 2023
cd861a8
debug/release provisioning profiles
owencraston Jun 20, 2023
9b02f37
basic build steps
owencraston Jun 20, 2023
47b75d2
flask pipelines
owencraston Jun 20, 2023
50a3475
fix yaml
owencraston Jun 20, 2023
5247447
remap flask variables
owencraston Jun 20, 2023
5924596
remove pubnub keys
owencraston Jun 20, 2023
7b275c4
add deploy pipelines
owencraston Jun 21, 2023
56f03d4
fix file paths and undo edits to qa build
owencraston Jun 21, 2023
69ccfe9
new flask release pipelines
owencraston Jun 21, 2023
061b507
update set-versions script and try to fix sourcemaps for flask
owencraston Jun 21, 2023
df55ec1
try a different sourcemp filepath
owencraston Jun 21, 2023
e82ff36
upgrade ruby version
owencraston Jun 22, 2023
5727bc3
update signing
owencraston Jun 23, 2023
2acb01b
set env to flask
owencraston Jun 23, 2023
5ca20dd
square icons
owencraston Jun 28, 2023
5b6d2d8
manually remove icon alpha
owencraston Jun 28, 2023
48b71e8
add archive path var
owencraston Jun 28, 2023
575e326
introduce build types in build pipeline
owencraston Jun 28, 2023
2191e4c
remove echo
owencraston Jun 28, 2023
17b6758
pass params to derive sentry environment and tests
owencraston Jun 29, 2023
2a71962
new build numbers
owencraston Jul 11, 2023
37aeb8a
fix: update cookie-tough dependency (#6772)
tommasini Jul 11, 2023
80aa292
move versions into product flavours
owencraston Jul 12, 2023
78c4a01
test prod build with flask variables
owencraston Jul 13, 2023
da12ce0
cleanup deriveSentryEnvironment function
owencraston Jul 13, 2023
fe3069e
cleanup comment
owencraston Jul 13, 2023
f79aab3
reset build numbers
owencraston Jul 13, 2023
9490d89
enable deploy to android and pass in env variable
owencraston Jul 13, 2023
38d2dc6
new syntax
owencraston Jul 13, 2023
1da8ac1
is expand true
owencraston Jul 13, 2023
6dfcce6
no android pipeline
owencraston Jul 13, 2023
cbd72aa
new syntax
owencraston Jul 13, 2023
889d066
new new syntax
owencraston Jul 13, 2023
285b28c
new new new syntax
owencraston Jul 13, 2023
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 app/components/Nav/App/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import branch from 'react-native-branch';
import AppConstants from '../../../core/AppConstants';
import Logger from '../../../util/Logger';
import { trackErrorAsAnalytics } from '../../../util/analyticsV2';
import { routingInstrumentation } from '../../../util/sentryUtils';
import { routingInstrumentation } from '../../../util/sentry/sentryUtils';
import Analytics from '../../../core/Analytics/Analytics';
import { connect, useSelector, useDispatch } from 'react-redux';
import {
Expand Down
56 changes: 43 additions & 13 deletions app/util/sentryUtils.js → app/util/sentry/sentryUtils.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* eslint-disable import/no-namespace */
import * as Sentry from '@sentry/react-native';
import { Dedupe, ExtraErrorData } from '@sentry/integrations';
import extractEthJsErrorMessage from './extractEthJsErrorMessage';
import extractEthJsErrorMessage from '../extractEthJsErrorMessage';
import DefaultPreference from 'react-native-default-preference';
import { AGREED, METRICS_OPT_IN } from '../constants/storage';
import { AGREED, METRICS_OPT_IN } from '../../constants/storage';

const METAMASK_ENVIRONMENT = process.env['METAMASK_ENVIRONMENT'] || 'local'; // eslint-disable-line dot-notation
const METAMASK_BUILD_TYPE = process.env.METAMASK_BUILD_TYPE || 'main';
const METAMASK_BUILD_TYPE = process.env['METAMASK_BUILD_TYPE'] || 'main'; // eslint-disable-line dot-notation

const ERROR_URL_ALLOWLIST = [
'cryptocompare.com',
Expand Down Expand Up @@ -150,24 +150,54 @@ function sanitizeAddressesFromErrorMessages(report) {
});
}

/**
* Derives the Sentry environment based on input parameters.
* This function is similar to the environment logic used in MetaMask extension.
* - https://github.com/MetaMask/metamask-extension/blob/34375a57e558853aab95fe35d5f278aa52b66636/app/scripts/lib/setupSentry.js#L91
*
* @param {boolean} isDev - Represents if the current environment is development (__DEV__ global variable).
* @param {string} [metamaskEnvironment='local'] - The environment MetaMask is running in
* (process.env.METAMASK_ENVIRONMENT).
* It defaults to 'local' if not provided.
* @param {string} [metamaskBuildType='main'] - The build type of MetaMask
* (process.env.METAMASK_BUILD_TYPE).
* It defaults to 'main' if not provided.
*
* @returns {string} - The Sentry environment. Possible values are 'development', 'local',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: it might be better to include less specifics here, so we don't have to update it each time we add a new environment

* 'production', or a string in the format `${metamaskEnvironment}-${metamaskBuildType}`.
* 'development' is returned if 'isDev' is true or 'metamaskEnvironment' is not provided.
* 'metamaskEnvironment' is returned if 'metamaskBuildType' is 'main' or undefined.
* `${metamaskEnvironment}-${metamaskBuildType}` is returned for other cases,
* for example 'production-flask' or 'debug-flask'.
*/
export function deriveSentryEnvironment(
isDev,
metamaskEnvironment = 'local',
metamaskBuildType = 'main',
) {
const environment =
Copy link
Member

@Gudahtt Gudahtt Jul 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Thoughts on splitting this up onto multiple statements? The standard metamask ESLint config (not yet used here) disallows nested ternaries. They're a bit hard to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have broken it up into multiple return statements in my latest commit.

isDev || !metamaskEnvironment
? 'development'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include the build type even for development builds? Seems like it could be useful

: metamaskBuildType === 'main'
? metamaskEnvironment
: `${metamaskEnvironment}-${metamaskBuildType}`;

return environment;
}

// Setup sentry remote error reporting
export function setupSentry() {
const init = async () => {
const dsn = process.env.MM_SENTRY_DSN;

/* Similar to the environment logic we use on extension:
- https://github.com/MetaMask/metamask-extension/blob/34375a57e558853aab95fe35d5f278aa52b66636/app/scripts/lib/setupSentry.js#L91
*/
const environment =
__DEV__ || !METAMASK_ENVIRONMENT
? 'development'
: METAMASK_BUILD_TYPE === 'main'
? METAMASK_ENVIRONMENT
: `${METAMASK_ENVIRONMENT}-${METAMASK_BUILD_TYPE}`;

const metricsOptIn = await DefaultPreference.get(METRICS_OPT_IN);

const integrations = [new Dedupe(), new ExtraErrorData()];
const environment = deriveSentryEnvironment(
__DEV__,
METAMASK_ENVIRONMENT,
METAMASK_BUILD_TYPE,
);

Sentry.init({
dsn,
Expand Down
68 changes: 68 additions & 0 deletions app/util/sentry/sentryUtils.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* eslint-disable dot-notation */
import { deriveSentryEnvironment } from './sentryUtils';

describe('deriveSentryEnvironment', () => {
test('should return production-flask for environment if __DEV__ is false, METAMASK_ENVIRONMENT is production, and METAMASK_BUILD_TYPE is flask', async () => {
const METAMASK_ENVIRONMENT = 'production';
const METAMASK_BUILD_TYPE = 'flask';
const isDev = false;

const env = deriveSentryEnvironment(
isDev,
METAMASK_ENVIRONMENT,
METAMASK_BUILD_TYPE,
);
expect(env).toBe('production-flask');
});

test('should return local-flask for environment if __DEV__ is false, METAMASK_ENVIRONMENT is undefined, and METAMASK_BUILD_TYPE is flask', async () => {
const METAMASK_BUILD_TYPE = 'flask';
const isDev = false;

const env = deriveSentryEnvironment(isDev, undefined, METAMASK_BUILD_TYPE);
expect(env).toBe('local-flask');
});

test('should return debug-flask for environment if __DEV__ is false, METAMASK_ENVIRONMENT is debug, and METAMASK_BUILD_TYPE is flask', async () => {
const METAMASK_BUILD_TYPE = 'flask';
const METAMASK_ENVIRONMENT = 'debug';
const isDev = false;

const env = deriveSentryEnvironment(
isDev,
METAMASK_ENVIRONMENT,
METAMASK_BUILD_TYPE,
);
expect(env).toBe('debug-flask');
});

test('should return local for environment if __DEV__ is false, METAMASK_ENVIRONMENT is local, and METAMASK_BUILD_TYPE is undefined', async () => {
const isDev = false;
const METAMASK_ENVIRONMENT = 'local';

const env = deriveSentryEnvironment(isDev, METAMASK_ENVIRONMENT);
expect(env).toBe('local');
});

test('should return local for environment if __DEV__ is false, and both METAMASK_ENVIRONMENT and METAMASK_BUILD_TYPE are undefined', async () => {
const isDev = false;

const env = deriveSentryEnvironment(isDev);
expect(env).toBe('local');
});

test('should return production for environment if __DEV__ is false, METAMASK_ENVIRONMENT is production, and METAMASK_BUILD_TYPE is undefined', async () => {
const METAMASK_ENVIRONMENT = 'production';
const isDev = false;

const env = deriveSentryEnvironment(isDev, METAMASK_ENVIRONMENT, undefined);
expect(env).toBe('production');
});

test('should return development for environment if __DEV__ is true', async () => {
const isDev = true;

const env = deriveSentryEnvironment(isDev, '', '');
expect(env).toBe('development');
});
});
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import crypto from 'crypto'; // eslint-disable-line import/no-nodejs-modules, no
require('react-native-browser-polyfill'); // eslint-disable-line import/no-commonjs

import * as Sentry from '@sentry/react-native'; // eslint-disable-line import/no-namespace
import { setupSentry } from './app/util/sentryUtils';
import { setupSentry } from './app/util/sentry/sentryUtils';
setupSentry();

import { AppRegistry, LogBox } from 'react-native';
Expand Down