{
"manifest": {
"name": "nypr-metrics",
"version": "0.3.1",
"description": "Analytics and tracking services for NYPR ember apps",
"keywords": [
"ember-addon"
],
"license": "MIT",
"author": {},
"repository": {
"type": "git",
"url": "https://github.com/nypublicradio/nypr-metrics"
},
"scripts": {
"build": "ember build",
"lint:js": "eslint ./*.js addon addon-test-support app config lib server test-support tests",
"start": "ember serve",
"test": "ember try:each"
},
"dependencies": {
"ember-cli-babel": "^6.6.0",
"ember-get-config": "^0.2.2",
"ember-metrics": "^0.12.1"
},
"devDependencies": {
"broccoli-asset-rev": "^2.4.5",
"ember-ajax": "^3.0.0",
"ember-cli": "~3.0.0",
"ember-cli-dependency-checker": "^2.0.0",
"ember-cli-eslint": "^4.2.1",
"ember-cli-htmlbars": "^2.0.1",
"ember-cli-htmlbars-inline-precompile": "^1.0.0",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-qunit": "^4.1.1",
"ember-cli-shims": "^1.2.0",
"ember-cli-sri": "^2.1.0",
"ember-cli-uglify": "^2.0.0",
"ember-disable-prototype-extensions": "^1.1.2",
"ember-export-application-global": "^2.0.0",
"ember-fetch": "^1.4.2",
"ember-hifi": "^1.11.3",
"ember-load-initializers": "^1.0.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-poll": "^1.2.0",
"ember-resolver": "^4.0.0",
"ember-sinon": "^1.0.1",
"ember-sinon-qunit": "^2.0.0",
"ember-source": "~3.0.0",
"ember-source-channel-url": "^1.0.1",
"ember-try": "^0.2.23",
"eslint-plugin-ember": "^5.0.0",
"eslint-plugin-node": "^5.2.1",
"loader.js": "^4.2.3"
},
"engines": {
"node": "^4.5 || 6.* || >= 7.*"
},
"ember-addon": {
"configPath": "tests/dummy/config"
},
"_registry": "npm",
"_loc": "/Users/jeff/Library/Caches/Yarn/v1/npm-nypr-metrics-0.3.1-b93fd646-e68c-47e6-9d73-70aceb3bc03c-1521727560629/package.json",
"readmeFilename": "README.md",
"readme": "# nypr-metrics\n\n## Required Config Values\n\nName | Type | Description\n--- | --- | ---\n`platformEventsAPI` | String | Used by the `data-pipeline` service to fire platform events.\n`siteName` | String | Used by the `npr-analytics` metrics adapter as a data point.\n`metricsAdapters` | Array | Holds adapter specific options\n\n\n## metrics-adapters/npr-analytics\nThe `npr-analytics` metrics adapter is designed to work with the `ember-metrics` addon, which is installed as part of the `nypr-metrics` addon as well. A config object for this metrics adapter **must** be added to the `metricsAdapters` array, like so:\n```js\n// config/environment.js\nmodule.exports = function(environment) {\n let ENV = {\n ...\n metricsAdapters: [{\n name: 'NprAnalytics',\n config: {\n id: 'UA-18188937-11',\n cookieDomain: 'auto',\n name: 'npr'\n }\n }]\n ...\n };\n ...\n};\n```\nThis will allow the web client to comply with NPR's reporting standards.\n\n### Methods\n#### `trackPage`\n\nSend a page view to the NPR account for the given page path and title.\n**Parameters**\n\nName | Type | Description\n--- | --- | ---\n`options` | Object | An options object with two keys: `page` and `title`\n`options.page` | String | The current page pathname and any query strings. Must start with a forward slash (`/`)\n`options.title` | String | The current page's title\n\n#### `trackEvent`\n\nFires an event to the NPR google analytics back end\n**Parameters**\n\nName | Type | Description\n--- | --- | ---\n`options` | Object | An options object with three keys: `category`, `action`, `label`\n`options.category` | String | The category value for the event\n`options.action` | String | The action value for the event\n`options.label` | String | The label value for the event\n\n#### `setDimensions`\nSets the required dimensions on the NPR analytics tracker. Only needs to be called on detail routes. The `Show`, `Channel`, and `Story` models found in `nypr-publisher-lib` have an `nprAnalyticsDimensions` attribute which can be passed directly to this method.\n\n**Parameters**\n\nName | Type | Description\n--- | --- | ---\n`options` | Object | An options object with one key: `nprVals`\n`options.nprVals` | Array | An array of values to be set on the NPR tracker. Can accept the `nprAnalyticsDimensions` attribute directly.\n\n\n## service/data-layer\nThe `data-layer` service provides a higher-level API to the `dataLayer` provided by Google Tag Manager. The API surface is tailored specifically for NYPR use-cases and can be easily extended as new requirements arise.\n\n**NOTE**\nThis service is injected under the `nypr-metrics` namespace in order to maintain a clear distinction between the global `window.dataLayer` and this particular service. So, you'd inject it like this:\n```js\ndataLayer: service('nypr-metrics/data-layer')\n```\n\n### Methods\n#### `setForType(type, instance)`\n\nSet particular `dataLayer` variables based on the given `type`.\n\n**Parameters**\n\nName | Type | Description\n--- | --- | ---\n`type` | String | The type of `instance` from which to pull values for the `dataLayer`. Determines specific logic and key names get pushed into the `dataLayer`.\n`instance` | Object/Model | The thing going into the `dataLayer`.\n\n\n#### `clearForType(type)`\n\nClears the `dataLayer` values for the given `type`.\n\n**Parameters**\n\nName | Type | Description\n--- | --- | ---\n`type` | String | Each type sets different values; this ensures only a given types variables are cleared.\n\n#### `setLoggedIn(state)`\n\nSet the `dataLayer` variable to indicate the user's logged-in status.\n\n**Parameters**\n\nName | Type | Description\n--- | --- | ---\n`state` | Boolean | `true` for logged in, `false` if not\n\n#### `setMemberStatus(state)`\n\nSet the `dataLayer` variable to indicate the user's membership status.\n\n**Parameters**\n\nName | Type | Description\n--- | --- | ---\n`state` | String | `Nonmember`, `One-Time Donor`, `Sustainer`\n\n#### `setPageTitle(title)`\n\nSet the `dataLayer` variable for the current page title.\n\n**Parameters**\n\nName | Type | Description\n--- | --- | ---\n`title` | String | The page title.\n\n#### `audioTracking(eventName, soundObject)`\n\nFires an audio event via the `dataLayer`.\n\n**Parameters**\n\nName | Type | Description\n--- | --- | ---\n`eventName` | String | `play`, `pause`, `end`, `resume`\n`soundObject` | Sound | A sound object as generated by `ember-hifi`\n\n#### `push(key, value)`\n\nIf there isn't a specific method for your use-case, you can use this to set arbitrary `dataLayer` variables.\n\n**Parameters**\n\nName | Type | Description\n--- | --- | ---\n`key` | String | Key under which this value will be stored in the `dataLayer`.\n`value` | Any | The value to save. Can be any valid JavaScript value, but keep in mind that uses complicated values directly in GA Tags is not supported.\n\n#### `clear(key[, key, ...])`\n\nSets the given `key` to `null` in the `dataLayer`, effectively clearing the value until it is set again. Accepts multiple keys.\n\n**Parameters**\n\nName | Type | Description\n--- | --- | ---\n`key` | String | The `dataLayer` variable name to clear\n\n## service/listen-analytics\nThe `listen-analytics` service coordinates analytics tracking related to listening activities. It listens to events fired by `ember-hifi` and makes calls to methods on the `data-pipeline` service and available `ember-metrics` adapters. It reads state directly off of `ember-hifi.`\n\n### event queues\nDue to a timing issue with firing the `audio-ended` event, the service queues up events and uses a debounced function to fire off queued events. We do this because when a piece of audio finishes, the `` element will fire first a `pause` event and then an `ended` event successively. When the queue flushes, it checks to see if the pending events are in a `pause -> ended` pattern, and if so it only fires the `ended` event. There's a queue for both listen actions (sent to `data-pipeline`) and google analytics.\n\n### metadata\nA recent update to `ember-hifi` allows consumers to attach arbitrary data to a `metadata` property on generated sound objects. `listen-analytics` expects a few properties on that `metadata` object for tracking purposes.\n* `analytics`: an object with arbitrary metadata to be passed to the data-pipeline\n* `contentModel`: a stream or story ember-data record\n* `contentModelType`: string representing the ember-data model type\n* `playContext`: a string representing where in the DOM the click to play this sound originally happened, e.g. 'StoryHeader', 'HomePage', if applicable\n* `autoplayChoice`\nGoogle Analytics events still include the `analyticsCode`, but this will soon be replaced by a simple string formatted as ` | `.`\n\n## service/data-pipeline\nThis service packages up data and fires it off to the platform events microservice. The service is configured to look for a `browserId` property on itself and include it in outgoing requests. It will also call an `authorize` method which the client can use to update the passed in `fetchOptions`.\n\n## Client Integration\n\nTo integrate with the `data-pipeline,` there is a simple strategy an upstream app can do. Import the service from the addon and re-export it within the app's namespace, adding a `browserId` computed and an `authorize` method.\n\n\n```javascript\n\nimport DataPipeline from 'nypr-metrics/services/data-pipeline';\nimport Ember from 'ember';\nimport computed from 'ember-computed';\n\nexport default DataPipeline.extend({\n session: Ember.inject.service(),\n browserId: computed.readOnly('session.data.browserId'),\n authorize(fetchOptions) {\n this.get('session').authorize('authorizer:nypr', (header, value) => {\n fetchOptions.headers[header] = value;\n });\n\n return fetchOptions;\n }\n\n})\n```\n\n## instance-initialzers/eager-load-services\n\nThis instance initializer is an affordance for upstream apps so the the `listen-analytics` service can attach event listeners as soon as possible.\n\n## Publishing\n\nThis addon is published to npm using semver. See the [wiki](https://wiki2.wnyc.org/index.php?title=WebClient:Developer_Guide) for more instructions.\n",
"licenseText": "The MIT License (MIT)\n\nCopyright (c) 2018\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
},
"artifacts": [],
"remote": {
"type": "copy",
"registry": "npm",
"hash": "cbbf9b1b-2ca9-400a-8514-fb9687975222-1521729706317",
"reference": "///Users/jeff/src/nypr-metrics"
},
"registry": "npm",
"hash": "cbbf9b1b-2ca9-400a-8514-fb9687975222-1521729706317"
}