|
2 | 2 |
|
3 | 3 | import fi.helsinki.cs.tmc.core.domain.Course; |
4 | 4 | import fi.helsinki.cs.tmc.core.domain.Exercise; |
5 | | -import fi.helsinki.cs.tmc.spyware.EventSendBuffer; |
6 | | -import fi.helsinki.cs.tmc.spyware.LoggableEvent; |
7 | | -import fi.helsinki.cs.tmc.spyware.SpywareSettings; |
| 5 | +import fi.helsinki.cs.tmc.snapshots.EventSendBuffer; |
| 6 | +import fi.helsinki.cs.tmc.snapshots.LoggableEvent; |
8 | 7 | import org.slf4j.LoggerFactory; |
9 | 8 | import java.util.Optional; |
10 | 9 |
|
11 | 10 | public class AnalyticsFacade { |
12 | 11 | private static final org.slf4j.Logger logger = LoggerFactory.getLogger(AnalyticsFacade.class); |
13 | 12 |
|
14 | 13 | private EventSendBuffer eventSendBuffer; |
15 | | - private SpywareSettings settings; |
16 | 14 |
|
17 | | - public AnalyticsFacade(SpywareSettings settings, EventSendBuffer eventSendBuffer) { |
18 | | - this.settings = settings; |
| 15 | + public AnalyticsFacade(EventSendBuffer eventSendBuffer) { |
19 | 16 | this.eventSendBuffer = eventSendBuffer; |
20 | 17 | } |
21 | 18 |
|
22 | 19 | public void saveAnalytics(String command) { |
23 | | - if (!settings.isSpywareEnabled()) { |
24 | | - return; |
25 | | - } |
26 | 20 | LoggableEvent event = LoggableEventCreator.createEvent(command); |
27 | 21 | saveEvent(event); |
28 | 22 | } |
29 | 23 |
|
30 | 24 | public void saveAnalytics(String courseName, String command) { |
31 | | - if (!settings.isSpywareEnabled()) { |
32 | | - return; |
33 | | - } |
34 | 25 | LoggableEvent event = LoggableEventCreator.createEvent(courseName, command); |
35 | 26 | saveEvent(event); |
36 | 27 | } |
37 | 28 |
|
38 | 29 | public void saveAnalytics(Course course, String command) { |
39 | | - if (!settings.isSpywareEnabled()) { |
40 | | - return; |
41 | | - } |
42 | 30 | LoggableEvent event = LoggableEventCreator.createEvent(course, command); |
43 | 31 | saveEvent(event); |
44 | 32 | } |
45 | 33 |
|
46 | 34 | public void saveAnalytics(Exercise exercise, String command) { |
47 | | - if (!settings.isSpywareEnabled()) { |
48 | | - return; |
49 | | - } |
50 | 35 | LoggableEvent event = LoggableEventCreator.createEvent(exercise, command); |
51 | 36 | saveEvent(event); |
52 | 37 | } |
53 | 38 |
|
54 | 39 | public Optional<Thread> sendAnalytics() { |
55 | | - if (!settings.isSpywareEnabled()) { |
56 | | - return Optional.empty(); |
57 | | - } |
58 | 40 | Thread t = new Thread(() -> this.eventSendBuffer.sendNow()); |
59 | 41 | t.run(); |
60 | 42 | return Optional.of(t); |
|
0 commit comments