-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
secrets.gradle | ||
# gradle | ||
|
||
.gradle/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package gg.meza.analytics; | ||
|
||
import com.posthog.java.PostHog; | ||
import gg.meza.SoundsBeGone; | ||
import net.minecraft.client.MinecraftClient; | ||
import org.apache.commons.codec.digest.DigestUtils; | ||
|
||
import java.util.HashMap; | ||
|
||
public class Analytics { | ||
private static final String POSTHOG_API_KEY = "POSTHOG_API_KEY_REPL"; | ||
private static final String POSTHOG_HOST = "https://eu.posthog.com"; | ||
private PostHog posthog; | ||
|
||
// Not actually sending any user info, just using the uuid to create a new uuid that cannot be traced back to the user | ||
private final String uuid = DigestUtils.sha256Hex(MinecraftClient.getInstance().getSession().getUsername()); | ||
private final String OS_NAME = System.getProperty("os.name"); | ||
private final String MC_VERSION = MinecraftClient.getInstance().getGameVersion(); | ||
private final String JAVA_VERSION = System.getProperty("java.version"); | ||
|
||
public Analytics() { | ||
this.posthog = new PostHog.Builder(POSTHOG_API_KEY).host(POSTHOG_HOST).build(); | ||
this.posthog.capture(this.uuid, "Started Minecraft"); | ||
} | ||
|
||
private void sendEvent(String event, String sound) { | ||
this.posthog.capture(this.uuid, event, new HashMap<String, Object>() { | ||
{ | ||
put("sound", sound); | ||
put("Minecraft Version", MC_VERSION); | ||
put("OS", OS_NAME); | ||
put("Local Time", new java.util.Date().toString()); | ||
put("ModVersion", SoundsBeGone.VERSION); | ||
put("Java Version", JAVA_VERSION); | ||
} | ||
}); | ||
} | ||
|
||
public void mutedSound(String sound) { | ||
this.sendEvent("Muted Sound", sound); | ||
} | ||
|
||
public void blockedSound(String sound) { | ||
this.sendEvent("Blocked Sound", sound); | ||
} | ||
|
||
public void unmutedSound(String sound) { | ||
this.sendEvent("UnMuted Sound", sound); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters