IP Anonymization
Built-in privacy protection for user data.
Insightcn includes built-in IP anonymization to protect user privacy. All IP addresses are automatically anonymized before being stored.
How It Works
The SDK anonymizes IP addresses by setting the last octet to 0. This prevents tracking individual users while still allowing geographic analysis.
Example
Original IP: 192.168.1.100
Anonymized IP: 192.168.1.0Usage
import { anonymizeIp } from "@insightcn/sdk";
const anonymized = anonymizeIp("192.168.1.100");
console.log(anonymized); // "192.168.1.0"Automatic Anonymization
When you use captureRegistryEvent, IP addresses are automatically anonymized before being sent to the backend:
import { captureRegistryEvent } from "@insightcn/sdk";
// IP is automatically anonymized
await captureRegistryEvent(request, "your-api-key", "installed");Extracting Client IP
You can extract the client IP from request headers using getClientIp:
import { getClientIp } from "@insightcn/sdk";
const ip = getClientIp(request);
console.log(ip); // "192.168.1.100"The function checks the following headers in order:
x-forwarded-forx-real-ip
Privacy Compliance
IP anonymization helps you comply with privacy regulations like GDPR and CCPA by:
- Preventing tracking of individual users
- Allowing aggregate geographic analysis
- Reducing data sensitivity