mozilla / nimbus-shared

Shared data and schemas for Project Nimbus
https://mozilla.github.io/nimbus-shared
Mozilla Public License 2.0
6 stars 15 forks source link

Combine data into a single file and expose in packages #63

Closed mythmon closed 4 years ago

mythmon commented 4 years ago

So somehow #43 only really caught half my data changes, and the rest were lost to a bad git rebase. I was able to resurrect them from the depths of the reflog, and here they are. This really should have been in v0.0.4, but alas.

This should fix #62

mythmon commented 4 years ago

@pdehaan You can install the NPM package from this PR before it merges with

npm install https://183-267090370-gh.circle-artifacts.com/0/artifacts/npm/mozilla-nimbus-shared-0.0.3.tgz

The Python version can similarly be installed with

pip install https://183-267090370-gh.circle-artifacts.com/0/artifacts/python/mozilla_nimbus_shared-0.0.3-py3-none-any.whl

(Yes, I know the version number is wrong).

pdehaan commented 4 years ago

And here's the results of the shared.data.features object:

const shared = require('@mozilla/nimbus-shared');

console.log(Object.keys(shared));
/* [
  'typeGuards',
  'checkSchema',
  'assertSchema',
  'isSchema',
  'schemas',
  'types',
  'data'
] */

console.log(JSON.stringify(shared.data.features, null, 2));

/* {
  "picture_in_picture": {
    "name": "Picture-in-Picture",
    "description": "Counts the fraction of users and the number of times that users open Picture-in-Picture\nwindows from videos. PiP can be opened by clicking on the PiP overlay or the video's context\nmenu.\n",
    "telemetry": [
      {
        "kind": "event",
        "event_category": "pictureinpicture",
        "event_method": "create",
        "event_object": "player"
      }
    ],
    "slug": "picture_in_picture"
  },
  "pinned_tabs": {
    "name": "Pinned tabs",
    "description": "Counts the number of times that a client pinned a tab. This doesn't measure whether users\nalready had tabs pinned when observation began.\n",
    "telemetry": [
      {
        "kind": "scalar",
        "name": "browser.engagement.tab_pinned_event_count"
      }
    ],
    "slug": "pinned_tabs"
  }
} */

Feels a bit odd that the description field has newlines, but 🤷.

mythmon commented 4 years ago

I agree that it's weird to have newlines there, but I think the library should faithfully preserve newlines that are entered in the data. You can see here that it's authored that way. Including \ escapes at the end of the line would allow the source to be split up across multiple lines without having a literal newline.