Repository navigation
feat(NB-3138): add hubspot:export-marketing command - #15
Merged
Merged
Conversation
- MarketingExportSource contract with an SDK implementation (contacts, lists, memberships, subscription definitions and statuses, spam-report events) - MarketingExporter writes JSON/JSONL files in a fixed order; manifest last - ExportMarketingCommand with --disk, --dir, --skip-preferences, --skip-events, --property options; new `export` config block - Archived contacts are never exported; write failures on throw=false disks raise a RuntimeException - Fake source fixture and feature tests Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
codelikesuraj
left a comment
Collaborator
There was a problem hiding this comment.
Review notes (2026-10-15)
Checked against the approved NB-3138 plan and the installed hubspot/api-client 13.2.0. Every SDK call matches (getPage with archived=false, list search offset paging, membership cursor paging, preference definition and status APIs, apiRequest for spam events). Write order, streaming through php://temp, the === false write checks, the mapping template and the manifest all match the plan. Package suite: 53 passing.
Should fix
src/Commands/ExportMarketingCommand.php:36:catch (Throwable)returns FAILURE withoutreport($e). A failure hours into a production export leaves one console line and nothing in the log. Addreport($e)before the error line.- No
CHANGELOG.mdentry. Add## 5.2.0 - unreleased/### Addedforhubspot:export-marketing, since a human tags it after merge. src/Export/SdkMarketingExportSource.php:76(contactLists()) and the spam-events loop at:168:while (getHasMore())with no guard against the same offset coming back, a known quirk of the legacy endpoints. Break when the offset does not advance.SdkMarketingExportSource.php:592-596: onlyClientException(4xx) is caught on the first events page. A 5xx fails the whole run after the slow per-contact status loop has finished. CatchBadResponseExceptionand distinguish "unavailable" from a logged failure.- Test gaps in
tests/Feature/ExportMarketingCommandTest.php:--skip-events,--disk/--dir/--propertyoverrides, paging termination for lists and memberships,subscriptionStatuses()mapping anApiExceptiontoerror,spamReportEvents()returning null, andwriteStream() === false.
Nits
MarketingExporter.php:267and:378callnow()twice for the run directory andexported_at; capture once.- The local
$reportclosure inMarketingExporter.php:269reads like Laravel'sreport()helper. - The test file's global helpers (
exportRunDir(),readJsonl(),readJson()) would collide with a second test file using the same names.
After merge: tag 5.2.0, then on the neurohub branch run composer update visualbuilder/filament-hubspot and commit the lock.
- log the failure before printing it, so a multi-hour run leaves a trace - stop paging lists and spam reports when HubSpot repeats an offset - treat a 5xx from the events endpoint as unavailable after logging it, instead of failing the run after the status loop has completed - take one timestamp for the run directory and exported_at - rename the progress closure so it does not read like report() - changelog entry for 5.2.0 - tests: --skip-events, --property merging, --disk/--dir overrides, streamed-write failure, stalled offsets, events errors, preference errors
Collaborator
|
Review notes applied in 3fa357c:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hubspot:export-marketingcommand exports contacts, contact lists, list memberships, subscription definitions, per-email subscription statuses and spam-report events to a filesystem disk.MarketingExportSourcecontract withSdkMarketingExportSource(hubspot/api-client 13.x). Bound lazily inHubspotApiServiceProvider, so tests bind a fake and need no credentials.MarketingExporterwrites files in a fixed order and the manifest last. Archived contacts are never requested ($archived = false). Afalsereturn from athrow => falsedisk raisesRuntimeException.exportconfig block (disk,directory,page_size,membership_page_size,contact_properties).Companion neurohub change:
marketing:import-hubspot(neurohub PR tofeature/NB-3135-marketing-campaigns, linked from NB-3138).Test plan
tests/Feature/ExportMarketingCommandTest.php: 7 tests (all files + manifest counts, mapping template,--skip-preferences, unavailable events warning, write failure, two-page cursor on the SDK source, status-loop failure keeps bulk files and no manifest)After merge
A human tags the next minor on
5.x(currently5.1.1, so5.2.0). The neurohub branch then runscomposer update visualbuilder/filament-hubspot --no-interaction. Tagging is deferred to a human, not done by the agent.YouTrack
NB-3138
Tier: coding_complex
🤖 Generated with Claude Code