﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using BugseePlugin;

// Learn more about launch options from our documentation
// iOS     - https://docs.bugsee.com/sdk/ios/configuration/
// Android - https://docs.bugsee.com/sdk/android/configuration/

public class BugseeLauncher : MonoBehaviour
{
	public Material mat;
	public string AppToken = "your-bugsee-token";
	public string Endpoint = "default";

	public int MaxRecordingTime = 60;
	public bool ScreenshotToReport = true;
	public bool CrashReporting = true;
	public bool MonitorNetwork = true;
	public bool VideoEnabled = true;
	public bool CaptureLogs = true;
	public BugseeStyle Style = BugseeStyle.Default;
	public BugseeSeverityLevel DefaultCrashPriority = BugseeSeverityLevel.Blocker;
	public BugseeSeverityLevel DefaultBugPriority = BugseeSeverityLevel.Low;
	public bool ShakeToReport = false;
	public bool ReportPrioritySelector = false;

	// It sets automaticaly for different devices, please don't touch it without nessesary
	public int MaxFrameRate = 0;

	// Experemental options
	public bool KillDetection = false;
	public bool EnableMachExceptions = false;

	// Use this for initialization
	void OnEnable ()
	{
		if (AppToken == "your-bugsee-token") {
			Debug.Log ("Please set your bugsee token, you can find it on app.bugsee.com");
		}
			
		Dictionary<string, object> parameters = new Dictionary<string, object> ();
		if (Endpoint != "default") parameters.Add (Bugsee.EndpointKey, Endpoint);
		parameters.Add (Bugsee.MaxRecordingTimeKey, MaxRecordingTime);
		parameters.Add (Bugsee.ScreenshotToReportKey, ScreenshotToReport);
		parameters.Add (Bugsee.CrashReportKey, CrashReporting);
		parameters.Add (Bugsee.MonitorNetworkKey, MonitorNetwork);
		parameters.Add (Bugsee.VideoEnabledKey, VideoEnabled);
		parameters.Add (Bugsee.CaptureLogsKey, CaptureLogs);
		parameters.Add (Bugsee.StyleKey, Style.ToString());
		parameters.Add (Bugsee.DefaultCrashPriorityKey, (int)DefaultCrashPriority);
		parameters.Add (Bugsee.DefaultBugPriorityKey, (int)DefaultBugPriority);
		parameters.Add (Bugsee.ShakeToReportKey, ShakeToReport);
		parameters.Add (Bugsee.ReportPrioritySelectorKey, ReportPrioritySelector);

		if (MaxFrameRate > 0) parameters.Add (Bugsee.MaxFrameRateKey, MaxFrameRate);
		parameters.Add (Bugsee.KillDetectionKey, KillDetection);
		parameters.Add (Bugsee.EnableMachExceptionsKey, EnableMachExceptions);

		Bugsee.Launch (AppToken, parameters);

		Bugsee.RegisterExceptionHandlers();
	}
}
