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

tracking consent #56

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

tracking consent #56

wants to merge 17 commits into from

Conversation

mraveux
Copy link
Member

@mraveux mraveux commented Oct 11, 2019

This Pr add the TrackingConsent component, used to setup matomo tracking easily.

You can try it locally in the wallet, branch matheo/matomo_tracking, or using "Curd's Fancy Deployment Selector".

@mraveux mraveux requested a review from danimoh October 11, 2019 11:51
Copy link
Member

@danimoh danimoh left a comment

Choose a reason for hiding this comment

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

See comments.

src/components/TrackingConsent.vue Outdated Show resolved Hide resolved
src/components/TrackingConsent.vue Outdated Show resolved Hide resolved
src/components/TrackingConsent.vue Outdated Show resolved Hide resolved
src/components/TrackingConsent.vue Outdated Show resolved Hide resolved
src/components/TrackingConsent.vue Outdated Show resolved Hide resolved
src/components/TrackingConsent.vue Outdated Show resolved Hide resolved
src/components/TrackingConsent.vue Outdated Show resolved Hide resolved
src/components/TrackingConsent.vue Outdated Show resolved Hide resolved
src/components/TrackingConsent.vue Outdated Show resolved Hide resolved
src/components/TrackingConsent.vue Outdated Show resolved Hide resolved
src/components/TrackingConsent.vue Outdated Show resolved Hide resolved
src/components/TrackingConsent.vue Outdated Show resolved Hide resolved
type: Boolean,
default: false,
})
public ignoreDoNotTrack: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

Is it a good idea to make this a setting in the first place? Shouldn't we respect this setting?

Copy link
Member Author

Choose a reason for hiding this comment

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

We do respect this setting by default. But if someone want to not respect it, then he's free to do so. (see Daniel's comment #56 (comment))

src/components/TrackingConsent.vue Outdated Show resolved Hide resolved
Comment on lines 212 to 230
const cookie = [cookieName + '=' + cookieValue];

if (options) {
if (!options.domain) options.domain = TrackingConsent.DEFAULT_COOKIE_DOMAIN;
if (!options.expirationDays) options.expirationDays = TrackingConsent.DEFAULT_COOKIE_EXPIRATION_DAYS;

cookie.push('domain=' + options.domain);
cookie.push('max-age=' + options.expirationDays * 24 * 60 * 60);
}

cookie.push('path=/');
document.cookie = cookie.join(';');
Copy link
Member

Choose a reason for hiding this comment

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

I believe this needs the sameSite setting as well nowadays.

Copy link
Member Author

Choose a reason for hiding this comment

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

SameSite require Secure sometimes, so i'll add both 👍

Comment on lines +392 to +407
export const LOCALSTORAGE_KEYS = [
'tracking-consent',
'tracking-consensus',
];
Copy link
Member

Choose a reason for hiding this comment

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

Why two keys? Maybe add a comment to explain.

export const COOKIE_STORAGE_KEY = 'tracking-consent';

export const DEFAULT_COOKIE_DOMAIN = document.location.hostname;
export const DEFAULT_COOKIE_EXPIRATION_DAYS = 365 * 20;
Copy link
Member

Choose a reason for hiding this comment

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

20 years? 😆

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually let me change it to 10 years, because 20 years won't work on 32bits systems.

mraveux added a commit that referenced this pull request Jul 28, 2020
Requested changes by Sisou
#56 (review)

- `options.setSiteId` doesn’t have a default value anymore, and is now required
- Renamed `DEFAULT_TRACKING_URL` to `DEFAULT_TRACKING_SCRIPT_URL`
- Moved the default `geoIpServer` value to a constant named `DEFAULT_GEOIP_SERVER_URL`
- Added possibility to set the cookie's attributes `secure` and `sameSite`
- Added a comment explaining the two `localStorage` keys
- Changed default lifetime of the cookie from 20 years to 10 years since 20 years would not work on 32bits systems. (the cookie would just disappear instantly)
mraveux added a commit that referenced this pull request Jul 28, 2020
PR #56
Requested changes by Sisou
#56 (review)

- `options.setSiteId` doesn’t have a default value anymore, and is now required
- Renamed `DEFAULT_TRACKING_URL` to `DEFAULT_TRACKING_SCRIPT_URL`
- Moved the default `geoIpServer` value to a constant named `DEFAULT_GEOIP_SERVER_URL`
- Added possibility to set the cookie's attributes `secure` and `sameSite`
- Added a comment explaining the two `localStorage` keys
- Changed default lifetime of the cookie from 20 years to 10 years since 20 years would not work on 32bits systems. (the cookie would just disappear instantly)
- turn public methods into static ones
- turn "domain" prop into static const
- PR requested changes
- Listening for tab / window focus in case the user allows tracking on another tab / window or change browser settings / vpn

ToDo:
- Should use BottomOverlay
- Component doc comment
- types fix
- setTrackerUrl & trackingScriptUrl urls fix
- add default setTrackerUrl value
- now using a window `focus` listener instead of document `visibilitychange` one
PR #56
Requested changes by Sisou
#56 (review)

- `options.setSiteId` doesn’t have a default value anymore, and is now required
- Renamed `DEFAULT_TRACKING_URL` to `DEFAULT_TRACKING_SCRIPT_URL`
- Moved the default `geoIpServer` value to a constant named `DEFAULT_GEOIP_SERVER_URL`
- Added possibility to set the cookie's attributes `secure` and `sameSite`
- Added a comment explaining the two `localStorage` keys
- Changed default lifetime of the cookie from 20 years to 10 years since 20 years would not work on 32bits systems. (the cookie would just disappear instantly)
- now loading Matomo tracking script before checking for UI requirement, but disable cookie usage before user give consent (if in EEA)
- removed `allowBrowserData` since we’re tracking browser data by default, without asking for consent
- fixed `geoIpServer` @prop default value
- now checking if `_paq` & `_mtm` are objects that have a `push` method, instead of checking if they’re Arrays (since they’re not Arrays, but objects with a single `push` method)
- removed the public static getter `allowsBrowserData` and the public static method `allowBrowserData `
- added a static public getter `isOutsideEEA`, since we can enable Cookies without consent for countries outside the EEA
- turned the `execFunction` method into a async one, allowing to `await` for the function result
- add a `trackPageView` public static method for easy page tracking on single-page apps
- set trackPageView by default to track first page view
@mraveux mraveux requested a review from sisou August 1, 2020 21: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.

None yet

3 participants