Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@ import {
AuthenticationControllerState,
Controller as AuthenticationController,
} from '@metamask/profile-sync-controller/auth';
import { Platform } from '@metamask/profile-sync-controller/sdk';
import { Env, Platform } from '@metamask/profile-sync-controller/sdk';
import { ControllerInitFunction } from '../types';
import {
AuthenticationControllerInitMessenger,
AuthenticationControllerMessenger,
} from '../messengers/identity';
import { ENVIRONMENT } from '../../../../development/build/constants';

/**
* Check if the build is a Development or Test build.
*
* @returns true if the build is a Development or Test build, false otherwise
*/
function isDevOrTestBuild() {
return (
process.env.METAMASK_ENVIRONMENT === ENVIRONMENT.DEVELOPMENT ||
process.env.METAMASK_ENVIRONMENT === ENVIRONMENT.TESTING
);
}

/**
* Initialize the Authentication controller.
Expand All @@ -34,6 +47,9 @@ export const AuthenticationControllerInit: ControllerInitFunction<
),
agent: Platform.EXTENSION,
},
config: {
env: isDevOrTestBuild() ? Env.DEV : Env.PRD,
},
});

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
UserStorageControllerState,
Controller as UserStorageController,
} from '@metamask/profile-sync-controller/user-storage';
import { Env } from '@metamask/profile-sync-controller/sdk';
import { ControllerInitFunction } from '../types';
import {
MetaMetricsEventCategory,
Expand All @@ -11,6 +12,19 @@ import {
import { trace } from '../../../../shared/lib/trace';
import { captureException } from '../../../../shared/lib/sentry';
import { UserStorageControllerInitMessenger } from '../messengers/identity/user-storage-controller-messenger';
import { ENVIRONMENT } from '../../../../development/build/constants';

/**
* Check if the build is a Development or Test build.
*
* @returns true if the build is a Development or Test build, false otherwise
*/
function isDevOrTestBuild() {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we only intend to check DEVELOPMENT or TESTING, we can use this shared utils, isProduction

return (
process.env.METAMASK_ENVIRONMENT === ENVIRONMENT.DEVELOPMENT ||
process.env.METAMASK_ENVIRONMENT === ENVIRONMENT.TESTING
);
}

/**
* Initialize the UserStorage controller.
Expand All @@ -32,6 +46,7 @@ export const UserStorageControllerInit: ControllerInitFunction<
// @ts-expect-error Controller uses string for names rather than enum
trace,
config: {
env: isDevOrTestBuild() ? Env.DEV : Env.PRD,
contactSyncing: {
onContactUpdated: (profileId) => {
initMessenger.call('MetaMetricsController:trackEvent', {
Expand Down
Loading