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

Get single page notification button from personalisation API on load #2443

Merged
merged 1 commit into from
Nov 18, 2021

Conversation

danacotoran
Copy link
Contributor

@danacotoran danacotoran commented Nov 11, 2021

The single page notification button exists in two states: default (unsubscribed) and already subscribed.

If a user is authenticated and already subscribed to email notifications on the current page, the button should say "Stop getting emails about this page". To request the user data for this layer of personalisation, there is a need to bypass the CDN, however it is not practical to serve all such requests from origin (especially on relatively high traffic pages such as the ones it is likely this feature will be added to).
As such the solution we've landed on is to use JS to perform this check on page load as an enhancement.

account-api serves the button HTML from the /api/personalisation/check-email-subscription endpoint – if the user is authenticated and already subscribed to the current page, the endpoint serves the "Already subscribed" variant of the button. The button that already exists on the page is replaced with this updated version, so the user can see that they are already subscribed to emails about the current page.

@govuk-ci govuk-ci temporarily deployed to components-gem-pr-2443 November 11, 2021 17:25 Inactive
@danacotoran danacotoran force-pushed the js-enhancement-single-page-notif-button branch from 7d4ccc8 to 0daaec7 Compare November 11, 2021 17:36
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-2443 November 11, 2021 17:36 Inactive
@danacotoran danacotoran force-pushed the js-enhancement-single-page-notif-button branch from 0daaec7 to 6282744 Compare November 12, 2021 09:46
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-2443 November 12, 2021 09:46 Inactive
@danacotoran danacotoran changed the title WIP: get button from personalisation API Get single page notification button from personalisation API on load Nov 12, 2021
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-2443 November 12, 2021 12:25 Inactive
@danacotoran danacotoran force-pushed the js-enhancement-single-page-notif-button branch from 117501d to 6282744 Compare November 12, 2021 12:28
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-2443 November 12, 2021 12:28 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-2443 November 12, 2021 12:34 Inactive
@danacotoran danacotoran force-pushed the js-enhancement-single-page-notif-button branch from c8e31a1 to 7c8480e Compare November 12, 2021 13:05
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-2443 November 12, 2021 13:06 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-2443 November 12, 2021 13:13 Inactive
@danacotoran danacotoran force-pushed the js-enhancement-single-page-notif-button branch from aa4e566 to 1be1a48 Compare November 12, 2021 13:15
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-2443 November 12, 2021 13:16 Inactive
@danacotoran danacotoran marked this pull request as ready for review November 12, 2021 13:21
@danacotoran danacotoran force-pushed the js-enhancement-single-page-notif-button branch from 1be1a48 to 22c3bb2 Compare November 12, 2021 15:33
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-2443 November 12, 2021 15:33 Inactive
@danacotoran danacotoran force-pushed the js-enhancement-single-page-notif-button branch from 22c3bb2 to 7f39893 Compare November 12, 2021 16:23
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-2443 November 12, 2021 16:24 Inactive
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-2443 November 12, 2021 17:01 Inactive
@danacotoran danacotoran force-pushed the js-enhancement-single-page-notif-button branch from 0b6cac3 to 18a8175 Compare November 15, 2021 09:44
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-2443 November 15, 2021 09:44 Inactive
@danacotoran danacotoran force-pushed the js-enhancement-single-page-notif-button branch from 18a8175 to 78b21e1 Compare November 15, 2021 19:26
@govuk-ci govuk-ci had a problem deploying to components-gem-pr-2443 November 15, 2021 19:27 Failure
@danacotoran danacotoran force-pushed the js-enhancement-single-page-notif-button branch from 78b21e1 to b3595d2 Compare November 15, 2021 19:30
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-2443 November 15, 2021 19:31 Inactive
@danacotoran danacotoran force-pushed the js-enhancement-single-page-notif-button branch from b3595d2 to 96e695d Compare November 16, 2021 11:00
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-2443 November 16, 2021 11:01 Inactive
@danacotoran danacotoran force-pushed the js-enhancement-single-page-notif-button branch from 96e695d to f7bfb15 Compare November 16, 2021 11:41
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-2443 November 16, 2021 11:42 Inactive
@danacotoran danacotoran force-pushed the js-enhancement-single-page-notif-button branch from f7bfb15 to a69b55d Compare November 17, 2021 10:55
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-2443 November 17, 2021 10:55 Inactive
Introduce JS that calls our personalisation API on page load. If the
user is authenticated, and already subscribed to email notifications on
the current page, the account-api serves the "Already subscribed"
version of the button HTML.

Add data attributes for analytics.
@danacotoran danacotoran force-pushed the js-enhancement-single-page-notif-button branch from a69b55d to 674540b Compare November 18, 2021 10:08
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-2443 November 18, 2021 10:08 Inactive
@danacotoran danacotoran merged commit 695e7c6 into master Nov 18, 2021
@danacotoran danacotoran deleted the js-enhancement-single-page-notif-button branch November 18, 2021 10:20
@danacotoran danacotoran mentioned this pull request Nov 18, 2021
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.

5 participants