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

Feature/referals #27

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft

Feature/referals #27

wants to merge 16 commits into from

Conversation

Naapperas
Copy link
Member

@Naapperas
Copy link
Member Author

UHHHHHHH, what?

I don't know what just happened lmao but will try a rebase.

@Naapperas Naapperas marked this pull request as draft August 4, 2024 17:49
@limwa
Copy link
Member

limwa commented Aug 4, 2024

Yeah, you just need to pull the changes from main (git checkout main && git pull --rebase) and then rebase this branch on main

Those commits got squashed and it caused some problems... The golden rule of rebase has its merit

database/helpers.php Outdated Show resolved Hide resolved
Comment on lines 36 to 44
// FIXME: This code is currently in the home page,
// where should the referral redirect to?
$referral_code = $request->input('ref');
if ($referral_code != null) {
// XXX: Cookie is stored forever, the limit is 400 days,
// browsers seem to cap it later
Cookie::queue(Cookie::forever('link_referral', $referral_code));
}

Choose a reason for hiding this comment

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

This stores a cookie with the referral code in it, it can be obtained with Cookie::get("link_referral").
Cookie::queue sends the cookie to the eventual response.

I researched a bit, and storing a referral code does not appear to require user permission, it is not a user's personal information. However, this cookie is not essential for the website to work.
This website (www.cookielawinfo.com/cookie-consent/) shows these bullet points as reasons to requiring permission:

  • Cookies that are used for direct marketing;
  • Cookies that are used to track users’ behavior across multiple websites;
  • Cookies that are used to compile a profile of a user’s interests, habits and preferences;
  • Third-party cookies, in other words, cookies placed on your website by someone other than the owner of the site you are visiting;
  • Socially shared content, for example, if someone shares content from your website on Facebook, or tweets a link to it; and
  • First-party cookies that are used for tracking.

Copy link
Member Author

Choose a reason for hiding this comment

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

Since we do not explicitly require user permission I believe it is fine for us to store them as is. There is a Laravel package to handle cookie authorizations if we want to though, it's this one by @spatie

Copy link
Member Author

Choose a reason for hiding this comment

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

I might need a refresher on this but why did you choose to go with the cookie route?

Choose a reason for hiding this comment

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

The idea was to store the referral in case the person does not register right away, once she comes back to the website we already have the referral code.

Choose a reason for hiding this comment

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

I'll mention this in tomorrow's meeting, however, I do think if cookies are used, I should change this to the register route and use your logic.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, something doesn't sit quite right with me but I can't still figure out what it is so for now I'll just accept this solution. If something better comes up I'll open up a discussion.

Just a question: one of the requirements for this feature is associate the referrer of the link to an account it the person had a session open already or logs in after using the referral link. I'm not seeing any way to do this other than storing this information on the server. Thoughts?

Choose a reason for hiding this comment

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

I think we store it on the server when the user registers, and just change that value if he already has an account, so, the cookies part would only be for someone who uses a referral link but does not register right away.

Copy link
Member Author

@Naapperas Naapperas left a comment

Choose a reason for hiding this comment

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

I had written this piece of code a while back but apparently forgot to push it upstream.

@AvilaAndre
Copy link

The points in the test cases I added are not connected to those in the database. Are we supposed to keep the editions table? If so, do referral points mix with the other types of points that may exist in the future? The logic implemented isn't right yet as this part is still missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Direct Referral System
3 participants