<commit_before>package com.ddiehl.android.simpleredditreader;

import android.content.Context;

import com.ddiehl.android.simpleredditreader.events.requests.HideEvent;
import com.ddiehl.android.simpleredditreader.events.requests.LoadLinkCommentsEvent;
import com.ddiehl.android.simpleredditreader.events.requests.LoadMoreChildrenEvent;
import com.ddiehl.android.simpleredditreader.events.requests.LoadSubredditEvent;
import com.ddiehl.android.simpleredditreader.events.requests.LoadUserProfileEvent;
import com.ddiehl.android.simpleredditreader.events.requests.ReportEvent;
import com.ddiehl.android.simpleredditreader.events.requests.SaveEvent;
import com.ddiehl.android.simpleredditreader.events.requests.UserSignOutEvent;
import com.ddiehl.android.simpleredditreader.events.requests.VoteEvent;
import com.ddiehl.android.simpleredditreader.events.responses.UserIdentityRetrievedEvent;
import com.ddiehl.android.simpleredditreader.utils.BaseUtils;
import com.ddiehl.reddit.identity.UserIdentity;
import com.ddiehl.reddit.listings.Listing;
import com.flurry.android.FlurryAgent;
import com.flurry.android.FlurryAgentListener;
import com.squareup.otto.Subscribe;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class HTNAnalytics {

    private static final String FLURRY_API_KEY = "***REMOVED***";
    private static final String FLURRY_API_KEY_DEBUG = "***REMOVED***";
    private static final int FLURRY_SESSION_TIMEOUT_SECONDS = 30;

    private static HTNAnalytics _instance;

    private HTNAnalytics() { }

    public void init(final Context context) {
        FlurryAgent.init(context, BuildConfig.DEBUG ? FLURRY_API_KEY_DEBUG : FLURRY_API_KEY);
        FlurryAgent.setContinueSessionMillis(FLURRY_SESSION_TIMEOUT_SECONDS * 1000);
        FlurryAgent.setCaptureUncaughtExceptions(true);
        FlurryAgent.setLogEnabled(BuildConfig.DEBUG); // Disable Flurry logging for release builds

        FlurryAgent.setFlurryAgentListener(new FlurryAgentListener() {
            @Override
            public void onSessionStarted() {
                // Log initial Flurry event
                Map<String, String> params = new HashMap<>();

                UserIdentity identity = RedditIdentityManager.getInstance(context).getUserIdentity();
                String userId = identity == null ?
                        "unauthorized" : BaseUtils.getMd5HexString(identity.getName());
                params.put("user", userId);
                FlurryAgent.setUserId(userId);

                boolean adsEnabled = RedditPreferences.getInstance(context).getAdsEnabled();
                params.put("ads enabled", String.valueOf(adsEnabled));

                FlurryAgent.logEvent("session started", params);
            }
        });
    }

    @Subscribe
    public void onError(Exception e) {
        FlurryAgent.onError("error", e.toString(), e);
    }

    @Subscribe
    public void onSignIn(UserIdentityRetrievedEvent event) {
        UserIdentity identity = event.getUserIdentity();
        Map<String, String> params = new HashMap<>();
        params.put("user", BaseUtils.getMd5HexString(identity.getName()));
        params.put("created", new Date(identity.getCreatedUTC()).toString());
        params.put("gold", String.valueOf(identity.isGold()));
        params.put("link karma", String.valueOf(identity.getLinkKarma()));
        params.put("comment karma", String.valueOf(identity.getCommentKarma()));
        params.put("over 18", String.valueOf(identity.isOver18()));
        params.put("mod", String.valueOf(identity.isMod()));
        FlurryAgent.logEvent("user signed in", params);
    }

    @Subscribe
    public void onSignOut(UserSignOutEvent event) {
        FlurryAgent.logEvent("user signed out");
        FlurryAgent.setUserId(null);
    }

    @Subscribe
    public void onLoadSubreddit(LoadSubredditEvent event) {
        Map<String, String> params = new HashMap<>();
        params.put("subreddit", event.getSubreddit());<commit_msg>Fixed create date for user in Flurry sign in event<commit_after>package com.ddiehl.android.simpleredditreader;

import android.content.Context;

import com.ddiehl.android.simpleredditreader.events.requests.HideEvent;
import com.ddiehl.android.simpleredditreader.events.requests.LoadLinkCommentsEvent;
import com.ddiehl.android.simpleredditreader.events.requests.LoadMoreChildrenEvent;
import com.ddiehl.android.simpleredditreader.events.requests.LoadSubredditEvent;
import com.ddiehl.android.simpleredditreader.events.requests.LoadUserProfileEvent;
import com.ddiehl.android.simpleredditreader.events.requests.ReportEvent;
import com.ddiehl.android.simpleredditreader.events.requests.SaveEvent;
import com.ddiehl.android.simpleredditreader.events.requests.UserSignOutEvent;
import com.ddiehl.android.simpleredditreader.events.requests.VoteEvent;
import com.ddiehl.android.simpleredditreader.events.responses.UserIdentityRetrievedEvent;
import com.ddiehl.android.simpleredditreader.utils.BaseUtils;
import com.ddiehl.reddit.identity.UserIdentity;
import com.ddiehl.reddit.listings.Listing;
import com.flurry.android.FlurryAgent;
import com.flurry.android.FlurryAgentListener;
import com.squareup.otto.Subscribe;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class HTNAnalytics {

    private static final String FLURRY_API_KEY = "***REMOVED***";
    private static final String FLURRY_API_KEY_DEBUG = "***REMOVED***";
    private static final int FLURRY_SESSION_TIMEOUT_SECONDS = 30;

    private static HTNAnalytics _instance;

    private HTNAnalytics() { }

    public void init(final Context context) {
        FlurryAgent.init(context, BuildConfig.DEBUG ? FLURRY_API_KEY_DEBUG : FLURRY_API_KEY);
        FlurryAgent.setContinueSessionMillis(FLURRY_SESSION_TIMEOUT_SECONDS * 1000);
        FlurryAgent.setCaptureUncaughtExceptions(true);
        FlurryAgent.setLogEnabled(BuildConfig.DEBUG); // Disable Flurry logging for release builds

        FlurryAgent.setFlurryAgentListener(new FlurryAgentListener() {
            @Override
            public void onSessionStarted() {
                // Log initial Flurry event
                Map<String, String> params = new HashMap<>();

                UserIdentity identity = RedditIdentityManager.getInstance(context).getUserIdentity();
                String userId = identity == null ?
                        "unauthorized" : BaseUtils.getMd5HexString(identity.getName());
                params.put("user", userId);
                FlurryAgent.setUserId(userId);

                boolean adsEnabled = RedditPreferences.getInstance(context).getAdsEnabled();
                params.put("ads enabled", String.valueOf(adsEnabled));

                FlurryAgent.logEvent("session started", params);
            }
        });
    }

    @Subscribe
    public void onError(Exception e) {
        FlurryAgent.onError("error", e.toString(), e);
    }

    @Subscribe
    public void onSignIn(UserIdentityRetrievedEvent event) {
        UserIdentity identity = event.getUserIdentity();
        Map<String, String> params = new HashMap<>();
        params.put("user", BaseUtils.getMd5HexString(identity.getName()));
        params.put("created", new Date(Double.valueOf(identity.getCreatedUTC() * 1000).longValue()).toString());
        params.put("gold", String.valueOf(identity.isGold()));
        params.put("link karma", String.valueOf(identity.getLinkKarma()));
        params.put("comment karma", String.valueOf(identity.getCommentKarma()));
        params.put("over 18", String.valueOf(identity.isOver18()));
        params.put("mod", String.valueOf(identity.isMod()));
        FlurryAgent.logEvent("user signed in", params);
    }

    @Subscribe
    public void onSignOut(UserSignOutEvent event) {
        FlurryAgent.logEvent("user signed out");
        FlurryAgent.setUserId(null);
    }

    @Subscribe
    public void onLoadSubreddit(LoadSubredditEvent event) {
        Map<String, String> params = new HashMap<>();
        params.put("subreddit", event.getSubreddit());
{'fraction_non_alphanumeric': 0.10720496894409938, 'fraction_numerical': 0.0034782608695652175, 'mean_word_length': 3.8383413461538463, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '5630597', 'n_tokens_mistral': 2368, 'n_tokens_neox': 2236, 'n_words': 385}