<commit_before>/// <summary>
/// Gleaner Tracker Unity implementation.
/// </summary>
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
using SimpleJSON;
using System;

public class Tracker : MonoBehaviour
{
	public static DateTime START_DATE = new DateTime (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

	public interface ITraceFormatter
	{
		string Serialize (List<string> traces);

		void StartData (JSONNode data);
	}

	private Storage storage;
	private ITraceFormatter traceFormatter;
	private bool sending;
	private bool connected;
	private bool connecting;
	private bool flushRequested;
	private List<string> queue = new List<string> ();
	private List<string> sent = new List<string> ();
	private float nextFlush;
	public float flushInterval = -1;
	public string storageType = "local";
	public string traceFormat = "csv";
	public string host;
	public string trackingCode;
	public Boolean debug = false;
	private StartListener startListener;
	private FlushListener flushListener;
	private static Tracker tracker;

	public static Tracker T ()
	{
		return tracker;
	}

	public Tracker ()
	{
		flushListener = new FlushListener (this);
		startListener = new StartListener (this);
		tracker = this;
	}

	public ITraceFormatter GetTraceFormatter ()
	{
		return this.traceFormatter;
	}

	private void SetConnected (bool connected)
	{
		this.connected = connected;
		connecting = false;
	}

	public void Start ()
	{
		switch (traceFormat) {
		case "json":
			this.traceFormatter = new SimpleJsonFormat ();
			break;
		case "xapi":
			this.traceFormatter = new XApiFormat ();
			break;
		default:
			this.traceFormatter = new DefaultTraceFromat ();
			break;
		}
		switch (storageType) {
		case "net":
			storage = new NetStorage (this, host, trackingCode);
			break;
		default:
			String path = Application.persistentDataPath;
			if (!path.EndsWith ("/")) {
				path += "/";
			}
			path += "traces";
			if (debug) {
				Debug.Log ("Storing traces in " + path);
			}
			storage = new LocalStorage (path);<commit_msg>Store traces in sdcard for LocalStorage in Android<commit_after>/// <summary>
/// Gleaner Tracker Unity implementation.
/// </summary>
using System.Collections.Generic;
using UnityEngine;
using System.Collections;
using SimpleJSON;
using System;

public class Tracker : MonoBehaviour
{
	public static DateTime START_DATE = new DateTime (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

	public interface ITraceFormatter
	{
		string Serialize (List<string> traces);

		void StartData (JSONNode data);
	}

	private Storage storage;
	private ITraceFormatter traceFormatter;
	private bool sending;
	private bool connected;
	private bool connecting;
	private bool flushRequested;
	private List<string> queue = new List<string> ();
	private List<string> sent = new List<string> ();
	private float nextFlush;
	public float flushInterval = -1;
	public string storageType = "local";
	public string traceFormat = "csv";
	public string host;
	public string trackingCode;
	public Boolean debug = false;
	private StartListener startListener;
	private FlushListener flushListener;
	private static Tracker tracker;

	public static Tracker T ()
	{
		return tracker;
	}

	public Tracker ()
	{
		flushListener = new FlushListener (this);
		startListener = new StartListener (this);
		tracker = this;
	}

	public ITraceFormatter GetTraceFormatter ()
	{
		return this.traceFormatter;
	}

	private void SetConnected (bool connected)
	{
		this.connected = connected;
		connecting = false;
	}

	public void Start ()
	{
		switch (traceFormat) {
		case "json":
			this.traceFormatter = new SimpleJsonFormat ();
			break;
		case "xapi":
			this.traceFormatter = new XApiFormat ();
			break;
		default:
			this.traceFormatter = new DefaultTraceFromat ();
			break;
		}
		switch (storageType) {
		case "net":
			storage = new NetStorage (this, host, trackingCode);
			break;
		default:
			String path = Application.persistentDataPath;
#if UNITY_ANDROID
			AndroidJavaObject env = new AndroidJavaObject("android.os.Environment");
			AndroidJavaObject file = env.CallStatic<AndroidJavaObject>("getExternalStorageDirectory");
			path = file.Call<String>("getAbsolutePath");
#endif
			if (!path.EndsWith ("/")) {
				path += "/";
			}
			path += "traces";
			if (debug) {
				Debug.Log ("Storing traces in " + path);
			}
			storage = new LocalStorage (path);
{'fraction_non_alphanumeric': 0.10279944928866452, 'fraction_numerical': 0.004589261128958238, 'mean_word_length': 4.152482269503546, 'pattern_counts': {'":': 6, '<': 19, '<?xml version=': 0, '>': 19, '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': '3989502', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1282, 'n_words': 404}