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(billing): add the acting user's email to the billing JWT (#98594)

Alex Maysedb90aaa793f
diff --git a/ee/api/test/test_billing.py b/ee/api/test/test_billing.py
index 2ea0d3f98191..925ad769cee3 100644
--- a/ee/api/test/test_billing.py
+++ b/ee/api/test/test_billing.py
@@ -357,6 +357,7 @@ class TestBillingAPI(APILicensedTest):
assert decoded_token == {
"aud": "posthog:license-key",
"distinct_id": str(self.user.distinct_id),
+ "email": self.user.email,
"exp": 1640996100,
"id": self.license.key.split("::")[0],
"organization_id": str(self.organization.id),
diff --git a/ee/billing/billing_manager.py b/ee/billing/billing_manager.py
index 535d15d4aca5..900c6baf3668 100644
--- a/ee/billing/billing_manager.py
+++ b/ee/billing/billing_manager.py
@@ -171,6 +171,9 @@ def build_billing_token(
authorizer_actor = authorizer_actor or user
payload["distinct_id"] = str(user.distinct_id)
+ # Billing's startup program checks read an email domain as evidence of who an applicant
+ # works for, and this is the only address it gets from us.
+ payload["email"] = user.email
authorizer_role = _get_user_organization_role(authorizer_actor, organization)
if authorizer_role:
diff --git a/ee/billing/test/test_billing_manager.py b/ee/billing/test/test_billing_manager.py
index e5c0c829f535..7a2b27a7154c 100644
--- a/ee/billing/test/test_billing_manager.py
+++ b/ee/billing/test/test_billing_manager.py
@@ -1050,6 +1050,7 @@ class TestBuildBillingToken(BaseTest):
assert decoded["organization_name"] == self.organization.name
assert decoded["aud"] == "posthog:license-key"
assert "distinct_id" not in decoded
+ assert "email" not in decoded
assert "organization_role" not in decoded
assert "original_role" not in decoded
# Only service-to-service tokens carry service_action; billing uses its absence
@@ -1063,6 +1064,7 @@ class TestBuildBillingToken(BaseTest):
assert decoded["service_action"] == "signals_pr_dispute"
assert "distinct_id" not in decoded
+ assert "email" not in decoded
assert "organization_role" not in decoded
def test_build_billing_token_with_user_who_is_member(self):
@@ -1074,6 +1076,7 @@ class TestBuildBillingToken(BaseTest):
assert decoded["id"] == "license_id"
assert decoded["organization_id"] == str(self.organization.id)
assert decoded["distinct_id"] == str(self.user.distinct_id)
+ assert decoded["email"] == self.user.email
# organization_role should be a level display string (e.g., "member", "administrator", "owner")
assert decoded["organization_role"] in ["member", "administrator", "owner"]
assert "original_role" not in decoded