-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathlibrary.js
More file actions
45 lines (36 loc) · 1.13 KB
/
library.js
File metadata and controls
45 lines (36 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict';
const meta = require.main.require('./src/meta');
const controllers = require('./lib/controllers');
const PLUGIN_NAME = 'google-analytics';
const plugin = {
settings: {},
};
plugin.init = async function(params) {
const { router } = params;
const routeHelpers = require.main.require('./src/routes/helpers');
routeHelpers.setupAdminPageRoute(router, `/admin/plugins/${PLUGIN_NAME}`, controllers.renderAdminPage);
};
plugin.filterConfigGet = async function (config) {
config[PLUGIN_NAME] = await meta.settings.get(PLUGIN_NAME);
return config;
};
plugin.addAdminNavigation = async (header) => {
header.plugins.push({
route: `/plugins/${PLUGIN_NAME}`,
icon: 'fa-bar-chart-o',
name: 'Google Analytics'
});
return header;
};
plugin.getNotices = async (notices) => {
const settings = await meta.settings.get(PLUGIN_NAME);
const gaId = settings.useUA === 'on' ? settings.id : settings.ga4id;
notices.push({
done: gaId !== undefined && gaId.length > 0,
doneText: 'Google Analytics OK',
notDoneText: 'Google Analytics needs setup',
link: '/admin/plugins/google-analytics',
});
return notices;
};
module.exports = plugin;