Last active
August 8, 2019 18:56
-
-
Save knownasilya/4e86b04b5075e28d5e458cd57a169f0c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import EmberRouter from '@ember/routing/router'; | |
import { inject as service } from '@ember/service'; | |
import config from './config/environment'; | |
export default class Router extends EmberRouter { | |
@service metrics; | |
@service router; | |
@service fastboot; | |
@service headData; | |
location = config.locationType; | |
rootURL = config.rootURL; | |
init() { | |
super.init(...arguments); | |
this.on('routeDidChange', () => { | |
if (!this.fastboot.isFastBoot) { | |
// calculate data | |
let data = { | |
page: this.router.currentURL | |
}; | |
// send to tracking service | |
this.metrics.trackPage(data); | |
} | |
// set head data for fastboot & opengraph | |
this.set('headData.ogUrl',`...${this.router.currentURL}`); | |
}); | |
} | |
} | |
Router.map(function() { | |
// routes here | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment