anonymizeIp
Anonymize an IP address.
Anonymize an IP address by setting the last octet to 0.
Signature
function anonymizeIp(ip: string): string;Parameters
| Parameter | Type | Description |
|---|---|---|
ip | string | IP address |
Returns
string — Anonymized IP address.
Example
import { anonymizeIp } from "@insightcn/sdk";
const anonymized = anonymizeIp("192.168.1.100");
console.log(anonymized); // "192.168.1.0"How It Works
The function sets the last octet (the last number) of the IP address to 0:
Original IP: 192.168.1.100
^^^^^^^^^ ^^^
Network Host
└── Set to 0
Anonymized IP: 192.168.1.0Use Cases
- Privacy Compliance — Help comply with GDPR and CCPA
- Aggregate Analysis — Analyze geographic data without tracking individuals
- Data Protection — Reduce data sensitivity in logs and storage
Automatic Anonymization
When you use captureRegistryEvent, IP addresses are automatically anonymized:
import { captureRegistryEvent } from "@insightcn/sdk";
// IP is automatically anonymized
await captureRegistryEvent(request, "your-api-key", "installed");