| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace ExploreV2Analytics |
| | 6 | | { |
| | 7 | | public interface IExploreV2Analytics |
| | 8 | | { |
| | 9 | | void SendExploreMainMenuVisibility(bool isVisible, ExploreUIVisibilityMethod method); |
| | 10 | | void SendExploreSectionVisibility(ExploreSection section, bool isVisible); |
| | 11 | | void SendEventTeleport(string eventId, string eventName, Vector2Int coords); |
| | 12 | | void SendClickOnEventInfo(string eventId, string eventName); |
| | 13 | | void SendPlaceTeleport(string placeId, string placeName, Vector2Int coords); |
| | 14 | | void SendClickOnPlaceInfo(string placeId, string placeName); |
| | 15 | | bool anyActionExecutedFromLastOpen { get; set; } |
| | 16 | |
|
| | 17 | | } |
| | 18 | |
|
| | 19 | | public class ExploreV2Analytics : IExploreV2Analytics |
| | 20 | | { |
| | 21 | | private const string EXPLORE_MAIN_MENU_VIBILILITY = "explore_main_menu_visibility"; |
| | 22 | | private const string EXPLORE_SECTION_VISIBILITY = "explore_section_visibility"; |
| | 23 | | private const string EXPLORE_EVENT_TELEPORT = "explore_event_teleport"; |
| | 24 | | private const string EXPLORE_CLICK_EVENT_INFO = "explore_click_event_info"; |
| | 25 | | private const string EXPLORE_PLACE_TELEPORT = "explore_place_teleport"; |
| | 26 | | private const string EXPLORE_CLICK_PLACE_INFO = "explore_click_place_info"; |
| | 27 | |
|
| | 28 | | private static DateTime? exploreMainMenuSetVisibleTimeStamp = null; |
| | 29 | | private static DateTime? exploreSectionSetVisibleTimeStamp = null; |
| | 30 | | private static bool anyActionExecutedFromLastOpenValue = false; |
| | 31 | |
|
| 0 | 32 | | public bool anyActionExecutedFromLastOpen { get => anyActionExecutedFromLastOpenValue; set => anyActionExecutedF |
| | 33 | |
|
| | 34 | | public void SendExploreMainMenuVisibility(bool isVisible, ExploreUIVisibilityMethod method) |
| | 35 | | { |
| 1 | 36 | | Dictionary<string, string> data = new Dictionary<string, string>(); |
| 1 | 37 | | data.Add("visible", isVisible.ToString()); |
| 1 | 38 | | data.Add("method", method.ToString()); |
| | 39 | |
|
| 1 | 40 | | if (isVisible) |
| 1 | 41 | | exploreMainMenuSetVisibleTimeStamp = DateTime.Now; |
| | 42 | | else |
| | 43 | | { |
| 0 | 44 | | if (exploreMainMenuSetVisibleTimeStamp.HasValue) |
| | 45 | | { |
| 0 | 46 | | data.Add("open_duration_ms", (DateTime.Now - exploreMainMenuSetVisibleTimeStamp.Value).TotalMillisec |
| 0 | 47 | | exploreMainMenuSetVisibleTimeStamp = null; |
| | 48 | | } |
| | 49 | |
|
| 0 | 50 | | data.Add("any_action_after_close", anyActionExecutedFromLastOpenValue.ToString()); |
| | 51 | | } |
| | 52 | |
|
| 1 | 53 | | GenericAnalytics.SendAnalytic(EXPLORE_MAIN_MENU_VIBILILITY, data); |
| 1 | 54 | | } |
| | 55 | |
|
| | 56 | | public void SendExploreSectionVisibility(ExploreSection section, bool isVisible) |
| | 57 | | { |
| 0 | 58 | | Dictionary<string, string> data = new Dictionary<string, string>(); |
| 0 | 59 | | data.Add("section", section.ToString()); |
| 0 | 60 | | data.Add("visible", isVisible.ToString()); |
| | 61 | |
|
| 0 | 62 | | if (isVisible) |
| 0 | 63 | | exploreSectionSetVisibleTimeStamp = DateTime.Now; |
| | 64 | | else |
| | 65 | | { |
| 0 | 66 | | if (exploreSectionSetVisibleTimeStamp.HasValue) |
| | 67 | | { |
| 0 | 68 | | data.Add("open_duration_ms", (DateTime.Now - exploreSectionSetVisibleTimeStamp.Value).TotalMilliseco |
| 0 | 69 | | exploreSectionSetVisibleTimeStamp = null; |
| | 70 | | } |
| | 71 | | } |
| | 72 | |
|
| 0 | 73 | | GenericAnalytics.SendAnalytic(EXPLORE_SECTION_VISIBILITY, data); |
| 0 | 74 | | } |
| | 75 | |
|
| | 76 | | public void SendEventTeleport(string eventId, string eventName, Vector2Int coords) |
| | 77 | | { |
| 0 | 78 | | Dictionary<string, string> data = new Dictionary<string, string>(); |
| 0 | 79 | | data.Add("event_id", eventId); |
| 0 | 80 | | data.Add("event_name", eventName); |
| 0 | 81 | | data.Add("event_coords_x", coords.x.ToString()); |
| 0 | 82 | | data.Add("event_coords_y", coords.y.ToString()); |
| 0 | 83 | | GenericAnalytics.SendAnalytic(EXPLORE_EVENT_TELEPORT, data); |
| 0 | 84 | | } |
| | 85 | |
|
| | 86 | | public void SendClickOnEventInfo(string eventId, string eventName) |
| | 87 | | { |
| 0 | 88 | | Dictionary<string, string> data = new Dictionary<string, string>(); |
| 0 | 89 | | data.Add("event_id", eventId); |
| 0 | 90 | | data.Add("event_name", eventName); |
| 0 | 91 | | GenericAnalytics.SendAnalytic(EXPLORE_CLICK_EVENT_INFO, data); |
| 0 | 92 | | } |
| | 93 | |
|
| | 94 | | public void SendPlaceTeleport(string placeId, string placeName, Vector2Int coords) |
| | 95 | | { |
| 0 | 96 | | Dictionary<string, string> data = new Dictionary<string, string>(); |
| 0 | 97 | | data.Add("place_id", placeId); |
| 0 | 98 | | data.Add("place_name", placeName); |
| 0 | 99 | | data.Add("place_coords_x", coords.x.ToString()); |
| 0 | 100 | | data.Add("place_coords_y", coords.y.ToString()); |
| 0 | 101 | | GenericAnalytics.SendAnalytic(EXPLORE_PLACE_TELEPORT, data); |
| 0 | 102 | | } |
| | 103 | |
|
| | 104 | | public void SendClickOnPlaceInfo(string placeId, string placeName) |
| | 105 | | { |
| 0 | 106 | | Dictionary<string, string> data = new Dictionary<string, string>(); |
| 0 | 107 | | data.Add("event_id", placeId); |
| 0 | 108 | | data.Add("event_name", placeName); |
| 0 | 109 | | GenericAnalytics.SendAnalytic(EXPLORE_CLICK_PLACE_INFO, data); |
| 0 | 110 | | } |
| | 111 | | } |
| | 112 | | } |