Skip to content

Commit

Permalink
include region, switch to reading ip from xff header
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobhero committed Feb 23, 2022
1 parent 343ae26 commit a2ca2ce
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion components/server/src/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ export async function trackSignup(user: User, request: Request, analytics: IAnal
function fullIdentify(user: User, request: Request, analytics: IAnalyticsWriter) {
//makes a full identify call for authenticated users
const coords = request.get("x-glb-client-city-lat-long")?.split(", ");
const ip = request.get("x-forwarded-for")?.split(",")[0];
analytics.identify({
anonymousId: stripCookie(request.cookies.ajs_anonymous_id),
userId:user.id,
context: {
"ip": maskIp(request.ips[0]),
"ip": ip ? maskIp(ip): undefined,
"userAgent": request.get("User-Agent"),
"location": {
"city": request.get("x-glb-client-city"),
"country": request.get("x-glb-client-region"),
"region": request.get("x-glb-client-region-subdivision"),
"latitude": coords?.length == 2 ? coords[0] : undefined,
"longitude": coords?.length == 2 ? coords[1] : undefined
}
Expand Down

0 comments on commit a2ca2ce

Please sign in to comment.