Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(growth): stop scoring personal email providers as icp companies (#114772)

Matt Brooker2911276efda2
diff --git a/posthog/helpers/generic_emails.txt b/posthog/helpers/generic_emails.txt
index 7dcd87b9fdc9..23ba1d1ec1a2 100644
--- a/posthog/helpers/generic_emails.txt
+++ b/posthog/helpers/generic_emails.txt
@@ -6,6 +6,7 @@
123mail.cl
123qwe.co.uk
126.com
+139.com
150ml.com
15meg4free.com
163.com
@@ -64,6 +65,7 @@ ace-of-base.com
acmecity.com
acmemail.net
acninc.net
+addy.io
adelphia.net
adexec.com
adfarrow.com
@@ -87,6 +89,7 @@ ajacied.com
ak47.hu
aknet.kg
albawaba.com
+aleeas.com
alex4all.com
alexandria.cc
algeria.com
@@ -125,6 +128,8 @@ animal.net
animalhouse.com
animalwoman.net
anjungcafe.com
+anonaddy.com
+anonaddy.me
anote.com
another.com
anotherwin95.com
@@ -177,6 +182,7 @@ atlanticbb.net
atlaswebmail.com
atlink.com
ato.check.com
+atomicmail.io
atozasia.com
att.net
att.net
@@ -309,6 +315,7 @@ bt.com
btinternet.com
btopenworld.co.uk
buffymail.com
+bugcrowdninja.com
bullsfan.com
bullsgame.com
bumerang.ro
@@ -588,6 +595,7 @@ dslextreme.com
dubaimail.com
dublin.com
dublin.ie
+duck.com
dunlopdriver.com
dunloprider.com
duno.com
@@ -628,6 +636,7 @@ elvis.com
email-london.co.uk
email.com
email.cz
+email.de
email.ee
email.it
email.nu
@@ -666,6 +675,7 @@ eqqu.com
eramail.co.za
eresmas.com
eriga.lv
+erine.email
erols.com
estranet.it
ethos.st
@@ -704,6 +714,7 @@ fastemail.us
fastemailer.com
fastermail.com
fastimap.com
+fastmail.com
fastmail.fm
fastmailbox.net
fastmessaging.com
@@ -931,6 +942,7 @@ gmx.de
gmx.fr
gmx.li
gmx.net
+gmx.us
gnwmail.com
go.com
go.ro
@@ -1002,6 +1014,7 @@ herediano.com
heremail.com
herono1.com
hetnet.nl
+hey.com
hey.to
hhdevel.com
highmilton.com
@@ -1037,18 +1050,24 @@ hotepmail.com
hotfire.net
hotletter.com
hotmail.be
+hotmail.ca
hotmail.co.il
+hotmail.co.jp
+hotmail.co.nz
hotmail.co.uk
hotmail.com
hotmail.com.ar
hotmail.com.br
hotmail.com.mx
+hotmail.com.tr
hotmail.de
hotmail.es
hotmail.fr
hotmail.it
hotmail.kg
hotmail.kz
+hotmail.nl
+hotmail.no
hotmail.ru
hotpop.com
hotpop3.com
@@ -1217,6 +1236,7 @@ katamail.com
kayafmmail.co.za
kbjrmail.com
kcks.com
+keemail.me
keg-party.com
keko.com.ar
kellychen.com
@@ -1283,15 +1303,21 @@ list.ru
littleblueroom.com
live.be
live.ca
+live.cl
+live.cn
live.co.uk
live.com
live.com.ar
live.com.au
live.com.mx
live.de
+live.dk
live.fr
+live.in
live.it
+live.jp
live.nl
+live.se
liverpoolfans.com
llandudno.com
llangollen.com
@@ -1348,6 +1374,7 @@ mail.bulgaria.com
mail.byte.it
mail.co.za
mail.com
+mail.de
mail.ee
mail.entrepeneurmag.com
mail.freetown.com
@@ -2645,6 +2672,7 @@ mailbox.as
mailbox.co.za
mailbox.gr
mailbox.hu
+mailbox.org
mailbr.com.br
mailc.net
mailcan.com
@@ -2654,6 +2682,7 @@ mailcity.com
mailclub.fr
mailclub.net
mailexcite.com
+mailfence.com
mailforce.net
mailftp.com
mailgate.gr
@@ -2761,6 +2790,7 @@ mostlysunny.com
motormania.com
movemail.com
movieluver.com
+mozmail.com
mp4.it
mr-potatohead.com
mrpost.com
@@ -2797,6 +2827,7 @@ mystupidjob.com
mythirdage.com
myway.com
myworldmail.com
+myyahoo.com
n2.com
n2business.com
n2mail.com
@@ -2939,8 +2970,23 @@ ourbrisbane.com
ournet.md
outel.com
outgun.com
+outlook.cl
+outlook.co.id
+outlook.co.nz
outlook.com
+outlook.com.ar
+outlook.com.au
outlook.com.br
+outlook.de
+outlook.es
+outlook.fr
+outlook.in
+outlook.it
+outlook.jp
+outlook.kr
+outlook.lv
+outlook.ph
+outlook.sa
over-the-rainbow.com
ownmail.net
ozbytes.net.au
@@ -2958,6 +3004,10 @@ parsmail.com
partlycloudy.com
partynight.at
parvazi.com
+passfwd.com
+passinbox.com
+passmail.com
+passmail.net
passwordmail.com
pathfindermail.com
patmedia.net
@@ -2997,6 +3047,7 @@ plasa.com
playersodds.com
playful.com
plusmail.com.br
+pm.me
pmail.net
pobox.com
pobox.hu
@@ -3027,6 +3078,8 @@ postaccesslite.com
postafree.com
postaweb.com
poste.it
+posteo.de
+posteo.net
postinbox.com
postino.ch
postmark.net
@@ -3041,6 +3094,7 @@ press.co.jp
priest.com
primposta.com
primposta.hu
+privaterelay.appleid.com
pro.hu
probemail.com
prodigy.net
@@ -3053,6 +3107,8 @@ project2k.com
prolaunch.com
promessage.com
prontomail.com
+proton.me
+protonmail.ch
protonmail.com
psi.net
psv-supporter.com
@@ -3199,6 +3255,8 @@ sialkotian.com
sialkotoye.com
sify.com
silkroad.net
+simplelogin.com
+simplelogin.fr
sina.cn
sina.com
sinamail.com
@@ -3213,6 +3271,8 @@ sky.com
skynet.be
slamdunkfan.com
slingshot.com
+slmail.me
+slmails.com
slo.net
slotter.com
smapxsmap.net
@@ -3281,6 +3341,7 @@ starpower.net
starspath.com
start.com.au
starting-point.com
+startmail.com
startrekmail.com
stealthmail.com
stockracer.com
@@ -3491,6 +3552,11 @@ tsamail.co.za
ttml.co.in
tunisiamail.com
turkey.com
+tuta.com
+tuta.io
+tutamail.com
+tutanota.com
+tutanota.de
tvcablenet.be
twinstarsmail.com
tycoonmail.com
@@ -3601,6 +3667,7 @@ warrior.hu
waumail.com
wbdet.com
wearab.net
+wearehackerone.com
web-mail.com.ar
web-police.com
web.de
@@ -3635,6 +3702,7 @@ whoopymail.com
wickedmail.com
wideopenwest.com
wildmail.com
+windowslive.com
windrivers.net
windstream.net
wingnutz.com
@@ -3721,10 +3789,12 @@ yalla.com.lb
yalook.com
yam.com
yandex.com
+yandex.kz
yandex.ru
yapost.com
yawmail.com
yclub.com
+yeah.net
yebox.com
yehaa.com
yehey.com
@@ -3771,6 +3841,9 @@ zipmail.com.br
zipmax.com
zmail.ru
zoho.com
+zohomail.com
+zohomail.com.au
+zohomail.in
zonnet.nl
zoominternet.net
zubee.com
diff --git a/posthog/utils.py b/posthog/utils.py
index f7f40d6e19c3..48461840f95f 100644
--- a/posthog/utils.py
+++ b/posthog/utils.py
@@ -1826,7 +1826,10 @@ class GenericEmails:
at_location = email.find("@")
if at_location == -1:
return False
- return self.emails.get(email[(at_location + 1) :], False)
+ return self.is_generic_domain(email[(at_location + 1) :])
+
+ def is_generic_domain(self, domain: str) -> bool:
+ return self.emails.get(domain, False)
# maxsize=2 keeps the previous hour's bucket warm so requests interleaved across the
diff --git a/products/growth/backend/enrichment/fit_score.py b/products/growth/backend/enrichment/fit_score.py
index 7f7d2ed7216f..e8aa07bb6ac8 100644
--- a/products/growth/backend/enrichment/fit_score.py
+++ b/products/growth/backend/enrichment/fit_score.py
@@ -141,3 +141,17 @@ def score_company(
payload, lists=lists, role=role, domain=domain, wizard_ai_sdk=wizard_ai_sdk, enrichments=enrichments
)
return score_context(inputs, source=lists.rules.source, lists_version=lists.version, input_versions=input_versions)
+
+
+def no_company_fit(
+ *, lists: CuratedLists, role: Optional[str], domain: Optional[str], wizard_ai_sdk: bool
+) -> IcpFitResult:
+ # The editable formula can give a missing company another status, such as the student
+ # disqualification that runs before its company check, so this result does not run it.
+ inputs = build_scoring_inputs(None, lists=lists, role=role, domain=domain, wizard_ai_sdk=wizard_ai_sdk)
+ return IcpFitResult(
+ status=STATUS_NOT_FOUND,
+ lists_version=lists.version,
+ input_hash=scoring_input_hash(inputs, {}),
+ input_values=inputs,
+ )
diff --git a/products/growth/backend/enrichment/gates.py b/products/growth/backend/enrichment/gates.py
index ea249c7261c2..b503d45f9b1e 100644
--- a/products/growth/backend/enrichment/gates.py
+++ b/products/growth/backend/enrichment/gates.py
@@ -18,6 +18,10 @@ SIGNUP_MEMBERSHIP_WINDOW = dt.timedelta(minutes=5)
_generic_emails = GenericEmails()
+# These domains identify no company. They stay out of GenericEmails because the internal-users
+# cohort also uses that list, and a test team needs its own test domain in that cohort.
+_NON_COMPANY_DOMAINS = frozenset({"example.com", "example.net", "example.org", "test.com"})
+
def enrichment_enabled() -> bool:
return bool(get_instance_setting(KILL_SWITCH_SETTING))
@@ -39,7 +43,17 @@ def domain_from_email(email: str) -> str | None:
return domain or None
-SignupIdentitySkipReason = Literal["signup_user_left", "no_usable_member"]
+def is_work_domain(domain: str) -> bool:
+ domain = domain.strip().lower()
+ return bool(domain) and domain not in _NON_COMPANY_DOMAINS and not _generic_emails.is_generic_domain(domain)
+
+
+def is_work_email(email: str) -> bool:
+ domain = domain_from_email(email)
+ return domain is not None and is_work_domain(domain)
+
+
+SignupIdentitySkipReason = Literal["signup_user_left", "no_usable_member", "not_work_email"]
@frozen
@@ -66,7 +80,9 @@ def resolve_signup_identity(organization_id: str) -> SignupIdentity | SignupIden
return SignupIdentitySkip(reason="signup_user_left")
user = membership.user
domain = domain_from_email(user.email) if user and user.email else None
- # The signup user's email can have changed since signup, so re-check it's a work email.
- if user is None or not user.distinct_id or not domain or _generic_emails.is_generic(user.email):
+ if user is None or not user.distinct_id or not domain:
return SignupIdentitySkip(reason="no_usable_member")
+ # The signup user's email can have changed since signup, so re-check it's a work email.
+ if not is_work_email(user.email):
+ return SignupIdentitySkip(reason="not_work_email")
return SignupIdentity(distinct_id=user.distinct_id, domain=domain)
diff --git a/products/growth/backend/management/commands/backfill_icp_fit_scores.py b/products/growth/backend/management/commands/backfill_icp_fit_scores.py
index a3a5194f41ec..dbf734284d5b 100644
--- a/products/growth/backend/management/commands/backfill_icp_fit_scores.py
+++ b/products/growth/backend/management/commands/backfill_icp_fit_scores.py
@@ -3,11 +3,17 @@
The score-side sibling of backfill_enrichment_fields (which owns the firmographic keys and
never touches any score): this command writes ONLY the icp_fit_* keys — a fit-only
write_organization_enrichment call — so the two backfills stay independently re-runnable,
-and the legacy clay icp_score is never touched here.
+and the legacy clay icp_score is never touched here. The one exception is work_email, which
+the clear below sets to false.
No new Harmonic calls: everything replays from the fetch archive. A sentinel (miss) archive
row scores as not_found, which is recorded rather than skipped so the re-enrichment sweep
can find those orgs.
+An org whose signup domain is a personal or relay email provider is cleared, not scored:
+its archived payload describes the email provider, so its fit becomes not_found. The signup
+domain is the one the stored score used, so a member who changes their email later does not
+move the org between scored and cleared.
+
Role for the student disqualification comes from the record's signup_role key, persisted at
signup since the fit score shipped; historical orgs without it simply score without the
student DQ.
@@ -44,7 +50,7 @@ from products.growth.backend.enrichment import (
from products.growth.backend.enrichment.bridge import read_organization_bridge_inputs
from products.growth.backend.enrichment.context import FIT_EVALUATION_KIND_BACKFILL
from products.growth.backend.enrichment.fit_recomputation import latest_fetch, score_archived_fit
-from products.growth.backend.enrichment.fit_score import IcpFitResult, score_company
+from products.growth.backend.enrichment.fit_score import IcpFitResult, no_company_fit, score_company
from products.growth.backend.enrichment.icp_lists import (
CuratedLists,
load_active_lists,
@@ -57,11 +63,18 @@ from products.growth.backend.enrichment.scoring_context import normalize_fit_pay
from products.growth.backend.enrichment.writer import (
lock_organization_enrichment,
project_organization_enrichment,
+ record_signup_work_email,
write_organization_enrichment,
)
from products.growth.backend.models import IcpScoringConfig, OrganizationEnrichment, OrganizationEnrichmentFetch
-_BackfillOutcome = Literal["written", "skipped_org_gone", "skipped_wizard_unavailable", "skipped_stale_fetch"]
+_BackfillOutcome = Literal[
+ "written",
+ "cleared_not_work_email",
+ "skipped_org_gone",
+ "skipped_wizard_unavailable",
+ "skipped_stale_fetch",
+]
class _Stats:
@@ -125,14 +138,20 @@ def _wizard_ai_sdk_for_backfill(*, organization_id: str, record: Optional[Organi
return True if persisted else None
-def _score_backfill_fetch(
- *, fetch: OrganizationEnrichmentFetch, organization: Organization, lists: CuratedLists, wizard_ai_sdk: bool
-) -> IcpFitResult:
- domain = signup_domain_for_organization(organization)
- record = OrganizationEnrichment.objects.filter(organization_id=fetch.organization_id).first()
- role = record.data.get("signup_role") if record else None
+def _signup_domain(*, organization: Organization, record: Optional[OrganizationEnrichment]) -> str | None:
+ signup = record.data.get("icp_fit_signup") if record else None
+ domain = signup.get("domain") if isinstance(signup, dict) else None
+ return domain if isinstance(domain, str) and domain else signup_domain_for_organization(organization)
+
+
+def _signup_role(organization_id: str) -> str | None:
+ record = OrganizationEnrichment.objects.filter(organization_id=organization_id).first()
+ return record.data.get("signup_role") if record else None
+
- return score_archived_fit(fetch, lists=lists, role=role, domain=domain, wizard_ai_sdk=wizard_ai_sdk)
+def _earliest_member_distinct_id(organization: Organization) -> str | None:
+ membership = organization.memberships.select_related("user").order_by("joined_at").first()
+ return membership.user.distinct_id if membership else None
def _iter_parity_payloads(path: str):
@@ -213,21 +232,32 @@ class Command(BaseCommand):
return "skipped_org_gone"
record = OrganizationEnrichment.objects.filter(organization_id=fetch.organization_id).first()
- wizard_ai_sdk = _wizard_ai_sdk_for_backfill(organization_id=str(fetch.organization_id), record=record)
+ domain = _signup_domain(organization=organization, record=record)
+ clears_fit = domain is not None and not gates.is_work_domain(domain)
+ outcome: _BackfillOutcome = "cleared_not_work_email" if clears_fit else "written"
+ verb, done = ("clear", "cleared") if clears_fit else ("write", "wrote")
+ detail = f" signup_domain={domain}" if clears_fit else ""
+ wizard_ai_sdk = (
+ saved_wizard_ai_sdk(record.data if record else {})
+ if clears_fit
+ else _wizard_ai_sdk_for_backfill(organization_id=str(fetch.organization_id), record=record)
+ )
if wizard_ai_sdk is None:
return "skipped_wizard_unavailable"
with lock_organization_enrichment(str(fetch.organization_id)):
current_fetch = latest_fetch(str(fetch.organization_id))
if current_fetch is None or current_fetch.id != fetch.id:
return "skipped_stale_fetch"
- result = _score_backfill_fetch(
- fetch=fetch, organization=organization, lists=lists, wizard_ai_sdk=wizard_ai_sdk
- )
- stats.add(result)
+ role = _signup_role(str(fetch.organization_id))
+ if clears_fit:
+ result = no_company_fit(lists=lists, role=role, domain=domain, wizard_ai_sdk=wizard_ai_sdk)
+ else:
+ result = score_archived_fit(fetch, lists=lists, role=role, domain=domain, wizard_ai_sdk=wizard_ai_sdk)
+ stats.add(result)
if dry_run:
- self.stdout.write(f"would write {fetch.organization_id}: {result.status} score={result.score}")
- return "written"
+ self.stdout.write(f"would {verb} {fetch.organization_id}: {result.status} score={result.score}{detail}")
+ return outcome
if (
require_active_config
@@ -244,13 +274,19 @@ class Command(BaseCommand):
fit_evaluation_kind=FIT_EVALUATION_KIND_BACKFILL,
project=False,
)
+ if clears_fit:
+ record_signup_work_email(organization_id=str(fetch.organization_id), work_email=False)
project_organization_enrichment(
- organization_id=str(fetch.organization_id), fields=None, pha_client=pha_client, fit=result
+ organization_id=str(fetch.organization_id),
+ fields=None,
+ pha_client=pha_client,
+ fit=result,
+ fit_mirror_distinct_id=_earliest_member_distinct_id(organization) if clears_fit else None,
)
- self.stdout.write(f"wrote {fetch.organization_id}: {result.status} score={result.score}")
+ self.stdout.write(f"{done} {fetch.organization_id}: {result.status} score={result.score}{detail}")
if delay:
time.sleep(delay)
- return "written"
+ return outcome
def _run_backfill(self, options: dict[str, Any]) -> None:
if not gates.region_allowed():
@@ -276,6 +312,7 @@ class Command(BaseCommand):
outcomes: dict[_BackfillOutcome, int] = {
"written": 0,
+ "cleared_not_work_email": 0,
"skipped_org_gone": 0,
"skipped_wizard_unavailable": 0,
"skipped_stale_fetch": 0,
@@ -297,10 +334,11 @@ class Command(BaseCommand):
finally:
pha_client.shutdown()
- verb = "would write" if dry_run else "wrote"
+ verb, clear_verb = ("would write", "would clear") if dry_run else ("wrote", "cleared")
self.stdout.write(
self.style.SUCCESS(
f"considered {considered}, {verb} {outcomes['written']}, "
+ f"{clear_verb} {outcomes['cleared_not_work_email']}, "
f"skipped_org_gone {outcomes['skipped_org_gone']}, "
f"skipped_wizard_unavailable {outcomes['skipped_wizard_unavailable']}, "
f"skipped_stale_fetch {outcomes['skipped_stale_fetch']}"
diff --git a/products/growth/backend/management/commands/backfill_signup_enrichment.py b/products/growth/backend/management/commands/backfill_signup_enrichment.py
index 044512dadc84..a25bd9308378 100644
--- a/products/growth/backend/management/commands/backfill_signup_enrichment.py
+++ b/products/growth/backend/management/commands/backfill_signup_enrichment.py
@@ -18,6 +18,12 @@ from products.growth.backend.enrichment import gates
from products.growth.backend.temporal.signup_enrichment.trigger import dispatch_signup_enrichment
from products.growth.backend.temporal.signup_enrichment.workflow import SignupEnrichmentInputs
+_SKIP_REASONS: dict[gates.SignupIdentitySkipReason, str] = {
+ "signup_user_left": "signup user no longer a member",
+ "no_usable_member": "no usable signup member",
+ "not_work_email": "signup email is not a work email",
+}
+
class Command(BaseCommand):
help = (
@@ -67,12 +73,7 @@ class Command(BaseCommand):
identity = gates.resolve_signup_identity(str(org.id))
if isinstance(identity, gates.SignupIdentitySkip):
skipped += 1
- if identity.reason == "signup_user_left":
- self.stdout.write(
- f"skip {org.id} ({org.created_at:%Y-%m-%d %H:%M}) (signup user no longer a member)"
- )
- else:
- self.stdout.write(f"skip {org.id} ({org.created_at:%Y-%m-%d %H:%M}) (no usable signup member)")
+ self.stdout.write(f"skip {org.id} ({org.created_at:%Y-%m-%d %H:%M}) ({_SKIP_REASONS[identity.reason]})")
continue
inputs = SignupEnrichmentInputs(
diff --git a/products/growth/backend/temporal/signup_enrichment/reenrichment.py b/products/growth/backend/temporal/signup_enrichment/reenrichment.py
index ff7dd630de3e..8e3570b01c08 100644
--- a/products/growth/backend/temporal/signup_enrichment/reenrichment.py
+++ b/products/growth/backend/temporal/signup_enrichment/reenrichment.py
@@ -127,9 +127,13 @@ async def select_reenrichment_candidates_activity(inputs: IcpReenrichmentSweepIn
due_for_retry = Q(data__has_key=ICP_REENRICHMENT_LAST_ATTEMPTED_AT_KEY) & Q(
**{f"data__{ICP_REENRICHMENT_LAST_ATTEMPTED_AT_KEY}__lte": attempt_cutoff}
)
+ # Excluding data__work_email=False instead would also drop every record without the key,
+ # for the same missing-key NULL reason as above.
+ not_work_email = Q(data__contains={"work_email": False})
attempt_eligible = {
str(record.organization_id): record.data.get(ICP_REENRICHMENT_LAST_ATTEMPTED_AT_KEY)
for record in OrganizationEnrichment.objects.filter(data__icp_fit_status__in=list(SWEEPABLE_STATUSES))
+ .exclude(not_work_email)
.filter(never_attempted | due_for_retry)
.only("organization_id", "data")
}
diff --git a/products/growth/backend/temporal/signup_enrichment/tests/test_reenrichment.py b/products/growth/backend/temporal/signup_enrichment/tests/test_reenrichment.py
index 1723ddf875f2..11503d836d10 100644
--- a/products/growth/backend/temporal/signup_enrichment/tests/test_reenrichment.py
+++ b/products/growth/backend/temporal/signup_enrichment/tests/test_reenrichment.py
@@ -55,8 +55,11 @@ class TestReenrichmentSelection(BaseTest):
last_attempted_days_ago: int | None = 31,
first_fetch_days_ago: int = 40,
signup_role: str | None = None,
+ work_email: bool | None = True,
) -> None:
- data: dict = {"icp_fit_status": status, "work_email": True}
+ data: dict = {"icp_fit_status": status}
+ if work_email is not None:
+ data["work_email"] = work_email
if signup_role:
data["signup_role"] = signup_role
if last_attempted_days_ago is not None:
@@ -101,12 +104,18 @@ class TestReenrichmentSelection(BaseTest):
never_attempted_but_freshly_fetched = self._org_with_member("[email protected]")
self._prime(never_attempted_but_freshly_fetched, last_attempted_days_ago=None, first_fetch_days_ago=1)
+ not_work_email = self._org_with_member("[email protected]")
+ self._prime(not_work_email, status="not_found", work_email=False)
+
+ missing_work_email = self._org_with_member("[email protected]")
+ self._prime(missing_work_email, last_attempted_days_ago=32, first_fetch_days_ago=40, work_email=None)
+
due = self._org_with_member("[email protected]")
self._prime(due, last_attempted_days_ago=31, first_fetch_days_ago=40)
candidates = self._select()
- assert [c["organization_id"] for c in candidates] == [str(due.id)]
+ assert [c["organization_id"] for c in candidates] == [str(missing_work_email.id), str(due.id)]
def test_cap_takes_the_least_recently_attempted_org_first(self):
newer = self._org_with_member("[email protected]")
diff --git a/products/growth/backend/temporal/signup_enrichment/tests/test_trigger.py b/products/growth/backend/temporal/signup_enrichment/tests/test_trigger.py
index 2ce491514a73..64a6b65a22b8 100644
--- a/products/growth/backend/temporal/signup_enrichment/tests/test_trigger.py
+++ b/products/growth/backend/temporal/signup_enrichment/tests/test_trigger.py
@@ -126,11 +126,12 @@ def test_kill_switch_off_never_dispatches_in_eu_either():
connect_mock.assert_not_called()
@override_settings(HARMONIC_API_KEY="key")
-def test_personal_email_records_work_email_false_without_provider_dispatch():
+def test_personal_email_records_work_email_false_without_provider_dispatch(email):
on_commit, connect, run, region, record = _dispatch_mocks()
with on_commit, connect as connect_mock, run, region, record as record_mock:
- start_signup_enrichment_workflow(organization_id="org-1", distinct_id="d1", email="[email protected]")
+ start_signup_enrichment_workflow(organization_id="org-1", distinct_id="d1", email=email)
connect_mock.assert_not_called()
record_mock.assert_called_once_with(organization_id="org-1", work_email=False, signup_role=None)
diff --git a/products/growth/backend/temporal/signup_enrichment/tests/test_workflow.py b/products/growth/backend/temporal/signup_enrichment/tests/test_workflow.py
index 44385d03676f..9a79db06e18f 100644
--- a/products/growth/backend/temporal/signup_enrichment/tests/test_workflow.py
+++ b/products/growth/backend/temporal/signup_enrichment/tests/test_workflow.py
@@ -209,19 +209,22 @@ async def test_a_second_signup_dispatch_keeps_its_first_leg_while_a_recheck_is_p
assert enrich.await_count == 2
-async def test_recheck_skips_deleted_organization():
- """The 4h recheck must not enrich or emit for an org deleted during the delay."""
+ "domain,org_exists,skip_key",
+ [("gone.dev", False, "org_deleted"), ("proton.me", True, "not_work_email")],
+)
+async def test_recheck_skips_without_enriching_or_emitting(domain, org_exists, skip_key):
inputs = SignupEnrichmentInputs(
- organization_id="00000000-0000-0000-0000-00000000dead", distinct_id="d1", domain="gone.dev"
+ organization_id="00000000-0000-0000-0000-00000000dead", distinct_id="d1", domain=domain
)
with (
patch(f"{_MODULE}.enrich_organization") as enrich_mock,
patch(f"{_MODULE}.get_regional_ph_client") as client_mock,
patch("posthog.models.Organization.objects") as org_objects,
):
- org_objects.filter.return_value.exists.return_value = False
+ org_objects.filter.return_value.exists.return_value = org_exists
result = await enrich_signup_organization_activity(inputs, is_recheck=True)
- assert result["org_deleted"] is True
+ assert result[skip_key] is True
assert result["matched"] is False
enrich_mock.assert_not_called()
client_mock.assert_not_called()
diff --git a/products/growth/backend/temporal/signup_enrichment/trigger.py b/products/growth/backend/temporal/signup_enrichment/trigger.py
index f06fb3050cca..58b3f3107e59 100644
--- a/products/growth/backend/temporal/signup_enrichment/trigger.py
+++ b/products/growth/backend/temporal/signup_enrichment/trigger.py
@@ -23,7 +23,6 @@ from temporalio.service import RPCError
from posthog.exceptions_capture import capture_exception
from posthog.geoip import get_geoip_properties
from posthog.temporal.common.client import sync_connect
-from posthog.utils import GenericEmails
from products.growth.backend.enrichment import gates
from products.growth.backend.enrichment.writer import record_signup_work_email
@@ -34,8 +33,6 @@ logger = structlog.get_logger(__name__)
RescoreDispatchFailure = Literal["dispatch_backlog_full", "dispatch_failed"]
-_generic_emails = GenericEmails()
-
# Bounded dispatch pool: a slow or unreachable Temporal must never let signup-triggered
# threads accumulate on web pods. When the pool's backlog cap is hit, dispatch drops —
# fire-and-forget degrades to "enrichment did not run", which the launch signal surfaces.
@@ -70,7 +67,7 @@ def start_signup_enrichment_workflow(
if not domain:
return
- work_email = not _generic_emails.is_generic(email)
+ work_email = gates.is_work_email(email)
_record_work_email(
organization_id=str(organization_id), work_email=work_email, signup_role=role_at_organization or None
)
diff --git a/products/growth/backend/temporal/signup_enrichment/workflow.py b/products/growth/backend/temporal/signup_enrichment/workflow.py
index 83989b4a29ad..460246161a22 100644
--- a/products/growth/backend/temporal/signup_enrichment/workflow.py
+++ b/products/growth/backend/temporal/signup_enrichment/workflow.py
@@ -101,6 +101,11 @@ async def enrich_signup_organization_activity(
if not org_exists:
logger.info("signup_enrichment_recheck_skipped_org_deleted")
return {"matched": False, "fields_filled": 0, "org_deleted": True}
+ # The personal email domain list can grow while a recheck waits, so a domain the trigger
+ # accepted can be a personal email provider by now.
+ if not gates.is_work_domain(inputs.domain):
+ logger.info("signup_enrichment_recheck_skipped_not_work_email")
+ return {"matched": False, "fields_filled": 0, "not_work_email": True}
# Region-local on purpose: EU enrichment lands in the EU internal project, US in US — the
# same split the usage report uses. Never fall back to a cross-region client here.
diff --git a/products/growth/backend/tests/test_backfill_icp_fit_scores.py b/products/growth/backend/tests/test_backfill_icp_fit_scores.py
index ead834e36ced..eafc6aae855a 100644
--- a/products/growth/backend/tests/test_backfill_icp_fit_scores.py
+++ b/products/growth/backend/tests/test_backfill_icp_fit_scores.py
@@ -6,6 +6,9 @@ from django.core.management.base import CommandError
from parameterized import parameterized
+from posthog.models.organization import Organization, OrganizationMembership
+from posthog.models.user import User
+
from products.growth.backend.enrichment.bridge import OrganizationBridgeInputs, WizardBridgeInputs
from products.growth.backend.enrichment.fit_score import score_company
from products.growth.backend.enrichment.icp_lists import build_curated_lists, clear_lists_cache
@@ -124,6 +127,65 @@ class TestBackfillIcpFitScores(BaseTest):
assert record.data["icp_fit_evaluation_kind"] == "backfill"
assert record.data["icp_fit_evaluated_at"]
+ def _member_org_record(self, email: str, data: dict) -> tuple[User, OrganizationEnrichment]:
+ organization = Organization.objects.create(name=email)
+ user = User.objects.create_user(email=email, password=None, first_name="signup")
+ OrganizationMembership.objects.create(organization=organization, user=user)
+ OrganizationEnrichmentFetch.objects.create(organization=organization, provider="harmonic", payload=_PAYLOAD)
+ return user, OrganizationEnrichment.objects.create(organization=organization, data=data)
+
+ def _backfill(self, pha_client: MagicMock) -> None:
+ with (
+ patch(f"{_GATES_MODULE}.get_instance_region", return_value="US"),
+ patch(f"{_COMMAND_MODULE}.get_regional_ph_client", return_value=pha_client),
+ patch(f"{_COMMAND_MODULE}.read_organization_bridge_inputs", return_value=OrganizationBridgeInputs()),
+ ):
+ call_command("backfill_icp_fit_scores", "--delay=0")
+
+ @parameterized.expand(
+ [
+ (
+ "stored_signup_domain",
+ {"icp_fit_signup": {"role": "", "domain": "proton.me", "wizard_ai_sdk": True}},
+ ),
+ ("member_email_without_a_stored_domain", "[email protected]", {"icp_fit_flags": {"wizard_ai_sdk": True}}),
+ ]
+ )
+ def test_clears_the_fit_of_an_org_scored_with_a_personal_email_domain(self, _name, email, saved):
+ IcpScoringConfig.objects.filter(is_active=True).update(
+ scoring_rules={"source": "return {'status': 'disqualified', 'score': 0, 'dq_reason': 'any'};"}
+ )
+ clear_lists_cache()
+ user, record = self._member_org_record(
+ email, {"icp_fit_status": "scored", "icp_fit_score": 75, "icp_fit_version": "v0.7", **saved}
+ )
+ pha_client = MagicMock()
+
+ self._backfill(pha_client)
+
+ record.refresh_from_db()
+ assert record.data["icp_fit_status"] == "not_found"
+ assert "icp_fit_score" not in record.data
+ assert record.data["work_email"] is False
+ assert record.data["icp_fit_signup"] == {"role": "", "domain": "proton.me", "wizard_ai_sdk": True}
+ assert pha_client.group_identify.call_args.kwargs["properties"] == {"icp_fit_status": "not_found"}
+ pha_client.set.assert_called_once_with(distinct_id=user.distinct_id, properties={"icp_fit_status": "not_found"})
+
+ def test_keeps_scoring_with_the_stored_domain_after_the_member_switches_to_a_personal_email(self):
+ _, record = self._member_org_record(
+ {"icp_fit_status": "scored", "icp_fit_score": 75, "icp_fit_signup": {"domain": "stripe.com"}},
+ )
+ pha_client = MagicMock()
+
+ self._backfill(pha_client)
+
+ record.refresh_from_db()
+ assert record.data["icp_fit_signup"]["domain"] == "stripe.com"
+ assert "work_email" not in record.data
+ pha_client.set.assert_not_called()
+
def test_policy_change_stops_an_old_backfill_before_it_overwrites_a_new_score(self):
record = self._record({})
next_config = IcpScoringConfig.objects.create(
diff --git a/products/growth/backend/tests/test_enrichment_gates.py b/products/growth/backend/tests/test_enrichment_gates.py
index 3fccbacf9967..42847c23b1cf 100644
--- a/products/growth/backend/tests/test_enrichment_gates.py
+++ b/products/growth/backend/tests/test_enrichment_gates.py
@@ -41,10 +41,19 @@ class TestEnrichmentGates(BaseTest):
assert resolve_signup_identity(str(organization.id)) == SignupIdentitySkip(reason="signup_user_left")
- def test_resolve_signup_identity_with_a_generic_email_is_unusable(self):
- organization = self._org_with_member("[email protected]")
+ @parameterized.expand(
+ [
+ ("generic_provider", "[email protected]"),
+ ("privacy_provider", "[email protected]"),
+ ("reserved_domain", "[email protected]"),
+ ("mixed_case_address_saved_before_normalization", "[email protected]"),
+ ]
+ )
+ def test_resolve_signup_identity_without_a_work_email_is_unusable(self, _name, email):
+ organization = self._org_with_member(email)
+ User.objects.filter(id=organization.memberships.get().user_id).update(email=email)
- assert resolve_signup_identity(str(organization.id)) == SignupIdentitySkip(reason="no_usable_member")
+ assert resolve_signup_identity(str(organization.id)) == SignupIdentitySkip(reason="not_work_email")
def test_resolve_signup_identity_with_a_work_email_returns_a_lowercased_identity(self):
organization = self._org_with_member("[email protected]")