<commit_before>package com.github.duke605.dce.util;

import com.github.duke605.dce.DiscordCE;
import com.github.duke605.dce.handler.MinecraftEventHandler;
import com.github.duke605.dce.lib.Config;
import com.github.duke605.dce.lib.Reference;
import com.github.duke605.dce.lib.Secret;
import com.mixpanel.mixpanelapi.MessageBuilder;
import com.mixpanel.mixpanelapi.MixpanelAPI;
import net.minecraftforge.common.ForgeVersion;
import net.minecraftforge.common.MinecraftForge;
import org.json.JSONObject;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class MixpanelUtil
{

    /**
     * @return A constructed message builder object initialized with token
     */
    public static MessageBuilder getMessageBuilder()
    {
        return new MessageBuilder(Secret.MIXPANEL_TOKEN);
    }

    /**
     * Sends a track event with game startup information
     *
     * @param runAsync Whether or not to run async
     */
    public static void setStartGameEvent(boolean runAsync)
    {
        // Stopping if user does not want to send this kind of event
        if (Config.trackGameStart)
            return;

        Runnable r = () ->
        {
            TimeZone tz = Calendar.getInstance().getTimeZone();
            Date now = Calendar.getInstance().getTime();
            String time = new SimpleDateFormat("EEEE, MMMM d, YYYY h:mma").format(now);

            JSONObject props = new JSONObject()
                    .put("forge_version", ForgeVersion.getVersion())
                    .put("mc_version", MinecraftForge.MC_VERSION)
                    .put("timezone", tz.getDisplayName(Locale.CANADA))
                    .put("dce_version", Reference.VERSION);

            MixpanelUtil.sendEvent("Start Game", props);
        };

        // Running async
        if (runAsync)
            ConcurrentUtil.executor.execute(r);

        // Run sync
        else
            r.run();
    }

    /**
     * Sends a track event when the game is stopped
     *
     * @param runAsync Whether or not to run async
     */
    public static void sentGameStopEvent(boolean runAsync)
    {
        // Stopping if user does not want to send this kind of event
        if (Config.trackGameStop)
            return;

        Runnable r = () -> {
            long gameTime = System.currentTimeMillis() - DiscordCE.startTime;

            JSONObject props = new JSONObject()
                    .put("single_player_games", MinecraftEventHandler.singlePlayerGames)
                    .put("play_time", gameTime)
                    .put("multiplayer_games", MinecraftEventHandler.multiplayerGames)
                    .put("num_guilds", DiscordCE.client.getGuilds().size())
                    .put("num_users", DiscordCE.client.getUsers().size());

            MixpanelUtil.sendEvent("Stop Game", props);
        };

        // Running async
        if (runAsync)
            ConcurrentUtil.executor.execute(r);

        // Run sync
        else
            r.run();
    }

    public static boolean sendEvent(String eventName, JSONObject props)
    {
        // Checking if email is blank
        if (Config.email.trim().isEmpty())
            return false;

        MessageBuilder b = getMessageBuilder();
        JSONObject event = b.event(Config.emailHash, eventName, props);

        try
        {
            new MixpanelAPI().sendMessage(event);
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return false;
        }

        return true;
    }
}
<commit_msg>forgot a not... I'm a derp<commit_after>package com.github.duke605.dce.util;

import com.github.duke605.dce.DiscordCE;
import com.github.duke605.dce.handler.MinecraftEventHandler;
import com.github.duke605.dce.lib.Config;
import com.github.duke605.dce.lib.Reference;
import com.github.duke605.dce.lib.Secret;
import com.mixpanel.mixpanelapi.MessageBuilder;
import com.mixpanel.mixpanelapi.MixpanelAPI;
import net.minecraftforge.common.ForgeVersion;
import net.minecraftforge.common.MinecraftForge;
import org.json.JSONObject;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class MixpanelUtil
{

    /**
     * @return A constructed message builder object initialized with token
     */
    public static MessageBuilder getMessageBuilder()
    {
        return new MessageBuilder(Secret.MIXPANEL_TOKEN);
    }

    /**
     * Sends a track event with game startup information
     *
     * @param runAsync Whether or not to run async
     */
    public static void setStartGameEvent(boolean runAsync)
    {
        // Stopping if user does not want to send this kind of event
        if (!Config.trackGameStart)
            return;

        Runnable r = () ->
        {
            TimeZone tz = Calendar.getInstance().getTimeZone();
            Date now = Calendar.getInstance().getTime();
            String time = new SimpleDateFormat("EEEE, MMMM d, YYYY h:mma").format(now);

            JSONObject props = new JSONObject()
                    .put("forge_version", ForgeVersion.getVersion())
                    .put("mc_version", MinecraftForge.MC_VERSION)
                    .put("timezone", tz.getDisplayName(Locale.CANADA))
                    .put("dce_version", Reference.VERSION);

            MixpanelUtil.sendEvent("Start Game", props);
        };

        // Running async
        if (runAsync)
            ConcurrentUtil.executor.execute(r);

        // Run sync
        else
            r.run();
    }

    /**
     * Sends a track event when the game is stopped
     *
     * @param runAsync Whether or not to run async
     */
    public static void sentGameStopEvent(boolean runAsync)
    {
        // Stopping if user does not want to send this kind of event
        if (!Config.trackGameStop)
            return;

        Runnable r = () -> {
            long gameTime = System.currentTimeMillis() - DiscordCE.startTime;

            JSONObject props = new JSONObject()
                    .put("single_player_games", MinecraftEventHandler.singlePlayerGames)
                    .put("play_time", gameTime)
                    .put("multiplayer_games", MinecraftEventHandler.multiplayerGames)
                    .put("num_guilds", DiscordCE.client.getGuilds().size())
                    .put("num_users", DiscordCE.client.getUsers().size());

            MixpanelUtil.sendEvent("Stop Game", props);
        };

        // Running async
        if (runAsync)
            ConcurrentUtil.executor.execute(r);

        // Run sync
        else
            r.run();
    }

    public static boolean sendEvent(String eventName, JSONObject props)
    {
        // Checking if email is blank
        if (Config.email.trim().isEmpty())
            return false;

        MessageBuilder b = getMessageBuilder();
        JSONObject event = b.event(Config.emailHash, eventName, props);

        try
        {
            new MixpanelAPI().sendMessage(event);
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return false;
        }

        return true;
    }
}

{'fraction_non_alphanumeric': 0.09918271228702036, 'fraction_numerical': 0.004986840282587616, 'mean_word_length': 2.089430894308943, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7057470', 'n_tokens_mistral': 2053, 'n_tokens_neox': 1963, 'n_words': 467}