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 cookie privacy setting to embed via queryString parameter #13510

Merged
merged 9 commits into from
Feb 12, 2018

Conversation

jesusbotella
Copy link
Contributor

@jesusbotella jesusbotella commented Feb 6, 2018

This PR adds the possibility to opt out of cookies in Builder embed.

When this Do not track mode is enabled via the query string parameter (cookies=0), we do not include either the Google Analytics script or the TrackJS script.

I talked to @javitonino and he told me that the best way to do it was to prevent the script from inserting, instead of conditional insertion in the template as I thought at first. This behaviour will allow us to share the same behaviour in all of our views by inserting cookies=0 query parameter.

The services adding cookies in our platform are Google Analytics, Hubspot, FullStory and TrackJS. FullStory script is not currently being rendered in our embed views, but as we need to be GDPR compliant I thought it was a good idea to disable it as well.

Related to https://github.com/CartoDB/support/issues/1296

@@ -20,7 +20,7 @@ def frontend_config_hash(user = current_user)
google_analytics_domain: Cartodb.get_config(:google_analytics, 'domain'),
hubspot_enabled: CartoDB::Hubspot::instance.enabled?,
intercom_app_id: Cartodb.get_config(:intercom, 'app_id'),
fullstory_enabled: Cartodb.get_config(:fullstory, 'org').present? && user && user.account_type.casecmp('FREE').zero?,
fullstory_enabled: Cartodb.get_config(:fullstory, 'org').present? && user && user.account_type.casecmp('FREE').zero? && params[:cookies] != '0',

Choose a reason for hiding this comment

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

Line is too long. [159/120]

@@ -119,7 +119,7 @@ def insert_hubspot_form(form = 'newsletter')
end

def insert_fullstory
if Cartodb.get_config(:fullstory, 'org').present? && current_user && current_user.account_type.casecmp('FREE').zero?
if Cartodb.get_config(:fullstory, 'org').present? && current_user && current_user.account_type.casecmp('FREE').zero? && params[:cookies] != '0'

Choose a reason for hiding this comment

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

Line is too long. [147/120]

@@ -20,7 +20,7 @@ def frontend_config_hash(user = current_user)
google_analytics_domain: Cartodb.get_config(:google_analytics, 'domain'),
hubspot_enabled: CartoDB::Hubspot::instance.enabled?,
intercom_app_id: Cartodb.get_config(:intercom, 'app_id'),
fullstory_enabled: Cartodb.get_config(:fullstory, 'org').present? && user && user.account_type.casecmp('FREE').zero?,
fullstory_enabled: Cartodb.get_config(:fullstory, 'org').present? && user && user.account_type.casecmp('FREE').zero? && params[:cookies] != '0',

Choose a reason for hiding this comment

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

Line is too long. [159/120]

@@ -119,7 +119,7 @@ def insert_hubspot_form(form = 'newsletter')
end

def insert_fullstory
if Cartodb.get_config(:fullstory, 'org').present? && current_user && current_user.account_type.casecmp('FREE').zero?
if Cartodb.get_config(:fullstory, 'org').present? && current_user && current_user.account_type.casecmp('FREE').zero? && params[:cookies] != '0'

Choose a reason for hiding this comment

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

Line is too long. [147/120]

@jesusbotella jesusbotella removed their assignment Feb 9, 2018
@alrocar alrocar self-requested a review February 9, 2018 14:03
Copy link
Contributor

@alrocar alrocar left a comment

Choose a reason for hiding this comment

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

LGTM

I don't think this is affecting this use case, but there are some html with the analytics and hubspot scripts hardcoded, tracked in this issue

@jesusbotella jesusbotella force-pushed the 1296-embed-no-tracking branch 2 times, most recently from f0d127a to 500409a Compare February 9, 2018 15:47
package.json Outdated
@@ -1,6 +1,6 @@
{
"name": "cartodb-ui",
"version": "4.11.32",
"version": "4.11.32-1296",
Copy link
Contributor

Choose a reason for hiding this comment

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

No need if you only touch backend files 😄

@@ -195,6 +195,14 @@ def stub_passwords(password)
response.body.should_not include("maps.google.com/maps/api/js")
end

it 'does not include 3rd party scripts if cookies=0 query param is present' do
Copy link
Contributor

Choose a reason for hiding this comment

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

This tests passes in the current version of master (or if you remove cookies: '0' here), which leads me to think that is not actually testing anything 😅

We probably need to set some configuration (Cartodb.with_config) to temporarily enable these services in the testing environment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I thought it was working because made it fail first but I enabled these services in my app_config.yml, so you are right. I am going to change the test :)

@jesusbotella
Copy link
Contributor Author

@javitonino I have just changed the test, it should be correct now. 😀

@jesusbotella jesusbotella merged commit ad2edd8 into master Feb 12, 2018
@jesusbotella jesusbotella deleted the 1296-embed-no-tracking branch February 12, 2018 09:12
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