Skip to content

Commit

Permalink
Add the UseIpAddressForGeolocation option for MixpanelSettings (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwe321qwe321qwe321 authored Mar 1, 2024
1 parent bd95d86 commit f1159c2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Mixpanel/MixpanelSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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 {
Expand All @@ -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;
Expand Down

0 comments on commit f1159c2

Please sign in to comment.