Allow usage of analytics adapter (#2327)
* Allow usage of analytics adapter * Use promises in controller
This commit is contained in:
committed by
Florent Vilmart
parent
02edf27f05
commit
d1a6caeee3
@@ -1,17 +1,20 @@
|
||||
// AnalyticsRouter.js
|
||||
import PromiseRouter from '../PromiseRouter';
|
||||
|
||||
// Returns a promise that resolves to an empty object response
|
||||
function ignoreAndSucceed(req) {
|
||||
return Promise.resolve({
|
||||
response: {}
|
||||
});
|
||||
function appOpened(req) {
|
||||
const analyticsController = req.config.analyticsController;
|
||||
return analyticsController.appOpened(req);
|
||||
}
|
||||
|
||||
function trackEvent(req) {
|
||||
const analyticsController = req.config.analyticsController;
|
||||
return analyticsController.trackEvent(req);
|
||||
}
|
||||
|
||||
|
||||
export class AnalyticsRouter extends PromiseRouter {
|
||||
mountRoutes() {
|
||||
this.route('POST','/events/AppOpened', ignoreAndSucceed);
|
||||
this.route('POST','/events/:eventName', ignoreAndSucceed);
|
||||
this.route('POST','/events/AppOpened', appOpened);
|
||||
this.route('POST','/events/:eventName', trackEvent);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user