fix: run analytics only on version specified in config
This commit is contained in:
parent
8c8a0a42f4
commit
cf86c50d60
2 changed files with 18 additions and 12 deletions
|
@ -9,5 +9,6 @@ This changelog only contains the changes that are unreleased. For changes for in
|
|||
|
||||
### Fixes
|
||||
- Add missing server_run analytics event
|
||||
- Run analytics only on version specified in config
|
||||
|
||||
### Misc
|
||||
|
|
|
@ -162,25 +162,30 @@ public final class Analytics {
|
|||
}
|
||||
|
||||
public static void endSession() {
|
||||
timer.cancel();
|
||||
if (sessionInitialised) {
|
||||
timer.cancel();
|
||||
|
||||
if (events.size() != 0) {
|
||||
sendAllStoredEvents(true);
|
||||
}
|
||||
if (events.size() != 0) {
|
||||
sendAllStoredEvents(true);
|
||||
}
|
||||
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("userId", App.settings.analyticsClientId);
|
||||
body.put("sessionId", sessionId);
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("userId", App.settings.analyticsClientId);
|
||||
body.put("sessionId", sessionId);
|
||||
|
||||
try {
|
||||
CompletableFuture<AnalyticsApiResponse> response = makeApiCall("/session/end", body);
|
||||
response.get(10, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException | ExecutionException | TimeoutException ignored) {
|
||||
try {
|
||||
CompletableFuture<AnalyticsApiResponse> response = makeApiCall("/session/end", body);
|
||||
response.get(10, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException | ExecutionException | TimeoutException ignored) {
|
||||
}
|
||||
|
||||
sessionInitialised = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
if (ConfigManager.getConfigItem("analytics.enabled", false) != true) {
|
||||
if (!ConfigManager.getConfigItem("analytics.enabledVersion", "None")
|
||||
.equals(Constants.VERSION.toStringForLogging())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue