* Add `open_popup`, `open_external_page`, `add_product`, `delete_product` and `undo_delete_product` probes (See ./docs/METRICS.md for their specifications).
* Update `badge_type` `extra_key` description in METRICS.md to add a new enum value of 'unknown' in the case that the badge text is unrecognized, and a badge type cannot be determined.
* Update `addProductFromExtracted` action creator to return a thunk, which returns a random UUID (v4) for use as a product key in telemetry. This allows us to differentiate one product from another for a particular user. This is NOT a universal product id across all users.
* Add `tabId` URL searchParam to browserAction popup URL when an extracted product is found on the current page in order to obtain the `badge_type` `extra_key` value for the `open_popup` event.
Switch to using a messaging port disconnect to detect when the browser action
closes. Without this, dismissing price alerts is not consistent as the JS
context for the browser action is unloaded before the async work of updating
the store is finished.
Because we are no longer performing async work after the browser action unloads,
we no longer see the errors from #60 about promises resolving after the context
is destroyed.
Incorporate more feedback on the metrics used for the extension.
METRICS.md
* For the `open_external_page` probe, moved the ‘objects’ enums to their own ‘extra_key’, ‘element’. This is so that the schema doesn’t have to change if the content of these UI elements changes down the road (feedback from Osmose).
* Arrange list items in Definitions section in alphabetical order and add Price Alert definition.
* Move questions under ‘Does it affect user behavior in Firefox?’ in the Analysis section to the ‘Questions to answer in future experiments’ subsection.
* Fixed probe name typos.
* Ensured consistent whitespace and use of markdown symbols.
telemetry.js
* Instead of exporting a single object, export the methods from the module directly.
* Update probes based on changes to METRICS.md
config.js
* Unrelated to the telemetry issue here; fixed a typo I noticed.
METRICS.md
* Reorganized the questions in the Analysis section to fall under broad categories of questions.
* Added a scalar 'supported_sites' to keep track of the number of times the user visits one of the five supported websites.
* Added an 'extra_keys' section that explains up front what each key represents.
* Made data types for all scalar and event telemetry values more explicit.
* Added a 'detect_price_change' event.
* Updated and added new keys to provide more context around certain events and ensure data collection is Category 1 or 2 at most.
telemetry.js
* Updated registered events and scalars to match METRICS.md
Note: While this patch does not record any events or scalars itself, recording can be tested with the following after 'telemetry.recordProbes()' in './src/background/index.js':
```javascript
await telemetry.scalarAdd('supported_sites', 1);
await telemetry.recordEvent(
'badge_toolbar_button',
'toolbar_button',
null,
{
badge_type: 'add',
tracked_prods: '5',
},
);
```
* Adds METRICS.md document in a new 'docs' subfolder.
* Adds 'telemetry.js' background script which registers all events and provides a wrapper method to record events.
* The event 'send_system_notice' was originally 'send_system_notification', however, that exceeded the [string length limit](https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/telemetry/collection/events.html#limits) imposed by Event Telemetry.
* There is no need to unregister the events, as the events are only registered for the duration of the [current Firefox session](https://dxr.mozilla.org/mozilla-central/source/toolkit/components/telemetry/core/nsITelemetry.idl#484).
Note: This PR does not actually record any events. That will happen in subsequent PRs. For the setup here, I did confirm that I can successfully records events in 'about:telemetry#events-tab' once 'browser.telemetry.recordEvent' is called. This can be confirmed by adding `telemetry.recordEvent('badge_toolbar_button', 'toolbar_button', null, {badge_type: 'add'});` after `telemetry.init()` in './src/background/index.js'.