Skip to content

Add residential property to Anonymizer record#319

Open
oschwald wants to merge 1 commit into
mainfrom
greg/stf-997-add-residential-to-anonymizer
Open

Add residential property to Anonymizer record#319
oschwald wants to merge 1 commit into
mainfrom
greg/stf-997-add-residential-to-anonymizer

Conversation

@oschwald

@oschwald oschwald commented Jul 10, 2026

Copy link
Copy Markdown
Member

Summary

The GeoIP Insights web service is adding a residential sub-object to the anonymizer object. It contains residential proxy data for the network and may be populated even when no other anonymizer properties are set.

  • New reusable record for the feed shape (confidence, network_last_seen, provider_name) named AnonymizerFeed, so future anonymizer feeds can share it
  • New residential property on the Anonymizer record
  • Tests, fixtures, and changelog updated

residential is always constructed (an empty AnonymizerFeed when there is no data), matching the library's existing sub-object pattern, and is omitted from jsonSerialize() output when empty.

Testing

phpunit, php-cs-fixer, phpcs, and phpstan all pass.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for residential anonymizer information in Insights results.
    • Residential data can include confidence, last-seen network date, and provider name.
    • Results may contain residential anonymizer data even when other anonymizer details are unavailable.
    • Empty residential data is omitted from serialized responses.
  • Documentation

    • Updated the unreleased changelog entry for version 3.4.0 with residential anonymizer details.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0ff24ee6-4e18-4252-9674-305e66dd4b49

📥 Commits

Reviewing files that changed from the base of the PR and between 1abe2bc and be47d40.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • src/Record/Anonymizer.php
  • src/Record/AnonymizerFeed.php
  • tests/GeoIp2/Test/Model/InsightsTest.php

📝 Walkthrough

Walkthrough

The anonymizer model now supports a residential feed containing confidence, last-seen, and provider data. A new immutable record handles parsing and serialization, with tests covering full, residential-only, and empty inputs.

Changes

Anonymizer residential feed

Layer / File(s) Summary
Residential feed model integration
src/Record/Anonymizer.php, src/Record/AnonymizerFeed.php
Adds the immutable AnonymizerFeed record and exposes it through Anonymizer, including conditional JSON serialization.
Residential feed validation and release documentation
tests/GeoIp2/Test/Model/InsightsTest.php, CHANGELOG.md
Tests populated, residential-only, and empty inputs, and documents the new residential property and feed fields.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant InputRecord
  participant Anonymizer
  participant AnonymizerFeed
  InputRecord->>Anonymizer: residential array
  Anonymizer->>AnonymizerFeed: construct feed record
  Anonymizer->>AnonymizerFeed: jsonSerialize()
  AnonymizerFeed-->>Anonymizer: residential JSON fields
Loading

Poem

A rabbit hops through fields so bright,
With confidence tucked in just right.
Last-seen dates and providers flow,
Residential details now show.
The feed springs cleanly into sight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.14% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a residential property to the Anonymizer record.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch greg/stf-997-add-residential-to-anonymizer

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.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a new residential property to the Anonymizer record, represented by the new AnonymizerFeed class, to support data from the GeoIP Residential Proxy database. It also includes comprehensive test coverage for this new feature. The review feedback suggests adding a defensive type check to ensure $record['residential'] is an array before instantiating AnonymizerFeed to prevent potential runtime type errors.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/Record/Anonymizer.php Outdated
Comment on lines +98 to +100
$this->residential = isset($record['residential'])
? new AnonymizerFeed($record['residential'])
: null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

To prevent a potential TypeError at runtime, it is safer to verify that $record['residential'] is indeed an array before passing it to the AnonymizerFeed constructor. If the API response is malformed or contains an unexpected type for this key, this defensive check will prevent a crash.

        $this->residential = isset($record['residential']) && \is_array($record['residential'])
            ? new AnonymizerFeed($record['residential'])
            : null;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Claude, on behalf of Greg: Declining this one. The record constructors in this library intentionally read fields with plain ?? null / isset access and no type guards — every sibling field in this constructor and the other Record classes follow that pattern, and the input comes from our own web service response decoding rather than untrusted data. A one-off is_array check here would be inconsistent with the rest of the records.

@oschwald oschwald force-pushed the greg/stf-997-add-residential-to-anonymizer branch from f0d050c to 0449833 Compare July 11, 2026 01:55
@oschwald oschwald force-pushed the greg/stf-997-add-residential-to-anonymizer branch 2 times, most recently from 8f738eb to 1abe2bc Compare July 14, 2026 00:06
Add a residential sub-object to the anonymizer object with confidence,
networkLastSeen, and providerName. Residential proxy data may be
present even when the other anonymizer properties are unset, so the
anonymizer object may now be returned with only this property set.

The new GeoIp2\Record\AnonymizerFeed class is written to be reused if
the server adds sibling sub-objects (vpn, mobile, datacenter) with the
same shape.

STF-997

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@oschwald oschwald force-pushed the greg/stf-997-add-residential-to-anonymizer branch from 1abe2bc to be47d40 Compare July 14, 2026 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant