public static void TrackEvent(string category, string action, int value = LunarConsoleAnalytics.kUndefinedValue)
        {
            if (LunarConsoleConfig.consoleEnabled && LunarConsoleConfig.consoleSupported)
            {
                var payloadStr = LunarConsoleAnalytics.CreatePayload(category, action, value);
                if (payloadStr != null)
                {
                    Log.d("Event track payload: " + payloadStr);

                    LunarConsoleHttpClient downloader = new LunarConsoleHttpClient(LunarConsoleAnalytics.TrackingURL);
                    downloader.UploadData(payloadStr, delegate(string result, Exception error)
                    {
                        if (error != null)
                        {
                            Log.e("Event track failed: " + error);
                        }
                        else
                        {
                            Log.d("Event track result: " + result);
                        }
                    });
                }
            }
        }
示例#2
0
        public static void CheckForUpdates(bool silent = true)
        {
            LunarConsoleHttpClient downloader = new LunarConsoleHttpClient(LunarConsoleConfig.fullVersion ? Constants.UpdateJsonURLFull : Constants.UpdateJsonURLFree);

            downloader.DownloadString(delegate(string response, Exception error)
            {
                if (error != null)
                {
                    Log.e(error, "Can't get updater info");
                    if (!silent)
                    {
                        Utils.ShowDialog(kMessageBoxTitle, "Update info is not available.\n\nTry again later.", "OK");
                    }
                    return;
                }

                UpdateInfo info;
                if (response != null && TryParseUpdateInfo(response, out info))
                {
                    if (IsShouldSkipVersion(info.version))
                    {
                        Log.d("User decided to skip version {0}", info.version);
                        return;
                    }

                    if (PluginVersionChecker.IsNewerVersion(info.version))
                    {
                        StringBuilder message = new StringBuilder();
                        message.AppendFormat("A new version {0} is available!\n\n", info.version);
                        if (info.message != null && info.message.Length > 0)
                        {
                            message.Append(info.message);
                            message.AppendLine();
                        }

                        Utils.ShowDialog(kMessageBoxTitle, message.ToString(),
                                         new DialogButton("Details...", delegate(string obj)
                        {
                            Application.OpenURL(info.url);
                            LunarConsoleEditorAnalytics.TrackEvent("Version", "updater_details");
                        }),
                                         new DialogButton("Remind me later", delegate(string obj) {
                            LunarConsoleEditorAnalytics.TrackEvent("Version", "updater_later");
                        }),
                                         new DialogButton("Skip this version", delegate(string obj)
                        {
                            SetShouldSkipVersion(info.version);
                            LunarConsoleEditorAnalytics.TrackEvent("Version", "updater_skip");
                        })
                                         );
                    }
                    else
                    {
                        if (!silent)
                        {
                            Utils.ShowMessageDialog(kMessageBoxTitle, "Everything is up to date");
                        }
                        Debug.Log("Everything is up to date");
                    }
                }
                else
                {
                    Log.e("Unable to parse response: '{0}'", response);
                    if (!silent)
                    {
                        Utils.ShowDialog(kMessageBoxTitle, "Update info is not available.\n\nTry again later.", "OK");
                    }
                }
            });
        }