diff --git a/.circleci/config.yml b/.circleci/config.yml index b84b351f865..09b8194a67b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -769,37 +769,37 @@ jobs: when: always - store_artifacts: path: ../uitest_android_results - api_1-amplify_e2e_tests: + api_2-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 resource_class: large steps: *ref_1 environment: - TEST_SUITE: src/__tests__/api_1.test.ts + TEST_SUITE: src/__tests__/api_2.test.ts CLI_REGION: us-east-2 - api_2-amplify_e2e_tests: + auth_1-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 resource_class: large steps: *ref_1 environment: - TEST_SUITE: src/__tests__/api_2.test.ts + TEST_SUITE: src/__tests__/auth_1.test.ts CLI_REGION: us-west-2 - auth_1-amplify_e2e_tests: + auth_2-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 resource_class: large steps: *ref_1 environment: - TEST_SUITE: src/__tests__/auth_1.test.ts + TEST_SUITE: src/__tests__/auth_2.test.ts CLI_REGION: eu-west-2 - auth_2-amplify_e2e_tests: + api_1-amplify_e2e_tests: working_directory: ~/repo docker: *ref_0 resource_class: large steps: *ref_1 environment: - TEST_SUITE: src/__tests__/auth_2.test.ts + TEST_SUITE: src/__tests__/api_1.test.ts CLI_REGION: eu-central-1 function_1-amplify_e2e_tests: working_directory: ~/repo @@ -1018,16 +1018,16 @@ workflows: - amplify_console_integration_tests - amplify_migration_tests_latest - amplify_migration_tests_v4 - - api_1-amplify_e2e_tests + - api_2-amplify_e2e_tests - plugin-amplify_e2e_tests - hostingPROD-amplify_e2e_tests - - api_2-amplify_e2e_tests + - auth_1-amplify_e2e_tests - datastore-modegen-amplify_e2e_tests - predictions-amplify_e2e_tests - - auth_1-amplify_e2e_tests + - auth_2-amplify_e2e_tests - interactions-amplify_e2e_tests - delete-amplify_e2e_tests - - auth_2-amplify_e2e_tests + - api_1-amplify_e2e_tests - hosting-amplify_e2e_tests - storage-amplify_e2e_tests - function_1-amplify_e2e_tests @@ -1044,7 +1044,7 @@ workflows: - release - master - beta - - api_1-amplify_e2e_tests: + - api_2-amplify_e2e_tests: filters: &ref_2 branches: only: @@ -1060,7 +1060,7 @@ workflows: filters: *ref_2 requires: - publish_to_local_registry - - api_2-amplify_e2e_tests: + - auth_1-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry @@ -1072,7 +1072,7 @@ workflows: filters: *ref_2 requires: - publish_to_local_registry - - auth_1-amplify_e2e_tests: + - auth_2-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry @@ -1084,7 +1084,7 @@ workflows: filters: *ref_2 requires: - publish_to_local_registry - - auth_2-amplify_e2e_tests: + - api_1-amplify_e2e_tests: filters: *ref_2 requires: - publish_to_local_registry diff --git a/packages/amplify-cli/scripts/post-install.js b/packages/amplify-cli/scripts/post-install.js index ea0263c8410..f2c6830dd7c 100755 --- a/packages/amplify-cli/scripts/post-install.js +++ b/packages/amplify-cli/scripts/post-install.js @@ -26,6 +26,18 @@ console.log(EOL); console.log(chalk.green('iOS Getting Started - https://docs.amplify.aws/start/q/integration/ios')); console.log(EOL); +console.log( + chalk.blue( + `Amplify CLI collects anonymized usage data, which is used to help understand${EOL}\ +how to improve the product. If you don't wish to send anonymized Amplify CLI${EOL}\ +usage data to AWS, run `, + ) + + chalk.blue.italic.bgWhite('amplify configure --usage-data-off ') + + chalk.blue(` to opt-out.${EOL}${EOL}\ +Learn more - https://docs.amplify.aws/cli/reference/usage-data`), +); +console.log(EOL); + if (fs.existsSync('../lib/plugin-manager.js')) { require('../lib/plugin-manager').scan(); } diff --git a/packages/amplify-cli/src/__tests__/context-manager.test.ts b/packages/amplify-cli/src/__tests__/context-manager.test.ts index fb3f9a72e00..52331b31c2a 100644 --- a/packages/amplify-cli/src/__tests__/context-manager.test.ts +++ b/packages/amplify-cli/src/__tests__/context-manager.test.ts @@ -35,17 +35,11 @@ describe('test attachUsageData', () => { mockContext.pluginPlatform = new PluginPlatform(); mockContext.pluginPlatform.plugins['core'] = [new PluginInfo('', version, '', new PluginManifest('', ''))]; - beforeAll(() => { - process.env.AMPLIFY_CLI_ENABLE_USAGE_DATA = 'true'; - }); + beforeAll(() => {}); afterEach(() => { jest.clearAllMocks(); }); - afterAll(() => { - delete process.env.AMPLIFY_CLI_ENABLE_USAGE_DATA; - }); - it('constructContext', () => { const context = constructContext(mockContext.pluginPlatform, mockContext.input); expect(context).toBeDefined(); @@ -81,20 +75,4 @@ describe('test attachUsageData', () => { attachUsageData(mockContext); expect(UsageData.NoUsageData.Instance.init).toBeCalledWith(returnValue.usageDataConfig.installationUuid, version, mockContext.input); }); - - it('test with AMPLIFY_CLI_ENABLE_USAGE_DATA set to falsy', () => { - delete process.env.AMPLIFY_CLI_ENABLE_USAGE_DATA; - const returnValue = { - usageDataConfig: { - installationUuid: 'uuid', - isUsageTrackingEnabled: true, - }, - setValues: jest.fn(), - }; - const mockedInit = appConfig.init as jest.Mock; - mockedInit.mockReturnValue(returnValue); - attachUsageData(mockContext); - expect(UsageData.NoUsageData.Instance.init).toBeCalledWith(returnValue.usageDataConfig.installationUuid, version, mockContext.input); - process.env.AMPLIFY_CLI_ENABLE_USAGE_DATA = 'true'; - }); }); diff --git a/packages/amplify-cli/src/commands/configure.js b/packages/amplify-cli/src/commands/configure.js index 8134ef3cd78..e1f4ce4c008 100644 --- a/packages/amplify-cli/src/commands/configure.js +++ b/packages/amplify-cli/src/commands/configure.js @@ -10,15 +10,19 @@ import { write } from '../app-config'; module.exports = { name: 'configure', run: async context => { - if (!context.parameters.first) { - await configureNewUser.run(context); - } - if (context.parameters.options['usage-data-off']) { write(context, { usageDataConfig: { isUsageTrackingEnabled: false } }); + context.print.success('Usage Data has been turned off'); + return; } if (context.parameters.options['usage-data-on']) { write(context, { usageDataConfig: { isUsageTrackingEnabled: true } }); + context.print.success('Usage Data has been turned on'); + return; + } + + if (!context.parameters.first) { + await configureNewUser.run(context); } if (context.parameters.first === 'project') { diff --git a/packages/amplify-cli/src/context-manager.ts b/packages/amplify-cli/src/context-manager.ts index 644e7ba326a..9648937ab87 100644 --- a/packages/amplify-cli/src/context-manager.ts +++ b/packages/amplify-cli/src/context-manager.ts @@ -14,7 +14,9 @@ export function constructContext(pluginPlatform: PluginPlatform, input: Input): export function attachUsageData(context: Context) { const { AMPLIFY_CLI_ENABLE_USAGE_DATA } = process.env; const config = init(context); - const usageTrackingEnabled = !AMPLIFY_CLI_ENABLE_USAGE_DATA ? false : config.usageDataConfig.isUsageTrackingEnabled; + const usageTrackingEnabled = AMPLIFY_CLI_ENABLE_USAGE_DATA + ? AMPLIFY_CLI_ENABLE_USAGE_DATA === 'true' + : config.usageDataConfig.isUsageTrackingEnabled; if (usageTrackingEnabled) { context.usageData = UsageData.Instance; } else {