-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(misc): add onboarding a/b testing
- Loading branch information
1 parent
efa59fa
commit 59d155e
Showing
18 changed files
with
320 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
const outputMessages = { | ||
'create-nx-workspace-success-ci-setup': [ | ||
{ | ||
code: 'nx-cloud-workspace-push-goto', | ||
createMessage: (url: string) => ({ | ||
title: `Your Nx Cloud workspace is ready.`, | ||
type: 'success', | ||
bodyLines: [ | ||
`To claim it, connect it to your Nx Cloud account:`, | ||
`- Push your repository to your git hosting provider.`, | ||
`- Go to the following URL to connect your workspace to Nx Cloud:`, | ||
'', | ||
`${url}`, | ||
], | ||
}), | ||
}, | ||
{ | ||
code: 'nx-cloud-powered-ci-setup-visit', | ||
createMessage: (url: string) => ({ | ||
title: `Your CI setup powered by Nx Cloud is almost complete.`, | ||
type: 'success', | ||
bodyLines: [`Finish it by visiting: ${url}`], | ||
}), | ||
}, | ||
{ | ||
code: 'nx-cloud-powered-ci-setup-connect', | ||
createMessage: (url: string) => ({ | ||
title: `Your CI setup powered by Nx Cloud is almost complete.`, | ||
type: 'success', | ||
bodyLines: [`Connect your repository: ${url}`], | ||
}), | ||
}, | ||
{ | ||
code: 'ci-setup-visit', | ||
createMessage: (url: string) => ({ | ||
title: `Your CI setup is almost complete.`, | ||
type: 'success', | ||
bodyLines: [`Finish it by visiting: ${url}`], | ||
}), | ||
}, | ||
{ | ||
code: 'ci-setup-connect', | ||
createMessage: (url: string) => ({ | ||
title: `Your CI setup is almost complete.`, | ||
type: 'success', | ||
bodyLines: [`Connect your repository: ${url}`], | ||
}), | ||
}, | ||
], | ||
'create-nx-workspace-success-cache-setup': [ | ||
{ | ||
code: 'nx-cloud-workspace-push-goto', | ||
createMessage: (url: string) => ({ | ||
title: `Your Nx Cloud workspace is ready.`, | ||
type: 'success', | ||
bodyLines: [ | ||
`To claim it, connect it to your Nx Cloud account:`, | ||
`- Push your repository to your git hosting provider.`, | ||
`- Go to the following URL to connect your workspace to Nx Cloud:`, | ||
'', | ||
`${url}`, | ||
], | ||
}), | ||
}, | ||
{ | ||
code: 'nx-cloud-remote-cache-setup-finish', | ||
createMessage: (url: string) => ({ | ||
title: `Your Nx Cloud remote cache setup is almost complete.`, | ||
type: 'success', | ||
bodyLines: [`Finish it by visiting: ${url}`], | ||
}), | ||
}, | ||
{ | ||
code: 'nx-cloud-remote-cache-setup-connect', | ||
createMessage: (url: string) => ({ | ||
title: `Your Nx Cloud remote cache setup is almost complete.`, | ||
type: 'success', | ||
bodyLines: [`Connect your repository: ${url}`], | ||
}), | ||
}, | ||
{ | ||
code: 'remote-cache-visit', | ||
createMessage: (url: string) => ({ | ||
title: `Your remote cache setup is almost complete.`, | ||
type: 'success', | ||
bodyLines: [`Finish it by visiting: ${url}`], | ||
}), | ||
}, | ||
{ | ||
code: 'remote-cache-connect', | ||
createMessage: (url: string) => ({ | ||
title: `Your remote cache setup is almost complete.`, | ||
type: 'success', | ||
bodyLines: [`Connect your repository: ${url}`], | ||
}), | ||
}, | ||
], | ||
} as const; | ||
type OutputMessageKey = keyof typeof outputMessages; | ||
|
||
class ABTestingMessages { | ||
private selectedMessages: Record<string, number> = {}; | ||
getMessageFactory(key: OutputMessageKey) { | ||
console.log({ key, outputMessages }); | ||
if (this.selectedMessages[key] === undefined) { | ||
if (process.env.NX_GENERATE_DOCS_PROCESS === 'true') { | ||
this.selectedMessages[key] = 0; | ||
} else { | ||
this.selectedMessages[key] = Math.floor( | ||
Math.random() * outputMessages[key].length | ||
); | ||
} | ||
} | ||
return outputMessages[key][this.selectedMessages[key]!]; | ||
} | ||
} | ||
|
||
const messages = new ABTestingMessages(); | ||
|
||
export function getMessageFactory(key: OutputMessageKey) { | ||
return messages.getMessageFactory(key); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.