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

feat: Programatically add dots to map #10225

Merged
merged 4 commits into from
Jan 30, 2025

Conversation

rafaeelaudibert
Copy link
Member

@rafaeelaudibert rafaeelaudibert commented Dec 26, 2024

Not many people online, and I chose to work on something fun today :)

Instead of having a hardcoded list of dots in our map, we're now collecting the latitude/longitude information from the information we're already collecting from everyone working at PostHog. We're doing some geocoding to transform that information into lat/long pairs.

There are some problems with the fact that there isn't much uniformity in the way everyone stores their information, so some dots are extremely inaccurate.

I've attempted the following pairs and they don't work that well

  • Location
  • Location, Country
  • Location | Country

I ultimately settled with the last one because it looks the most accurate, but there are still errors.

My suggestion: we should suggest everyone to fill their "Location" field with either a "city, country" tuple or simply the long form of their country name, which should make the map more accurate.

Before After
image image

Copy link

vercel bot commented Dec 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
posthog ✅ Ready (Inspect) Visit Preview Jan 29, 2025 9:22pm

{
resolve: `gatsby-mapbox-locations`,
options: {
mapboxToken: process.env.MAPBOX_TOKEN,
Copy link
Member Author

Choose a reason for hiding this comment

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

My biggest concern is this.

I set this on Vercel already, I'm using a private token, but I'm happy to create a PostHog one. They have 50,000 requests/month for free, so we shouldn't hit that from production alone, but everytime we run this locally and/or create a preview environment, we'll fetch all of the latitude/longitudes. I'm pretty sure we'll eventually go over 50k/month if we do that. I'm not really sure it's worth it, though.

Other solutions:

  • Just add a new latitude/longitude field to our Squeak profile and fetch it from there
  • Use their enterprise plan and cache requests, should make it free IIUC?

Instead of having a hardcoded list of dots in our map, we're now collecting the latitude/longitude information from the information we're already collecting from everyone working at PostHog. We're doing some geocoding to transform that information into lat/long pairs.

There are some problems with the fact that there isn't much uniformity in the way everyone stores their information, so some dots are extremely innacurate.

I've attempted the following pairs and they don't work that well
- Location
- Location, Country
- Location | Country

I ultimately settled with the last one because it looks the most accurate - but there are errors still.

My suggestion: we should suggest everyone to fill their "Location" field with either a "city, country" tuple or simply the long form of their country name, which **should** make the map more accurate.
@rafaeelaudibert rafaeelaudibert force-pushed the programatically-add-dots-to-map branch from a875221 to ef6f749 Compare December 26, 2024 22:49
@rafaeelaudibert
Copy link
Member Author

Minor minor minor

BTW, there's room to add more people to that map, the code is ready already, we just need a competition to figure out who are the (un)lucky few :)

image

@rafaeelaudibert
Copy link
Member Author

@smallbrownbike I'm cleaning up some of my old-ish PRs, you think we'll be able to merge/look into this, or should I close it?

Copy link
Collaborator

@smallbrownbike smallbrownbike left a comment

Choose a reason for hiding this comment

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

I added a MapboxLocation schema so the build will run without a Mapbox token. This allows us to run the repo locally without a Mapbox token and add the token to production builds only in Vercel. Thus, we only query Mapbox on production builds, so we don't have to worry about hitting the Mapbox API limits!

@rafaeelaudibert
Copy link
Member Author

@smallbrownbike That's awesome, I'm not well-versed in Gatsby, so thank you for adding that!

It's probably a good idea to create a PostHog token rather than using mine, though. Do you want me to handle this, or will you?

@smallbrownbike
Copy link
Collaborator

@rafaeelaudibert Should be all set now!

@smallbrownbike smallbrownbike merged commit c15da73 into master Jan 30, 2025
3 checks passed
@smallbrownbike smallbrownbike deleted the programatically-add-dots-to-map branch January 30, 2025 03:22
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.

2 participants