2018-01-20 00:46:47 -08:00
|
|
|
import Route from '@ember/routing/route';
|
|
|
|
import { get } from '@ember/object';
|
|
|
|
import { inject } from '@ember/service';
|
2017-02-13 15:07:18 -08:00
|
|
|
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';
|
2018-07-24 11:01:50 -07:00
|
|
|
import Configurator from 'wherehows-web/services/configurator';
|
2017-02-13 15:07:18 -08:00
|
|
|
|
2017-05-22 19:55:07 -07:00
|
|
|
export default Route.extend(AuthenticatedRouteMixin, {
|
|
|
|
/**
|
|
|
|
* @type {Ember.Service}
|
|
|
|
*/
|
2018-01-20 00:46:47 -08:00
|
|
|
sessionUser: inject('current-user'),
|
2017-05-22 19:55:07 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Metrics tracking service
|
|
|
|
* @type {Ember.Service}
|
|
|
|
*/
|
2018-01-20 00:46:47 -08:00
|
|
|
metrics: inject(),
|
2017-09-18 17:51:36 -07:00
|
|
|
|
2017-05-22 19:55:07 -07:00
|
|
|
/**
|
|
|
|
* Perform post model operations
|
|
|
|
* @return {Promise}
|
|
|
|
*/
|
2018-07-10 21:32:14 -07:00
|
|
|
async beforeModel() {
|
2017-05-22 19:55:07 -07:00
|
|
|
this._super(...arguments);
|
|
|
|
|
2018-07-10 21:32:14 -07:00
|
|
|
await this._trackCurrentUser();
|
|
|
|
this.replaceWithBrowseDatasetsRoute();
|
|
|
|
},
|
|
|
|
|
|
|
|
replaceWithBrowseDatasetsRoute() {
|
2018-07-24 11:23:13 -07:00
|
|
|
this.replaceWith('browse.entity', 'datasets');
|
2017-05-22 19:55:07 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* On entry into route, track the currently logged in user
|
|
|
|
* @return {Promise.<void>}
|
|
|
|
* @private
|
|
|
|
*/
|
|
|
|
async _trackCurrentUser() {
|
2018-07-24 11:01:50 -07:00
|
|
|
const { tracking = {} } = await 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
|
|
|
}
|
|
|
|
});
|