Skip to content

Commit f6b5140

Browse files
authored
Remove email capture, usage tracking (#489)
* remove anonymous telemetry stuff * rm email capture * fix tests * try unknown cast * update remix template * try latest cypress action * changeset
1 parent dc2d009 commit f6b5140

36 files changed

+215
-1334
lines changed

Diff for: .changeset/rich-adults-train.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"mailing": minor
3+
"mailing-core": minor
4+
---
5+
6+
remove anonymous telemetry and email collection

Diff for: .env.example

-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,3 @@ MAILING_SES_PASSWORD=
1414
MAILING_DATABASE_URL_TEST=
1515
WEB_DATABASE_URL_TEST=
1616
# Note: MAILING_SESSION_PASSWORD must also be set for integration tests to run
17-
18-
## Anonymous telemetry
19-
POSTHOG_API_KEY=

Diff for: .github/workflows/e2e.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
run: yarn jest --rootDir=mailing_tests/jest --config mailing_tests/jest/jest.config.json
4040
working-directory: /tmp/mailing_e2e/ci
4141
- name: Run ${{ matrix.e2e-config }} cypress tests
42-
uses: cypress-io/github-action@v4
42+
uses: cypress-io/github-action@v6
4343
env:
4444
DEBUG: "@cypress/github-action"
4545
with:

Diff for: e2e/app/remix_ts.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def initialize(root_dir, *args)
1414
def yarn_create!
1515
Dir.chdir(root_dir) do
1616
# install with the "remix" template
17-
system_quiet('yarn create remix . --template=remix --typescript --install')
17+
system_quiet('yarn create remix . --template=remix-run/remix/templates/remix --typescript --install')
1818

1919
## variation: indie-stack is a different remix template that people use
2020
# system_quiet("yarn create remix . --template=remix-run/indie-stack --typescript --install")

Diff for: packages/cli/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
"nodemailer": "6.8.0",
8585
"open": "^8.4.0",
8686
"postcss": "^8.4.16",
87-
"posthog-node": "^2.2.3",
8887
"prettier": "^2.7.1",
8988
"prisma": "^4.4.0",
9089
"prompts": "^2.4.2",

Diff for: packages/cli/src/commands/__test__/exportPreviews.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ describe("exportPreviews command", () => {
1414
typescript: true,
1515
emailsDir: "./packages/cli/src/__mocks__/emails",
1616
outDir: "./previews_html",
17-
anonymousId: "TEST_VALUE",
1817
}));
1918
});
2019

Diff for: packages/cli/src/commands/exportPreviews.ts

+93-103
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export type ExportPreviewsArgs = ArgumentsCamelCase<{
1515
outDir?: string;
1616
quiet?: boolean;
1717
minify?: boolean;
18-
anonymousId?: string | null;
1918
skipLint?: boolean;
2019
}>;
2120

@@ -61,113 +60,104 @@ export function previewFilename(moduleName: string, functionName: string) {
6160
);
6261
}
6362

