Skip to content

fix(basket): correct geo resolution telemetry + drop redis geoip cache - #589

Merged
izadoesdev merged 2 commits into
stagingfrom
izadoesdev/basket-geo-telemetry
Aug 4, 2026
Merged

fix(basket): correct geo resolution telemetry + drop redis geoip cache#589
izadoesdev merged 2 commits into
stagingfrom
izadoesdev/basket-geo-telemetry

Conversation

@izadoesdev

@izadoesdev izadoesdev commented Aug 4, 2026

Copy link
Copy Markdown
Member

What

Two slices fixing the basket IP-geo pipeline.

1. Geo resolution telemetry blind spot (fix)

The Axiom geo dashboard showed 0.4% resolution / 17.1M "failed to locate" — a measurement artifact, not an outage. getGeo() only merged a geo.* wide-event field on the Cloudflare-fallback and skipped-IP paths. On the MaxMind success path (~99.5% of traffic) it returned the country but never logged it, so Axiom recorded geo.country = null and the dashboard read those as failures.

Evidence (7d, basket dataset): geo.source=cloudflare_header = 76,957 = exactly the "resolved" count; zero GeoIP load errors; MaxMind lookups run on all 17.18M events at 0.26ms p50; flat 30-day trend with no cliff.

Fix: every request now emits a geo.sourcemaxmind / cloudflare_header / unresolved / skipped.

2. Drop the Redis GeoIP cache (perf)

timing.getGeo p50 was 142ms while the in-memory MaxMind lookup is 0.26ms — the cacheable Redis wrapper was ~500x slower than the value it cached. Removed the cache and the /24 coarsenIpForCache helper; lookups now hit the in-process reader on the full IP, restoring city/region precision the coarsening discarded.

Test

bun test src/utils/ip-geo.test.ts -> 20 pass; check-types green across all packages.

Follow-up (dashboard owner)

Update the Axiom panels to compute resolution from geo.source (maxmind + cloudflare_header = resolved) instead of isnull(geo.country).


Summary by cubic

Fixes geo resolution telemetry by always emitting geo.source, and removes the Redis GeoIP cache to use the in-process MaxMind lookup. This corrects false “failed to locate” readings in Axiom and cuts lookup p50 from ~142ms to ~0.26ms while restoring city/region precision.

  • Migration
    • Update Axiom dashboards to compute resolution from geo.source (maxmind + cloudflare_header = resolved) instead of isnull(geo.country).

Written for commit 1aa2b32. Summary will update on new commits.

Review in cubic

@cursor

cursor Bot commented Aug 4, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
databuddy-status Ready Ready Preview Aug 4, 2026 11:50am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
dashboard Skipped Skipped Aug 4, 2026 11:50am
documentation Skipped Skipped Aug 4, 2026 11:50am

@unkey-deploy

unkey-deploy Bot commented Aug 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Unkey Deploy

Name Status Preview Inspect Updated (UTC)
links (preview) Ready Visit Preview Inspect Aug 4, 2026 11:50am

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: c3e6260e-0d96-4485-a6e5-310b54661845

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dosubot

dosubot Bot commented Aug 4, 2026

Copy link
Copy Markdown

📄 Knowledge review

Dosu skipped reviewing this PR because your organization has used its 200 included credits for the month. Your usage will reset on 2026-09-01. To have Dosu review this PR before then, ask your organization admin to upgrade to a pro account.


Leave Feedback Ask Dosu about Databuddy Add Dosu to your team

@izadoesdev
izadoesdev merged commit d80410d into staging Aug 4, 2026
19 checks passed
@izadoesdev
izadoesdev deleted the izadoesdev/basket-geo-telemetry branch August 4, 2026 11:51
@greptile-apps

greptile-apps Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes Redis-backed, coarsened-IP GeoIP caching in favor of direct full-IP MaxMind lookups and adds resolution-source telemetry.

  • Records MaxMind and unresolved outcomes in the request-wide event.
  • Preserves Cloudflare country fallback while restoring full-IP region and city precision.
  • Leaves the skipped-IP branch without the promised geo.source value and broadens precise-location telemetry.

Confidence Score: 4/5

The skipped-IP telemetry defect should be fixed before merging so the promised source-based accounting covers every request; precise city and region logging should also be reconsidered.

The primary telemetry correction remains incomplete because the early skipped-IP return emits no source, while the MaxMind branch additionally broadens precise user-location data sent to operational telemetry.

Files Needing Attention: apps/basket/src/utils/ip-geo.ts

Important Files Changed

Filename Overview
apps/basket/src/utils/ip-geo.ts Removes Redis/coarsened lookup caching and adds MaxMind telemetry, but skipped IPs still lack geo.source and the new merge unnecessarily expands city/region observability.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[getGeo receives client IP] --> B{Invalid or local IP?}
  B -- Yes --> C[Emit skipped metadata and return]
  B -- No --> D[Direct MaxMind lookup using full IP]
  D --> E{Country resolved?}
  E -- Yes --> F[Emit source=maxmind and geo fields]
  E -- No --> G{Cloudflare country header?}
  G -- Yes --> H[Emit source=cloudflare_header]
  G -- No --> I[Emit source=unresolved]
Loading

Comments Outside Diff (1)

  1. apps/basket/src/utils/ip-geo.ts, line 185-187 (link)

    P1 Skipped source remains unreported

    When an IP is empty, malformed, or local, this early return records only skipped and reason, leaving geo.source unset and preventing the source-based dashboard from accounting for these requests as skipped.

    Knowledge Base Used: Basket Ingestion Flow

Reviews (1): Last reviewed commit: "perf(basket): drop redis geoip cache in ..." | Re-trigger Greptile

Comment on lines +216 to +225
mergeWideEvent({
geo: geo.country
? {
source: "maxmind",
country: geo.country,
region: geo.region,
city: geo.city,
}
: { source: "unresolved" },
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Telemetry expands precise geo data

The new MaxMind merge sends user-derived city and region data to operational telemetry even for callers that never persist an analytics event. These fields are unnecessary for measuring resolution source and broaden the retention and audience exposure of precise location data.

Suggested change
mergeWideEvent({
geo: geo.country
? {
source: "maxmind",
country: geo.country,
region: geo.region,
city: geo.city,
}
: { source: "unresolved" },
});
mergeWideEvent({
geo: geo.country
? {
source: "maxmind",
country: geo.country,
}
: { source: "unresolved" },
});

Knowledge Base Used: Basket Ingestion Flow

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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

Successfully merging this pull request may close these issues.

1 participant