Skip to content
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

record quickstart usage to telemetry, w/tests #804

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/commands/app/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ class InitCommand extends TemplatesCommand {
}

async withQuickstart (fullRepo, githubPat) {
// telemetry hook for quickstart installs
await this.config.runHook('telemetry', { data: `installQuickstart:${fullRepo}` })

const octokit = new Octokit({
auth: githubPat ?? '',
userAgent: 'ADP App Builder v1'
Expand Down
7 changes: 6 additions & 1 deletion test/commands/app/init.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ beforeEach(() => {

command = new TheCommand([])
command.config = {
findCommand: jest.fn(() => ({}))
findCommand: jest.fn(() => ({})),
runHook: jest.fn()
}

command.selectTemplates = jest.fn()
Expand Down Expand Up @@ -313,6 +314,7 @@ describe('--no-login', () => {
command.argv = ['--no-login', '--standalone-app']
await command.run()

expect(command.config.runHook).not.toHaveBeenCalled()
expect(command.installTemplates).toHaveBeenCalledWith(installOptions)
expect(command.runCodeGenerators).toHaveBeenCalledWith(['base-app', 'add-ci', 'application'], false, 'cwd', 'basic')
expect(LibConsoleCLI.init).not.toHaveBeenCalled()
Expand All @@ -328,6 +330,7 @@ describe('--no-login', () => {
command.argv = ['--no-login', '--repo=adobe/appbuilder-quickstarts/qr-code']
await command.run()

expect(command.config.runHook).toHaveBeenCalled()
expect(command.installTemplates).not.toHaveBeenCalled()
expect(LibConsoleCLI.init).not.toHaveBeenCalled()
expect(importHelperLib.importConfigJson).not.toHaveBeenCalled()
Expand Down Expand Up @@ -356,6 +359,7 @@ describe('--no-login', () => {
command.argv = ['--login', '--repo=adobe/appbuilder-quickstarts/qr-code']
await command.run()

expect(command.config.runHook).toHaveBeenCalled()
expect(command.installTemplates).not.toHaveBeenCalled()
expect(LibConsoleCLI.init).toHaveBeenCalled()
expect(importHelperLib.importConfigJson).toHaveBeenCalled()
Expand All @@ -375,6 +379,7 @@ describe('--no-login', () => {

await command.run()

expect(command.config.runHook).toHaveBeenCalled()
expect(command.error).toHaveBeenCalledWith('--repo does not point to a valid Adobe App Builder app')
expect(command.installTemplates).not.toHaveBeenCalled()
expect(LibConsoleCLI.init).not.toHaveBeenCalled()
Expand Down