Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

v4.3.1 #105

Merged
merged 11 commits into from
Sep 15, 2023
Merged
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
# 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

- James ([@jamesrp13](https://github.com/jamesrp13))
- Aditya Kulkarni ([@AdityaKulkarni](https://github.com/AdityaKulkarni))

---

# v4.2.0 (Mon Sep 11 2023)

#### 🚀 Enhancement
Expand Down
18 changes: 14 additions & 4 deletions core/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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());
Expand All @@ -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);
}
Expand Down
12 changes: 7 additions & 5 deletions core/create-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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={[
{
Expand Down
6 changes: 6 additions & 0 deletions core/global-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,11 @@ export const globalOptions: Flags<GlobalOptions> = {
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,
};
20 changes: 7 additions & 13 deletions core/utils/usagePermissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
import crypto from 'crypto';
import { loadConfig, saveConfig } from '../config';

const { Select } = require('enquirer');

export const promptForUsageDataIfNeeded = async (): Promise<boolean> => {
export const initializeUsageConfigIfneeded = async (): Promise<boolean> => {
let config = await loadConfig();

if (!config) {
const answer = await promptForUsageData();
config = { shouldTrackUsageData: answer };
config = { shouldTrackUsageData: true };
await saveConfig(config);
}

Expand All @@ -22,12 +19,9 @@ export const promptForUsageDataIfNeeded = async (): Promise<boolean> => {
return config.shouldTrackUsageData ?? false;
};

const promptForUsageData = async (): Promise<boolean> => {
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;
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down