{ "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 `