<commit_before>package floobits.common;

import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
import java.util.Date;
import java.util.HashMap;

public class CrashDump implements Serializable {
    public String owner;
    public String workspace;
    public String dir;
    public String subject;
    public String username;
    public static String userAgent;
    public HashMap<String, String> message = new HashMap<String, String>();
    private static String editor = "";

    public static void setUA(String userAgent, String editor) {
        CrashDump.userAgent = userAgent;
        CrashDump.editor = editor;
    }
    public CrashDump(Throwable e, String owner, String workspace, String dir, String username) {
        this.owner = owner;
        this.workspace = workspace;
        this.dir = dir;
        this.username = username;
        message.put("sendingAt", String.format("%s", new Date().getTime()));
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        e.printStackTrace(pw);
        message.put("stack", sw.toString());
        message.put("description", e.getMessage());
        setContextInfo("%s died%s!");
    }

    public CrashDump(String description, String username) {
        this.username = username;
        message.put("sendingAt", String.format("%s", new Date().getTime()));
        message.put("description", description);
        setContextInfo("%s submitted an issues%s!");
    }

    protected void setContextInfo(String subjectText) {
        subject = String.format(subjectText, editor, username != null ? " for " + username : "");
    }
}<commit_msg>Add plugin version info to crash reports.<commit_after>package floobits.common;

import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManager;
import com.intellij.openapi.extensions.PluginId;

import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
import java.util.Date;
import java.util.HashMap;

public class CrashDump implements Serializable {
    public String owner;
    public String workspace;
    public String dir;
    public String subject;
    public String username;
    public static String userAgent;
    public HashMap<String, String> message = new HashMap<String, String>();
    private static String editor = "";

    public static void setUA(String userAgent, String editor) {
        CrashDump.userAgent = userAgent;
        CrashDump.editor = editor;
    }

    private IdeaPluginDescriptor getPlugin() {
        return PluginManager.getPlugin(PluginId.getId("com.floobits.unique.plugin.id"));
    }

    public CrashDump(Throwable e, String owner, String workspace, String dir, String username) {
        this.owner = owner;
        this.workspace = workspace;
        this.dir = dir;
        this.username = username;
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        e.printStackTrace(pw);
        addVersionInfo(message);
        message.put("stack", sw.toString());
        message.put("description", e.getMessage());
        setContextInfo("%s died%s!");
    }

    public CrashDump(String description, String username) {
        this.username = username;
        addVersionInfo(message);
        message.put("description", description);
        setContextInfo("%s submitted an issues%s!");
    }

    protected void setContextInfo(String subjectText) {
        subject = String.format(subjectText, editor, username != null ? " for " + username : "");
    }

    private void addVersionInfo(HashMap<String, String> message) {
        IdeaPluginDescriptor p = getPlugin();
        if (p != null) {
            message.put("floobits_plugin_version", p.getVersion());
        } else {
            message.put("floobits_plugin_version", "No version information.");
        }
        message.put("sendingAt", String.format("%s", new Date().getTime()));
    }
}
{'fraction_non_alphanumeric': 0.11256610425585495, 'fraction_numerical': 0.0, 'mean_word_length': 3.1810526315789476, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '1192893', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1062, 'n_words': 281}