diff --git a/CHANGELOG.md b/CHANGELOG.md index 66cf900..431f663 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,21 @@ -# v4.2.2 (Tue Sep 12 2023) +# v4.3.1 (Fri Sep 15 2023) #### 🚀 Enhancement +- Enables anonymous usage tracking with a command to opt out +- Updates Quickstart to use Dedicated Wallet + +#### Authors: 2 + +- James ([@jamesrp13](https://github.com/jamesrp13)) +- Aditya Kulkarni ([@AdityaKulkarni](https://github.com/AdityaKulkarni)) + +--- + +# v4.2.2 (Tue Sep 12 2023) + +#### 🐛 Bug Fix + - Fix bug where network isn't always added into template configuration #### Authors: 2 @@ -9,6 +23,8 @@ - James ([@jamesrp13](https://github.com/jamesrp13)) - Aditya Kulkarni ([@AdityaKulkarni](https://github.com/AdityaKulkarni)) +--- + # v4.2.0 (Mon Sep 11 2023) #### 🚀 Enhancement diff --git a/core/cli.ts b/core/cli.ts index c6e750d..053cee1 100644 --- a/core/cli.ts +++ b/core/cli.ts @@ -9,7 +9,7 @@ import { parseFlags } from './flags'; import { globalOptions } from './global-options'; import { shutdown, useGracefulShutdown } from './utils/shutdown'; import { SharedAnalytics } from './analytics'; -import { promptForUsageDataIfNeeded } from './utils/usagePermissions'; +import { modifyUsageConsent, initializeUsageConfigIfneeded } from './utils/usagePermissions'; import { loadConfig } from './config'; import suppressWarnings from './utils/suppress-experimental-warnings'; @@ -34,7 +34,9 @@ function sayHello() { useGracefulShutdown(); - const { version, help, projectName, template, branch, network } = await parseFlags(globalOptions); + const { version, help, projectName, template, branch, network, shareUsageData } = await parseFlags(globalOptions); + const collectUsageData = await initializeUsageConfigIfneeded(); + const config = loadConfig(); if (version) { console.log(getMakeMagicVersion()); @@ -47,10 +49,18 @@ function sayHello() { shutdown(0); } + if (shareUsageData !== undefined) { + const consent = await modifyUsageConsent(shareUsageData); + if (consent) { + console.log('Thanks for helping us improve the developer experience by sharing anonymous usage data!'); + } else { + console.log('You are now opted out of sharing anonymous usage data.'); + } + shutdown(0); + } + sayHello(); - const collectUsageData = await promptForUsageDataIfNeeded(); - const config = loadConfig(); if (collectUsageData && config?.id) { SharedAnalytics.identifyUser(config.id); } diff --git a/core/create-app.tsx b/core/create-app.tsx index 13bfd37..0245815 100644 --- a/core/create-app.tsx +++ b/core/create-app.tsx @@ -90,20 +90,21 @@ export async function createApp(config: CreateMagicAppConfig) { let chain: Chain | undefined = undefined; let product: 'universal' | 'dedicated' | undefined = undefined; + let configuration = ''; if (!config.template) { - const configuration = await new Select({ + configuration = await new Select({ name: 'configuration', message: 'Select a configuration to start with:', choices: [ - { name: 'quickstart', message: 'Quickstart (Nextjs, Universal Wallet, Polygon Testnet)' }, + { name: 'quickstart', message: 'Quickstart (Nextjs, Dedicated Wallet, Polygon Testnet, Email OTP)' }, { name: 'custom', message: 'Custom Setup (Choose product, network, etc.)' }, ], }).run(); if (configuration === 'quickstart') { - config.template = 'nextjs-universal-wallet'; + config.template = 'nextjs-dedicated-wallet'; config.network = 'polygon-mumbai'; - product = 'universal'; + product = 'dedicated'; chain = 'evm'; isChosenTemplateValid = true; } @@ -169,8 +170,8 @@ export async function createApp(config: CreateMagicAppConfig) { name: 'product', message: 'Choose your wallet type', choices: [ - { name: 'universal', message: 'Universal' }, { name: 'dedicated', message: 'Dedicated' }, + { name: 'universal', message: 'Universal' }, ], }).run(); @@ -199,6 +200,7 @@ export async function createApp(config: CreateMagicAppConfig) { template: isChosenTemplateValid ? config.template : undefined, network: config.network, npmClient: 'npm', + loginMethods: configuration === 'quickstart' ? ['EmailOTP'] : undefined, })} prompts={[ { diff --git a/core/global-options.ts b/core/global-options.ts index ee06925..eb39500 100644 --- a/core/global-options.ts +++ b/core/global-options.ts @@ -43,5 +43,11 @@ export const globalOptions: Flags = { description: `Show which version of \`${BINARY}\` is currently in use.`, }, + shareUsageData: { + type: Boolean, + description: + 'A boolean representing whether or not to share anonymous usage data with Magic. The data cannot be traced back to you and is used to improve the developer experience.', + }, + ...BlockchainNetworkPrompt.flags, }; diff --git a/core/utils/usagePermissions.ts b/core/utils/usagePermissions.ts index fe5a49a..5ca89f0 100644 --- a/core/utils/usagePermissions.ts +++ b/core/utils/usagePermissions.ts @@ -3,14 +3,11 @@ import crypto from 'crypto'; import { loadConfig, saveConfig } from '../config'; -const { Select } = require('enquirer'); - -export const promptForUsageDataIfNeeded = async (): Promise => { +export const initializeUsageConfigIfneeded = async (): Promise => { let config = await loadConfig(); if (!config) { - const answer = await promptForUsageData(); - config = { shouldTrackUsageData: answer }; + config = { shouldTrackUsageData: true }; await saveConfig(config); } @@ -22,12 +19,9 @@ export const promptForUsageDataIfNeeded = async (): Promise => { return config.shouldTrackUsageData ?? false; }; -const promptForUsageData = async (): Promise => { - const answer = await new Select({ - name: 'analytics', - message: 'Would you like to help us improve this tool by allowing us to collect anonymous usage data?', - choices: [{ name: 'Yes' }, { name: 'No' }], - }).run(); - - return answer === 'Yes'; +export const modifyUsageConsent = async (shouldTrackUsageData: boolean) => { + let config = await loadConfig(); + config = { ...config, shouldTrackUsageData }; + await saveConfig(config); + return config?.shouldTrackUsageData ?? false; }; diff --git a/package.json b/package.json index 014cbd3..7865c98 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "make-magic", - "version": "4.2.2", + "version": "4.3.1", "description": "A tool for quickly scaffolding an app with Magic authentication baked-in!", "repository": "magiclabs/create-magic-app", "license": "MIT",