SL-1950: Record anonymous project storage geolocation#73651
SL-1950: Record anonymous project storage geolocation#73651artem-vavilov wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
💡 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".
There was a problem hiding this comment.
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::AnonymousGeoRecordingJobwhen a new anonymousstorage_idcookie is created (using a writer DB connection for enqueue). - Add
ProjectStorage::Geomodel +ProjectStorage#geoassociation 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
Geocoderusage to centralize retry logic viaGeocoder.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. |
Records geolocation data for anonymous project storage records.
ProjectStorage::AnonymousGeoRecordingJobrecords only the first geolocation for astorage_idwhen a new anonymous project storage is created, mirroring the existing first-IP behavior used for signed-in users throughuser_geos.Links