64-
export const handler = buildHandler(
65-
async (argv: ExportPreviewsArgs) => {
66-
if (!argv.outDir) throw new Error("outDir option is not set");
63+
export const handler = buildHandler(async (argv: ExportPreviewsArgs) => {
64+
if (!argv.outDir) throw new Error("outDir option is not set");
6765

68-
const outDir = argv.outDir;
66+
const outDir = argv.outDir;
6967

70-
if (typeof outDir !== "string") {
71-
error("please specify an outDir like --outDir ./html");
72-
return;
73-
}
68+
if (typeof outDir !== "string") {
69+
error("please specify an outDir like --outDir ./html");
70+
return;
71+
}
7472

75-
if (undefined === argv.emailsDir) {
76-
error("please specific an emailsDir like --emailsDir ./emails");
77-
return;
78-
}
73+
if (undefined === argv.emailsDir) {
74+
error("please specific an emailsDir like --emailsDir ./emails");
75+
return;
76+
}
7977

80-
const previewsPath = getPreviewsDirectory(argv.emailsDir);
81-
if (!previewsPath) {
82-
error(
83-
"Could not find emails directory. Have you initialized the project with `mailing init`?"
84-
);
85-
return;
86-
}
87-
88-
registerRequireHooks();
89-
90-
const previewText = argv.minify ? "minified preview html" : "preview html";
91-
92-
let count = 0;
93-
94-
const lint: { [filename: string]: HtmlLintError[] } = {};
95-
const toWrite: Array<() => Promise<void>> = [];
96-
const filenames: string[] = [];
97-
98-
const previewRenders = readdirSync(previewsPath)
99-
.filter((path) => !/^\./.test(path))
100-
.flatMap((p) => {
101-
const previewPath = resolve(previewsPath, p);
102-
const previewModule = require(previewPath);
103-
104-
return Object.keys(require(previewPath)).flatMap(
105-
async (previewFunction) => {
106-
const filename = previewFilename(p, previewFunction);
107-
count++;
108-
109-
const { html, errors, htmlLint } = render(
110-
await previewModule[previewFunction]()
111-
);
112-
if (errors.length) {
113-
error(`MJML errors rendering ${filename}:`, errors);
114-
}
115-
116-
if (htmlLint.length && !argv.skipLint) {
117-
lint[filename] = htmlLint;
118-
}
119-
120-
const minifyConfig = {
121-
collapseWhitespace: true,
122-
minifyCSS: false,
123-
caseSensitive: true,
124-
removeEmptyAttributes: true,
125-
};
126-
127-
const outHtml = argv.minify
128-
? await minify(html, minifyConfig)
129-
: html;
130-
filenames.push(filename);
131-
toWrite.push(async () =>
132-
outputFile(resolve(outDir, filename), outHtml)
133-
);
78+
const previewsPath = getPreviewsDirectory(argv.emailsDir);
79+
if (!previewsPath) {
80+
error(
81+
"Could not find emails directory. Have you initialized the project with `mailing init`?"
82+
);
83+
return;
84+
}
85+
86+
registerRequireHooks();
87+
88+
const previewText = argv.minify ? "minified preview html" : "preview html";
89+
90+
let count = 0;
91+
92+
const lint: { [filename: string]: HtmlLintError[] } = {};
93+
const toWrite: Array<() => Promise<void>> = [];
94+
const filenames: string[] = [];
95+
96+
const previewRenders = readdirSync(previewsPath)
97+
.filter((path) => !/^\./.test(path))
98+
.flatMap((p) => {
99+
const previewPath = resolve(previewsPath, p);
100+
const previewModule = require(previewPath);
101+
102+
return Object.keys(require(previewPath)).flatMap(
103+
async (previewFunction) => {
104+
const filename = previewFilename(p, previewFunction);
105+
count++;
106+
107+
const { html, errors, htmlLint } = render(
108+
await previewModule[previewFunction]()
109+
);
110+
if (errors.length) {
111+
error(`MJML errors rendering ${filename}:`, errors);
112+
}
113+
114+
if (htmlLint.length && !argv.skipLint) {
115+
lint[filename] = htmlLint;
134116
}
135-
);
136-
});
137-
await Promise.all(previewRenders);
138-
139-
const lintCount = Object.keys(lint).length;
140-
if (lintCount) {
141-
error(
142-
lintCount > 1
143-
? `Aborted because ${lintCount} files have lint errors:`
144-
: `Aborted because 1 file has lint errors:`,
145-
"\n\n",
146-
Object.entries(lint)
147-
.map(
148-
([filename, errors]) =>
149-
`${filename}\n${errors
150-
.map((e, i) => ` ${i + 1}. ${e.message}`)
151-
.join("\n\n")}`
152-
)
153-
.join("\n\n"),
154-
"\n\n"
155-
);
156117

157-
return;
158-
}
118+
const minifyConfig = {
119+
collapseWhitespace: true,
120+
minifyCSS: false,
121+
caseSensitive: true,
122+
removeEmptyAttributes: true,
123+
};
124+
125+
const outHtml = argv.minify ? await minify(html, minifyConfig) : html;
126+
filenames.push(filename);
127+
toWrite.push(async () =>
128+
outputFile(resolve(outDir, filename), outHtml)
129+
);
130+
}
131+
);
132+
});
133+
await Promise.all(previewRenders);
134+
135+
const lintCount = Object.keys(lint).length;
136+
if (lintCount) {
137+
error(
138+
lintCount > 1
139+
? `Aborted because ${lintCount} files have lint errors:`
140+
: `Aborted because 1 file has lint errors:`,
141+
"\n\n",
142+
Object.entries(lint)
143+
.map(
144+
([filename, errors]) =>
145+
`${filename}\n${errors
146+
.map((e, i) => ` ${i + 1}. ${e.message}`)
147+
.join("\n\n")}`
148+
)
149+
.join("\n\n"),
150+
"\n\n"
151+
);
152+
153+
return;
154+
}
159155

160-
log(`Exporting ${previewText} to`);
161-
log(`${outDir}/`);
162-
await Promise.all(toWrite.map((f) => f()));
163-
for (const f of filenames.sort()) {
164-
log(` |-- ${f}`);
165-
}
166-
log(`✅ Processed ${count} previews\n`);
167-
},
168-
{
169-
captureOptions: () => {
170-
return { event: "export-previews invoked" };
171-
},
156+
log(`Exporting ${previewText} to`);
157+
log(`${outDir}/`);
158+
await Promise.all(toWrite.map((f) => f()));
159+
for (const f of filenames.sort()) {
160+
log(` |-- ${f}`);
172161
}
173-
);
162+
log(`✅ Processed ${count} previews\n`);
163+
});

Diff for: packages/cli/src/commands/init.ts

+26-66
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import prompts from "prompts";
2-
import fetch from "node-fetch";
31
import { existsSync } from "fs-extra";
42
import { ArgumentsCamelCase } from "yargs";
5-
import { error, log } from "../util/serverLogger";
6-
import { getMailingAPIBaseURL } from "../util/paths";
3+
import { log } from "../util/serverLogger";
74
import { generateEmailsDirectory } from "../util/generators";
85
import { handler as previewHandler, PreviewArgs } from "./preview/preview";
96
import { defaults } from "../util/config";
@@ -15,7 +12,6 @@ export type InitArguments = ArgumentsCamelCase<{
1512
typescript?: boolean;
1613
port?: number;
1714
quiet?: boolean;
18-
anonymousId?: string | null;
1915
}>;
2016

2117
export const command = ["$0", "init"];
@@ -53,69 +49,33 @@ export const builder = {
5349
},
5450
};
5551

56-
export const handler = buildHandler(
57-
async (argv: InitArguments) => {
58-
if (typeof argv.port !== "number")
59-
throw new Error("port option is not set");
60-
if (typeof argv.typescript !== "boolean")
61-
throw new Error("typescript option not set");
62-
if (undefined === argv.emailsDir)
63-
throw new Error("emailsDir option not set");
52+
export const handler = buildHandler(async (argv: InitArguments) => {
53+
if (typeof argv.port !== "number") throw new Error("port option is not set");
54+
if (typeof argv.typescript !== "boolean")
55+
throw new Error("typescript option not set");
56+
if (undefined === argv.emailsDir) throw new Error("emailsDir option not set");
6457

65-
if (existsSync(resolve(argv.emailsDir, "previews"))) {
66-
log("Using emails directory", argv.emailsDir);
67-
} else {
68-
const options = {
69-
isTypescript: argv.typescript,
70-
emailsDir: argv.emailsDir,
71-
};
72-
await generateEmailsDirectory(options);
73-
74-
if (argv.scaffoldOnly) {
75-
return;
76-
}
77-
78-
if (!argv.quiet) {
79-
const emailResponse = await prompts({
80-
type: "text",
81-
name: "email",
82-
message:
83-
"enter your email for occasional updates about mailing (optional)",
84-
});
85-
const { email } = emailResponse;
86-
if (email?.length > 0) {
87-
log("great, talk soon");
88-
try {
89-
const url = `${getMailingAPIBaseURL()}/api/newsletterSubscribers`;
90-
91-
void fetch(url, {
92-
method: "POST",
93-
headers: { "Content-Type": "application/json" },
94-
body: JSON.stringify({ email }),
95-
});
96-
} catch (e) {
97-
error(e);
98-
}
99-
} else {
100-
log("ok, no problem");
101-
}
102-
}
103-
}
104-
105-
const previewHandlerArgv: PreviewArgs = {
106-
port: argv.port,
107-
quiet: argv.quiet,
58+
if (existsSync(resolve(argv.emailsDir, "previews"))) {
59+
log("Using emails directory", argv.emailsDir);
60+
} else {
61+
const options = {
62+
isTypescript: argv.typescript,
10863
emailsDir: argv.emailsDir,
109-
anonymousId: argv.anonymousId,
110-
$0: argv.$0,
111-
_: argv._,
11264
};
65+
await generateEmailsDirectory(options);
11366

114-
await previewHandler(previewHandlerArgv);
115-
},
116-
{
117-
captureOptions: () => {
118-
return { event: "init invoked" };
119-
},
67+
if (argv.scaffoldOnly) {
68+
return;
69+
}
12070
}
121-
);
71+
72+
const previewHandlerArgv: PreviewArgs = {
73+
port: argv.port,
74+
quiet: argv.quiet,
75+
emailsDir: argv.emailsDir,
76+
$0: argv.$0,
77+
_: argv._,
78+
};
79+
80+
await previewHandler(previewHandlerArgv);
81+
});

0 commit comments

Comments
 (0)