2017-02-13 15:07:18 -08:00
|
|
|
import Ember from 'ember';
|
|
|
|
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
|
2017-09-18 17:51:36 -07:00
|
|
|
import { featureEntryPoints } from 'wherehows-web/constants/application';
|
2017-02-13 15:07:18 -08:00
|
|
|
|
2017-05-22 19:55:07 -07:00
|
|
|
const { get, Route, inject: { service } } = Ember;
|
2017-09-18 17:51:36 -07:00
|
|
|
const { browse, scriptFinder, schemaHistory, idpc } = featureEntryPoints;
|
2017-05-22 19:55:07 -07:00
|
|
|
|
|
|
|
export default Route.extend(AuthenticatedRouteMixin, {
|
|
|
|
/**
|
|
|
|
* @type {Ember.Service}
|
|
|
|
*/
|
|
|
|
sessionUser: service('current-user'),
|
|
|
|
|
2017-06-19 16:35:00 -07:00
|
|
|
/**
|
|
|
|
* Runtime application configuration options
|
|
|
|
* @type {Ember.Service}
|
|
|
|
*/
|
|
|
|
configurator: service(),
|
|
|
|
|
2017-05-22 19:55:07 -07:00
|
|
|
/**
|
|
|
|
* Metrics tracking service
|
|
|
|
* @type {Ember.Service}
|
|
|
|
*/
|
|
|
|
metrics: service(),
|
2017-09-18 17:51:36 -07:00
|
|
|
|
2017-04-27 00:57:29 -07:00
|
|
|
model() {
|
|
|
|
// Static list of content for the index route featureCard links
|
2017-09-18 17:51:36 -07:00
|
|
|
return [browse, scriptFinder, schemaHistory, idpc];
|
2017-05-22 19:55:07 -07:00
|
|
|
},
|
|
|
|
/**
|
|
|
|
* Perform post model operations
|
|
|
|
* @return {Promise}
|
|
|
|
*/
|
|
|
|
afterModel() {
|
|
|
|
this._super(...arguments);
|
|
|
|
|
|
|
|
return this._trackCurrentUser();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* On entry into route, track the currently logged in user
|
|
|
|
* @return {Promise.<void>}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
async _trackCurrentUser() {
|
2017-06-19 16:35:00 -07:00
|
|
|
const { tracking = {} } = await get(this, 'configurator.getConfig')();
|
2017-05-22 19:55:07 -07:00
|
|
|
|
2017-06-19 16:35:00 -07:00
|
|
|
// Check if tracking is enabled prior to invoking
|
|
|
|
// Passes an anonymous function to track the currently logged in user using the singleton `current-user` service
|
|
|
|
return (
|
|
|
|
tracking.isEnabled &&
|
|
|
|
get(this, 'sessionUser').trackCurrentUser(userId => get(this, 'metrics').identify({ userId }))
|
|
|
|
);
|
2017-02-13 15:07:18 -08:00
|
|
|
}
|
|
|
|
});
|