From 12d26427e55924e70764bc90711654587c8e4ef8 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Wed, 13 Sep 2023 14:46:36 -0700 Subject: [PATCH 1/7] Usage analytics enabled by default. Added a flag to opt out --- core/cli.ts | 18 ++++++++++++++---- core/global-options.ts | 5 +++++ core/utils/usagePermissions.ts | 20 +++++++------------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/core/cli.ts b/core/cli.ts index ff7be35..09e8775 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 } = await parseFlags(globalOptions); + const { version, help, projectName, template, branch, shouldTrackUsageData } = await parseFlags(globalOptions); + const collectUsageData = await initializeUsageConfigIfneeded(); + const config = loadConfig(); if (version) { console.log(getMakeMagicVersion()); @@ -47,10 +49,18 @@ function sayHello() { shutdown(0); } + if (shouldTrackUsageData !== undefined) { + const consent = await modifyUsageConsent(shouldTrackUsageData); + if (consent) { + console.log('Thank you for opting in for our developer experience improvement program.'); + } else { + console.log('You have opted out of our developer experience improvement program.'); + } + shutdown(0); + } + sayHello(); - const collectUsageData = await promptForUsageDataIfNeeded(); - const config = loadConfig(); if (collectUsageData && config?.id) { SharedAnalytics.identifyUser(config.id); } diff --git a/core/global-options.ts b/core/global-options.ts index 85f367e..bedcd68 100644 --- a/core/global-options.ts +++ b/core/global-options.ts @@ -41,4 +41,9 @@ export const globalOptions: Flags = { alias: 'v', description: `Show which version of \`${BINARY}\` is currently in use.`, }, + + shouldTrackUsageData: { + type: Boolean, + description: chalk`Modify your consent for tracking anonymous usage data to improve developer experience.\nTo opt out, run {blue npx make-magic --should-track-usage-data false}\n`, + }, }; 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; }; From f301143e9fc41a6a361e938b1871a6d0a5126e51 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Wed, 13 Sep 2023 16:21:45 -0700 Subject: [PATCH 2/7] Changed usage tracking flag name and description --- core/cli.ts | 6 +++--- core/global-options.ts | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core/cli.ts b/core/cli.ts index 09e8775..0a6a743 100644 --- a/core/cli.ts +++ b/core/cli.ts @@ -34,7 +34,7 @@ function sayHello() { useGracefulShutdown(); - const { version, help, projectName, template, branch, shouldTrackUsageData } = await parseFlags(globalOptions); + const { version, help, projectName, template, branch, shareUsageData } = await parseFlags(globalOptions); const collectUsageData = await initializeUsageConfigIfneeded(); const config = loadConfig(); @@ -49,8 +49,8 @@ function sayHello() { shutdown(0); } - if (shouldTrackUsageData !== undefined) { - const consent = await modifyUsageConsent(shouldTrackUsageData); + if (shareUsageData !== undefined) { + const consent = await modifyUsageConsent(shareUsageData); if (consent) { console.log('Thank you for opting in for our developer experience improvement program.'); } else { diff --git a/core/global-options.ts b/core/global-options.ts index bedcd68..2bed9b1 100644 --- a/core/global-options.ts +++ b/core/global-options.ts @@ -42,8 +42,9 @@ export const globalOptions: Flags = { description: `Show which version of \`${BINARY}\` is currently in use.`, }, - shouldTrackUsageData: { + shareUsageData: { type: Boolean, - description: chalk`Modify your consent for tracking anonymous usage data to improve developer experience.\nTo opt out, run {blue npx make-magic --should-track-usage-data false}\n`, + 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.', }, }; From 21e5f4c0c11202f985fcd78e9ec3962b9d3f98a8 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Wed, 13 Sep 2023 16:40:50 -0700 Subject: [PATCH 3/7] Changed sentence framing for usage tracking --- core/cli.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/cli.ts b/core/cli.ts index c47780d..053cee1 100644 --- a/core/cli.ts +++ b/core/cli.ts @@ -52,9 +52,9 @@ function sayHello() { if (shareUsageData !== undefined) { const consent = await modifyUsageConsent(shareUsageData); if (consent) { - console.log('Thank you for opting in for our developer experience improvement program.'); + console.log('Thanks for helping us improve the developer experience by sharing anonymous usage data!'); } else { - console.log('You have opted out of our developer experience improvement program.'); + console.log('You are now opted out of sharing anonymous usage data.'); } shutdown(0); } From 345f35eb67519ec7b0ee35ef9cff22640f0a865c Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Thu, 14 Sep 2023 12:11:00 -0700 Subject: [PATCH 4/7] Updated quickstart configuration to use dedicated wallet with Email OTP --- core/create-app.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/create-app.tsx b/core/create-app.tsx index 13bfd37..9d0b0cc 100644 --- a/core/create-app.tsx +++ b/core/create-app.tsx @@ -90,18 +90,19 @@ 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'; chain = 'evm'; @@ -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={[ { From 8237376f2c2c7e0dea957a353dc1c1984f2042f1 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Thu, 14 Sep 2023 12:13:53 -0700 Subject: [PATCH 5/7] Updated missed universal reference for quickstart configuration --- core/create-app.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/create-app.tsx b/core/create-app.tsx index 9d0b0cc..eee23dc 100644 --- a/core/create-app.tsx +++ b/core/create-app.tsx @@ -104,7 +104,7 @@ export async function createApp(config: CreateMagicAppConfig) { if (configuration === 'quickstart') { config.template = 'nextjs-dedicated-wallet'; config.network = 'polygon-mumbai'; - product = 'universal'; + product = 'dedicated'; chain = 'evm'; isChosenTemplateValid = true; } From b1bb46616b6ade202eb6c092e512f5a74abe67b9 Mon Sep 17 00:00:00 2001 From: James Pacheco Date: Fri, 15 Sep 2023 12:18:18 -0600 Subject: [PATCH 6/7] Flips Dedicated/Universal order on wallet prompt --- core/create-app.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/create-app.tsx b/core/create-app.tsx index eee23dc..0245815 100644 --- a/core/create-app.tsx +++ b/core/create-app.tsx @@ -170,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(); From 9d77dc067632302be1dfc62b8ce933ea4c9df752 Mon Sep 17 00:00:00 2001 From: James Pacheco Date: Fri, 15 Sep 2023 12:21:00 -0600 Subject: [PATCH 7/7] Update changelog and version --- CHANGELOG.md | 18 +++++++++++++++++- package.json | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) 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/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",