From 27c5523051a78a46318ba9391e0f98e48f5c8829 Mon Sep 17 00:00:00 2001 From: Jared McFarland Date: Tue, 20 Sep 2022 16:42:08 -0700 Subject: [PATCH 1/4] dont use milliseconds for $duration of timed events --- CHANGELOG.md | 8 ++++++++ Mixpanel/Controller.cs | 6 +++--- Mixpanel/MixpanelAPI.cs | 6 +++--- Mixpanel/Worker.cs | 9 ++++++++- package.json | 2 +- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c88d454..908aa2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # +## [v3.3.2](https://github.com/mixpanel/mixpanel-unity/tree/v3.3.2) (2022-09-20) + +### Fixes + +- Revert timed event $durations to seconds + +# + ## [v3.3.1](https://github.com/mixpanel/mixpanel-unity/tree/v3.3.1) (2022-08-18) # diff --git a/Mixpanel/Controller.cs b/Mixpanel/Controller.cs index 3a90348..eadc31b 100644 --- a/Mixpanel/Controller.cs +++ b/Mixpanel/Controller.cs @@ -351,12 +351,12 @@ internal static void DoTrack(string eventName, Value properties) Value startTime; if (MixpanelStorage.TimedEvents.TryGetValue(eventName, out startTime)) { - properties["$duration"] = Util.CurrentTime() - (double)startTime; + properties["$duration"] = Util.CurrentTimeInSeconds() - (double)startTime; MixpanelStorage.TimedEvents.Remove(eventName); } properties["token"] = MixpanelSettings.Instance.Token; properties["distinct_id"] = MixpanelStorage.DistinctId; - properties["time"] = Util.CurrentTime(); + properties["time"] = Util.CurrentTimeInMilliseconds(); Value data = new Value(); @@ -376,7 +376,7 @@ internal static void DoEngage(Value properties) if (!MixpanelStorage.IsTracking) return; properties["$token"] = MixpanelSettings.Instance.Token; properties["$distinct_id"] = MixpanelStorage.DistinctId; - properties["$time"] = Util.CurrentTime(); + properties["$time"] = Util.CurrentTimeInMilliseconds(); properties["$mp_metadata"] = Metadata.GetPeopleMetadata(); MixpanelStorage.EnqueueTrackingData(properties, MixpanelStorage.FlushType.PEOPLE); diff --git a/Mixpanel/MixpanelAPI.cs b/Mixpanel/MixpanelAPI.cs index 6d68a82..33af866 100644 --- a/Mixpanel/MixpanelAPI.cs +++ b/Mixpanel/MixpanelAPI.cs @@ -18,7 +18,7 @@ namespace mixpanel /// public static partial class Mixpanel { - internal const string MixpanelUnityVersion = "3.3.1"; + internal const string MixpanelUnityVersion = "3.3.2"; /// /// Creates an Mixpanel instance. Use only if you have enabled "Manual Initialization" from your Project Settings. @@ -217,7 +217,7 @@ public static void StartTimedEvent(string eventName) { if (!IsInitialized()) return; Value properties = MixpanelStorage.TimedEvents; - properties[eventName] = Util.CurrentTime(); + properties[eventName] = Util.CurrentTimeInSeconds(); MixpanelStorage.TimedEvents = properties; } @@ -232,7 +232,7 @@ public static void StartTimedEventOnce(string eventName) if (!MixpanelStorage.TimedEvents.ContainsKey(eventName)) { Value properties = MixpanelStorage.TimedEvents; - properties[eventName] = Util.CurrentTime(); + properties[eventName] = Util.CurrentTimeInMilliseconds(); MixpanelStorage.TimedEvents = properties; } } diff --git a/Mixpanel/Worker.cs b/Mixpanel/Worker.cs index 27cb859..9601580 100644 --- a/Mixpanel/Worker.cs +++ b/Mixpanel/Worker.cs @@ -14,7 +14,14 @@ namespace mixpanel internal static class Util { - internal static double CurrentTime() + internal static double CurrentTimeInSeconds() + { + DateTime epochStart = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + double currentEpochTime = (DateTime.UtcNow - epochStart).TotalSeconds; + return currentEpochTime; + } + + internal static double CurrentTimeInMilliseconds() { DateTime epochStart = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); long currentEpochTime = (long)(DateTime.UtcNow - epochStart).TotalMilliseconds; diff --git a/package.json b/package.json index cbbb65a..4f0c234 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.mixpanel.unity", "displayName": "Mixpanel", - "version": "3.3.1", + "version": "3.3.2", "description": "Official Mixpanel library for Unity.", "repository": { "type": "git", From dd4e94901744009b7a888add8dd1584e8785ae3e Mon Sep 17 00:00:00 2001 From: Jared McFarland Date: Tue, 20 Sep 2022 16:44:18 -0700 Subject: [PATCH 2/4] update changelod --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 908aa2a..3080b18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Fixes -- Revert timed event $durations to seconds +- dont use milliseconds for $duration of timed events [\#150](https://github.com/mixpanel/mixpanel-unity/pull/150) # From 3a7399c748db1d63418adf8ec80886ab1b9d8f4c Mon Sep 17 00:00:00 2001 From: Jared McFarland Date: Tue, 20 Sep 2022 16:46:44 -0700 Subject: [PATCH 3/4] fix StartTimedEventOnce --- Mixpanel/MixpanelAPI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mixpanel/MixpanelAPI.cs b/Mixpanel/MixpanelAPI.cs index 33af866..66a8817 100644 --- a/Mixpanel/MixpanelAPI.cs +++ b/Mixpanel/MixpanelAPI.cs @@ -232,7 +232,7 @@ public static void StartTimedEventOnce(string eventName) if (!MixpanelStorage.TimedEvents.ContainsKey(eventName)) { Value properties = MixpanelStorage.TimedEvents; - properties[eventName] = Util.CurrentTimeInMilliseconds(); + properties[eventName] = Util.CurrentTimeInSeconds(); MixpanelStorage.TimedEvents = properties; } } From 000c20becd166016ff7956b8b85a846c9bdfd5f1 Mon Sep 17 00:00:00 2001 From: Jared McFarland Date: Tue, 20 Sep 2022 17:10:01 -0700 Subject: [PATCH 4/4] update changelog again --- CHANGELOG.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3080b18..1501cd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,10 @@ # -## [v3.3.2](https://github.com/mixpanel/mixpanel-unity/tree/v3.3.2) (2022-09-20) +## [v3.3.1](https://github.com/mixpanel/mixpanel-unity/tree/v3.3.1) (2022-08-18) ### Fixes -- dont use milliseconds for $duration of timed events [\#150](https://github.com/mixpanel/mixpanel-unity/pull/150) - -# - -## [v3.3.1](https://github.com/mixpanel/mixpanel-unity/tree/v3.3.1) (2022-08-18) +- LICENSE has no meta file [\#147](https://github.com/mixpanel/mixpanel-unity/issues/147) #