diff --git a/CHANGELOG.md b/CHANGELOG.md index c88d454..1501cd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [v3.3.1](https://github.com/mixpanel/mixpanel-unity/tree/v3.3.1) (2022-08-18) +### Fixes + +- LICENSE has no meta file [\#147](https://github.com/mixpanel/mixpanel-unity/issues/147) + # ## [v3.3.0](https://github.com/mixpanel/mixpanel-unity/tree/v3.3.0) (2022-08-04) 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..66a8817 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.CurrentTimeInSeconds(); 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",