From b82b4a867b19de2aeca49ac659f63a9e7a5c088b Mon Sep 17 00:00:00 2001 From: Chad Hietala Date: Thu, 1 Nov 2018 15:23:02 -0400 Subject: [PATCH 01/22] RouteInfo Metadata Co-Authored-By: rwjblue --- text/0000-RouteInfo-Metadata.md | 217 ++++++++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 text/0000-RouteInfo-Metadata.md diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md new file mode 100644 index 0000000000..5c533ec923 --- /dev/null +++ b/text/0000-RouteInfo-Metadata.md @@ -0,0 +1,217 @@ +- Start Date: 2018-11-02 +- RFC PR: (leave this empty) +- Ember Issue: (leave this empty) + +# RouteInfo MetaData + +## Summary + +The RFC introduces the ability to associate application specific metadata with it's corresponding `RouteInfo` object. This also adds a `metadata` field to the `RouteInfo` which will be the return value of `buildRouteInfoMetadata` for it's corresponding `Route`. + +```js +// app/route/profile.js +import Route from '@ember/routing/route'; +import { inject } from '@ember/service'; +export default Route.extend({ + user: inject('user'), + buildRouteInfoMetadata() { + return { + trackingKey: 'page_profile', + user: { + id: this.user.id, + type: this.user.type + } + } + } + // ... +}); +``` + +```js +// app/services/analytics.js +import Service, { inject } from '@ember/service'; + +export default Service.extend({ + router: inject('router'), + init() { + this._super(...arguments); + this.router.on('routeDidUpdate', (transition) => { + let { to, from } = transition; + let fromMeta = from.metadata; + let toMeta = to.metadata; + ga.sendEvent('pageView', { + from: fromMeta, + to: toMeta, + timestamp: Date.now(), + }) + }) + }, + // ... +}); +``` + +## Motivation + +While the `RouteInfo` object is sufficient in providing developers metadata about the `Route` itself, it is not sufficient in layering on application specific metadata about the `Route`. This metadata could be anything from just a more domain specific name for a `Route` e.g. `profile_page` vs `profile.index`, all the way to providing contextual data when the `Route` was visited. + +## Detailed design + +### `buildRouteInfoMetadata` + +This optional hook is intended to be used as a way of letting the routing system know about any metadata associated with the route. + +#### `Route` Interface Extension + +```ts +interface Route { + // ... existing public API + buildRouteInfoMetadata(): unknown +} +``` + +#### Runtime Semantics + +- **Always** called before the `beforeModel` hook is called +- **Maybe** be called more than once during a transition e.g. aborts, redirects. + +### `RouteInfo.metadata` + +The `metadata` optional field on the `RouteInfo` will be populated with the return value of `buildRouteInfoMetadata`. If there is no metadata associated with the `Route`, the `metadata` field will be `null`. + +```ts +interface RouteInfo { + // ... existing public API + metadata: Maybe; +} +``` + +This field will also be added to `RouteInfoWithAttributes` as it is just a super-set of `RouteInfo`. + + +## How we teach this + +We feel that this a low-level primitive that will allow existing tracking addons to encapsulate. That being said the concept here is pretty simple: What gets returned from `buildRouteInfoMetadata` becomes the value of `RouteInfo.metadata` for that `Route`. + +The guides and tutorial should be updated to encoporate an example on how these APIs could integrate with services like Google Analytics. + +## Drawbacks + +This adds an additional hook that is called during route activation, expands the surface area of the `Route` class. While this is true there is currently know good way to associate application specicific metadata with a route transition. + +## Alternatives + +There are numerous alternative to the proposal: + +### `setRouteMetaData` + +This API would be similar to `setComponentManager` and `setModifierManager`. For example: + +```js +// app/route/profile.js +import Route, { setRouteMetaData } from '@ember/routing/route'; + +export default Route.extend({ + + init() { + this._super(...arguments); + setRouteMetaData(this, { + trackingKey: 'page_profile', + profile: { + viewing: this.userId, + locale: this.userLocale + } + }); + } + // ... +}); +``` + +You would then use the a `RouteInfo` to lookup the value: + + +```js +// app/services/analytics.js +import { getRouteMetaData } from '@ember/routing/route'; +import Service, { inject } from '@ember/service'; + export default Service.extend({ + router: inject('router'), + init() { + this._super(...arguments); + this.router.on('routeDidUpdate', (transition) => { + let { to, from } = transition; + let { trackingKey: fromKey } = getRouteMetaData(from); + let { trackingKey: toKey } = getRouteMetaData(to); + ga.sendEvent('pageView', { + from: fromKey, + to: toKey, + timestamp: Date.now(), + }) + }) + }, + // ... +}); +``` + +This could work but there are two things that are confusing here: + +1. What happens if you call `setRouteMetaData` mutliple times. Do you clobber the existing metadata? Do you merge it? +2. It is very odd that you would use a `RouteInfo` to access the metadata when you set it on the `Route`. + +### `Route.metadata` + +This would add a special field to the `Route` class that would be copied off on to the `RouteInfo`. For example: + +```js +// app/route/profile.js +import Route, { setRouteMetaData } from '@ember/routing/route'; + +export default Route.extend({ + metadata: { + trackingKey: 'page_profile', + profile: { + viewing: this.userId, + locale: this.userLocale + } + } + // ... +}); +``` + +The value would then be populated on `RouteInfo.metadata`. + + +```js +// app/services/analytics.js +import { getRouteMetaData } from '@ember/routing/route'; +import Service, { inject } from '@ember/service'; + export default Service.extend({ + router: inject('router'), + init() { + this._super(...arguments); + this.router.on('routeDidUpdate', (transition) => { + let { to, from } = transition; + let fromMeta = from.metadata; + let toMeta = to.metadata; + ga.sendEvent('pageView', { + from: fromKey, + to: toKey, + timestamp: Date.now(), + }) + }) + }, + // ... +}); +``` + +This could work but there are two things that are problematic here: + +1. What happens to the this data if you subclass it? Do you merge or clobber the field? +2. This is a generic property name and may conflict in existing applications + +### Return MetaData From `activate` + +Today `activate` does not get called when the dynamic segments of the `Route` change, making it not well fit for this use case. + +## Unresolved questions + +TBD? From 526cfbbda42d0659f859eba74137dbd2ea6262ea Mon Sep 17 00:00:00 2001 From: Chad Hietala Date: Fri, 2 Nov 2018 16:34:05 -0400 Subject: [PATCH 02/22] Add document title example --- text/0000-RouteInfo-Metadata.md | 88 +++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index 5c533ec923..b7f52c1943 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -54,6 +54,10 @@ export default Service.extend({ While the `RouteInfo` object is sufficient in providing developers metadata about the `Route` itself, it is not sufficient in layering on application specific metadata about the `Route`. This metadata could be anything from just a more domain specific name for a `Route` e.g. `profile_page` vs `profile.index`, all the way to providing contextual data when the `Route` was visited. +This metadata could be used for more pratical things like updating the `document.title`. Currently addons like [Ember CLI Head](https://github.com/ronco/ember-cli-head) and [Ember CLI Document Title](https://github.com/kimroen/ember-cli-document-title) require to supply special metadata fields on your `Route` that will be used to update the title. This API would be a formalized place to place that metadata. + +See the [appendix](#appendix-a) for examples. + ## Detailed design ### `buildRouteInfoMetadata` @@ -215,3 +219,87 @@ Today `activate` does not get called when the dynamic segments of the `Route` ch ## Unresolved questions TBD? + + +### Apendix A + +Tracking example + +```js +// app/route/profile.js +import Route from '@ember/routing/route'; +import { inject } from '@ember/service'; +export default Route.extend({ + user: inject('user'), + buildRouteInfoMetadata() { + return { + trackingKey: 'page_profile', + user: { + id: this.user.id, + type: this.user.type + } + } + } + // ... +}); +``` + +```js +// app/services/analytics.js +import Service, { inject } from '@ember/service'; + +export default Service.extend({ + router: inject('router'), + init() { + this._super(...arguments); + this.router.on('routeDidUpdate', (transition) => { + let { to, from } = transition; + let fromMeta = from.metadata; + let toMeta = to.metadata; + ga.sendEvent('pageView', { + from: fromMeta, + to: toMeta, + timestamp: Date.now(), + }) + }) + }, + // ... +}); +``` + + +### Appendix B + +Updating document.title + +```js +// app/route/profile.js +import Route from '@ember/routing/route'; +import { inject } from '@ember/service'; +export default Route.extend({ + user: inject('user'), + buildRouteInfoMetadata() { + return { + title: 'My Cool WebPage' + } + } + // ... +}); +``` + +```js +// app/router.js +import Router from '@ember/routing/router'; + +// ... +export default Router.extend({ + init() { + this._super(...arguments); + this.on('routeDidUpdate', (transition) => { + let { title } = transition.metadata; + document.title = title; + }); + }, + // ... +}); +``` \ No newline at end of file From f469a745154c62e5f4812f857f7bafbca7d3fa86 Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Mon, 5 Nov 2018 17:10:26 -0500 Subject: [PATCH 03/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index b7f52c1943..184202c3e0 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -1,5 +1,5 @@ - Start Date: 2018-11-02 -- RFC PR: (leave this empty) +- RFC PR: https://github.com/emberjs/rfcs/pull/398 - Ember Issue: (leave this empty) # RouteInfo MetaData @@ -302,4 +302,4 @@ export default Router.extend({ }, // ... }); -``` \ No newline at end of file +``` From 82e7e81e341b11ff579f2e767ce391e10f423f5a Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Mon, 5 Nov 2018 17:10:50 -0500 Subject: [PATCH 04/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 1 + 1 file changed, 1 insertion(+) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index 184202c3e0..e6194faf04 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -12,6 +12,7 @@ The RFC introduces the ability to associate application specific metadata with i // app/route/profile.js import Route from '@ember/routing/route'; import { inject } from '@ember/service'; + export default Route.extend({ user: inject('user'), buildRouteInfoMetadata() { From ade9f97fb91cb4287aef6f2140aeb140a0375faa Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Mon, 5 Nov 2018 17:10:55 -0500 Subject: [PATCH 05/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index e6194faf04..4665545469 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -11,7 +11,7 @@ The RFC introduces the ability to associate application specific metadata with i ```js // app/route/profile.js import Route from '@ember/routing/route'; -import { inject } from '@ember/service'; +import { inject as service } from '@ember/service'; export default Route.extend({ user: inject('user'), From 2c3c728b0d827336ea641d60e61d4c3b74718e9f Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Mon, 5 Nov 2018 17:11:03 -0500 Subject: [PATCH 06/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index 4665545469..a1937d201c 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -53,7 +53,7 @@ export default Service.extend({ ## Motivation -While the `RouteInfo` object is sufficient in providing developers metadata about the `Route` itself, it is not sufficient in layering on application specific metadata about the `Route`. This metadata could be anything from just a more domain specific name for a `Route` e.g. `profile_page` vs `profile.index`, all the way to providing contextual data when the `Route` was visited. +While the `RouteInfo` object is sufficient in providing developers metadata about the `Route` itself, it is not sufficient in layering on application specific metadata about the `Route`. This metadata could be anything from a more domain-specific name for a `Route`, e.g. `profile_page` vs `profile.index`, all the way to providing contextual data when the `Route` was visited. This metadata could be used for more pratical things like updating the `document.title`. Currently addons like [Ember CLI Head](https://github.com/ronco/ember-cli-head) and [Ember CLI Document Title](https://github.com/kimroen/ember-cli-document-title) require to supply special metadata fields on your `Route` that will be used to update the title. This API would be a formalized place to place that metadata. From 7aa2971caa7a17007da38b5d1862b922e4f831e4 Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Mon, 5 Nov 2018 17:11:13 -0500 Subject: [PATCH 07/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index a1937d201c..9b0c057131 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -55,7 +55,8 @@ export default Service.extend({ While the `RouteInfo` object is sufficient in providing developers metadata about the `Route` itself, it is not sufficient in layering on application specific metadata about the `Route`. This metadata could be anything from a more domain-specific name for a `Route`, e.g. `profile_page` vs `profile.index`, all the way to providing contextual data when the `Route` was visited. -This metadata could be used for more pratical things like updating the `document.title`. Currently addons like [Ember CLI Head](https://github.com/ronco/ember-cli-head) and [Ember CLI Document Title](https://github.com/kimroen/ember-cli-document-title) require to supply special metadata fields on your `Route` that will be used to update the title. This API would be a formalized place to place that metadata. +This metadata could be used for more pratical things like updating the `document.title`. +Currently, addons like [Ember CLI Head](https://github.com/ronco/ember-cli-head) and [Ember CLI Document Title](https://github.com/kimroen/ember-cli-document-title) require the user to supply special metadata fields on your `Route` that will be used to update the title. This API would be a formalized place to place that metadata. See the [appendix](#appendix-a) for examples. From ad677753f776a684b25cc4ddae5ee4254f37a6ef Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Mon, 5 Nov 2018 17:11:39 -0500 Subject: [PATCH 08/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index 9b0c057131..4e0898a7b8 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -78,7 +78,7 @@ interface Route { #### Runtime Semantics - **Always** called before the `beforeModel` hook is called -- **Maybe** be called more than once during a transition e.g. aborts, redirects. +- **Maybe** called more than once during a transition e.g. aborts, redirects. ### `RouteInfo.metadata` From 42ed7fbc30c06a99e7b16bbbfcacca4742e05302 Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Mon, 5 Nov 2018 17:11:46 -0500 Subject: [PATCH 09/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index 4e0898a7b8..d7a65c14cc 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -82,7 +82,7 @@ interface Route { ### `RouteInfo.metadata` -The `metadata` optional field on the `RouteInfo` will be populated with the return value of `buildRouteInfoMetadata`. If there is no metadata associated with the `Route`, the `metadata` field will be `null`. +The `metadata` optional field on `RouteInfo` will be populated with the return value of `buildRouteInfoMetadata`. If there is no metadata associated with the `Route`, the `metadata` field will be `null`. ```ts interface RouteInfo { From c191ee8d91c40d762c109347bf7cad971dd26b60 Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Mon, 5 Nov 2018 17:11:51 -0500 Subject: [PATCH 10/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index d7a65c14cc..dc7af581f3 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -98,7 +98,7 @@ This field will also be added to `RouteInfoWithAttributes` as it is just a super We feel that this a low-level primitive that will allow existing tracking addons to encapsulate. That being said the concept here is pretty simple: What gets returned from `buildRouteInfoMetadata` becomes the value of `RouteInfo.metadata` for that `Route`. -The guides and tutorial should be updated to encoporate an example on how these APIs could integrate with services like Google Analytics. +The guides and tutorial should be updated to incorporate an example on how these APIs could integrate with services like Google Analytics. ## Drawbacks From 36795dbe2c6435e7e19d875386f6a41a0c7e21ee Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Mon, 5 Nov 2018 17:11:54 -0500 Subject: [PATCH 11/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index dc7af581f3..545f23a396 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -102,7 +102,8 @@ The guides and tutorial should be updated to incorporate an example on how these ## Drawbacks -This adds an additional hook that is called during route activation, expands the surface area of the `Route` class. While this is true there is currently know good way to associate application specicific metadata with a route transition. +This adds an additional hook that is called during route activation, expanding the surface area of the `Route` class. +While this is true, there is currently no good way to associate application-specific metadata with a route transition. ## Alternatives From fa93479b695d27200336bb43145e4ece060fe570 Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Mon, 5 Nov 2018 17:11:59 -0500 Subject: [PATCH 12/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index 545f23a396..cbdeef4564 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -109,7 +109,7 @@ While this is true, there is currently no good way to associate application-spec There are numerous alternative to the proposal: -### `setRouteMetaData` +### `setRouteMetadata` This API would be similar to `setComponentManager` and `setModifierManager`. For example: From 4a564249b2b8521ef669dac211fa5f1ed3e051e9 Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Mon, 5 Nov 2018 17:12:04 -0500 Subject: [PATCH 13/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index cbdeef4564..a183068bd9 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -115,7 +115,7 @@ This API would be similar to `setComponentManager` and `setModifierManager`. For ```js // app/route/profile.js -import Route, { setRouteMetaData } from '@ember/routing/route'; +import Route, { setRouteMetadata } from '@ember/routing/route'; export default Route.extend({ From bfed6f367a54d00a5445064693676edd36ac6660 Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Mon, 5 Nov 2018 17:12:08 -0500 Subject: [PATCH 14/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index a183068bd9..c3c42d2e00 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -121,7 +121,7 @@ export default Route.extend({ init() { this._super(...arguments); - setRouteMetaData(this, { + setRouteMetadata(this, { trackingKey: 'page_profile', profile: { viewing: this.userId, From 2677e9dab783723b5b6f9823e7138a122f6a1e28 Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Mon, 5 Nov 2018 17:12:11 -0500 Subject: [PATCH 15/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index c3c42d2e00..9274230952 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -138,7 +138,7 @@ You would then use the a `RouteInfo` to lookup the value: ```js // app/services/analytics.js -import { getRouteMetaData } from '@ember/routing/route'; +import { getRouteMetadata } from '@ember/routing/route'; import Service, { inject } from '@ember/service'; export default Service.extend({ router: inject('router'), From 3d2630b5684842c828bae223f7149ec1a6f7599f Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Mon, 5 Nov 2018 17:12:14 -0500 Subject: [PATCH 16/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index 9274230952..e85831f327 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -146,7 +146,7 @@ import Service, { inject } from '@ember/service'; this._super(...arguments); this.router.on('routeDidUpdate', (transition) => { let { to, from } = transition; - let { trackingKey: fromKey } = getRouteMetaData(from); + let { trackingKey: fromKey } = getRouteMetadata(from); let { trackingKey: toKey } = getRouteMetaData(to); ga.sendEvent('pageView', { from: fromKey, From 64b0f5a3b650623f8d68f6479174564bf16d3a7d Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Mon, 5 Nov 2018 17:12:17 -0500 Subject: [PATCH 17/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index e85831f327..0b06a66dc8 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -147,7 +147,7 @@ import Service, { inject } from '@ember/service'; this.router.on('routeDidUpdate', (transition) => { let { to, from } = transition; let { trackingKey: fromKey } = getRouteMetadata(from); - let { trackingKey: toKey } = getRouteMetaData(to); + let { trackingKey: toKey } = getRouteMetadata(to); ga.sendEvent('pageView', { from: fromKey, to: toKey, From caa8d8707797b70e173f4a434204ab89e824e62b Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Mon, 5 Nov 2018 17:12:20 -0500 Subject: [PATCH 18/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index 0b06a66dc8..f852d25fd4 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -161,7 +161,7 @@ import Service, { inject } from '@ember/service'; This could work but there are two things that are confusing here: -1. What happens if you call `setRouteMetaData` mutliple times. Do you clobber the existing metadata? Do you merge it? +1. What happens if you call `setRouteMetadata` mutliple times. Do you clobber the existing metadata? Do you merge it? 2. It is very odd that you would use a `RouteInfo` to access the metadata when you set it on the `Route`. ### `Route.metadata` From 448274657f969b4c3946285357c3a89c5a44a595 Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Mon, 5 Nov 2018 17:12:23 -0500 Subject: [PATCH 19/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index f852d25fd4..5f7582b1fc 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -170,7 +170,7 @@ This would add a special field to the `Route` class that would be copied off on ```js // app/route/profile.js -import Route, { setRouteMetaData } from '@ember/routing/route'; +import Route, { setRouteMetadata } from '@ember/routing/route'; export default Route.extend({ metadata: { From 9124f7b88933cb1bf632c425c4fd4455a678ba0e Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Mon, 5 Nov 2018 17:12:25 -0500 Subject: [PATCH 20/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index 5f7582b1fc..d72d89bd91 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -189,7 +189,7 @@ The value would then be populated on `RouteInfo.metadata`. ```js // app/services/analytics.js -import { getRouteMetaData } from '@ember/routing/route'; +import { getRouteMetadata } from '@ember/routing/route'; import Service, { inject } from '@ember/service'; export default Service.extend({ router: inject('router'), From 653fd9cc6194a2e4ed3453942f243443c55ca36e Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Mon, 5 Nov 2018 17:12:28 -0500 Subject: [PATCH 21/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index d72d89bd91..10fb1f71d8 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -215,7 +215,7 @@ This could work but there are two things that are problematic here: 1. What happens to the this data if you subclass it? Do you merge or clobber the field? 2. This is a generic property name and may conflict in existing applications -### Return MetaData From `activate` +### Return Metadata From `activate` Today `activate` does not get called when the dynamic segments of the `Route` change, making it not well fit for this use case. From 17b6ee2ae1ec6850f1489ca0627a711bf06a52b8 Mon Sep 17 00:00:00 2001 From: Ricardo Mendes Date: Wed, 7 Nov 2018 10:37:12 -0500 Subject: [PATCH 22/22] Update text/0000-RouteInfo-Metadata.md Co-Authored-By: chadhietala --- text/0000-RouteInfo-Metadata.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/0000-RouteInfo-Metadata.md b/text/0000-RouteInfo-Metadata.md index 10fb1f71d8..e8bb2e18a8 100644 --- a/text/0000-RouteInfo-Metadata.md +++ b/text/0000-RouteInfo-Metadata.md @@ -6,7 +6,7 @@ ## Summary -The RFC introduces the ability to associate application specific metadata with it's corresponding `RouteInfo` object. This also adds a `metadata` field to the `RouteInfo` which will be the return value of `buildRouteInfoMetadata` for it's corresponding `Route`. +The RFC introduces the ability to associate application specific metadata with its corresponding `RouteInfo` object. This also adds a `metadata` field to `RouteInfo`, which will be the return value of `buildRouteInfoMetadata` for its corresponding `Route`. ```js // app/route/profile.js