Skip to content

Commit f1159c2

Browse files
Add the UseIpAddressForGeolocation option for MixpanelSettings (#170)
1 parent bd95d86 commit f1159c2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Mixpanel/MixpanelSettings.cs

+7-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ namespace mixpanel
1010
{
1111
public class MixpanelSettings : ScriptableObject
1212
{
13-
private const string TrackUrlTemplate = "{0}track/?ip=1";
14-
private const string EngageUrlTemplate = "{0}engage/?ip=1";
13+
private const string TrackUrlTemplate = "{0}track/?ip={1}";
14+
private const string EngageUrlTemplate = "{0}engage/?ip={1}";
1515

1616
//TODO: Convert to log level
1717
[Tooltip("If true will print helpful debugging messages")]
@@ -26,6 +26,8 @@ public class MixpanelSettings : ScriptableObject
2626
public string DebugToken = "";
2727
[Tooltip("Seconds (in realtime) between sending data to the API Host.")]
2828
public float FlushInterval = 60f;
29+
[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.")]
30+
public bool UseIpAddressForGeolocation = true;
2931

3032
internal string Token {
3133
get {
@@ -40,8 +42,9 @@ internal string Token {
4042
public void ApplyToConfig()
4143
{
4244
string host = APIHostAddress.EndsWith("/") ? APIHostAddress : $"{APIHostAddress}/";
43-
Config.TrackUrl = string.Format(TrackUrlTemplate, host);
44-
Config.EngageUrl = string.Format(EngageUrlTemplate, host);
45+
string useIpAddressForGeolocation = UseIpAddressForGeolocation ? "1" : "0";
46+
Config.TrackUrl = string.Format(TrackUrlTemplate, host, useIpAddressForGeolocation);
47+
Config.EngageUrl = string.Format(EngageUrlTemplate, host, useIpAddressForGeolocation);
4548
Config.ShowDebug = ShowDebug;
4649
Config.ManualInitialization = ManualInitialization;
4750
Config.FlushInterval = FlushInterval;

0 commit comments

Comments
 (0)