Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anonymize IP addresses client-side #57

Open
robertvazan opened this issue Sep 19, 2018 · 1 comment
Open

Anonymize IP addresses client-side #57

robertvazan opened this issue Sep 19, 2018 · 1 comment
Milestone

Comments

@robertvazan
Copy link

robertvazan commented Sep 19, 2018

I am using this library server-side, proxying analytics data from the client. I want to anonymize IP addresses before sending them to GA. I am currently doing this:

/*
 * Perform local IP address anonymization.
 * We are also instructing GA to anonymize IPs on GA end,
 * but it is technically and legally safer to anonymize locally.
 * Anonymization rules are the same as those used by GA,
 * i.e. zero last 80 bits of IPv6 and last 8 bits of IPv4.
 */
InetAddress ip = InetAddress.getByName("12.34.56.78");
byte[] address = ip.getAddress();
int anonymizedBytes = ip instanceof Inet6Address ? 10 : 1;
for (int i = 0; i < anonymizedBytes; ++i)
	address[address.length - i - 1] = 0;
return InetAddress.getByAddress(address).getHostAddress();

I guess many people could use IP anonymization for compliance reasons. It would give your library a privacy edge. Consider adding this as an option. Thanks.

@brsanthu brsanthu added this to the 2.1 milestone May 20, 2019
@brsanthu
Copy link
Owner

Added the feature into library via setAnonymizeUserIp config flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants