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

Cookie prompt management #312

Merged
merged 5 commits into from
Feb 22, 2022
Merged

Cookie prompt management #312

merged 5 commits into from
Feb 22, 2022

Conversation

sammacbeth
Copy link
Contributor

Task/Issue URL: https://app.asana.com/0/72649045549333/1201033079931464/f
Tech Design URL: https://app.asana.com/0/481882893211075/1201233831195884/f
CC: @tomasstrba

Description:
Implements cookie prompt management using @cliqz/autoconsent. This is currently without a UI as the design project is not yet underway, but I'm opening this PR to get early feedback on the implementation.

We're running that library in a background Webview and exposing an API for it to native code. This API allows:

  • Checking if there's a consent provider we understand on a specific tab.
  • Checking if the popup is being displayed on the tab.
  • Clicking through the popup to opt the user out.
  • Testing if the page has correctly stored the opt-out.

The JS code component is currently in the Submodules folder as a simple project which provides the glue between the native messaging and autoconsent library. This is not currently an actual git submodule, but it could make sense to have it as one if we wish to using this implementation on iOS too.

Steps to test this PR:

  1. Visit theguardian.com
  2. The consent popup should be automatically opted out of.

The test page in duckduckgo/privacy-test-pages#65 has a more comprehensive set of test pages.

Testing checklist:

  • Test with Release configuration

Internal references:

Software Engineering Expectations
Technical Design Template
When ready for review, remember to post the PR in MM

@tomasstrba
Copy link
Contributor

Sam, please, would you like to have this reviewed?

@sammacbeth
Copy link
Contributor Author

@tomasstrba I've just added remote config support, so I think it's good to go through a round of review. Thanks!

@tomasstrba tomasstrba self-assigned this Nov 10, 2021
Copy link
Contributor

@tomasstrba tomasstrba left a comment

Choose a reason for hiding this comment

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

@sammacbeth, thanks for creating this PR for getting the feedback sooner! 👍 In general, it is pretty good, I only found few tips for making the code more readable and maintainable in the future.

Plus, there are few inconsistencies in file management:

  1. autoconsent folder shouldn't be commited to Submodules if it isn't true git submodule.

  2. There are inconsistencies between Xcode file structure and real file structure (Autoconsent folder, Submodules folder). Ideally, it should be the same.

DuckDuckGo/Autoconsent/AutoconsentUserScript.swift Outdated Show resolved Hide resolved
DuckDuckGo/Autoconsent/AutoconsentUserScript.swift Outdated Show resolved Hide resolved
DuckDuckGo/Autoconsent/AutoconsentUserScript.swift Outdated Show resolved Hide resolved
DuckDuckGo/Common/Extensions/URLExtension.swift Outdated Show resolved Hide resolved
@tomasstrba tomasstrba assigned sammacbeth and unassigned tomasstrba Nov 11, 2021
@sammacbeth
Copy link
Contributor Author

