Bug 1824842 Comment 0 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

This bug covers adding the advertiser name and tile ID to the `topsites.impression` and `topsites.click` events for sponsored tiles.

I'm marking it moco-confidential for now, because it's sensitive data that depends on the outcome of the [data review](https://wiki.mozilla.org/Data_Collection#Step_3:_Sensitive_Data_Collection_Review_Process) thread that :chutten started.

As part of this, I think we'll want to add:

* `advertiser` and `tile_id` keys to the [Glean events](https://searchfox.org/mozilla-central/rev/736eb58cd30da3afc0310b58232a1e4d0dcc86a4/browser/components/newtab/metrics.yaml#251,282) for impressions and clicks.
* Instrumentation to `TelemetryFeed.jsm` that records these keys for [sponsored tiles](https://searchfox.org/mozilla-central/rev/736eb58cd30da3afc0310b58232a1e4d0dcc86a4/browser/components/newtab/lib/TelemetryFeed.jsm#876-879,889-892).
This bug covers adding the advertiser name and tile ID to the `topsites.impression` and `topsites.click` events for sponsored tiles.

I'm marking it moco-confidential for now, because it's sensitive data that depends on the outcome of the [data review](https://wiki.mozilla.org/Data_Collection#Step_3:_Sensitive_Data_Collection_Review_Process) thread that :chutten started.

As part of this, I think we'll want to add:

* `advertiser` and `tile_id` keys to the [Glean events](https://searchfox.org/mozilla-central/rev/736eb58cd30da3afc0310b58232a1e4d0dcc86a4/browser/components/newtab/metrics.yaml#251,282) for impressions and clicks.
* Instrumentation to `TelemetryFeed.jsm` that records these keys for [sponsored tiles](https://searchfox.org/mozilla-central/rev/736eb58cd30da3afc0310b58232a1e4d0dcc86a4/browser/components/newtab/lib/TelemetryFeed.jsm#876-879,889-892).
* Tests covering the new instrumentation ☺️

Here are some things I found really helpful when adding instrumentation for organic tiles in bug 1820707:

* The [metric types reference](https://mozilla.github.io/glean/book/reference/metrics/index.html) from the Glean book.
* Other metrics in the `metrics.yaml` file, for inspiration.
* Bug 1766887, which initially added the `newtab` ping and metrics.
* Some discussion in the patch for bug 1688698 about the different telemetry instrumentation for Pocket ("Discovery Stream") sponsored vs. non-Pocket sponsored and organic tiles.
* The [Data Collection page on the Mozilla wiki](https://wiki.mozilla.org/Data_Collection) with an explanation of the data review process, and links to the forms.
* Bug 1733443, comment 3 for an explanation of how the potentially sensitive data review (step 3) is handled.

When I'm hacking on New Tab locally, I use:

* `./mach npm run testmc:unit --prefix=browser/components/newtab` to run the Node-based unit tests for New Tab.
* `./mach npm run bundle --prefix=browser/components/newtab` to rebuild the bundle—only needed once you're ready to push your changes.

Running the Node tests can take quite a while, and I didn't find (after like a minute; I didn't look very hard 😅) a way to make Karma run just a subset. But I found that editing [this line](https://searchfox.org/mozilla-central/rev/736eb58cd30da3afc0310b58232a1e4d0dcc86a4/browser/components/newtab/test/unit/unit-entry.js#31) with just the test files I wanted to run, to something like this:

```js
const files = req.keys().filter(file => file.endsWith("/TopSites.test.jsx"));
```

...worked perfectly, so I didn't poke further.

I had great results with using `./mach try auto` to run the tests on automation, too.

We can't use [artifact builds](https://firefox-source-docs.mozilla.org/contributing/build/artifact_builds.html) when adding / changing Glean metrics yet, but I think we'll be able to again once bug 1820241 is fixed! 🎊

Back to Bug 1824842 Comment 0