feat: add logging for Java version and install method on launch if analytics enabled
This commit is contained in:
parent
59cc868dd6
commit
2dcce88594
16 changed files with 184 additions and 10 deletions
|
@ -14,6 +14,7 @@ This changelog only contains the changes that are unreleased. For changes for in
|
|||
- Add name of platform an instance is from when launching [#740]
|
||||
- Add in Get Help button to more instances when available [#734]
|
||||
- Add dialog warning user when trying to skip external download mods from CurseForge
|
||||
- Add logging for Java version and install method on launch if analytics enabled
|
||||
|
||||
### Fixes
|
||||
- Remove old OmitStackTraceInFastThrow JVM arg
|
||||
|
|
11
README.md
11
README.md
|
@ -75,6 +75,17 @@ To check for dependency updates with gradle, simply run:
|
|||
|
||||
This will print a report to the console about any dependencies which have updates.
|
||||
|
||||
## Updating new GraphQL queries/mutations
|
||||
|
||||
When new GraphQL queries/mutations are added into the `src/main/graphql` directory, you must run the below 2 commands:
|
||||
|
||||
```sh
|
||||
./gradlew downloadApolloSchema --endpoint="https://api.atlauncher.com/v2/graphql" --schema="src/main/graphql/com/atlauncher/schema.json"
|
||||
./gradlew generateApolloSources
|
||||
```
|
||||
|
||||
This will fetch the latest schema and then codegen the java files so you can use the query/mutation.
|
||||
|
||||
## Updating license headers in all files
|
||||
|
||||
If you add new files, or update the `LICENSEHEADER` file, you can add that to all source files by running:
|
||||
|
|
|
@ -9,4 +9,4 @@ cd "${HOME}/.local/share/atlauncher"
|
|||
cp -u /usr/share/java/atlauncher/ATLauncher.jar .
|
||||
|
||||
# disable launcher updates since we're managing updates through AUR
|
||||
exec java -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -jar ATLauncher.jar --no-launcher-update "$@" >/dev/null
|
||||
exec java -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -jar ATLauncher.jar --install-method=aur-bin --no-launcher-update "$@" >/dev/null
|
||||
|
|
|
@ -9,4 +9,4 @@ cd "${HOME}/.local/share/atlauncher"
|
|||
cp -u /usr/share/java/atlauncher/ATLauncher.jar .
|
||||
|
||||
# disable launcher updates since we're managing updates through AUR
|
||||
exec java -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -jar ATLauncher.jar --no-launcher-update "$@" >/dev/null
|
||||
exec java -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -jar ATLauncher.jar --install-method=aur --no-launcher-update "$@" >/dev/null
|
||||
|
|
|
@ -4,7 +4,7 @@ LABEL maintainer="ryan.dowling@atlauncher.com"
|
|||
# add in all the files
|
||||
ADD deb/control /work/atlauncher/DEBIAN/control
|
||||
ADD deb/postrm /work/atlauncher/DEBIAN/postrm
|
||||
ADD _common/atlauncher /work/atlauncher/usr/bin/atlauncher
|
||||
ADD deb/atlauncher /work/atlauncher/usr/bin/atlauncher
|
||||
ADD _common/atlauncher.desktop /work/atlauncher/usr/share/applications/atlauncher.desktop
|
||||
ADD _common/atlauncher.metainfo.xml /work/atlauncher/usr/share/metainfo/atlauncher.metainfo.xml
|
||||
ADD _common/atlauncher.png /work/atlauncher/usr/share/pixmaps/atlauncher.png
|
||||
|
|
|
@ -13,4 +13,4 @@ if [[ ! -f ${INSTDIR}/ATLauncher.jar ]]; then
|
|||
wget "https://download.nodecdn.net/containers/atl/ATLauncher.jar" 2>&1
|
||||
fi
|
||||
|
||||
exec java -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -jar ATLauncher.jar "$@"
|
||||
exec java -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -jar ATLauncher.jar --install-method=deb "$@"
|
|
@ -8,7 +8,7 @@ RUN dnf install -y rpmdevtools libappstream-glib desktop-file-utils \
|
|||
|
||||
# add in all the files
|
||||
ADD rpm/atlauncher.spec /work/atlauncher.spec
|
||||
ADD _common/atlauncher /work/atlauncher
|
||||
ADD rpm/atlauncher /work/atlauncher
|
||||
ADD _common/atlauncher.desktop /work/atlauncher.desktop
|
||||
ADD _common/atlauncher.metainfo.xml /work/atlauncher.metainfo.xml
|
||||
ADD _common/atlauncher.png /work/atlauncher.png
|
||||
|
|
16
packaging/linux/rpm/atlauncher
Normal file
16
packaging/linux/rpm/atlauncher
Normal file
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
INSTDIR="${XDG_DATA_HOME-$HOME/.local/share}/atlauncher"
|
||||
|
||||
if [[ ! -d ${INSTDIR} ]]; then
|
||||
mkdir -p $INSTDIR
|
||||
fi
|
||||
|
||||
cd $INSTDIR
|
||||
|
||||
if [[ ! -f ${INSTDIR}/ATLauncher.jar ]]; then
|
||||
wget "https://download.nodecdn.net/containers/atl/ATLauncher.jar" 2>&1
|
||||
fi
|
||||
|
||||
exec java -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -jar ATLauncher.jar --install-method=rpm "$@"
|
|
@ -0,0 +1,3 @@
|
|||
mutation AddLauncherLaunch($input: AddLauncherLaunchInput!) {
|
||||
addLauncherLaunch(input: $input)
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -159,6 +159,14 @@ public class App {
|
|||
*/
|
||||
public static boolean disableErrorReporting = false;
|
||||
|
||||
/**
|
||||
* This is passed in by launch scripts on Linux to help the launcher know which
|
||||
* method was used to install the launcher (deb, rpm, aur or aur-bin)
|
||||
* <p/>
|
||||
* --install-method=deb
|
||||
*/
|
||||
public static String installMethod = null;
|
||||
|
||||
/**
|
||||
* This forces the working directory for the launcher. It can be changed with
|
||||
* the below command line argument.
|
||||
|
@ -478,8 +486,7 @@ public class App {
|
|||
boolean matched = false;
|
||||
|
||||
// user used the installer
|
||||
if (Files.exists(FileSystem.BASE_DIR.resolve("unins000.dat"))
|
||||
&& Files.exists(FileSystem.BASE_DIR.resolve("unins000.exe"))) {
|
||||
if (OS.isWindows() && OS.usedInstaller()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -856,6 +863,8 @@ public class App {
|
|||
parser.accepts("disable-analytics", "If analytics should be disabled.").withOptionalArg().ofType(Boolean.class);
|
||||
parser.accepts("disable-error-reporting", "If error reporting should be disabled.").withOptionalArg()
|
||||
.ofType(Boolean.class);
|
||||
parser.accepts("install-method", "The method used to install the launcher.").withRequiredArg()
|
||||
.ofType(String.class);
|
||||
parser.accepts("working-dir", "This forces the working directory for the launcher.").withRequiredArg()
|
||||
.ofType(String.class);
|
||||
parser.accepts("base-launcher-domain", "The base launcher domain.").withRequiredArg().ofType(String.class);
|
||||
|
@ -933,6 +942,10 @@ public class App {
|
|||
LogManager.debug("Disabling error reporting!");
|
||||
}
|
||||
|
||||
if (options.has("install-method")) {
|
||||
installMethod = (String) options.valueOf("install-method");
|
||||
}
|
||||
|
||||
if (options.has("working-dir")) {
|
||||
Path workingDirTemp = Paths.get(String.valueOf(options.valueOf("working-dir")));
|
||||
workingDir = workingDirTemp;
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.io.FileNotFoundException;
|
|||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -40,6 +41,9 @@ import com.atlauncher.builders.HTMLBuilder;
|
|||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.data.DownloadableFile;
|
||||
import com.atlauncher.data.LauncherVersion;
|
||||
import com.atlauncher.graphql.AddLauncherLaunchMutation;
|
||||
import com.atlauncher.graphql.type.AddLauncherLaunchInput;
|
||||
import com.atlauncher.graphql.type.LauncherJavaVersionInput;
|
||||
import com.atlauncher.gui.dialogs.ProgressDialog;
|
||||
import com.atlauncher.gui.tabs.InstancesTab;
|
||||
import com.atlauncher.gui.tabs.PacksBrowserTab;
|
||||
|
@ -62,6 +66,7 @@ import com.atlauncher.managers.ServerManager;
|
|||
import com.atlauncher.managers.TechnicModpackUpdateManager;
|
||||
import com.atlauncher.network.Analytics;
|
||||
import com.atlauncher.network.DownloadPool;
|
||||
import com.atlauncher.network.GraphqlClient;
|
||||
import com.atlauncher.utils.Java;
|
||||
import com.atlauncher.utils.OS;
|
||||
import com.google.gson.JsonIOException;
|
||||
|
@ -102,6 +107,22 @@ public class Launcher {
|
|||
|
||||
NewsManager.loadNews(); // Load the news
|
||||
|
||||
if (App.settings.enableAnalytics && ConfigManager.getConfigItem("useGraphql.launcherLaunch", false) == true) {
|
||||
App.TASKPOOL.execute(() -> {
|
||||
GraphqlClient.mutate(new AddLauncherLaunchMutation(
|
||||
AddLauncherLaunchInput.builder().version(Constants.VERSION.toStringForLogging())
|
||||
.hash(Constants.VERSION.getSha1Revision().toString())
|
||||
.installMethod(OS.getInstallMethod())
|
||||
.javaVersion(LauncherJavaVersionInput.builder().raw(Java.getLauncherJavaVersion())
|
||||
.majorVersion(Integer.toString(Java.getLauncherJavaVersionNumber()))
|
||||
.bitness(Java.is64Bit() ? 64 : 32)
|
||||
.usingJreDir(OS.isWindows() && OS.usingExe()
|
||||
&& Files.exists(FileSystem.BASE_DIR.resolve("jre")))
|
||||
.build())
|
||||
.build()));
|
||||
});
|
||||
}
|
||||
|
||||
MinecraftManager.loadMinecraftVersions(); // Load info about the different Minecraft versions
|
||||
MinecraftManager.loadJavaRuntimes(); // Load info about the different java runtimes
|
||||
LWJGLManager.loadLWJGLVersions(); // Load info about the different LWJGL versions
|
||||
|
|
|
@ -65,6 +65,10 @@ public class LauncherVersion {
|
|||
return this.stream;
|
||||
}
|
||||
|
||||
public HashCode getSha1Revision() {
|
||||
return this.sha1Revision;
|
||||
}
|
||||
|
||||
public boolean isReleaseStream() {
|
||||
return this.stream.equals("Release");
|
||||
}
|
||||
|
|
|
@ -21,14 +21,14 @@ import java.awt.Color;
|
|||
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import com.atlauncher.App;
|
||||
import com.atlauncher.FileSystem;
|
||||
import com.atlauncher.gui.components.Console;
|
||||
import com.atlauncher.managers.LogManager;
|
||||
import com.atlauncher.utils.Timestamper;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public final class LogEvent {
|
||||
public static final int CONSOLE = 0xA;
|
||||
public static final int LOG4J = 0xB;
|
||||
|
@ -43,6 +43,10 @@ public final class LogEvent {
|
|||
public LogEvent(LogType type, String body, int meta) {
|
||||
this.type = type;
|
||||
|
||||
if (body == null) {
|
||||
body = "";
|
||||
}
|
||||
|
||||
if (App.settings != null && !LogManager.showDebug) {
|
||||
body = body.replace(FileSystem.BASE_DIR.toAbsolutePath().toString(), "**USERSDIR**");
|
||||
}
|
||||
|
|
|
@ -164,4 +164,19 @@ public class GraphqlClient {
|
|||
|
||||
return data.get();
|
||||
}
|
||||
|
||||
public static <D extends Operation.Data, T, V extends Operation.Variables> void mutate(
|
||||
@NotNull Mutation<D, T, V> mutation) {
|
||||
apolloClient.mutate(mutation)
|
||||
.enqueue(new ApolloCall.Callback<T>() {
|
||||
@Override
|
||||
public void onResponse(@NotNull Response<T> response) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull ApolloException e) {
|
||||
LogManager.logStackTrace("Error on GraphQL query", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ import java.util.stream.Collectors;
|
|||
import com.atlauncher.App;
|
||||
import com.atlauncher.FileSystem;
|
||||
import com.atlauncher.constants.Constants;
|
||||
import com.atlauncher.graphql.type.LauncherInstallMethod;
|
||||
import com.atlauncher.managers.LogManager;
|
||||
import com.atlauncher.managers.PerformanceManager;
|
||||
import com.atlauncher.network.Analytics;
|
||||
|
@ -656,4 +657,89 @@ public enum OS {
|
|||
public static String getNativesArch() {
|
||||
return OS.is64Bit() ? "64" : "32";
|
||||
}
|
||||
|
||||
public static boolean usingExe() {
|
||||
return getRunningProgramPath().getFileName().toString().endsWith("exe");
|
||||
}
|
||||
|
||||
public static LauncherInstallMethod getInstallMethod() {
|
||||
if (isWindows()) {
|
||||
Path path = getRunningProgramPath();
|
||||
|
||||
if (path.getFileName().toString().endsWith("exe")) {
|
||||
if (usedInstaller()) {
|
||||
return LauncherInstallMethod.WINDOWS_SETUP;
|
||||
}
|
||||
|
||||
return LauncherInstallMethod.WINDOWS_PORTABLE;
|
||||
}
|
||||
|
||||
if (path.getFileName().toString().endsWith("jar")) {
|
||||
return LauncherInstallMethod.WINDOWS_JAR;
|
||||
}
|
||||
|
||||
if (Files.isDirectory(path)) {
|
||||
return LauncherInstallMethod.WINDOWS_SOURCE;
|
||||
}
|
||||
|
||||
return LauncherInstallMethod.WINDOWS_UNKNOWN;
|
||||
} else if (isMac()) {
|
||||
if (isUsingMacApp()) {
|
||||
return LauncherInstallMethod.MAC_APP;
|
||||
}
|
||||
|
||||
Path path = getRunningProgramPath();
|
||||
|
||||
if (path.getFileName().toString().endsWith("jar")) {
|
||||
return LauncherInstallMethod.MAC_JAR;
|
||||
}
|
||||
|
||||
if (Files.isDirectory(path)) {
|
||||
return LauncherInstallMethod.MAC_SOURCE;
|
||||
}
|
||||
|
||||
return LauncherInstallMethod.MAC_UNKNOWN;
|
||||
} else {
|
||||
if (isUsingFlatpak()) {
|
||||
return LauncherInstallMethod.LINUX_FLATPAK;
|
||||
}
|
||||
|
||||
if (App.installMethod != null) {
|
||||
if (App.installMethod.equalsIgnoreCase("deb")) {
|
||||
return LauncherInstallMethod.LINUX_DEB;
|
||||
}
|
||||
|
||||
if (App.installMethod.equalsIgnoreCase("rpm")) {
|
||||
return LauncherInstallMethod.LINUX_RPM;
|
||||
}
|
||||
|
||||
if (App.installMethod.equalsIgnoreCase("aur")) {
|
||||
return LauncherInstallMethod.LINUX_AUR;
|
||||
}
|
||||
|
||||
if (App.installMethod.equalsIgnoreCase("aur-bin")) {
|
||||
return LauncherInstallMethod.LINUX_AUR_BIN;
|
||||
}
|
||||
|
||||
return LauncherInstallMethod.LINUX_UNKNOWN;
|
||||
}
|
||||
|
||||
Path path = getRunningProgramPath();
|
||||
|
||||
if (path.getFileName().toString().endsWith("jar")) {
|
||||
return LauncherInstallMethod.LINUX_JAR;
|
||||
}
|
||||
|
||||
if (Files.isDirectory(path)) {
|
||||
return LauncherInstallMethod.LINUX_SOURCE;
|
||||
}
|
||||
|
||||
return LauncherInstallMethod.LINUX_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean usedInstaller() {
|
||||
return Files.exists(FileSystem.BASE_DIR.resolve("unins000.dat"))
|
||||
&& Files.exists(FileSystem.BASE_DIR.resolve("unins000.exe"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue