+
Skip to content

Add a 'Get Started' button after entering an email #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function activate(context: vscode.ExtensionContext): void {
if (!context.globalState.get(TRIAL_STARTED_TIMESTAMP)) {
context.globalState.update(TRIAL_STARTED_TIMESTAMP, new Date().getTime());
reporter.sendTelemetryEvent('firstActivation');
askForEmail();
askForEmail(reporter);

const getStartedText = 'Get started debugging faster';
vscode.window
Expand All @@ -69,7 +69,7 @@ export function activate(context: vscode.ExtensionContext): void {
if (clicked === getStartedText) {
vscode.commands.executeCommand(
'workbench.action.openWalkthrough',
'LocalCI.local-ci#welcomeLocalCi'
`${EXTENSION_ID}#welcomeLocalCi`
);
reporter.sendTelemetryEvent('click.getStarted');
}
Expand Down
79 changes: 43 additions & 36 deletions src/utils/askForEmail.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,50 @@
import * as vscode from 'vscode';
import TelemetryReporter from '@vscode/extension-telemetry';
import sendEnteredEmail from './sendEnteredEmail';
import { EXTENSION_ID } from '../constants';

export default function askForEmail(): void {
vscode.window
.showInputBox({
title: 'Email',
prompt:
'Could you please enter your email for your free preview of Local CI?',
})
.then((enteredEmail) => {
if (enteredEmail === undefined) {
return; // They pressed Escape or exited the input box.
}
export default async function askForEmail(
reporter: TelemetryReporter
): Promise<void> {
const enteredEmail = await vscode.window.showInputBox({
title: 'Email',
prompt:
'Could you please enter your email for your free preview of Local CI?',
});

vscode.window
.showInputBox({
title: 'Name',
prompt: `Thanks a lot! What's your first name?`,
})
.then((enteredName) => {
if (enteredName === undefined) {
sendEnteredEmail(enteredEmail); // They pressed Escape or exited the input box.
return;
}
if (enteredEmail === undefined) {
return; // They pressed Escape or exited the input box.
}

const yesText = 'Yes';
vscode.window
.showQuickPick(['No', yesText], {
title: `Thanks so much! Can I send you occasional emails with CI/CD tips? You can unsubscribe any time. I'll never share your email.`,
})
.then(async (selection) => {
const optedIntoNewsletter = selection === yesText;
const enteredName = await vscode.window.showInputBox({
title: 'Name',
prompt: `Thanks a lot! What's your first name?`,
});

vscode.window.showInformationMessage(
'Thanks a lot, your free preview has started!',
{ detail: 'Local CI free preview' }
);
sendEnteredEmail(enteredEmail, enteredName, optedIntoNewsletter);
});
});
});
if (enteredName === undefined) {
sendEnteredEmail(enteredEmail); // They pressed Escape or exited the input box.
return;
}

const yesText = 'Yes';
const optInSelection = await vscode.window.showQuickPick(['No', yesText], {
title: `Thanks so much! Can I send you occasional emails with CI/CD tips? You can unsubscribe any time. I'll never share your email.`,
});
const optedIntoNewsletter = optInSelection === yesText;
sendEnteredEmail(enteredEmail, enteredName, optedIntoNewsletter);

const getStartedText = 'Get started';
const buttonClicked = await vscode.window.showInformationMessage(
'Thanks a lot, your free preview has started!',
{ detail: 'Local CI free preview' },
getStartedText
);

if (buttonClicked === getStartedText) {
vscode.commands.executeCommand(
'workbench.action.openWalkthrough',
`${EXTENSION_ID}#welcomeLocalCi`
);
reporter.sendTelemetryEvent('click.getStarted');
}
}
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载