Thanks for the review @tomasstrba. I've addressed your inline comments. I've also:

  • Added unit-tests for config.featureEnabled.
  • Added integration tests for the feature. These depend on Add autoconsent test page privacy-test-pages#65 being merged before they will pass.
  • Fixed CMP checking for the first page load (previously there was a race when the background page wasn't get ready for the API calls).

Regarding file managment:

  1. I put this code in the Submodules folder as I imagine it could easily become a submodule if we decide to add this to iOS too. However in the meantime it could be somewhere else. Should I just create a new directory in the root for it, or nest it inside DuckDuckGo/Autoconsent? I'm not sure what the convention should be for code which should not be bundled in the build (e.g. node_modules folder).
  2. This is related to the first point. The autoconsent submodule contains files in dist which should be included in the browser bundle (so we can load the background page and userscript). Is there a way to make that happen without adding them to the DuckDuckGo/Autoconent folder in Xcode?

Copy link
Contributor

@brindy brindy left a comment

Choose a reason for hiding this comment

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

Sorry for butting in, but I've added a few comments to help make this clear and align with our (granted implied) code style.

DuckDuckGo/Autoconsent/AutoconsentUserScript.swift Outdated Show resolved Hide resolved
DuckDuckGo/Autoconsent/AutoconsentUserScript.swift Outdated Show resolved Hide resolved
DuckDuckGo/Autoconsent/AutoconsentUserScript.swift Outdated Show resolved Hide resolved
@tomasstrba
Copy link
Contributor

@sammacbeth, sorry for later responses to your questions:

  1. Ideally, we include another repo as submodule and use the code from there. Is the code currently copied from somewhere?
  2. Please see "Copy Bundle Resources" phase in Xcode, where you can specify what is copied into the bundle.

Screen Shot 2021-11-18 at 14 02 22

.

@sammacbeth sammacbeth force-pushed the sammacbeth/autoconsent branch from bb25b41 to 474509e Compare November 26, 2021 09:54
@sammacbeth sammacbeth force-pushed the sammacbeth/autoconsent branch 5 times, most recently from 18e6c49 to dd14037 Compare December 14, 2021 09:20
@tomasstrba tomasstrba assigned tomasstrba and unassigned sammacbeth Dec 22, 2021
Copy link
Contributor

@tomasstrba tomasstrba left a comment

Choose a reason for hiding this comment

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

Sam, this is really nice code! 🥇 🎖️

Please, could merge develop into this branch so I can compile with the latest Xcode? Then I will test the functionality.

DuckDuckGo/BrowserTab/Model/UserScripts.swift Outdated Show resolved Hide resolved
DuckDuckGo/Autoconsent/AutoconsentBackground.swift Outdated Show resolved Hide resolved
@tomasstrba tomasstrba assigned sammacbeth and unassigned tomasstrba Jan 4, 2022
@sammacbeth sammacbeth force-pushed the sammacbeth/autoconsent branch 2 times, most recently from a82720f to 82f7c22 Compare February 9, 2022 15:26
@sammacbeth sammacbeth force-pushed the sammacbeth/autoconsent branch 3 times, most recently from 4d69127 to 637bea9 Compare February 17, 2022 13:49
Copy link
Contributor

@tomasstrba tomasstrba left a comment

Choose a reason for hiding this comment

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

@sammacbeth, nice work! 👏 Can't wait to have this feature live 🚀

Code in general looks good and I like the architecture. There are few polishing tips so the style is aligned with Swift conventions. Sorry if they are a bit annoying

The feature worked for me after visiting theguardian.com, unfortunately these are the issues I found:

  • After loading of the website, there is a period of time I can't do anything with the site. It feels like the main thread is blocked, but only the current webview seems to be unresponsive
  • If you open a new tab, start loading theguardian.com and immediately switch the tab, you still get "Popups managed" info
  • After popup is dismissed, the website scroll position is reset to the beginning (probably known issue)

DuckDuckGo/Fire/Model/Fire.swift Outdated Show resolved Hide resolved
DuckDuckGo/Autoconsent/AutoconsentBackground.swift Outdated Show resolved Hide resolved
DuckDuckGo/Autoconsent/AutoconsentUserScript.swift Outdated Show resolved Hide resolved
DuckDuckGo/Autoconsent/AutoconsentBackground.swift Outdated Show resolved Hide resolved
DuckDuckGo/Autoconsent/AutoconsentBackground.swift Outdated Show resolved Hide resolved
DuckDuckGo/Autoconsent/AutoconsentBackground.swift Outdated Show resolved Hide resolved
@sammacbeth sammacbeth force-pushed the sammacbeth/autoconsent branch from cb66ba0 to 915a0d5 Compare February 21, 2022 10:21
@tomasstrba tomasstrba assigned tomasstrba and unassigned sammacbeth Feb 22, 2022
Copy link
Contributor

@tomasstrba tomasstrba left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀 🚀 🚀

Thanks for making the code more readable! If all reviews including the product review are finished, feel free to merge 🥇

Good job! 👏

@tomasstrba tomasstrba assigned sammacbeth and unassigned tomasstrba Feb 22, 2022
Increase test timeout for CI

Updated cookie-consent copy.

Fix error when trying to run an action on a closed tab.

Break autoconsent popover message

Make autoconsent popover open underneath the urlbar.

Move preferences scrollbar to the edge of the window

Move cookie settings above GPC.

Update copy
@sammacbeth sammacbeth force-pushed the sammacbeth/autoconsent branch from 915a0d5 to 8fa0712 Compare February 22, 2022 10:05
@sammacbeth sammacbeth merged commit e0345e7 into develop Feb 22, 2022
@sammacbeth sammacbeth deleted the sammacbeth/autoconsent branch February 22, 2022 10:25
samsymons added a commit that referenced this pull request Feb 22, 2022
* develop:
  Waiting for ContentBlockingRules to be applied before navigation (#402)
  Cookie prompt management (#312)
  Pass config data to Autofill UserScript (#418)
samsymons added a commit that referenced this pull request Feb 22, 2022
* develop:
  Waiting for ContentBlockingRules to be applied before navigation (#402)
  Cookie prompt management (#312)
  Pass config data to Autofill UserScript (#418)
  Fix video fullscreen exit crash (#295)
samsymons added a commit that referenced this pull request Feb 23, 2022
…ntication

# By Alexey Martemyanov (1) and others
* sam/logins-filtering-and-sorting:
  Disable the search field when editing.
  Waiting for ContentBlockingRules to be applied before navigation (#402)
  Cookie prompt management (#312)
  Pass config data to Autofill UserScript (#418)

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift
#	DuckDuckGo/Preferences/Model/PreferenceSections.swift
#	DuckDuckGo/Preferences/View/PrivacySecurityPreferencesTableCellView.xib
jonathanKingston pushed a commit that referenced this pull request Feb 25, 2022
* Consent popup management feature

Increase test timeout for CI

Updated cookie-consent copy.

Fix error when trying to run an action on a closed tab.

Break autoconsent popover message

Make autoconsent popover open underneath the urlbar.

Move preferences scrollbar to the edge of the window

Move cookie settings above GPC.

Update copy

* Another copy tweak.

* Code tidying.

* Extract protocol for autoconsent cache clear.

* Final copy
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.

4 participants