Skip to content

Commit

Permalink
chore(gatsby): Increase chances of seeing feedback request 5x (#22393)
Browse files Browse the repository at this point in the history
  • Loading branch information
blainekasten committed Mar 19, 2020
1 parent d4d347b commit 3380e89
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions packages/gatsby/src/utils/feedback.ts
Expand Up @@ -22,14 +22,7 @@ export function showFeedbackRequest(): void {
report.log(`\nGive us your feedback here: https://gatsby.dev/feedback\n\n`)
}

// We are only showing feedback requests to users in if they pass a few checks:
// 1. They pass a Math.random() check. This is a skateboard version of not sending out all requests in one day.
// 2. They haven't disabled the feedback mechanism
// 3. They don't have the environment variable to disable feedback present
// 4. It's been at least 3 months since the last feedback request
// 5. They are on the most recent version of Gatsby
export async function userPassesFeedbackRequestHeuristic(): Promise<boolean> {
// Heuristic 1
const randomChanceToBeTrue = (): boolean => {
// This is spreading the request volume over the quarter.
// We are grabbing a randomNumber within the spread of a first day
// of a quarter, to the last day
Expand All @@ -41,7 +34,28 @@ export async function userPassesFeedbackRequestHeuristic(): Promise<boolean> {
)
const randomNumberWithinQuarter = randomNumber * currentQuarter

if (randomNumberWithinQuarter !== getDayOfYear(new Date())) {
return randomNumberWithinQuarter === getDayOfYear(new Date())
}

// We are only showing feedback requests to users in if they pass a few checks:
// 1. They pass a Math.random() check. This is a skateboard version of not sending out all requests in one day.
// 2. They haven't disabled the feedback mechanism
// 3. They don't have the environment variable to disable feedback present
// 4. It's been at least 3 months since the last feedback request
// 5. They are on the most recent version of Gatsby
export async function userPassesFeedbackRequestHeuristic(): Promise<boolean> {
// Heuristic 1
// We originally wrote this to have a single chance of hitting.
// We wanted to up the chance by 5x, so this is our crude - temporary -
// way of giving the user 5 chances to passing.
const randomlyPassingHeuristic =
randomChanceToBeTrue() ||
randomChanceToBeTrue() ||
randomChanceToBeTrue() ||
randomChanceToBeTrue() ||
randomChanceToBeTrue()

if (!randomlyPassingHeuristic) {
return false
}

Expand Down

0 comments on commit 3380e89

Please sign in to comment.