From f1159c2f5571974987d27e5d0b9116579c48232b Mon Sep 17 00:00:00 2001 From: PeDev Date: Fri, 1 Mar 2024 09:09:16 +0800 Subject: [PATCH] Add the UseIpAddressForGeolocation option for MixpanelSettings (#170) --- Mixpanel/MixpanelSettings.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Mixpanel/MixpanelSettings.cs b/Mixpanel/MixpanelSettings.cs index 765813f..637e56c 100644 --- a/Mixpanel/MixpanelSettings.cs +++ b/Mixpanel/MixpanelSettings.cs @@ -10,8 +10,8 @@ namespace mixpanel { public class MixpanelSettings : ScriptableObject { - private const string TrackUrlTemplate = "{0}track/?ip=1"; - private const string EngageUrlTemplate = "{0}engage/?ip=1"; + private const string TrackUrlTemplate = "{0}track/?ip={1}"; + private const string EngageUrlTemplate = "{0}engage/?ip={1}"; //TODO: Convert to log level [Tooltip("If true will print helpful debugging messages")] @@ -26,6 +26,8 @@ public class MixpanelSettings : ScriptableObject public string DebugToken = ""; [Tooltip("Seconds (in realtime) between sending data to the API Host.")] public float FlushInterval = 60f; + [Tooltip("If true, the library will use the IP address of the client for geolocation. If false, the library will use the IP address of the Mixpanel server for geolocation.")] + public bool UseIpAddressForGeolocation = true; internal string Token { get { @@ -40,8 +42,9 @@ internal string Token { public void ApplyToConfig() { string host = APIHostAddress.EndsWith("/") ? APIHostAddress : $"{APIHostAddress}/"; - Config.TrackUrl = string.Format(TrackUrlTemplate, host); - Config.EngageUrl = string.Format(EngageUrlTemplate, host); + string useIpAddressForGeolocation = UseIpAddressForGeolocation ? "1" : "0"; + Config.TrackUrl = string.Format(TrackUrlTemplate, host, useIpAddressForGeolocation); + Config.EngageUrl = string.Format(EngageUrlTemplate, host, useIpAddressForGeolocation); Config.ShowDebug = ShowDebug; Config.ManualInitialization = ManualInitialization; Config.FlushInterval = FlushInterval;