Skip to content

feat: rename profile sync to backup and sync #5686

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

Merged
merged 5 commits into from
May 7, 2025
Merged
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
2 changes: 2 additions & 0 deletions packages/profile-sync-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- **BREAKING:** Replace all "Profile Syncing" mentions to "Backup & Sync" ([#5686](https://github.com/MetaMask/core/pull/5686))
- Replaces state properties `isProfileSyncingEnabled` to `isBackupAndSyncEnabled`, and `isProfileSyncingUpdateLoading` to `isBackupAndSyncUpdateLoading`
- **BREAKING:** Bump `@metamask/accounts-controller` peer dependency from `^27.0.0` to `^28.0.0` ([#5763](https://github.com/MetaMask/core/pull/5763))
- **BREAKING:** Bump `@metamask/snaps-controllers` peer dependency from `^9.19.0` to `^11.0.0` ([#5639](https://github.com/MetaMask/core/pull/5639))
- **BREAKING:** Bump `@metamask/providers` peer dependency from `^18.1.1` to `^21.0.0` ([#5639](https://github.com/MetaMask/core/pull/5639))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export type AuthenticationControllerMessenger = RestrictedMessenger<

/**
* Controller that enables authentication for restricted endpoints.
* Used for Global Profile Syncing and Notifications
* Used for Backup & Sync, Notifications, and other services.
*/
export default class AuthenticationController extends BaseController<
typeof controllerName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('user-storage/user-storage-controller - constructor() tests', () => {
messenger: messengerMocks.messenger,
});

expect(controller.state.isProfileSyncingEnabled).toBe(true);
expect(controller.state.isBackupAndSyncEnabled).toBe(true);
});

it('should call startNetworkSyncing', async () => {
Expand Down Expand Up @@ -608,28 +608,6 @@ describe('user-storage/user-storage-controller - getStorageKey() tests', () => {
});
});

describe('user-storage/user-storage-controller - disableProfileSyncing() tests', () => {
const arrangeMocks = async () => {
return {
messengerMocks: mockUserStorageMessenger(),
};
};

it('should disable user storage / profile syncing when called', async () => {
const { messengerMocks } = await arrangeMocks();
const controller = new UserStorageController({
messenger: messengerMocks.messenger,
});

expect(controller.state.isProfileSyncingEnabled).toBe(true);
await controller.setIsBackupAndSyncFeatureEnabled(
BACKUPANDSYNC_FEATURES.main,
false,
);
expect(controller.state.isProfileSyncingEnabled).toBe(false);
});
});

describe('user-storage/user-storage-controller - setIsBackupAndSyncFeatureEnabled tests', () => {
const arrangeMocks = async () => {
return {
Expand All @@ -644,21 +622,21 @@ describe('user-storage/user-storage-controller - setIsBackupAndSyncFeatureEnable
const controller = new UserStorageController({
messenger: messengerMocks.messenger,
state: {
isProfileSyncingEnabled: false,
isProfileSyncingUpdateLoading: false,
isBackupAndSyncEnabled: false,
isBackupAndSyncUpdateLoading: false,
isAccountSyncingEnabled: false,
hasAccountSyncingSyncedAtLeastOnce: false,
isAccountSyncingReadyToBeDispatched: false,
isAccountSyncingInProgress: false,
},
});

expect(controller.state.isProfileSyncingEnabled).toBe(false);
expect(controller.state.isBackupAndSyncEnabled).toBe(false);
await controller.setIsBackupAndSyncFeatureEnabled(
BACKUPANDSYNC_FEATURES.main,
true,
);
expect(controller.state.isProfileSyncingEnabled).toBe(true);
expect(controller.state.isBackupAndSyncEnabled).toBe(true);
expect(messengerMocks.mockAuthIsSignedIn).toHaveBeenCalled();
expect(messengerMocks.mockAuthPerformSignIn).toHaveBeenCalled();
});
Expand All @@ -670,16 +648,16 @@ describe('user-storage/user-storage-controller - setIsBackupAndSyncFeatureEnable
const controller = new UserStorageController({
messenger: messengerMocks.messenger,
state: {
isProfileSyncingEnabled: false,
isProfileSyncingUpdateLoading: false,
isBackupAndSyncEnabled: false,
isBackupAndSyncUpdateLoading: false,
isAccountSyncingEnabled: false,
hasAccountSyncingSyncedAtLeastOnce: false,
isAccountSyncingReadyToBeDispatched: false,
isAccountSyncingInProgress: false,
},
});

expect(controller.state.isProfileSyncingEnabled).toBe(false);
expect(controller.state.isBackupAndSyncEnabled).toBe(false);
messengerMocks.mockAuthPerformSignIn.mockRejectedValue(new Error('error'));

await expect(
Expand All @@ -688,7 +666,7 @@ describe('user-storage/user-storage-controller - setIsBackupAndSyncFeatureEnable
true,
),
).rejects.toThrow('error');
expect(controller.state.isProfileSyncingEnabled).toBe(false);
expect(controller.state.isBackupAndSyncEnabled).toBe(false);
});

it('should not disable backup and sync when disabling account syncing', async () => {
Expand All @@ -698,22 +676,22 @@ describe('user-storage/user-storage-controller - setIsBackupAndSyncFeatureEnable
const controller = new UserStorageController({
messenger: messengerMocks.messenger,
state: {
isProfileSyncingEnabled: true,
isProfileSyncingUpdateLoading: false,
isBackupAndSyncEnabled: true,
isBackupAndSyncUpdateLoading: false,
isAccountSyncingEnabled: true,
hasAccountSyncingSyncedAtLeastOnce: false,
isAccountSyncingReadyToBeDispatched: false,
isAccountSyncingInProgress: false,
},
});

expect(controller.state.isProfileSyncingEnabled).toBe(true);
expect(controller.state.isBackupAndSyncEnabled).toBe(true);
await controller.setIsBackupAndSyncFeatureEnabled(
BACKUPANDSYNC_FEATURES.accountSyncing,
false,
);
expect(controller.state.isAccountSyncingEnabled).toBe(false);
expect(controller.state.isProfileSyncingEnabled).toBe(true);
expect(controller.state.isBackupAndSyncEnabled).toBe(true);
});
});

Expand Down Expand Up @@ -912,15 +890,15 @@ describe('user-storage/user-storage-controller - error handling edge cases', ()
messenger: messengerMocks.messenger,
state: {
...defaultState,
isProfileSyncingEnabled: false,
isBackupAndSyncEnabled: false,
},
});

await controller.setIsBackupAndSyncFeatureEnabled(
BACKUPANDSYNC_FEATURES.main,
false,
);
expect(controller.state.isProfileSyncingEnabled).toBe(false);
expect(controller.state.isBackupAndSyncEnabled).toBe(false);
});

it('handles enabling backup & sync when already enabled and signed in', async () => {
Expand All @@ -931,15 +909,15 @@ describe('user-storage/user-storage-controller - error handling edge cases', ()
messenger: messengerMocks.messenger,
state: {
...defaultState,
isProfileSyncingEnabled: true,
isBackupAndSyncEnabled: true,
},
});

await controller.setIsBackupAndSyncFeatureEnabled(
BACKUPANDSYNC_FEATURES.main,
true,
);
expect(controller.state.isProfileSyncingEnabled).toBe(true);
expect(controller.state.isBackupAndSyncEnabled).toBe(true);
expect(messengerMocks.mockAuthPerformSignIn).not.toHaveBeenCalled();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ export type UserStorageControllerState = {
/**
* Condition used by UI and to determine if we can use some of the User Storage methods.
*/
isProfileSyncingEnabled: boolean;
isBackupAndSyncEnabled: boolean;
/**
* Loading state for the profile syncing update
* Loading state for the backup and sync update
*/
isProfileSyncingUpdateLoading: boolean;
isBackupAndSyncUpdateLoading: boolean;
/**
* Condition used by UI to determine if account syncing is enabled.
*/
Expand All @@ -89,20 +89,20 @@ export type UserStorageControllerState = {
};

export const defaultState: UserStorageControllerState = {
isProfileSyncingEnabled: true,
isProfileSyncingUpdateLoading: false,
isBackupAndSyncEnabled: true,
isBackupAndSyncUpdateLoading: false,
isAccountSyncingEnabled: true,
hasAccountSyncingSyncedAtLeastOnce: false,
isAccountSyncingReadyToBeDispatched: false,
isAccountSyncingInProgress: false,
};

const metadata: StateMetadata<UserStorageControllerState> = {
isProfileSyncingEnabled: {
isBackupAndSyncEnabled: {
persist: true,
anonymous: true,
},
isProfileSyncingUpdateLoading: {
isBackupAndSyncUpdateLoading: {
persist: false,
anonymous: false,
},
Expand Down Expand Up @@ -612,7 +612,7 @@ export default class UserStorageController extends BaseController<
enabled: boolean,
): Promise<void> {
try {
this.#setIsProfileSyncingUpdateLoading(true);
this.#setIsBackupAndSyncUpdateLoading(true);

if (enabled) {
// If any of the features are enabled, we need to ensure the user is signed in
Expand All @@ -624,7 +624,7 @@ export default class UserStorageController extends BaseController<

this.update((state) => {
if (feature === BACKUPANDSYNC_FEATURES.main) {
state.isProfileSyncingEnabled = enabled;
state.isBackupAndSyncEnabled = enabled;
}

if (feature === BACKUPANDSYNC_FEATURES.accountSyncing) {
Expand All @@ -639,15 +639,15 @@ export default class UserStorageController extends BaseController<
`${controllerName} - failed to ${enabled ? 'enable' : 'disable'} ${feature} - ${errorMessage}`,
);
} finally {
this.#setIsProfileSyncingUpdateLoading(false);
this.#setIsBackupAndSyncUpdateLoading(false);
}
}

#setIsProfileSyncingUpdateLoading(
isProfileSyncingUpdateLoading: boolean,
#setIsBackupAndSyncUpdateLoading(
isBackupAndSyncUpdateLoading: boolean,
): void {
this.update((state) => {
state.isProfileSyncingUpdateLoading = isProfileSyncingUpdateLoading;
state.isBackupAndSyncUpdateLoading = isBackupAndSyncUpdateLoading;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import {
import { MOCK_STORAGE_KEY } from '../mocks';

const baseState = {
isProfileSyncingEnabled: true,
isBackupAndSyncEnabled: true,
isAccountSyncingEnabled: true,
isProfileSyncingUpdateLoading: false,
isBackupAndSyncUpdateLoading: false,
hasAccountSyncingSyncedAtLeastOnce: false,
isAccountSyncingReadyToBeDispatched: false,
isAccountSyncingInProgress: false,
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('user-storage/account-syncing/controller-integration - syncInternalAcco
it('returns void if UserStorage is not enabled', async () => {
const { controller, messengerMocks, options } = await arrangeMocks({
stateOverrides: {
isProfileSyncingEnabled: false,
isBackupAndSyncEnabled: false,
},
});

Expand Down Expand Up @@ -973,7 +973,7 @@ describe('user-storage/account-syncing/controller-integration - saveInternalAcco
it('returns void if UserStorage is not enabled', async () => {
const { options } = await arrangeMocks({
stateOverrides: {
isProfileSyncingEnabled: false,
isBackupAndSyncEnabled: false,
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { AccountSyncingOptions } from './types';
describe('user-storage/account-syncing/sync-utils', () => {
describe('canPerformAccountSyncing', () => {
const arrangeMocks = ({
isProfileSyncingEnabled = true,
isBackupAndSyncEnabled = true,
isAccountSyncingEnabled = true,
isAccountSyncingInProgress = false,
messengerCallControllerAndAction = 'AuthenticationController:isSignedIn',
Expand All @@ -29,7 +29,7 @@ describe('user-storage/account-syncing/sync-utils', () => {
}),
getUserStorageControllerInstance: jest.fn().mockReturnValue({
state: {
isProfileSyncingEnabled,
isBackupAndSyncEnabled,
isAccountSyncingEnabled,
isAccountSyncingInProgress,
},
Expand All @@ -40,14 +40,14 @@ describe('user-storage/account-syncing/sync-utils', () => {
};

const failureCases = [
['profile syncing is not enabled', { isProfileSyncingEnabled: false }],
['backup and sync is not enabled', { isBackupAndSyncEnabled: false }],
[
'profile syncing is not enabled but account syncing is',
{ isProfileSyncingEnabled: false, isAccountSyncingEnabled: true },
'backup and sync is not enabled but account syncing is',
{ isBackupAndSyncEnabled: false, isAccountSyncingEnabled: true },
],
[
'profile syncing is enabled but not account syncing',
{ isProfileSyncingEnabled: true, isAccountSyncingEnabled: false },
'backup and sync is enabled but not account syncing',
{ isBackupAndSyncEnabled: true, isAccountSyncingEnabled: false },
],
[
'authentication is not enabled',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function canPerformAccountSyncing(
const { getMessenger, getUserStorageControllerInstance } = options;

const {
isProfileSyncingEnabled,
isBackupAndSyncEnabled,
isAccountSyncingEnabled,
isAccountSyncingInProgress,
} = getUserStorageControllerInstance().state;
Expand All @@ -25,7 +25,7 @@ export function canPerformAccountSyncing(
);

if (
!isProfileSyncingEnabled ||
!isBackupAndSyncEnabled ||
!isAccountSyncingEnabled ||
!isAuthEnabled ||
isAccountSyncingInProgress
Expand Down
Loading