fix: hubspot attribution issues
Thanks for submitting a PR! Please check the boxes below:
- [ ] I have added information to
docs/if required so people know about the feature! - [x] I have filled in the "Changes" section below?
- [x] I have filled in the "How did you test this code" section below?
- [x] I have used a Conventional Commit title for this Pull Request
Changes
⚠️ Hubspot is now in charge of initially creating (if not exists) / associating organisation with users. Reconciliation is based on domain.
- Pass hubspot cookie from frontend on signup action
- Reworked the hubspot tracking flow so that:
- Every new sign-up creates a hubspot contact (using
create_lead_formwith or without cookie) and savesHubspotLeads - On UsersOrganisation creation
a) If organisation was just created and exists in hubspot => get company data from hubspot, saves the
HubspotOrganisationobject with correct id b) if doesn't exist in hubspot for X reason => creates it and saves hubspot ID - On UsersOrganisation creation, associates the contact with the
- Removed the 30min background checker as hubspot creates/associates automatically the company
How did you test this code?
Please describe.
- Added battery of tests on client and lead_tracker
Functionally:
Set
"ENABLE_HUBSPOT_LEAD_TRACKING": "True"andHUBSPOT_ACCESS_TOKENCreate user, organisation, invite users
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| docs | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Jun 20, 2025 7:52am |
| flagsmith-frontend-preview | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Jun 20, 2025 7:52am |
| flagsmith-frontend-staging | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Jun 20, 2025 7:52am |
Docker builds report
| Image | Build Status | Security report |
|---|---|---|
ghcr.io/flagsmith/flagsmith-api-test:pr-5560 |
Finished :white_check_mark: | Skipped |
ghcr.io/flagsmith/flagsmith-e2e:pr-5560 |
Finished :white_check_mark: | Skipped |
ghcr.io/flagsmith/flagsmith-api:pr-5560 |
Finished :white_check_mark: | Results :white_check_mark: |
ghcr.io/flagsmith/flagsmith:pr-5560 |
Finished :white_check_mark: | Results :white_check_mark: |
ghcr.io/flagsmith/flagsmith-private-cloud:pr-5560 |
Finished :white_check_mark: | Results :white_check_mark: |
ghcr.io/flagsmith/flagsmith-frontend:pr-5560 |
Finished :white_check_mark: | Results :white_check_mark: |
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 97.76%. Comparing base (
23aa20f) to head (3d84158). Report is 1 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #5560 +/- ##
==========================================
+ Coverage 97.74% 97.76% +0.02%
==========================================
Files 1255 1255
Lines 44500 44643 +143
==========================================
+ Hits 43496 43645 +149
+ Misses 1004 998 -6
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Thanks for the detailed feedback.
The naming could definitely be improved in a few places
Definitely, let me know if this feels clearer
As far as I'm aware, this work should ideally have resulted in 3 tasks
That should be the case, more precisely there are 2 entrypoints:
- User registration triggers
create_hubspot_contact_for_userand ultimately the lead_form - New UserOrganisation entity triggers
track_hubspot_user_organisation_associationthat wrapsupdate_companyif name needs to be updated (merged with update subscription)
Additionally, I added a basic retry with backoff in create_lead_form, without raising for now