Skip to content

Conversation

@morleyzhi
Copy link
Contributor

@morleyzhi morleyzhi commented Sep 3, 2025

@morleyzhi
Copy link
Contributor Author

@jaredmixpanel Can you get someone to review this PR? It seems like a serious bug -- library consumers think they're turning off IP tracking, but they're not, possibly breaking their regulatory commitments.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a critical bug in the getUseIpAddressForGeolocation method where it always returned true, even when explicitly set to false. The issue stemmed from using || true as the fallback, which caused the logical OR to always return true when the value was false. The fix uses the in operator to explicitly check if the property exists before accessing it, correctly handling the case where the value is intentionally set to false.

Key Changes:

  • Fixed boolean logic in getUseIpAddressForGeolocation to properly return false when explicitly configured
  • Minor code style improvement to import statement spacing

Comment on lines 67 to 76
getUseIpAddressForGeolocation(token) {
return (
(this._config[token] && this._config[token].useIpAddressForGeolocation) ||
true
);
if (
this._config[token] &&
"useIpAddressForGeolocation" in this._config[token]
) {
return this._config[token].useIpAddressForGeolocation;
}

return true;
}
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix correctly addresses the bug where getUseIpAddressForGeolocation always returned true due to the || true fallback. However, this fix lacks test coverage. Consider adding a test case to verify that when useIpAddressForGeolocation is explicitly set to false, the getter returns false rather than true. This would prevent regression of this bug.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

@jaredmixpanel jaredmixpanel merged commit 0b1a1d0 into mixpanel:master Dec 15, 2025
6 checks passed
@jaredmixpanel jaredmixpanel added the bug Something isn't working label Dec 15, 2025
@jaredmixpanel
Copy link
Collaborator

Sorry this took so long, thanks for the fix. Released with v3.1.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: IP geolocation cannot be turned off

2 participants