Collapse privacy extra keys into a single key

Event Telemetry [limits the max number of extra keys](https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/telemetry/collection/events.html#limits) for an event to 10. In the fix for Issue #185, where three new privacy-related extra keys were added to every telemetry event, the number of extra keys for the 'open_external_page' event went to 11, which causes event telemetry to fail at the registration step.

This patch collapses these 3 privacy keys into a single key that points to a stringified JSON object.
This commit is contained in:
Bianca Danforth 2018-11-02 09:41:52 -07:00
Родитель 0bca7d982a
Коммит 349787b8d5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 2C96DD7DB2A2D72D
2 изменённых файлов: 17 добавлений и 16 удалений

Просмотреть файл

@ -138,6 +138,17 @@ Below is a sample ping for the `badge_toolbar_button` and `visit_supported_site`
`extra_keys` are keys in the [optional `extra` object field](https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/telemetry/collection/events.html#serialization-format) for telemetry events. All `extra_keys` and their values are strings.
- `'badge_type'`: Indicates what, if any, badge was present on the browserAction toolbar button. One of 'add', 'price_alert', or 'none'. A value of 'unknown' is possible if the badge text is unrecognized.
- `'dnt_tp_cookie'`: The status of three different privacy settings collapsed into a single, stringified JSON object:
- `'dnt'`: 'true' if the user has [requested not to be tracked by websites, content, or advertising](https://support.mozilla.org/en-US/kb/how-do-i-turn-do-not-track-feature); otherwise 'false'.
- `'tp'`: The user's [tracking protection](https://support.mozilla.org/en-US/kb/tracking-protection) setting:
- `'always'`: Tracking Protection is on
- `'never'`: Tracking Protection is off
- `'private_browsing'`: Tracking Protection is on in private browsing windows only
- `'cookie'`: The user's [cookie setting](https://support.mozilla.org/en-US/kb/disable-third-party-cookies):
- `'allow_all'`: Accept all cookies
- `'reject_all'`: Reject all cookies
- `'reject_third_party'`: Reject all third-party cookies
- `'allow_visited'`: Accept a third-party cookie only if the cookie's top-level domain already has at least one cookie.
- `'extraction_id'`: A unique identifier to associate an extraction attempt to an extraction completion event for a given page.
- `'is_bg_update'`: 'true' if the extraction is associated with a background price check; otherwise 'false'.
- `method`: The extraction method that was successful, if any. One of: 'fathom', 'css_selectors', 'open_graph' or 'none'. A value of 'none' means that all extraction methods failed.
@ -161,16 +172,6 @@ Below is a sample ping for the `badge_toolbar_button` and `visit_supported_site`
- `'product_card'`: Sends the user to the product page for the given Product Card.
- `'system_notification'`: Sends the user to the product page for the Price Alert displayed in the notification.
- `'walmart_link'`: Sends the user to Walmart.
- `'privacy_dnt'`: 'true' if the user has [requested not to be tracked by websites, content, or advertising](https://support.mozilla.org/en-US/kb/how-do-i-turn-do-not-track-feature); otherwise 'false'.
- `'privacy_tp'`: The user's [tracking protection](https://support.mozilla.org/en-US/kb/tracking-protection) setting:
- `'always'`: Tracking Protection is on
- `'never'`: Tracking Protection is off
- `'private_browsing'`: Tracking Protection is on in private browsing windows only
- `'privacy_cookie'`: The user's [cookie setting](https://support.mozilla.org/en-US/kb/disable-third-party-cookies):
- `'allow_all'`: Accept all cookies
- `'reject_all'`: Reject all cookies
- `'reject_third_party'`: Reject all third-party cookies
- `'allow_visited'`: Accept a third-party cookie only if the cookie's top-level domain already has at least one cookie.
## Collection (User Events)

Просмотреть файл

@ -15,9 +15,7 @@ const CATEGORY = 'extension.price_wise';
const DEFAULT_EXTRAS = [
'tracked_prods',
'privacy_dnt',
'privacy_tp',
'privacy_cookie',
'dnt_tp_cookie',
];
const EVENTS = {
@ -181,9 +179,11 @@ export async function recordEvent(method, object, value, extraBase = {}) {
const extra = {
...extraBase,
tracked_prods: getAllProducts(store.getState()).length,
privacy_dnt: navigator.doNotTrack === '1',
privacy_tp: (await browser.privacy.websites.trackingProtectionMode.get({})).value,
privacy_cookie: (await browser.privacy.websites.cookieConfig.get({})).value.behavior,
dnt_tp_cookie: JSON.stringify({
dnt: (navigator.doNotTrack === '1'),
tp: (await browser.privacy.websites.trackingProtectionMode.get({})).value,
cookie: (await browser.privacy.websites.cookieConfig.get({})).value.behavior,
}),
};
// Convert all extra key values to strings as required by event telemetry