Skip to content

Commit

Permalink
fix(hubspot): create hubspot company with domain (#3844)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewelwell authored Apr 29, 2024
1 parent 210dbf7 commit d4c9173
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion api/integrations/lead_tracking/hubspot/lead_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ def update_company_active_subscription(
def _get_or_create_company_by_domain(self, domain: str) -> dict:
company = self.client.get_company_by_domain(domain)
if not company:
company = self.client.create_company(name=domain)
# Since we don't know the company's name, we pass the domain as
# both the name and the domain. This can then be manually
# updated in Hubspot if needed.
company = self.client.create_company(name=domain, domain=domain)

return company

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ def test_track_hubspot_lead_without_organisation(
# Given
hubspot_company_id = "company-id"
hubspot_contact_id = "contact-id"
domain = "example.com"
email = f"test@{domain}"

settings.ENABLE_HUBSPOT_LEAD_TRACKING = True

user = FFAdminUser.objects.create(email="[email protected]")
user = FFAdminUser.objects.create(email=email)

mock_hubspot_client = mocker.MagicMock(spec=HubspotClient)
mocker.patch(
Expand All @@ -56,5 +58,8 @@ def test_track_hubspot_lead_without_organisation(
track_hubspot_lead_without_organisation(user_id=user.id)

# Then
mock_hubspot_client.create_company.assert_called_once_with(
name=domain, domain=domain
)
mock_hubspot_client.create_contact.assert_called_once_with(user, hubspot_company_id)
assert HubspotLead.objects.filter(user=user).exists()

0 comments on commit d4c9173

Please sign in to comment.