mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Add analytics service to v3
This commit is contained in:
23
website/src/middlewares/api-v3/analytics.js
Normal file
23
website/src/middlewares/api-v3/analytics.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import nconf from 'nconf';
|
||||
import {
|
||||
track,
|
||||
trackPurchase,
|
||||
mockAnalyticsService,
|
||||
} from '../../libs/api-v3/analyticsService';
|
||||
|
||||
let service;
|
||||
|
||||
if (nconf.get('IS_PROD')) {
|
||||
service = {
|
||||
track,
|
||||
trackPurchase,
|
||||
};
|
||||
} else {
|
||||
service = mockAnalyticsService;
|
||||
}
|
||||
|
||||
export default function attachAnalytics (req, res, next) {
|
||||
res.analytics = service;
|
||||
|
||||
next();
|
||||
}
|
||||
Reference in New Issue
Block a user