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

Determine the first date to show feedback question banner more randomly #18315

Merged
merged 3 commits into from Nov 15, 2021

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented Nov 15, 2021

Description:

This should randomize the first time the feedback banner is shown

@tsteur is this random enough?

follow-up to #18308

Review

@sgiehl sgiehl added the Needs Review PRs that need a code review label Nov 15, 2021
@sgiehl sgiehl added this to the 4.6.0 milestone Nov 15, 2021
Copy link
Member

@tsteur tsteur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sgiehl it looks random. However, if I see this correct there is one problem:

Date::factory($userCreatedDate)->addMonth(6)->getTimestamp() > $now

This would apply to a lot of users after updating? Would potentially most users get to see this after updating if their users was created more than 6 months ago? I think I mention something like we may want to check something like if the user was created between 6 and 6.5 months ago.

For this to work we might actually need to do a modulo as a user might have been created 1 year ago. Would we need to find out number of days since signing up, and then do a modulo (like $numDaysSinceRegister modulo 6*30)?

plugins/Feedback/Feedback.php Outdated Show resolved Hide resolved
@sgiehl
Copy link
Member Author

sgiehl commented Nov 15, 2021

@tsteur updated the code. I had actually used the wrong line of code. It should now do what I had described in the PR.
Users created within the last 6 months will see the banner 6 months after the creation. Users that are older will get a random date within the next 6 months.

@tsteur
Copy link
Member

tsteur commented Nov 15, 2021

@sgiehl I'm not sure if it would still cause every user that was created like a year ago to see this at the same time?

Like assuming creation date was 1.5 years ago. That means !empty($userCreatedDate) && Date::factory($userCreatedDate)->addMonth(6)->getTimestamp() > $now === true meaning it goes into the if block.

It then adds 6 months to the creation date in $nextReminder = Date::factory($userCreatedDate)->addMonth(6)->toString('Y-m-d');. Meaning nextReminder is in this case 1 year ago. Meaning next page load we would show it?

The same would happen for users signed up 1 year ago and 2 years ago etc. Basically, as soon as they upgrade to the next version, they would all get to see the feedback screen?

Or maybe I'm missing something?

@sgiehl
Copy link
Member Author

sgiehl commented Nov 15, 2021

@tsteur it actually should only go into the if block if the creation date is within the past 6 months. If it is older (creationdate + 6 months) should be lower than $now. Or did I get something wrong in the if statement 🤔

@justinvelluppillai
Copy link
Contributor

Looks right to me, if the creation date plus six months is less than now it will skip the if block

@tsteur
Copy link
Member

tsteur commented Nov 15, 2021

I see, makes sense. Sorry about that. So in that case we then just pick something randomly. I thought initially to make it then continuous so we show it after 1 year, 1.5 years, 2 years but we make it instead randomly. That's why I read it wrong. That should be all fine though and works too 👍

Ideally there were tests for it @sgiehl as working with date etc there's always quickly a bug introduced. But I'm happy to skip it to get it into the RC.

@tsteur
Copy link
Member

tsteur commented Nov 15, 2021

Meaning feel free to merge if tests pass.

@sgiehl
Copy link
Member Author

sgiehl commented Nov 15, 2021

@tsteur it should only be the first date that is picked randomly in that case. Once it was shown and clicked away it will be shown again after 6 months.

@tsteur
Copy link
Member

tsteur commented Nov 15, 2021

Yep 👍 all good.

I meant the first one we show after 1 year, or 1.5 year etc. But that's not important actually just something I had in my mind somehow. Picking the first date randomly is probably even better 👍 so all good

@sgiehl sgiehl added the not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. label Nov 15, 2021
@sgiehl sgiehl merged commit 3313293 into 4.x-dev Nov 15, 2021
@sgiehl sgiehl deleted the feedbackquestion branch November 15, 2021 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants