{"id":13807229,"url":"https://github.com/adopted-ember-addons/ember-metrics","last_synced_at":"2025-10-05T20:58:13.956Z","repository":{"id":38193352,"uuid":"38898695","full_name":"adopted-ember-addons/ember-metrics","owner":"adopted-ember-addons","description":"Send data to multiple analytics integrations without re-implementing new API","archived":false,"fork":false,"pushed_at":"2025-05-05T15:41:59.000Z","size":3938,"stargazers_count":367,"open_issues_count":40,"forks_count":160,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-05-22T19:11:28.593Z","etag":null,"topics":["analytics","ember","ember-addon","ember-metrics"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adopted-ember-addons.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-07-10T19:37:39.000Z","updated_at":"2025-02-27T05:19:12.000Z","dependencies_parsed_at":"2023-02-01T08:45:59.468Z","dependency_job_id":"ebb20428-c689-4ff1-8f6d-afecabee0c3e","html_url":"https://github.com/adopted-ember-addons/ember-metrics","commit_stats":{"total_commits":425,"total_committers":88,"mean_commits":4.829545454545454,"dds":0.7411764705882353,"last_synced_commit":"33e31a36ef20842993343e48b60319dcf7e87a4a"},"previous_names":["poteto/ember-metrics"],"tags_count":48,"template":false,"template_full_name":null,"purl":"pkg:github/adopted-ember-addons/ember-metrics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adopted-ember-addons%2Fember-metrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adopted-ember-addons%2Fember-metrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adopted-ember-addons%2Fember-metrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adopted-ember-addons%2Fember-metrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adopted-ember-addons","download_url":"https://codeload.github.com/adopted-ember-addons/ember-metrics/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adopted-ember-addons%2Fember-metrics/sbom","scorecard":{"id":167520,"data":{"date":"2025-08-11","repo":{"name":"github.com/adopted-ember-addons/ember-metrics","commit":"db562f6409f83d671633e8fdd044155638fd2f52"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.6,"checks":[{"name":"Code-Review","score":3,"reason":"Found 3/9 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: jobLevel 'contents' permission set to 'write': .github/workflows/plan-release.yml:39","Info: jobLevel 'issues' permission set to 'read': .github/workflows/plan-release.yml:40","Warn: jobLevel 'contents' permission set to 'write': .github/workflows/publish.yml:42","Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Warn: no topLevel permission defined: .github/workflows/plan-release.yml:1","Warn: no topLevel permission defined: .github/workflows/publish.yml:1"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/adopted-ember-addons/ember-metrics/ci.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/adopted-ember-addons/ember-metrics/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/adopted-ember-addons/ember-metrics/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:43: update your workflow using https://app.stepsecurity.io/secureworkflow/adopted-ember-addons/ember-metrics/ci.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:44: update your workflow using https://app.stepsecurity.io/secureworkflow/adopted-ember-addons/ember-metrics/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:47: update your workflow using https://app.stepsecurity.io/secureworkflow/adopted-ember-addons/ember-metrics/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:76: update your workflow using https://app.stepsecurity.io/secureworkflow/adopted-ember-addons/ember-metrics/ci.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:77: update your workflow using https://app.stepsecurity.io/secureworkflow/adopted-ember-addons/ember-metrics/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:81: update your workflow using https://app.stepsecurity.io/secureworkflow/adopted-ember-addons/ember-metrics/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/plan-release.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/adopted-ember-addons/ember-metrics/plan-release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/plan-release.yml:49: update your workflow using https://app.stepsecurity.io/secureworkflow/adopted-ember-addons/ember-metrics/plan-release.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/plan-release.yml:55: update your workflow using https://app.stepsecurity.io/secureworkflow/adopted-ember-addons/ember-metrics/plan-release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/plan-release.yml:58: update your workflow using https://app.stepsecurity.io/secureworkflow/adopted-ember-addons/ember-metrics/plan-release.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/plan-release.yml:82: update your workflow using https://app.stepsecurity.io/secureworkflow/adopted-ember-addons/ember-metrics/plan-release.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/adopted-ember-addons/ember-metrics/publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/adopted-ember-addons/ember-metrics/publish.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/publish.yml:49: update your workflow using https://app.stepsecurity.io/secureworkflow/adopted-ember-addons/ember-metrics/publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:52: update your workflow using https://app.stepsecurity.io/secureworkflow/adopted-ember-addons/ember-metrics/publish.yml/main?enable=pin","Info:   0 out of  12 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   6 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Packaging","score":10,"reason":"packaging workflow detected","details":["Info: Project packages its releases by way of GitHub Actions.: .github/workflows/publish.yml:36"],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 29 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":1,"reason":"9 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-whgm-jr23-g3j9","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-wxhq-pm8v-cw75","Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-76c9-3jph-rj3q","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-16T15:19:41.015Z","repository_id":38193352,"created_at":"2025-08-16T15:19:41.015Z","updated_at":"2025-08-16T15:19:41.015Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278518899,"owners_count":26000177,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analytics","ember","ember-addon","ember-metrics"],"created_at":"2024-08-04T01:01:22.863Z","updated_at":"2025-10-05T20:58:13.925Z","avatar_url":"https://github.com/adopted-ember-addons.png","language":"JavaScript","funding_links":[],"categories":["Packages"],"sub_categories":["Metrics"],"readme":"# ember-metrics\n\n_Send data to multiple analytics services without re-implementing new API_\n\n![Download count all time](https://img.shields.io/npm/dt/ember-metrics.svg) [![npm version](https://badge.fury.io/js/ember-metrics.svg)](http://badge.fury.io/js/ember-metrics) ![Build Status](https://github.com/adopted-ember-addons/ember-metrics/workflows/Test/badge.svg?branch=master) [![Ember Observer Score](http://emberobserver.com/badges/ember-metrics.svg)](http://emberobserver.com/addons/ember-metrics)\n\nThis addon adds a simple `metrics` service to your app that makes it simple to send data to multiple analytics services without having to implement a new API each time.\n\nUsing this addon, you can easily use bundled adapters for various analytics services, and one API to track events, page views, and more. When you decide to add another analytics service to your stack, all you need to do is add it to your configuration, and that's it!\n\nWriting your own adapters for currently unsupported analytics services is easy too. If you'd like to then share it with the world, submit a pull request and we'll add it to the bundled adapters.\n\n#### Currently supported services and options\n\n1. `GoogleAnalytics`\n\n   - `id`: [Property ID](https://support.google.com/analytics/answer/1032385?hl=en), e.g. `UA-XXXX-Y`\n\n1. `GoogleAnalyticsFour`\n\n   - `id`: [Measurement Id](https://support.google.com/analytics/answer/9539598?hl=en), e.g. `G-XXXX`\n   - `options`: _optional_ An object which will be directly passed to the configuration tag, e.g.:\n\n   ```js\n   options = {\n     anonymize_ip: true,\n     debug_mode: environment === 'development',\n   };\n   ```\n\n   By default GA4 automatically tracks page views when the history locations changes. This means that `this.metrics.trackPage()` is ignoreded by default. However, if you want to track the page views manually, you need to set `send_page_view: false` inside the options. To avoid double counting page views make sure [enhanced measurement](https://support.google.com/analytics/answer/9216061) is configured correctly. Typically, this means disabling _Page changes based on browser history events_ under the advanced settings of the page views section.\n\n1. `Mixpanel`\n\n   - `token`: [Mixpanel token](https://mixpanel.com/help/questions/articles/where-can-i-find-my-project-token)\n   - Optionally other [config options to override](https://developer.mixpanel.com/docs/javascript-full-api-reference#mixpanelinit)\n\n1. `GoogleTagManager`\n\n   - `id`: [Container ID](https://developers.google.com/tag-manager/quickstart), e.g. `GTM-XXXX`\n\n   - `dataLayer`: An array containing a single POJO of information, e.g.:\n\n   ```js\n   dataLayer = [\n     {\n       pageCategory: 'signup',\n       visitorType: 'high-value',\n     },\n   ];\n   ```\n\n   - `envParams`: A string with custom arguments for configuring GTM environments (Live, Dev, etc), e.g.:\n\n   ```js\n   envParams: 'gtm_auth=xxxxx\u0026gtm_preview=env-xx\u0026gtm_cookies_win=x';\n   ```\n\n1. `Segment`\n\n   - `key`: [Segment key](https://segment.com/docs/libraries/analytics.js/quickstart/)\n   - `proxyDomain`: _optional_ [Custom domain proxy](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/custom-proxy/)\n\n1. `Piwik`\n\n   - `piwikUrl`: [Tracker URL](http://developer.piwik.org/guides/tracking-javascript-guide)\n   - `siteId`: [Site Id](http://developer.piwik.org/guides/tracking-javascript-guide)\n\n1. `Intercom`\n\n   - `appId`: [App ID](https://docs.intercom.com/help-and-faqs/getting-set-up/where-can-i-find-my-app-id)\n\n1. `Facebook Pixel`\n\n   - `id`: [ID](https://www.facebook.com/ads/manager/pixel/facebook_pixel/?act=129849836\u0026pid=p1)\n   - dataProcessingOptions: _optional_ An object defining the method, country and state for [data processing options](https://developers.facebook.com/docs/marketing-apis/data-processing-options/)\n\n   ```js\n   dataProcessingOptions: {\n     method: ['LDU'],\n     country: 1,\n     state: 1000\n   }\n   ```\n\n1. `Amplitude`\n\n   - `apiKey`: [API Key](https://developers.amplitude.com/#setting-up-our-sdks)\n\n1. `Azure App Insights`\n\n   - `instrumentationKey`: [Instrumentation Key](https://github.com/microsoft/ApplicationInsights-JS#configuration)\n\n1. `Pendo`\n\n   - `apiKey`: [API Key](https://developers.pendo.io/docs/?bash#options)\n\n1. `MatomoTagManager`\n\n   - `matomoUrl`: [Matomo URL](https://developer.matomo.org/guides/tagmanager/embedding)\n   - `containerId`: [Container ID](https://developer.matomo.org/guides/tagmanager/embedding), e.g. `acbd1234`\n\n1. `Hotjar`\n\n   - `siteId`: [SiteID](https://help.hotjar.com/hc/en-us/articles/115009336727-How-to-Install-your-Hotjar-Tracking-Code)\n\n#### Community adapters\n\n1. `Adobe Dynamic Tag Management`\n\n   - [ember-metrics-adobe-dtm](https://github.com/kellyselden/ember-metrics-adobe-dtm)\n\n1. `Simple Analytics`\n\n   - [ember-metrics-simple-analytics](https://github.com/mrloop/ember-metrics-simple-analytics)\n\n## Installing The Addon\n\n```shell\nember install ember-metrics\n```\n\n## Compatibility\n\n- Ember.js v3.28 or above\n- Ember CLI v3.28 or above\n- Node.js v18 or above\n\n## Configuration\n\nTo setup, you should first configure the service through `config/environment`:\n\n```javascript\nmodule.exports = function (environment) {\n  var ENV = {\n    metricsAdapters: [\n      {\n        name: 'GoogleAnalytics',\n        environments: ['development', 'production'],\n        config: {\n          id: 'UA-XXXX-Y',\n          // Use `analytics_debug.js` in development\n          debug: environment === 'development',\n          // Use verbose tracing of GA events\n          trace: environment === 'development',\n          // Ensure development env hits aren't sent to GA\n          sendHitTask: environment !== 'development',\n          // Specify Google Analytics plugins\n          require: ['ecommerce'],\n        },\n      },\n      {\n        name: 'GoogleAnalyticsFour',\n        environments: ['production'],\n        config: {\n          id: 'G-XXXX',\n          options: {\n            anonymize_ip: true,\n            debug_mode: environment === 'development',\n          },\n        },\n      },\n      {\n        name: 'Mixpanel',\n        environments: ['production'],\n        config: {\n          token: '0f76c037-4d76-4fce-8a0f-a9a8f89d1453',\n        },\n      },\n      {\n        name: 'Segment',\n        environments: ['production'],\n        config: {\n          key: '4fce-8a0f-a9a8f89d1453',\n        },\n      },\n      {\n        name: 'Piwik',\n        environments: ['production'],\n        config: {\n          piwikUrl: 'http://piwik.my.com',\n          siteId: 42,\n        },\n      },\n      {\n        name: 'Intercom',\n        environments: ['production'],\n        config: {\n          appId: 'def1abc2',\n        },\n      },\n      {\n        name: 'FacebookPixel',\n        environments: ['production'],\n        config: {\n          id: '1234567890',\n          dataProcessingOptions: {\n            method: ['LDU'],\n            country: 1,\n            state: 1000,\n          },\n        },\n      },\n      {\n        name: 'Amplitude',\n        environments: ['production'],\n        config: {\n          apiKey: '12345672daf5f3515f30f0000f1f0000cdfe433888',\n          options: {\n            trackingOptions: {\n              ip_address: false,\n            },\n            // ...other amplitude configuration options\n            // https://developers.amplitude.com/#sdk-advanced-settings\n          },\n        },\n      },\n      {\n        name: 'AzureAppInsights',\n        environments: ['production'],\n        config: {\n          instrumentationKey: '123',\n          // ...other appInsights configuration options\n          // https://github.com/microsoft/ApplicationInsights-JS#configuration\n        },\n      },\n      {\n        name: 'Pendo',\n        environments: ['production'],\n        config: {\n          apiKey: '123456789',\n        },\n      },\n      {\n        name: 'LocalAdapter',\n        environments: ['all'], // default\n        config: {\n          foo: 'bar',\n        },\n      },\n      {\n        name: 'MatomoTagManager',\n        environments: ['production'],\n        config: {\n          matomoUrl: 'matomo.my.com',\n          containerId: 'acd123',\n        },\n      },\n      {\n        name: 'Hotjar',\n        environments: ['production'],\n        config: {\n          siteId: '123456789',\n        },\n      },\n    ],\n  };\n};\n```\n\nAdapter names are PascalCased. Refer to the [list of supported adapters](#currently-supported-services-and-options) above for more information.\n\nThe `metricsAdapters` option in `ENV` accepts an array of objects containing settings for each analytics service you want to use in your app in the following format:\n\n```js\n/**\n * @param {String} name Adapter name\n * @param {Array} environments Environments that the adapter should be activated in\n * @param {Object} config Configuration options for the service\n */\n{\n  name: 'Analytics',\n  environments: ['all'],\n  config: {}\n}\n```\n\nValues in the `config` portion of the object are dependent on the adapter. If you're writing your own adapter, you will be able to retrieve the options passed into it:\n\n```js\n// Example adapter\nexport default class ExampleAdapter extends BaseAdapter {\n  init() {\n    const { apiKey, options } = this.config;\n    this.setupService(apiKey);\n    this.setOptions(options);\n  }\n}\n```\n\nTo only activate adapters in specific environments, you can add an array of environment names to the config, as the `environments` key. Valid environments are:\n\n- `development`\n- `test`\n- `production`\n- `all` (default, will be activated in all environments)\n\n## Content Security Policy\n\nIf you're using [ember-cli-content-security-policy](https://github.com/rwjblue/ember-cli-content-security-policy), you'll need to modify the content security policy to allow loading of any remote scripts. In `config/environment.js`, add this to the `ENV` hash (modify as necessary):\n\n```js\n// example for loading Google Analytics\ncontentSecurityPolicy: {\n  'default-src': \"'none'\",\n  'script-src': \"'self' www.google-analytics.com\",\n  'font-src': \"'self'\",\n  'connect-src': \"'self' www.google-analytics.com\",\n  'img-src': \"'self'\",\n  'style-src': \"'self'\",\n  'media-src': \"'self'\"\n}\n```\n\n## Usage\n\nIn order to use the addon, you must first [configure](#configuration) it, then inject it into any Object registered in the container that you wish to track. For example, you can call a `trackPage` event across all your analytics services whenever you transition into a route, like so:\n\n```js\n// app/routes/application.js\nimport Route from '@ember/routing/route';\nimport { inject as service } from '@ember/service';\n\nexport default class ApplicationRoute extends Route {\n  @service metrics;\n  @service router;\n\n  constructor() {\n    super(...arguments);\n\n    this.router.on('routeDidChange', () =\u003e {\n      const page = this.router.currentURL;\n      const title = this.router.currentRouteName || 'unknown';\n\n      this.metrics.trackPage({ page, title });\n    });\n  }\n}\n```\n\nIf you wish to only call a single service, just specify it's name as the first argument:\n\n```js\n// only invokes the `trackPage` method on the `GoogleAnalyticsAdapter`\nmetrics.trackPage('GoogleAnalytics', {\n  title: 'My Awesome App',\n});\n```\n\n#### Context\n\nOften, you may want to include information like the current user's name with every event or page view that's tracked. Any properties that are set on `metrics.context` will be merged into options for every Service call.\n\n```js\nthis.metrics.context.userName = 'Jimbo';\nthis.metrics.trackPage({ page: 'page/1' }); // { userName: 'Jimbo', page: 'page/1' }\n```\n\n### API\n\n#### Service API\n\nThere are 4 main methods implemented by the service, with the same argument signature:\n\n- `trackPage([analyticsName], options)`\n\n  This is commonly used by analytics services to track page views. Due to the way Single Page Applications implement routing, you will need to call this on the `activate` hook of each route to track all page views.\n\n- `trackEvent([analyticsName], options)`\n\n  This is a general purpose method for tracking a named event in your application.\n\n- `identify([analyticsName], options)`\n\n  For analytics services that have identification functionality.\n\n- `alias([analyticsName], options)`\n\n  For services that implement it, this method notifies the analytics service that an anonymous user now has a unique identifier.\n\nIf an adapter implements specific methods you wish to call, then you can use `invoke`\n\n- `invoke(method, [analyticsName], options)`\n\n  ```js\n  metrics.invoke('trackLink', 'Piwik', {\n    url: 'my_favorite_link',\n    linkType: 'download',\n  });\n  ```\n\n### Lazy Initialization\n\nIf your app implements dynamic API keys for various analytics integration, you can defer the initialization of the adapters. Instead of configuring `ember-metrics` through `config/environment`, you can call the following from any Object registered in the container:\n\n```js\n// app/routes/application.js\nimport Route from '@ember/routing/route';\nimport { inject as service } from '@ember/service';\n\nexport default class ApplicationRoute extends Route {\n  @service metrics;\n\n  afterModel(model) {\n    const id = model.googleAnalyticsKey;\n\n    this.metrics.activateAdapters([\n      {\n        name: 'GoogleAnalytics',\n        environments: ['all'],\n        config: {\n          id,\n        },\n      },\n    ]);\n  }\n}\n```\n\nBecause `activateAdapters` is idempotent, you can call it as many times as you'd like. However, it will not reinstantiate existing adapters.\n\nSince ember-metrics now automatically removes all unused adapters, it's also important to force the inclusion of the adapter via `config/environment`. NOTE: If the adapter is already defined in the `metricsAdapters` array of `config/environment` then this step is not necessary.\n\n```js\n// config/environment\nmodule.exports = function(environment) {\n  var ENV = {\n    'ember-metrics': {\n      includeAdapters: ['google-analytics']\n    }\n  };\n\n  return ENV;\n```\n\n## Writing Your Own Adapters\n\nFirst, generate a new Metrics Adapter:\n\n```sh\n$ ember generate metrics-adapter foo-bar\n```\n\nThis creates `app/metrics-adapters/foo-bar.js` and a unit test at `tests/unit/metrics-adapters/foo-bar-test.js`, which you should now customize.\n\n### Required Methods\n\nThe standard contracts are optionally defined, but `init` and `willDestroy` must be implemented by your adapter.\n\n#### init\n\nThis method is called when an adapter is activated by the service. It is responsible for adding the required script tag used by the integration, and for initializing it.\n\n#### willDestroy\n\nWhen the adapter is destroyed, it should remove its script tag and property. This is usually defined on the `window`.\n\n### Usage\n\nOnce you have implemented your adapter, you can add it to your [app's config](#configuration), like so:\n\n```js\nmodule.exports = function (environment) {\n  var ENV = {\n    metricsAdapters: [\n      {\n        name: 'MyAdapter',\n        environments: ['all'],\n        config: {\n          secret: '29fJs90qnfEa',\n          options: {\n            foo: 'bar',\n          },\n        },\n      },\n    ],\n  };\n};\n```\n\n## Contributors\n\nWe're grateful to these wonderful contributors who've contributed to `ember-metrics`:\n\n[//]: contributor-faces\n\n\u003ca href=\"https://github.com/jherdman\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/3300?v=4\" title=\"jherdman\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/poteto\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/1390709?v=4\" title=\"poteto\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/kellyselden\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/602423?v=4\" title=\"kellyselden\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/chrismllr\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/9942917?v=4\" title=\"chrismllr\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/josemarluedke\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/230476?v=4\" title=\"josemarluedke\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/lfrost\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/5996000?v=4\" title=\"lfrost\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/dcyriller\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/6677373?v=4\" title=\"dcyriller\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/jfdnc\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/15672873?v=4\" title=\"jfdnc\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/mike-north\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/558005?v=4\" title=\"mike-north\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/jelhan\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/4965703?v=4\" title=\"jelhan\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/jwlawrence\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/488888?v=4\" title=\"jwlawrence\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/cah-briangantzler\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/1529286?v=4\" title=\"cah-briangantzler\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/GreatWizard\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/1322081?v=4\" title=\"GreatWizard\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/denneralex\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/5065602?v=4\" title=\"denneralex\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/Turbo87\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/141300?v=4\" title=\"Turbo87\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/CvX\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/66961?v=4\" title=\"CvX\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/Windvis\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/3533236?v=4\" title=\"Windvis\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/sly7-7\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/1826661?v=4\" title=\"sly7-7\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/tyleryasaka\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/6504519?v=4\" title=\"tyleryasaka\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/opsb\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/46232?v=4\" title=\"opsb\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/charlesfries\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/2275005?v=4\" title=\"charlesfries\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/Artmann\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/91954?v=4\" title=\"Artmann\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/colinhoernig\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/195992?v=4\" title=\"colinhoernig\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/gmurphey\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/373721?v=4\" title=\"gmurphey\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/gilest\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/36919?v=4\" title=\"gilest\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/bobisjan\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/112557?v=4\" title=\"bobisjan\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/JoepHeijnen\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/23332441?v=4\" title=\"JoepHeijnen\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/jrjohnson\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/349624?v=4\" title=\"jrjohnson\" width=\"80\" height=\"80\"\u003e\u003c/a\u003e\n\n[//]: contributor-faces\n\n## Contributing\n\nSee the [Contributing](CONTRIBUTING.md) guide for details.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadopted-ember-addons%2Fember-metrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadopted-ember-addons%2Fember-metrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadopted-ember-addons%2Fember-metrics/lists"}