Skip to content

SL-1950: Record anonymous project storage geolocation#73651

Open
artem-vavilov wants to merge 5 commits into
stagingfrom
SL-1950/project-storage-geos
Open

SL-1950: Record anonymous project storage geolocation#73651
artem-vavilov wants to merge 5 commits into
stagingfrom
SL-1950/project-storage-geos

Conversation

@artem-vavilov

Copy link
Copy Markdown
Member

Records geolocation data for anonymous project storage records.

ProjectStorage::AnonymousGeoRecordingJob records only the first geolocation for a storage_id when a new anonymous project storage is created, mirroring the existing first-IP behavior used for signed-in users through user_geos.

Links

@artem-vavilov artem-vavilov requested a review from a team as a code owner July 2, 2026 20:34
@artem-vavilov artem-vavilov requested a review from sureshc July 2, 2026 20:34
@artem-vavilov artem-vavilov requested a review from Copilot July 2, 2026 20:41

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 936da5e4e7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread dashboard/app/jobs/project_storage/anonymous_geo_recording_job.rb
Comment thread lib/cdo/geocoder.rb

Copilot AI left a comment

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.

Pull request overview

Records first-seen geolocation (country/state/city/postal code) for newly-created anonymous ProjectStorage records, and exports the new data for analytics, mirroring the existing “first IP” approach used for signed-in users via user_geos.

Changes:

  • Enqueue ProjectStorage::AnonymousGeoRecordingJob when a new anonymous storage_id cookie is created (using a writer DB connection for enqueue).
  • Add ProjectStorage::Geo model + ProjectStorage#geo association and a job to populate the first geo row per storage.
  • Add unit/controller tests, factories, and analytics (Redshift MV templates) for the new table; refactor Geocoder usage to centralize retry logic via Geocoder.find.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
shared/test/common_test_helper.rb Ensures project_storage_geos is truncated for repeatable tests.
shared/middleware/helpers/storage_id.rb Enqueues geo-recording job on anonymous storage cookie creation (writer role).
lib/cdo/geocoder.rb Adds Geocoder.find wrapper with retries and updates callers to use it.
dashboard/app/jobs/project_storage/anonymous_geo_recording_job.rb New job to persist first geo row for anonymous ProjectStorage.
dashboard/app/models/project_storage/geo.rb New ProjectStorage::Geo ActiveRecord model + analytics export classification.
dashboard/app/models/project_storage.rb Adds has_one :geo association to ProjectStorage.
dashboard/test/jobs/project_storage/anonymous_geo_recording_job_test.rb Unit tests for job behavior (happy path + edge cases).
dashboard/test/factories/factories.rb Adds :project_storage_geo factory for tests.
dashboard/test/controllers/projects_controller_test.rb Verifies job enqueued only for anonymous project creation; adds Sequel transaction wrapper.
bin/cron/user_geos Switches to Geocoder.find for consistent retry behavior.
aws/redshift/zeroetl_materialized_views/project_storage_geos.sql.erb Adds analytics MV template for non-PII schema.
aws/redshift/zeroetl_materialized_views/project_storage_geos_pii.sql.erb Adds analytics MV template for PII schema.

Comment thread dashboard/test/controllers/projects_controller_test.rb
Comment thread dashboard/test/controllers/projects_controller_test.rb
Comment thread lib/cdo/geocoder.rb
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