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

add user data for cookies for marketing #42634

Merged
merged 9 commits into from
Oct 7, 2021

Conversation

maureensturgeon
Copy link
Contributor

@maureensturgeon maureensturgeon commented Sep 22, 2021

The changes here add cookies which can be used by marketing to segment the user experience on Optimizely. The cookies will be added when the teacher visits the homepage and will be removed on log-out. I was able to verify that the cookies were being set through tests and by running locally.

Links

Testing story

Tested through unit tests that set-cookies header had expected values

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@maureensturgeon maureensturgeon marked this pull request as ready for review October 1, 2021 20:29
@maureensturgeon maureensturgeon requested a review from a team as a code owner October 1, 2021 20:29
@maureensturgeon maureensturgeon requested a review from a team October 1, 2021 20:29
Copy link
Contributor

@jamescodeorg jamescodeorg left a comment

Choose a reason for hiding this comment

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

Nice work!

Did you mean to omit schema_cache.yml from this PR?

private

def account_age_in_years
Copy link
Contributor

Choose a reason for hiding this comment

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

Just checking that we always want to round down here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was on the fence about this, I'll change it to .round

end

# Returns a list of all courses that the teacher currently has sections for
def courses_being_taught
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we call this something like curriculums_being_taught or something similar? (I'm worried that course means something specific in the model.)

end

def self.marketing_segment_data_keys
%w(locale account_age_in_years grades courses has_attended_pd within_usschool_percent_frl school_title_i)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a test that checks that this list is in sync with the data returned above?

@@ -23,7 +23,7 @@ def setup

sign_in_as section.teacher

assert_queries 11 do
assert_queries 15 do
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we worried about all of these query counts going up by so much? Do we incur this cost on every request or just login?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These requests are made in after_set_user, so it should just be when the user logs in. It follows the pattern for setting cookies at login like the experiments cookie. It's not ideal that I've added extra queries, but I didn't see a great alternative.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved where the cookies get set to the homepage which eliminated the extra queries.

Copy link
Contributor

@jamescodeorg jamescodeorg left a comment

Choose a reason for hiding this comment

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

🎉

@maureensturgeon maureensturgeon merged commit f1498b7 into staging Oct 7, 2021
@maureensturgeon maureensturgeon deleted the maureen/LP-2039-segment-teacher-banner branch October 7, 2021 16:10
@breville
Copy link
Member

Very interesting integration with Optimizely! Just curious about a couple things:

  • Is there any concern about exposing this particular data via non-HttpOnly cookies? (Understood that Optimizely needs them to be accessible by the client.)
  • This adds quite a few cookies, which we need to track for policy reasons (cc @dju90). Would it be possible to put all of this into a single cookie? I think we could then give Optimizely some JS to parse this.

@maureensturgeon
Copy link
Contributor Author

maureensturgeon commented Feb 17, 2022

Very interesting integration with Optimizely! Just curious about a couple things:

  • Is there any concern about exposing this particular data via non-HttpOnly cookies? (Understood that Optimizely needs them to be accessible by the client.)

Before I added these cookies, I confirmed with Travis that there are no data privacy issues with adding these cookies.

  • This adds quite a few cookies, which we need to track for policy reasons (cc @dju90). Would it be possible to put all of this into a single cookie? I think we could then give Optimizely some JS to parse this.

The benefits of having the data in separate cookies is it makes it easy for marketing to set up their own custom audiences, but I think that you're right, it'd be possible to combine these into one cookie, it would just take a bit of additional work/guidance for marketing to set up new audiences.

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.

None yet

3 participants