static void StartRecordingEvents() { // A basic event // Every time this is called, the "hits" value will increment for this event // Event IDs are created on-the-fly in your code and DO NOT need to be setup on the Lumos website first LumosAnalytics.RecordEvent("lumos-is-ready"); // Any events recorded after this point in execution should record }
/// <summary> /// Records an event. /// </summary> /// <param name="category">The event's category.</param> /// <param name="eventID">The event identifier.</param> /// <param name="value">An arbitrary value to send with the event.</param> /// <param name="repeatable">Whether this event should only be logged once.</param> public static void Record(string category, string eventID, float?val, bool repeatable) { // Checks if Lumos and LumosAnalytics is installed correctly if (!LumosAnalytics.IsInitialized()) { return; } if (eventID == null || eventID == "") { LumosUnity.Debug.LogWarning("An event ID and category must be supplied. Event not recorded."); return; } if (category == null || category == "") { if (LumosAnalytics.levelsAsCategories) { category = Application.loadedLevelName; } else { category = "default"; } } var key = category + ":" + eventID; var prefsKey = "lumospowered_event_" + key + "_recorded"; // Ensure unrepeatable event hasn't been logged before. if (!repeatable) { if (PlayerPrefs.HasKey(prefsKey) || unsentUniqueEvents.Contains(key)) { return; } unsentUniqueEvents.Add(key); } var evt = new Dictionary <string, object>() { { "category", category }, { "event_id", eventID } }; if (val.HasValue) { evt["value"] = val.Value; } events[key] = evt; }
void OnGUI() { GUILayout.Label(errorMessage); GUILayout.Space(20); // Event with value GUILayout.BeginHorizontal(); GUILayout.Label("Event Value (float)", GUILayout.Width(baseWidth)); eventValue = GUILayout.TextField(eventValue, GUILayout.Width(baseWidth)); if (GUILayout.Button("Event + Value", GUILayout.Width(baseWidth))) { Debug.Log("Sending event with value..."); var eventAsFloat = float.Parse(eventValue); LumosAnalytics.RecordEvent("event-with-value", eventAsFloat); } GUILayout.EndHorizontal(); GUILayout.Space(20); // Event with custom category GUILayout.BeginHorizontal(); GUILayout.Label("Custom Category", GUILayout.Width(baseWidth)); category = GUILayout.TextField(category, GUILayout.Width(baseWidth)); if (GUILayout.Button("Event + Category", GUILayout.Width(baseWidth))) { Debug.Log("Sending event with custom category..."); LumosAnalytics.RecordEvent(category, "event-with-custom-category"); } GUILayout.EndHorizontal(); GUILayout.Space(20); // Unique event GUILayout.BeginHorizontal(); GUILayout.Label("Unique Event (per user)", GUILayout.Width(baseWidth)); eventName = GUILayout.TextField(eventName, GUILayout.Width(baseWidth)); if (GUILayout.Button("Unique Event", GUILayout.Width(baseWidth))) { Debug.Log("Sending unique event..."); LumosAnalytics.RecordEvent(eventName, false); } GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); }
IEnumerator FPS() { // Infinite loop executed every "frenquency" secondes. while (true) { // Update the FPS float fps = accum / frames; sFPS = fps.ToString("f" + Mathf.Clamp(nbDecimal, 0, 10)); LumosAnalytics.RecordEvent("FPS", "LowEnd", fps); //Update the color color = (fps >= 30) ? Color.green : ((fps > 10) ? Color.red : Color.yellow); accum = 0.0F; frames = 0; yield return(new WaitForSeconds(frequency)); } }
void Awake() { instance = this; Lumos.OnReady += Ready; }
// An example of a unique event // Unique events are not repeatable per player // This is great if you want to know information such as how many players have completed a certain level // as opposed to how many times a level has been completed public static void ExampleUniqueEvent(string eventID) { LumosAnalytics.RecordEvent(eventID, false); }
// An example of an event being recorded with a custom category // Events have a default category called 'default' that is used when you do not supply one // There is also an option in LumosAnalytics.cs to use scene names as categories public static void ExampleEventWithCategory(string category, string eventID) { LumosAnalytics.RecordEvent(category, eventID); }
// An example of an event being recorded with a value. // The value is used in a number of ways to show you interesting statistics // On the Lumos website you can see it's average, sum, and more public static void ExampleEventWithValue(string eventID, float eventValue) { LumosAnalytics.RecordEvent(eventID, eventValue); }
void Awake () { instance = this; Lumos.OnReady += Ready; }