Skip to content

Commit b5854b8

Browse files
feat(wallet/wallet-dashboard/explorer): Build env for growthbook, amplitude & sentry (#5216)
* feat(wallet/wallet-dashboard/explorer): Staging env for growthbook * fmt * rename WALLET_RC to IS_RC * add BUILD_ENV to turbo.json * feat: enable account finder in production * fix: Use `BUILD_ENV` instead of `NODE_ENV` * fix(explorer): Use `BUILD_ENV` instead of `import.meta.env.PROD` * fmt, ignore * `VITE_BUILD_ENV` * Use `NEXT_PUBLIC_BUILD_ENV` in dashboard amplitude and sentry * update env example * hook NEXT_PUBLIC_BUILD_ENV * revert enabling account finder in prod features * use staging build env in rc builds of the wallet * chore: disable production feature flags * fmt --------- Co-authored-by: Begoña Alvarez <[email protected]>
1 parent 582eb7a commit b5854b8

File tree

17 files changed

+96
-54
lines changed

17 files changed

+96
-54
lines changed

apps/apps-backend/src/features/features.controller.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { Network } from '@iota/iota-sdk/client';
77

88
@Controller('/api/features')
99
export class FeaturesController {
10-
@Get('/development')
11-
getDevelopmentFeatures() {
10+
@Get('/staging')
11+
getStagingFeatures() {
1212
return {
1313
status: 200,
1414
features: {
@@ -153,10 +153,10 @@ export class FeaturesController {
153153
defaultValue: false,
154154
},
155155
[Feature.StardustMigration]: {
156-
defaultValue: true,
156+
defaultValue: false,
157157
},
158158
[Feature.SupplyIncreaseVesting]: {
159-
defaultValue: true,
159+
defaultValue: false,
160160
},
161161
[Feature.BurntAndMintedTokensInEndedEpochs]: {
162162
defaultValue: {

apps/explorer/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
VITE_SENTRY_SAMPLE_RATE=xxxxxxx
2+
VITE_BUILD_ENV='development'

apps/explorer/src/lib/utils/analytics/amplitude.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { PersistableStorage } from '@iota/core';
88

99
import { ampli } from './ampli';
1010

11-
const IS_PROD_ENV = import.meta.env.PROD;
11+
const IS_PROD_ENV = import.meta.env.VITE_BUILD_ENV === 'production';
1212

1313
export const persistableStorage = new PersistableStorage<UserSession>();
1414

apps/explorer/src/lib/utils/growthbook.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,26 @@
55
import { GrowthBook } from '@growthbook/growthbook';
66
import { getAppsBackend } from '@iota/iota-sdk/client';
77

8+
const GROWTHBOOK_ENVIRONMENTS = {
9+
production: {
10+
clientKey: 'production',
11+
enableDevMode: false,
12+
},
13+
staging: {
14+
clientKey: 'staging',
15+
enableDevMode: false,
16+
},
17+
development: {
18+
clientKey: 'staging',
19+
enableDevMode: true,
20+
},
21+
};
22+
23+
const environment =
24+
(import.meta.env.VITE_BUILD_ENV as keyof typeof GROWTHBOOK_ENVIRONMENTS) || 'development';
25+
826
export const growthbook = new GrowthBook({
927
// If you want to develop locally, you can set the API host to this:
1028
apiHost: getAppsBackend(),
11-
clientKey: import.meta.env.PROD ? 'production' : 'development',
12-
enableDevMode: import.meta.env.DEV,
29+
...GROWTHBOOK_ENVIRONMENTS[environment],
1330
});

apps/explorer/src/lib/utils/sentry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import {
1111
useNavigationType,
1212
} from 'react-router-dom';
1313

14-
const SENTRY_ENABLED = import.meta.env.PROD;
14+
const SENTRY_ENABLED = import.meta.env.VITE_BUILD_ENV === 'production';
1515
const SENTRY_SAMPLE_RATE = import.meta.env.VITE_SENTRY_SAMPLE_RATE
1616
? parseFloat(import.meta.env.VITE_SENTRY_SAMPLE_RATE)
1717
: 0;
1818

1919
export function initSentry() {
2020
Sentry.init({
2121
enabled: SENTRY_ENABLED,
22-
dsn: import.meta.env.PROD
22+
dsn: SENTRY_ENABLED
2323
? 'https://ce107602e4d122f0639332c7c43fdc08@o4508279186718720.ingest.de.sentry.io/4508279962140752'
2424
: 'https://c8085701fa2650fb2a090ed6aba6bc62@o4508279186718720.ingest.de.sentry.io/4508279963320400',
2525
environment: import.meta.env.VITE_VERCEL_ENV,

apps/explorer/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import svgr from 'vite-plugin-svgr';
1010
import { configDefaults } from 'vitest/config';
1111

1212
process.env.VITE_VERCEL_ENV = process.env.VERCEL_ENV || 'development';
13+
process.env.VITE_BUILD_ENV = process.env.BUILD_ENV || 'development';
1314
const EXPLORER_REV = execSync('git rev-parse HEAD').toString().trim().toString();
1415

1516
// https://vitejs.dev/config/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
NEXT_PUBLIC_APPS_BACKEND_URL=
2+
NEXT_PUBLIC_BUILD_ENV='development'

apps/wallet-dashboard/lib/utils/analytics/amplitude.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { PersistableStorage } from '@iota/core';
88

99
import { ampli } from './ampli';
1010

11-
const IS_PROD_ENV = process.env.NODE_ENV == 'production';
11+
const IS_PROD_ENV = process.env.NEXT_PUBLIC_BUILD_ENV == 'production';
1212

1313
export const persistableStorage = new PersistableStorage<UserSession>();
1414

apps/wallet-dashboard/lib/utils/growthbook.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,25 @@
44
import { GrowthBook } from '@growthbook/growthbook';
55
import { getAppsBackend } from '@iota/iota-sdk/client';
66

7+
const GROWTHBOOK_ENVIRONMENTS = {
8+
production: {
9+
clientKey: 'production',
10+
enableDevMode: false,
11+
},
12+
staging: {
13+
clientKey: 'staging',
14+
enableDevMode: false,
15+
},
16+
development: {
17+
clientKey: 'staging',
18+
enableDevMode: true,
19+
},
20+
};
21+
22+
const environment =
23+
(process.env.NEXT_PUBLIC_BUILD_ENV as keyof typeof GROWTHBOOK_ENVIRONMENTS) || 'development';
24+
725
export const growthbook = new GrowthBook({
826
apiHost: getAppsBackend(),
9-
clientKey: process.env.NODE_ENV === 'production' ? 'production' : 'development',
10-
enableDevMode: process.env.NODE_ENV === 'development',
27+
...GROWTHBOOK_ENVIRONMENTS[environment],
1128
});

apps/wallet-dashboard/next.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { SENTRY_ORG_NAME, SENTRY_PROJECT_NAME } from './sentry.common.config.mjs
55
import { withSentryConfig } from '@sentry/nextjs';
66
import { execSync } from 'child_process';
77
const NEXT_PUBLIC_DASHBOARD_REV = execSync('git rev-parse HEAD').toString().trim().toString();
8+
const NEXT_PUBLIC_BUILD_ENV = process.env.BUILD_ENV;
89

910
/** @type {import('next').NextConfig} */
1011
const nextConfig = {
@@ -23,6 +24,7 @@ const nextConfig = {
2324
},
2425
env: {
2526
NEXT_PUBLIC_DASHBOARD_REV,
27+
NEXT_PUBLIC_BUILD_ENV,
2628
},
2729
};
2830

0 commit comments

Comments
 (0)