-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.php
More file actions
106 lines (89 loc) · 3.17 KB
/
start.php
File metadata and controls
106 lines (89 loc) · 3.17 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/**
* User and usage statistics
*
* @author Ismayil Khayredinov <ismayil@arckinteractive.com>
*/
require_once __DIR__ . '/autoloader.php';
use ArckInteractive\Analytics\LoggingService;
use ArckInteractive\Analytics\Menus;
use ArckInteractive\Analytics\Router;
elgg_register_event_handler('init', 'system', function() {
/*
* Log page view
*/
elgg_register_action('analytics/log_page_view', __DIR__ . '/actions/analytics/log_page_view.php', 'public');
elgg_extend_view('page/elements/foot', 'analytics/logger/page');
/*
* Log entity summary/profile views
*/
elgg_register_action('analytics/log_entity_view', __DIR__ . '/actions/analytics/log_entity_view.php', 'public');
elgg_register_plugin_hook_handler('view', 'profile/details', [LoggingService::class, 'logProfileViewHandler']);
elgg_register_plugin_hook_handler('view', 'groups/profile/layout', [LoggingService::class, 'logProfileViewHandler']);
elgg_register_plugin_hook_handler('view', 'object/default', [LoggingService::class, 'logListingViewHandler']);
$subtypes = (array) get_registered_entity_types('object');
foreach ($subtypes as $subtype) {
elgg_register_plugin_hook_handler('view', "object/$subtype", [LoggingService::class, 'logListingViewHandler']);
}
$translations = [];
foreach ($subtypes as $subtype) {
$translations["analytics:stat:posts:$subtype"] = elgg_echo("item:object:$subtype");
}
add_translation(get_current_language(), $translations);
/*
* Log events
*/
elgg_register_action('analytics/log_event', __DIR__ . '/actions/analytics/log_event.php', 'public');
elgg_extend_view('elgg.js', 'analytics/logger/events.js');
elgg_register_event_handler('all', 'object', [LoggingService::class, 'entityEventHandler'], 999);
elgg_register_event_handler('all', 'group', [LoggingService::class, 'entityEventHandler'], 999);
elgg_register_event_handler('all', 'user', [LoggingService::class, 'entityEventHandler'], 999);
elgg_register_event_handler('all', 'relationship', [LoggingService::class, 'relationshipEventHandler'], 999);
/*
* Log benchmarks
*/
elgg_register_plugin_hook_handler('cron', 'daily', [LoggingService::class, 'logDailyBenchmarks']);
/*
* Reports
*/
elgg_register_page_handler('analytics', [Router::class, 'analyticsHandler']);
/*
* Widgets
*/
$types = [
'a_sessions',
'a_visitors',
'a_page_views',
'a_entity_views',
'a_posts',
'a_registration',
'a_geography',
'a_top_pages',
'a_top_posts',
'a_active_users',
];
foreach ($types as $type) {
$name = elgg_echo("analytics:widget:$type");
elgg_register_widget_type($type, $name, null, ['analytics', 'admin'], true);
}
/*
* Assets
*/
elgg_define_js('chartjs', [
'src' => elgg_get_simplecache_url('chartjs/Chart.js'),
'exports' => 'Chart',
]);
elgg_extend_view('elgg.css', 'analytics/styles.css');
elgg_extend_view('admin.css', 'analytics/styles.css');
elgg_register_ajax_view('analytics/charts/map');
/*
* Menus
*/
elgg_register_plugin_hook_handler('register', 'menu:user_hover', [Menus::class, 'setupUserHoverMenu']);
}, 1001);
elgg_register_event_handler('upgrade', 'system', function() {
if (!elgg_is_admin_logged_in()) {
return;
}
require __DIR__ . '/lib/upgrades.php';
});