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.

feat(data-warehouse): implement pardot source (#73787)

Tom Owers088456dcd27e
diff --git a/frontend/src/lib/integrations/integrationsLogic.ts b/frontend/src/lib/integrations/integrationsLogic.ts
index a69ea201efab..f83221a6de25 100644
--- a/frontend/src/lib/integrations/integrationsLogic.ts
+++ b/frontend/src/lib/integrations/integrationsLogic.ts
@@ -71,6 +71,7 @@ export interface integrationsLogicValues {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
@@ -145,6 +146,7 @@ export interface integrationsLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
@@ -240,6 +242,7 @@ export interface integrationsLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
@@ -290,6 +293,7 @@ export interface integrationsLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
@@ -357,6 +361,7 @@ export interface integrationsLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
@@ -411,6 +416,7 @@ export interface integrationsLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
@@ -458,6 +464,7 @@ export interface integrationsLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
@@ -516,6 +523,7 @@ export interface integrationsLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
@@ -559,6 +567,7 @@ export interface integrationsLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
@@ -614,6 +623,7 @@ export interface integrationsLogicMeta {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
diff --git a/frontend/src/lib/integrations/utils.ts b/frontend/src/lib/integrations/utils.ts
index d68d3aca53ef..18eb5e9d889f 100644
--- a/frontend/src/lib/integrations/utils.ts
+++ b/frontend/src/lib/integrations/utils.ts
@@ -25,6 +25,7 @@ import IconLinear from 'public/services/linear.png'
import IconLinkedIn from 'public/services/linkedin.png'
import IconMailjet from 'public/services/mailjet.png'
import IconMetaAds from 'public/services/meta-ads.png'
+import IconPardot from 'public/services/pardot.png'
import IconPinterest from 'public/services/pinterest_ads.png'
import IconPostgres from 'public/services/postgres.png'
import IconReddit from 'public/services/reddit.png'
@@ -69,6 +70,7 @@ export const ICONS: Record<IntegrationKind, any> = {
firebase: IconFirebase,
jira: IconJira,
'pinterest-ads': IconPinterest,
+ pardot: IconPardot,
'customerio-app': IconCustomerIO,
'customerio-webhook': IconCustomerIO,
'customerio-track': IconCustomerIO,
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index b6455eb8c19b..2bc2b921af9b 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -27546,6 +27546,7 @@
"firebase",
"jira",
"pinterest-ads",
+ "pardot",
"customerio-app",
"customerio-webhook",
"customerio-track",
diff --git a/frontend/src/scenes/settings/organization/organizationIntegrationsLogic.ts b/frontend/src/scenes/settings/organization/organizationIntegrationsLogic.ts
index 6852486f0233..2f0927bec663 100644
--- a/frontend/src/scenes/settings/organization/organizationIntegrationsLogic.ts
+++ b/frontend/src/scenes/settings/organization/organizationIntegrationsLogic.ts
@@ -40,6 +40,7 @@ export interface organizationIntegrationsLogicValues {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
@@ -108,6 +109,7 @@ export interface organizationIntegrationsLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
@@ -158,6 +160,7 @@ export interface organizationIntegrationsLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
@@ -209,6 +212,7 @@ export interface organizationIntegrationsLogicMeta {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
diff --git a/frontend/src/scenes/settings/user/personalIntegrationsLogic.ts b/frontend/src/scenes/settings/user/personalIntegrationsLogic.ts
index 9059868f2f94..087277725af8 100644
--- a/frontend/src/scenes/settings/user/personalIntegrationsLogic.ts
+++ b/frontend/src/scenes/settings/user/personalIntegrationsLogic.ts
@@ -144,6 +144,7 @@ export interface personalIntegrationsLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
@@ -194,6 +195,7 @@ export interface personalIntegrationsLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index c6728e318620..09b098618117 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -5467,6 +5467,7 @@ export const INTEGRATION_KINDS = [
'firebase',
'jira',
'pinterest-ads',
+ 'pardot',
'customerio-app',
'customerio-webhook',
'customerio-track',
diff --git a/posthog/migrations/1271_add_pardot_integration_kind.py b/posthog/migrations/1271_add_pardot_integration_kind.py
new file mode 100644
index 000000000000..557efa2c2c12
--- /dev/null
+++ b/posthog/migrations/1271_add_pardot_integration_kind.py
@@ -0,0 +1,63 @@
+# Generated by Django 5.2.14 on 2026-07-29 15:04
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ ("posthog", "1270_untrack_provisioning_auth_columns"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="integration",
+ name="kind",
+ field=models.CharField(
+ choices=[
+ ("anthropic", "Anthropic"),
+ ("apns", "Apple Push"),
+ ("aws-s3", "Aws S3"),
+ ("azure-blob", "Azure Blob"),
+ ("bing-ads", "Bing Ads"),
+ ("clickup", "Clickup"),
+ ("customerio-app", "Customerio App"),
+ ("customerio-track", "Customerio Track"),
+ ("customerio-webhook", "Customerio Webhook"),
+ ("databricks", "Databricks"),
+ ("email", "Email"),
+ ("firebase", "Firebase"),
+ ("github", "Github"),
+ ("gitlab", "Gitlab"),
+ ("google-ads", "Google Ads"),
+ ("google-analytics", "Google Analytics"),
+ ("google-cloud-service-account", "Google Cloud Service Account"),
+ ("google-cloud-storage", "Google Cloud Storage"),
+ ("google-pubsub", "Google Pubsub"),
+ ("google-search-console", "Google Search Console"),
+ ("google-sheets", "Google Sheets"),
+ ("hubspot", "Hubspot"),
+ ("intercom", "Intercom"),
+ ("jira", "Jira"),
+ ("linear", "Linear"),
+ ("linkedin-ads", "Linkedin Ads"),
+ ("meta-ads", "Meta Ads"),
+ ("pardot", "Pardot"),
+ ("pinterest-ads", "Pinterest Ads"),
+ ("postgresql", "Postgresql"),
+ ("reddit-ads", "Reddit Ads"),
+ ("resend", "Resend"),
+ ("s3-compatible", "S3 Compatible"),
+ ("salesforce", "Salesforce"),
+ ("slack", "Slack"),
+ ("slack-posthog-code", "Slack Posthog Code"),
+ ("snapchat", "Snapchat"),
+ ("snowflake", "Snowflake"),
+ ("stripe", "Stripe"),
+ ("tiktok-ads", "Tiktok Ads"),
+ ("twilio", "Twilio"),
+ ("vercel", "Vercel"),
+ ],
+ max_length=32,
+ ),
+ ),
+ ]
diff --git a/posthog/migrations/max_migration.txt b/posthog/migrations/max_migration.txt
index 7c9d997701b2..91f82bca936c 100644
--- a/posthog/migrations/max_migration.txt
+++ b/posthog/migrations/max_migration.txt
@@ -1 +1 @@
-1270_untrack_provisioning_auth_columns
+1271_add_pardot_integration_kind
diff --git a/posthog/models/integration.py b/posthog/models/integration.py
index 5bf5520fe060..5e7c4cfe704e 100644
--- a/posthog/models/integration.py
+++ b/posthog/models/integration.py
@@ -414,6 +414,7 @@ class Integration(models.Model):
LINEAR = "linear"
LINKEDIN_ADS = "linkedin-ads"
META_ADS = "meta-ads"
+ PARDOT = "pardot"
PINTEREST_ADS = "pinterest-ads"
POSTGRESQL = "postgresql"
REDDIT_ADS = "reddit-ads"
@@ -600,6 +601,12 @@ def _salesforce_instance_host(instance_url: str | None) -> str | None:
return f"https://{host}"
+# Kinds authorized against Salesforce's OAuth server, so they share its quirks: the token
+# response often omits expires_in, and refresh/revoke must go to the org's own instance host
+# rather than the hardcoded login host (sandbox orgs reject the prod endpoints).
+SALESFORCE_OAUTH_KINDS = ("salesforce", "pardot")
+
+
class OauthIntegration:
supported_kinds = [
"slack",
@@ -619,6 +626,7 @@ class OauthIntegration:
"linear",
"clickup",
"jira",
+ "pardot",
"pinterest-ads",
"stripe",
"resend",
@@ -694,6 +702,26 @@ class OauthIntegration:
name_path="instance_url",
pkce=True,
)
+ elif kind == "pardot":
+ if not settings.SALESFORCE_CONSUMER_KEY or not settings.SALESFORCE_CONSUMER_SECRET:
+ raise NotImplementedError("Salesforce app not configured")
+
+ # Account Engagement (formerly Pardot) authorizes against Salesforce, so this reuses the
+ # Salesforce connected app rather than registering a second one. It needs its own kind
+ # because `pardot_api` is not covered by the `full` scope the `salesforce` kind requests:
+ # a Salesforce integration authorized for the CRM cannot call the Account Engagement API,
+ # and a token scoped for Account Engagement should not appear in the CRM picker.
+ return OauthConfig(
+ authorize_url="https://login.salesforce.com/services/oauth2/authorize",
+ token_url="https://login.salesforce.com/services/oauth2/token",
+ token_revoke_url="https://login.salesforce.com/services/oauth2/revoke",
+ client_id=settings.SALESFORCE_CONSUMER_KEY,
+ client_secret=settings.SALESFORCE_CONSUMER_SECRET,
+ scope="pardot_api refresh_token",
+ id_path="instance_url",
+ name_path="instance_url",
+ pkce=True,
+ )
elif kind == "hubspot":
if not settings.HUBSPOT_APP_CLIENT_ID or not settings.HUBSPOT_APP_CLIENT_SECRET:
raise NotImplementedError("Hubspot app not configured")
@@ -1363,7 +1391,7 @@ class OauthIntegration:
}
# Handle case where Salesforce doesn't provide expires_in in initial response
- if not config.get("expires_in") and kind == "salesforce":
+ if not config.get("expires_in") and kind in SALESFORCE_OAUTH_KINDS:
# Default to 1 hour for Salesforce if not provided (conservative)
config["expires_in"] = 3600
@@ -1431,11 +1459,11 @@ class OauthIntegration:
return
revoke_url = oauth_config.token_revoke_url
- # Salesforce sandbox integrations are stored as kind "salesforce" (the sandbox is only
- # a token-exchange fallback), so the static prod revoke URL would miss them. Revoke at
- # the validated instance host so a stray write to config can't redirect the token to
+ # Salesforce sandbox integrations are stored under the production kind (the sandbox is
+ # only a token-exchange fallback), so the static prod revoke URL would miss them. Revoke
+ # at the validated instance host so a stray write to config can't redirect the token to
# an attacker origin.
- if self.integration.kind == "salesforce":
+ if self.integration.kind in SALESFORCE_OAUTH_KINDS:
allowed_host = _salesforce_instance_host(self.integration.config.get("instance_url"))
if allowed_host:
revoke_url = f"{allowed_host}/services/oauth2/revoke"
@@ -1471,7 +1499,7 @@ class OauthIntegration:
if not refresh_token:
return False
- if not expires_in and self.integration.kind == "salesforce":
+ if not expires_in and self.integration.kind in SALESFORCE_OAUTH_KINDS:
# Salesforce tokens typically last 2-4 hours, we'll assume 1 hour (3600 seconds) to be conservative
expires_in = 3600
@@ -1543,13 +1571,13 @@ class OauthIntegration:
)
else:
token_url = oauth_config.token_url
- # Salesforce sandbox integrations are stored as kind "salesforce" (the sandbox
+ # Salesforce sandbox integrations are stored under the production kind (the sandbox
# is only a token-exchange fallback in the OAuth callback), so the static prod
# token URL would refuse a sandbox-issued refresh_token. Refresh at the org's
# own instance host instead. Validate the host before sending client_secret +
# refresh_token so a stray write to config can't exfiltrate the fleet-wide
# Salesforce app secret; fall back to the hardcoded prod URL on rejection.
- if kind == "salesforce":
+ if kind in SALESFORCE_OAUTH_KINDS:
allowed_host = _salesforce_instance_host(self.integration.config.get("instance_url"))
if allowed_host:
token_url = f"{allowed_host}/services/oauth2/token"
@@ -1643,7 +1671,7 @@ class OauthIntegration:
# Handle case where Salesforce/Stripe doesn't provide expires_in in refresh response
expires_in = config.get("expires_in")
- if not expires_in and self.integration.kind == "salesforce":
+ if not expires_in and self.integration.kind in SALESFORCE_OAUTH_KINDS:
expires_in = 3600
if not expires_in and self.integration.kind == "stripe":
expires_in = 3600
diff --git a/posthog/models/test/test_integration_model.py b/posthog/models/test/test_integration_model.py
index 17d7564f0b97..446f9354847b 100644
--- a/posthog/models/test/test_integration_model.py
+++ b/posthog/models/test/test_integration_model.py
@@ -4208,3 +4208,76 @@ class TestResendIntegrationModel(BaseTest):
assert sent["client_id"] == "resend-client-id"
assert sent["client_secret"] == "resend-client-secret"
assert sent["token_type_hint"] == "refresh_token"
+
+
+@override_settings(
+ SALESFORCE_CONSUMER_KEY="salesforce-client-id", SALESFORCE_CONSUMER_SECRET="salesforce-client-secret"
+)
+class TestPardotIntegrationModel(BaseTest):
+ def test_oauth_config_requests_the_account_engagement_scope(self):
+ config = OauthIntegration.oauth_config_for_kind("pardot")
+
+ assert config.authorize_url == "https://login.salesforce.com/services/oauth2/authorize"
+ assert config.token_url == "https://login.salesforce.com/services/oauth2/token"
+ assert config.token_revoke_url == "https://login.salesforce.com/services/oauth2/revoke"
+ assert config.client_id == "salesforce-client-id"
+ assert config.client_secret == "salesforce-client-secret"
+ assert config.pkce is True
+ assert config.id_path == "instance_url"
+ # Salesforce's `full` scope does not cover the Account Engagement API, so a token
+ # minted for the CRM kind cannot call it. That is why this kind exists at all.
+ assert config.scope == "pardot_api refresh_token"
+ assert config.scope != OauthIntegration.oauth_config_for_kind("salesforce").scope
+
+ def test_pardot_is_an_oauth_kind(self):
+ # Not being listed makes the authorize + callback endpoints reject the kind and drops
+ # it out of the scheduled token refresh sweep.
+ assert "pardot" in OauthIntegration.supported_kinds
+
+ @override_settings(SALESFORCE_CONSUMER_KEY="", SALESFORCE_CONSUMER_SECRET="")
+ def test_oauth_config_unconfigured_raises(self):
+ with pytest.raises(NotImplementedError, match="Salesforce app not configured"):
+ OauthIntegration.oauth_config_for_kind("pardot")
+
+ @patch("posthog.models.integration.reload_integrations_on_workers")
+ @patch("posthog.models.integration.requests.post")
+ def test_refresh_uses_the_org_instance_host_and_assumes_an_hour(self, mock_post, mock_reload):
+ # Account Engagement business units can live on a sandbox org, whose refresh token
+ # login.salesforce.com rejects, and Salesforce often omits expires_in — without the
+ # assumed hour the token is never treated as expired and syncs fail on a stale one.
+ mock_post.return_value.status_code = 200
+ mock_post.return_value.json.return_value = {"access_token": "REFRESHED_ACCESS_TOKEN"}
+
+ instance_url = "https://acme--sandbox.sandbox.my.salesforce.com"
+ integration = Integration.objects.create(
+ team=self.team,
+ kind="pardot",
+ config={"instance_url": instance_url, "refreshed_at": int(time.time())},
+ sensitive_config={"refresh_token": "REFRESH"},
+ )
+
+ OauthIntegration(integration).refresh_access_token()
+
+ assert integration.errors == ""
+ assert mock_post.call_args.args[0] == f"{instance_url}/services/oauth2/token"
+ assert integration.sensitive_config["access_token"] == "REFRESHED_ACCESS_TOKEN"
+ assert integration.config["expires_in"] == 3600
+
+ @patch("posthog.models.integration.requests.post")
+ def test_expiry_is_assumed_when_the_token_response_omits_it(self, mock_post):
+ mock_post.return_value.status_code = 200
+ mock_post.return_value.json.return_value = {
+ "access_token": "at",
+ "refresh_token": "rt",
+ "instance_url": "https://acme.my.salesforce.com",
+ }
+
+ integration = OauthIntegration.integration_from_oauth_response(
+ "pardot",
+ self.team.id,
+ self.user,
+ {"code": "code", "state": "token=state_token"},
+ )
+
+ assert integration.integration_id == "https://acme.my.salesforce.com"
+ assert integration.config["expires_in"] == 3600
diff --git a/posthog/schema_enums.py b/posthog/schema_enums.py
index d9984250203c..2de7695f756d 100644
--- a/posthog/schema_enums.py
+++ b/posthog/schema_enums.py
@@ -2830,6 +2830,7 @@ class IntegrationKind(StrEnum):
FIREBASE = "firebase"
JIRA = "jira"
PINTEREST_ADS = "pinterest-ads"
+ PARDOT = "pardot"
CUSTOMERIO_APP = "customerio-app"
CUSTOMERIO_WEBHOOK = "customerio-webhook"
CUSTOMERIO_TRACK = "customerio-track"
diff --git a/products/alerts/frontend/logic/alertNotificationLogic.ts b/products/alerts/frontend/logic/alertNotificationLogic.ts
index a2e9b54d441c..f3545e5e7ff5 100644
--- a/products/alerts/frontend/logic/alertNotificationLogic.ts
+++ b/products/alerts/frontend/logic/alertNotificationLogic.ts
@@ -97,6 +97,7 @@ export interface alertNotificationLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
@@ -147,6 +148,7 @@ export interface alertNotificationLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index 42966d87b09c..2c7f2e821bcd 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -4469,6 +4469,7 @@ export const IntegrationKindApi = {
Firebase: 'firebase',
Jira: 'jira',
PinterestAds: 'pinterest-ads',
+ Pardot: 'pardot',
CustomerioApp: 'customerio-app',
CustomerioWebhook: 'customerio-webhook',
CustomerioTrack: 'customerio-track',
diff --git a/products/integrations/frontend/generated/api.schemas.ts b/products/integrations/frontend/generated/api.schemas.ts
index f1e23441926f..49626995e716 100644
--- a/products/integrations/frontend/generated/api.schemas.ts
+++ b/products/integrations/frontend/generated/api.schemas.ts
@@ -176,6 +176,7 @@ export interface RoleLookupResponseApi {
* * `linear` - Linear
* * `linkedin-ads` - Linkedin Ads
* * `meta-ads` - Meta Ads
+ * * `pardot` - Pardot
* * `pinterest-ads` - Pinterest Ads
* * `postgresql` - Postgresql
* * `reddit-ads` - Reddit Ads
@@ -221,6 +222,7 @@ export const IntegrationKindEnumApi = {
Linear: 'linear',
LinkedinAds: 'linkedin-ads',
MetaAds: 'meta-ads',
+ Pardot: 'pardot',
PinterestAds: 'pinterest-ads',
Postgresql: 'postgresql',
RedditAds: 'reddit-ads',
@@ -457,6 +459,7 @@ export interface IntegrationAccessRequestApi {
* * `linear` - Linear
* * `linkedin-ads` - Linkedin Ads
* * `meta-ads` - Meta Ads
+ * * `pardot` - Pardot
* * `pinterest-ads` - Pinterest Ads
* * `postgresql` - Postgresql
* * `reddit-ads` - Reddit Ads
@@ -547,6 +550,7 @@ export type IntegrationsListParams = {
* * `linear` - Linear
* * `linkedin-ads` - Linkedin Ads
* * `meta-ads` - Meta Ads
+ * * `pardot` - Pardot
* * `pinterest-ads` - Pinterest Ads
* * `postgresql` - Postgresql
* * `reddit-ads` - Reddit Ads
@@ -603,6 +607,7 @@ export const IntegrationsListKind = {
Linear: 'linear',
LinkedinAds: 'linkedin-ads',
MetaAds: 'meta-ads',
+ Pardot: 'pardot',
PinterestAds: 'pinterest-ads',
Postgresql: 'postgresql',
RedditAds: 'reddit-ads',
diff --git a/products/integrations/frontend/generated/api.zod.ts b/products/integrations/frontend/generated/api.zod.ts
index e428f49d086a..c522f4669416 100644
--- a/products/integrations/frontend/generated/api.zod.ts
+++ b/products/integrations/frontend/generated/api.zod.ts
@@ -89,6 +89,7 @@ export const IntegrationsCreateBody = /* @__PURE__ */ zod
'linear',
'linkedin-ads',
'meta-ads',
+ 'pardot',
'pinterest-ads',
'postgresql',
'reddit-ads',
@@ -105,7 +106,7 @@ export const IntegrationsCreateBody = /* @__PURE__ */ zod
'vercel',
])
.describe(
- '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
+ '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
),
config: zod.unknown().optional(),
})
@@ -142,6 +143,7 @@ export const IntegrationsEmailPartialUpdateBody = /* @__PURE__ */ zod
'linear',
'linkedin-ads',
'meta-ads',
+ 'pardot',
'pinterest-ads',
'postgresql',
'reddit-ads',
@@ -159,7 +161,7 @@ export const IntegrationsEmailPartialUpdateBody = /* @__PURE__ */ zod
])
.optional()
.describe(
- '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
+ '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
),
config: zod.unknown().optional(),
})
@@ -196,6 +198,7 @@ export const IntegrationsEmailVerifyCreateBody = /* @__PURE__ */ zod
'linear',
'linkedin-ads',
'meta-ads',
+ 'pardot',
'pinterest-ads',
'postgresql',
'reddit-ads',
@@ -212,7 +215,7 @@ export const IntegrationsEmailVerifyCreateBody = /* @__PURE__ */ zod
'vercel',
])
.describe(
- '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
+ '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
),
config: zod.unknown().optional(),
})
@@ -256,6 +259,7 @@ export const IntegrationsDomainConnectApplyUrlCreateBody = /* @__PURE__ */ zod
'linear',
'linkedin-ads',
'meta-ads',
+ 'pardot',
'pinterest-ads',
'postgresql',
'reddit-ads',
@@ -272,7 +276,7 @@ export const IntegrationsDomainConnectApplyUrlCreateBody = /* @__PURE__ */ zod
'vercel',
])
.describe(
- '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
+ '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
),
config: zod.unknown().optional(),
})
@@ -363,6 +367,7 @@ export const IntegrationsRequestAccessCreateBody = /* @__PURE__ */ zod.object({
'linear',
'linkedin-ads',
'meta-ads',
+ 'pardot',
'pinterest-ads',
'postgresql',
'reddit-ads',
@@ -379,10 +384,10 @@ export const IntegrationsRequestAccessCreateBody = /* @__PURE__ */ zod.object({
'vercel',
])
.describe(
- '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
+ '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
)
.describe(
- "The kind of integration the member is requesting be connected (e.g. 'slack', 'github').\n\n\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel"
+ "The kind of integration the member is requesting be connected (e.g. 'slack', 'github').\n\n\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel"
),
reason: zod
.string()
diff --git a/products/logs/frontend/components/LogsAlerting/logsAlertNotificationLogic.ts b/products/logs/frontend/components/LogsAlerting/logsAlertNotificationLogic.ts
index 68a9ea4e781c..e29adcb81216 100644
--- a/products/logs/frontend/components/LogsAlerting/logsAlertNotificationLogic.ts
+++ b/products/logs/frontend/components/LogsAlerting/logsAlertNotificationLogic.ts
@@ -97,6 +97,7 @@ export interface logsAlertNotificationLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
@@ -147,6 +148,7 @@ export interface logsAlertNotificationLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.ts b/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.ts
index 72e1a8bebb38..b4a902c80131 100644
--- a/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.ts
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.ts
@@ -140,6 +140,7 @@ export interface taskTrackerSceneLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
@@ -190,6 +191,7 @@ export interface taskTrackerSceneLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.ts
index 6f490b4d0c22..763c3fe06f3f 100644
--- a/products/product_analytics/frontend/generated/api.schemas.ts
+++ b/products/product_analytics/frontend/generated/api.schemas.ts
@@ -3801,6 +3801,7 @@ export const IntegrationKindApi = {
Firebase: 'firebase',
Jira: 'jira',
PinterestAds: 'pinterest-ads',
+ Pardot: 'pardot',
CustomerioApp: 'customerio-app',
CustomerioWebhook: 'customerio-webhook',
CustomerioTrack: 'customerio-track',
diff --git a/products/visual_review/frontend/scenes/visualReviewSettingsSceneLogic.ts b/products/visual_review/frontend/scenes/visualReviewSettingsSceneLogic.ts
index c6191a884602..72995c144668 100644
--- a/products/visual_review/frontend/scenes/visualReviewSettingsSceneLogic.ts
+++ b/products/visual_review/frontend/scenes/visualReviewSettingsSceneLogic.ts
@@ -86,6 +86,7 @@ export interface visualReviewSettingsSceneLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
@@ -136,6 +137,7 @@ export interface visualReviewSettingsSceneLogicActions {
| 'linear'
| 'linkedin-ads'
| 'meta-ads'
+ | 'pardot'
| 'pinterest-ads'
| 'postgresql'
| 'reddit-ads'
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md
index 3688636bc014..37121260694f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md
@@ -447,6 +447,7 @@ the row lists both.
| pandadoc | HTTP | requests | ✅ |
| paperform | HTTP | requests | ✅ |
| papersign | HTTP | requests | ✅ |
+| pardot | HTTP | requests | ✅ |
| partnerize | HTTP | requests | ✅ |
| partnerstack | HTTP | requests | ✅ |
| payfit | HTTP | requests | ✅ |
@@ -1164,7 +1165,6 @@ doesn't conflict with concurrent PRs.
- ownerrez
- pagbank
- pagerduty
-- pardot
- patreon
- pax8
- paychex
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/pardot.py b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/pardot.py
index da4581612347..4115882b8df0 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/pardot.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/pardot.py
@@ -1,9 +1,13 @@
# This file is automatically generated from `SourceRegistry.get_all_sources()`
# Do not edit manually - run `pnpm generate:source-configs` to regenerate.
+from typing import Literal
+
from products.warehouse_sources.backend.temporal.data_imports.sources.common import config
@config.config
class PardotSourceConfig(config.Config):
- pass
+ business_unit_id: str
+ pardot_integration_id: int = config.value(converter=config.str_to_int)
+ environment: Literal["production", "sandbox"] = config.value(default="production")
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/pardot/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/pardot/canonical_descriptions.py
new file mode 100644
index 000000000000..88ffa0775251
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/pardot/canonical_descriptions.py
@@ -0,0 +1,247 @@
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
+ CanonicalDescriptions,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.pardot.settings import PARDOT_ENDPOINTS
+
+_DOCS_BASE = "https://developer.salesforce.com/docs/marketing/pardot/guide"
+
+_SHARED_COLUMNS = {
+ "id": "Account Engagement ID of the record.",
+ "createdAt": "Timestamp of when the record was created.",
+ "updatedAt": "Timestamp of the last update to the record.",
+ "createdById": "ID of the user who created the record.",
+ "updatedById": "ID of the user who last updated the record.",
+ "isDeleted": "Whether the record is in the recycle bin.",
+ "salesforceId": "ID of the matching record in Salesforce.",
+ "campaignId": "ID of the campaign associated with the record.",
+ "folderId": "ID of the folder that contains the record.",
+ "name": "Name of the record.",
+}
+
+
+def _shared(endpoint: str) -> dict[str, str]:
+ """The shared column blurbs that the endpoint actually returns."""
+ fields = set(PARDOT_ENDPOINTS[endpoint].fields)
+ return {name: description for name, description in _SHARED_COLUMNS.items() if name in fields}
+
+
+CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
+ "prospects": {
+ "description": "A person tracked in Account Engagement, with their profile, scoring and activity timestamps.",
+ "docs_url": f"{_DOCS_BASE}/prospect-v5.html",
+ "columns": {
+ **_shared("prospects"),
+ "email": "Primary email address of the prospect.",
+ "firstName": "First name of the prospect.",
+ "lastName": "Last name of the prospect.",
+ "company": "Company the prospect belongs to.",
+ "jobTitle": "Job title of the prospect.",
+ "score": "Behavioral score, driven by the prospect's activity.",
+ "grade": "Profile grade of the prospect.",
+ "source": "Source the prospect came from.",
+ "optedOut": "Whether the prospect has opted out of marketing emails.",
+ "isDoNotEmail": "Whether the prospect is flagged as do not email.",
+ "isDoNotCall": "Whether the prospect is flagged as do not call.",
+ "doNotSell": "Whether the prospect asked not to have their data sold.",
+ "isEmailHardBounced": "Whether the prospect's email address hard bounced.",
+ "emailBouncedAt": "Timestamp of the most recent email bounce.",
+ "emailBouncedReason": "Reason given for the most recent email bounce.",
+ "firstActivityAt": "Timestamp of the prospect's first tracked activity.",
+ "firstAssignedAt": "Timestamp of when the prospect was first assigned to a user.",
+ "lastActivityAt": "Timestamp of the prospect's most recent tracked activity.",
+ "convertedAt": "Timestamp of when the prospect was converted in Salesforce.",
+ "prospectAccountId": "ID of the prospect account the prospect belongs to.",
+ "lifecycleStageId": "ID of the prospect's current lifecycle stage.",
+ "assignedToId": "ID of the user the prospect is assigned to.",
+ "userId": "ID of the user who owns the prospect.",
+ "profileId": "ID of the profile used to grade the prospect.",
+ "campaignParameter": "utm_campaign value from the prospect's first touch.",
+ "mediumParameter": "utm_medium value from the prospect's first touch.",
+ "sourceParameter": "utm_source value from the prospect's first touch.",
+ "termParameter": "utm_term value from the prospect's first touch.",
+ "contentParameter": "utm_content value from the prospect's first touch.",
+ "salesforceLeadId": "ID of the matching Salesforce lead.",
+ "salesforceContactId": "ID of the matching Salesforce contact.",
+ "salesforceAccountId": "ID of the matching Salesforce account.",
+ "salesforceLastSync": "Timestamp of the last sync with Salesforce.",
+ },
+ },
+ "prospect_accounts": {
+ "description": "A company record that prospects are grouped under, mirroring a Salesforce account.",
+ "docs_url": f"{_DOCS_BASE}/prospect-account-v5.html",
+ "columns": {
+ **_shared("prospect_accounts"),
+ "annualRevenue": "Annual revenue of the account.",
+ "employees": "Number of employees at the account.",
+ "industry": "Industry of the account.",
+ "website": "Website of the account.",
+ "assignedToId": "ID of the user the account is assigned to.",
+ "billingCity": "City of the account's billing address.",
+ "billingCountry": "Country of the account's billing address.",
+ "type": "Type of the account, as set in Salesforce.",
+ },
+ },
+ "lists": {
+ "description": "A static or dynamic list of prospects used for sending and segmentation.",
+ "docs_url": f"{_DOCS_BASE}/list-v5.html",
+ "columns": {
+ **_shared("lists"),
+ "description": "Internal description of the list.",
+ "title": "Title shown to prospects on the email preference page.",
+ "isPublic": "Whether prospects can subscribe to the list themselves.",
+ "isDynamic": "Whether membership is maintained by a dynamic list rule.",
+ },
+ },
+ "list_memberships": {
+ "description": "The membership of one prospect on one list, including their opt-out state.",
+ "docs_url": f"{_DOCS_BASE}/list-membership-v5.html",
+ "columns": {
+ **_shared("list_memberships"),
+ "listId": "ID of the list.",
+ "prospectId": "ID of the prospect on the list.",
+ "optedOut": "Whether the prospect opted out of this list.",
+ },
+ },
+ "campaigns": {
+ "description": "A marketing campaign that prospects and assets are attributed to.",
+ "docs_url": f"{_DOCS_BASE}/campaign-v5.html",
+ "columns": {
+ **_shared("campaigns"),
+ "cost": "Cost recorded for the campaign.",
+ "parentCampaignId": "ID of the parent campaign in the campaign hierarchy.",
+ },
+ },
+ "opportunities": {
+ "description": "A sales opportunity synced from Salesforce and linked to Account Engagement campaigns.",
+ "docs_url": f"{_DOCS_BASE}/opportunity-v5.html",
+ "columns": {
+ **_shared("opportunities"),
+ "stage": "Sales stage of the opportunity.",
+ "status": "Status of the opportunity (won, lost or open).",
+ "probability": "Percentage likelihood the opportunity closes.",
+ "value": "Monetary value of the opportunity.",
+ "type": "Type of the opportunity.",
+ "closedAt": "Timestamp of when the opportunity closed.",
+ },
+ },
+ "users": {
+ "description": "A user of the Account Engagement business unit.",
+ "docs_url": f"{_DOCS_BASE}/user-v5.html",
+ "columns": {
+ **_shared("users"),
+ "email": "Email address of the user.",
+ "firstName": "First name of the user.",
+ "lastName": "Last name of the user.",
+ "username": "Login username of the user.",
+ "jobTitle": "Job title of the user.",
+ "role": "Role assigned to the user.",
+ "roleName": "Display name of the user's role.",
+ "tagReplacementLanguage": "Language used for tag replacement in the user's emails.",
+ },
+ },
+ "visits": {
+ "description": "A browsing session on your tracked site, grouped from a visitor's page views.",
+ "docs_url": f"{_DOCS_BASE}/visit-v5.html",
+ "columns": {
+ **_shared("visits"),
+ "visitorId": "ID of the visitor the session belongs to.",
+ "prospectId": "ID of the prospect the visitor was identified as, if any.",
+ "visitorPageViewCount": "Number of page views in the session.",
+ "firstVisitorPageViewAt": "Timestamp of the first page view in the session.",
+ "lastVisitorPageViewAt": "Timestamp of the last page view in the session.",
+ "durationInSeconds": "Length of the session in seconds.",
+ "campaignParameter": "utm_campaign value recorded for the session.",
+ "mediumParameter": "utm_medium value recorded for the session.",
+ "sourceParameter": "utm_source value recorded for the session.",
+ "termParameter": "utm_term value recorded for the session.",
+ "contentParameter": "utm_content value recorded for the session.",
+ },
+ },
+ "visitors": {
+ "description": "An anonymous or identified browser tracked by the Account Engagement tracking code.",
+ "docs_url": f"{_DOCS_BASE}/visitor-v5.html",
+ "columns": {
+ **_shared("visitors"),
+ "prospectId": "ID of the prospect the visitor was identified as, if any.",
+ "hostname": "Hostname resolved from the visitor's IP address.",
+ "ipAddress": "IP address the visitor browsed from.",
+ "pageViewCount": "Total page views recorded for the visitor.",
+ "isIdentified": "Whether the visitor has been matched to a prospect.",
+ "doNotSell": "Whether the visitor asked not to have their data sold.",
+ },
+ },
+ "visitor_activities": {
+ "description": "A single tracked action by a prospect or visitor, such as a form submit, email click or page view.",
+ "docs_url": f"{_DOCS_BASE}/visitor-activity-v5.html",
+ "columns": {
+ **_shared("visitor_activities"),
+ "type": "Numeric code of the activity type.",
+ "typeName": "Human-readable name of the activity type.",
+ "details": "Details of the activity, such as the name of the asset involved.",
+ "prospectId": "ID of the prospect who performed the activity.",
+ "visitorId": "ID of the visitor who performed the activity.",
+ "visitId": "ID of the visit the activity belongs to.",
+ "visitorPageViewId": "ID of the page view the activity belongs to.",
+ "customRedirectId": "ID of the custom redirect involved in the activity.",
+ "emailId": "ID of the email involved in the activity.",
+ "emailTemplateId": "ID of the email template involved in the activity.",
+ "fileId": "ID of the file involved in the activity.",
+ "formId": "ID of the form involved in the activity.",
+ "formHandlerId": "ID of the form handler involved in the activity.",
+ "landingPageId": "ID of the landing page involved in the activity.",
+ "listEmailId": "ID of the list email involved in the activity.",
+ "opportunityId": "ID of the opportunity involved in the activity.",
+ "paidSearchAdId": "ID of the paid search ad involved in the activity.",
+ "siteSearchQueryId": "ID of the site search query involved in the activity.",
+ },
+ },
+ "custom_fields": {
+ "description": "A custom prospect field defined in the business unit.",
+ "docs_url": f"{_DOCS_BASE}/custom-field-v5.html",
+ "columns": {
+ **_shared("custom_fields"),
+ "fieldId": "API name used to reference the field in forms and imports.",
+ "type": "Data type of the field.",
+ "isRequired": "Whether the field is required on forms.",
+ "isRecordMultipleResponses": "Whether every response is kept rather than overwriting the last one.",
+ "isUseValues": "Whether the field is limited to a predefined set of values.",
+ "valuesPrefill": "Whether the field's values prefill for known prospects.",
+ "isAnalyticsSynced": "Whether the field syncs with connected analytics.",
+ },
+ },
+ "forms": {
+ "description": "An Account Engagement form used to capture prospect submissions.",
+ "docs_url": f"{_DOCS_BASE}/form-v5.html",
+ "columns": {
+ **_shared("forms"),
+ "layoutTemplateId": "ID of the layout template applied to the form.",
+ "trackerDomainId": "ID of the tracker domain the form is served from.",
+ "submitButtonText": "Label of the form's submit button.",
+ "redirectLocation": "URL prospects are sent to after submitting.",
+ "isUseRedirectLocation": "Whether the form redirects instead of showing thank-you content.",
+ "isAlwaysDisplay": "Whether the form always shows, even to known prospects.",
+ "isCaptchaEnabled": "Whether CAPTCHA is enabled on the form.",
+ "isCookieless": "Whether the form runs in cookieless tracking mode.",
+ "url": "Public URL of the form.",
+ "embedCode": "HTML snippet used to embed the form.",
+ "salesforceCmsId": "ID of the matching form in Salesforce CMS.",
+ },
+ },
+ "list_emails": {
+ "description": "A one-off email sent to lists of prospects.",
+ "docs_url": f"{_DOCS_BASE}/list-email-v5.html",
+ "columns": {
+ **_shared("list_emails"),
+ "subject": "Subject line of the email.",
+ "emailTemplateId": "ID of the template the email was built from.",
+ "trackerDomainId": "ID of the tracker domain used for links in the email.",
+ "clientType": "Client the email was created in.",
+ "type": "Type of the email.",
+ "isOperational": "Whether the email is operational and ignores opt-outs.",
+ "isPaused": "Whether sending is paused.",
+ "isSent": "Whether the email has been sent.",
+ "scheduledTime": "Timestamp the email is scheduled to send at.",
+ "sentAt": "Timestamp the email was sent at.",
+ },
+ },
+}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/pardot/pardot.py b/products/warehouse_sources/backend/temporal/data_imports/sources/pardot/pardot.py
new file mode 100644
index 000000000000..5726f3d0ef75
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/pardot/pardot.py
@@ -0,0 +1,313 @@
+import dataclasses
+from collections.abc import Iterator
+from datetime import UTC, date, datetime
+from typing import Any, Optional
+
+import requests
+from structlog.types import FilteringBoundLogger
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse
+from products.warehouse_sources.backend.temporal.data_imports.sources.pardot.settings import (
+ PARDOT_ENDPOINTS,
+ PardotEndpointConfig,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.salesforce.auth import (
+ salesforce_refresh_access_token,
+)
+
+# Account Engagement runs on its own host per environment. Demos, developer orgs and
+# sandboxes are served from the demo host, everything else from the production host. This
+# is a separate axis from the Salesforce login host — a developer org signs in at
+# login.salesforce.com but its business units still live on pi.demo.pardot.com.
+PARDOT_HOSTS = {
+ "production": "https://pi.pardot.com",
+ "sandbox": "https://pi.demo.pardot.com",
+}
+# v5 caps a query page at 200 records.
+PAGE_SIZE = 200
+REQUEST_TIMEOUT_SECONDS = 60
+
+
+class PardotResumeConfig:
+ # v5 pages via an opaque `nextPageToken` that encapsulates the filters, limit and
+ # orderBy of the original query, so the token alone is enough to resume.
+ next_page_token: str
+
+
+class PardotPageTokenExpiredError(Exception):
+ """A saved `nextPageToken` was rejected — page tokens expire after 4 hours."""
+
+
+def _api_host(environment: str) -> str:
+ api_host = PARDOT_HOSTS.get(environment)
+ if api_host is None:
+ raise ValueError(f"Invalid Account Engagement environment: {environment}")
+ return api_host
+
+
+def _get_session(business_unit_id: str, access_token: str, refresh_token: str | None) -> requests.Session:
+ # capture=False: prospect/visitor records carry PII (emails, addresses, phones, free-text
+ # notes, visitor IPs) the name-based sample scrubber can't reliably redact, and the token
+ # exchange returns a secret, so every request path must opt out of HTTP sample capture while
+ # staying metered and logged.
+ return make_tracked_session(
+ headers={"Pardot-Business-Unit-Id": business_unit_id, "Accept": "application/json"},
+ redact_values=tuple(value for value in (access_token, refresh_token) if value),
+ capture=False,
+ )
+
+
+def _refresh_token(refresh_token: str | None, instance_url: str | None) -> str:
+ """Mint a fresh access token part-way through a sync that outlived the current one.
+
+ Account Engagement and the Salesforce CRM share one connected app and one token endpoint,
+ so this rides the Salesforce source's helper — including its retry for Salesforce
+ serializing concurrent refreshes of the same app.
+ """
+ if not refresh_token or not instance_url:
+ raise ValueError("Reconnect the Account Engagement integration: it has no refresh token")
+ # capture=False for the same reason as the source session: the refresh request carries the
+ # refresh token and shared client secret, and its response a minted access token.
+ return salesforce_refresh_access_token(refresh_token, instance_url, capture=False)
+
+
+def _format_datetime(value: Any) -> str:
+ """Format an incremental cursor as the ISO 8601 UTC timestamp v5 filters expect."""
+ if isinstance(value, datetime):
+ dt = value
+ elif isinstance(value, date):
+ dt = datetime.combine(value, datetime.min.time())
+ else:
+ return str(value)
+
+ utc_dt = dt.replace(tzinfo=UTC) if dt.tzinfo is None else dt.astimezone(UTC)
+ return utc_dt.strftime("%Y-%m-%dT%H:%M:%SZ")
+
+
+def _cursor_field(config: PardotEndpointConfig, incremental_field: str | None) -> str | None:
+ """The user's chosen cursor, if this endpoint actually advertises it."""
+ advertised = {f["field"] for f in config.incremental_fields}
+ if incremental_field and incremental_field in advertised:
+ return incremental_field
+ return None
+
+
+def _build_query_params(
+ config: PardotEndpointConfig,
+ should_use_incremental_field: bool,
+ db_incremental_field_last_value: Any,
+ incremental_field: str | None,
+) -> dict[str, Any]:
+ params: dict[str, Any] = {"limit": PAGE_SIZE, "fields": ",".join(config.fields)}
+
+ cursor = _cursor_field(config, incremental_field) if should_use_incremental_field else None
+ if cursor is not None:
+ # Sort on the cursor field for every incremental run, including the first one
+ # that has no watermark yet, so rows always arrive in the ascending order the
+ # pipeline checkpoints against.
+ params["orderBy"] = cursor
+ if db_incremental_field_last_value is not None:
+ # The inclusive variant re-reads the boundary record, which merge dedupes,
+ # rather than risking a same-second row being skipped.
+ params[f"{cursor}AfterOrEqualTo"] = _format_datetime(db_incremental_field_last_value)
+ elif config.order_by is not None:
+ params["orderBy"] = config.order_by
+
+ return params
+
+
+def _is_expired_page_token(response: requests.Response) -> bool:
+ """Whether a 400 is the API rejecting our page token rather than the query itself.
+
+ v5 page tokens expire after 4 hours; the rejection is a 400 whose body names the
+ token. Matching on the message is the only signal documented, so keep it broad.
+ """
+ if response.status_code != 400:
+ return False
+ return "pagetoken" in response.text.lower().replace(" ", "").replace("_", "")
+
+
+def validate_credentials(
+ environment: str,
+ business_unit_id: str,
+ access_token: str,
+ refresh_token: str | None = None,
+ instance_url: str | None = None,
+) -> tuple[bool, str | None]:
+ """Read one campaign — the cheapest proof the token, business unit and host all line up."""
+ try:
+ api_host = _api_host(environment)
+ except ValueError as e:
+ return False, str(e)
+
+ session = _get_session(business_unit_id, access_token, refresh_token)
+
+ try:
+ response = session.get(
+ f"{api_host}/api/v5/objects/campaigns",
+ headers={"Authorization": f"Bearer {access_token}"},
+ params={"limit": "1", "fields": "id"},
+ timeout=REQUEST_TIMEOUT_SECONDS,
+ )
+ except Exception:
+ return False, "Could not reach the Account Engagement API"
+
+ if response.status_code == 200:
+ return True, None
+ if response.status_code == 401:
+ # The stored token can be older than its lifetime, so a 401 is expected rather than a
+ # rejection. Mint a fresh one and try again before telling the user to reconnect.
+ try:
+ access_token = _refresh_token(refresh_token, instance_url)
+ response = session.get(
+ f"{api_host}/api/v5/objects/campaigns",
+ headers={"Authorization": f"Bearer {access_token}"},
+ params={"limit": "1", "fields": "id"},
+ timeout=REQUEST_TIMEOUT_SECONDS,
+ )
+ except Exception:
+ return False, "Salesforce rejected the connection. Reconnect your Account Engagement account."
+ if response.status_code == 200:
+ return True, None
+ if response.status_code in (401, 403):
+ return (
+ False,
+ "Account Engagement rejected the connection. Check the business unit ID, and that the connected "
+ "user has API access to it.",
+ )
+ return False, f"Account Engagement returned an unexpected status ({response.status_code})"
+
+
+def get_rows(
+ environment: str,
+ business_unit_id: str,
+ access_token: str,
+ refresh_token: str | None,
+ instance_url: str | None,
+ endpoint: str,
+ api_version: str,
+ resumable_source_manager: ResumableSourceManager[PardotResumeConfig],
+ logger: FilteringBoundLogger,
+ should_use_incremental_field: bool = False,
+ db_incremental_field_last_value: Optional[Any] = None,
+ incremental_field: str | None = None,
+) -> Iterator[list[dict[str, Any]]]:
+ config = PARDOT_ENDPOINTS[endpoint]
+ api_host = _api_host(environment)
+ url = f"{api_host}/api/{api_version}/objects/{config.path}"
+
+ session = _get_session(business_unit_id, access_token, refresh_token)
+ token = access_token
+
+ query_params = _build_query_params(
+ config, should_use_incremental_field, db_incremental_field_last_value, incremental_field
+ )
+ # Only `fields` may ride along with a page token — sending limit/orderBy/filters
+ # alongside one is a 400.
+ page_params = {"fields": query_params["fields"]}
+
+ def request(params: dict[str, Any]) -> dict[str, Any]:
+ nonlocal token
+
+ def _do() -> requests.Response:
+ return session.get(
+ url,
+ headers={"Authorization": f"Bearer {token}"},
+ params=params,
+ timeout=REQUEST_TIMEOUT_SECONDS,
+ )
+
+ response = _do()
+ # Salesforce access tokens are short lived; re-mint once if the sync outlives one.
+ if response.status_code == 401:
+ token = _refresh_token(refresh_token, instance_url)
+ response = _do()
+
+ if _is_expired_page_token(response):
+ raise PardotPageTokenExpiredError(response.text)
+
+ if not response.ok:
+ logger.error(f"Account Engagement API error: status={response.status_code}, body={response.text}")
+ response.raise_for_status()
+
+ return response.json()
+
+ next_page_token: str | None = None
+ resumed = False
+ if resumable_source_manager.can_resume():
+ resume = resumable_source_manager.load_state()
+ if resume is not None and resume.next_page_token:
+ next_page_token = resume.next_page_token
+ resumed = True
+
+ while True:
+ params = {**page_params, "nextPageToken": next_page_token} if next_page_token else query_params
+ try:
+ data = request(params)
+ except PardotPageTokenExpiredError:
+ if not resumed:
+ raise
+ # The resumed token aged out of its 4h window: drop it and restart the
+ # endpoint from the first page rather than failing the job.
+ logger.warning("Account Engagement page token expired, restarting the sync from the first page")
+ resumable_source_manager.clear_state()
+ next_page_token = None
+ resumed = False
+ continue
+
+ values = data.get("values") or []
+ if values:
+ yield values
+
+ next_page_token = data.get("nextPageToken")
+ if not next_page_token:
+ break
+
+ # Save after yielding so a crash re-yields the last page (merge dedupes)
+ # instead of skipping it.
+ resumable_source_manager.save_state(PardotResumeConfig(next_page_token=next_page_token))
+
+ resumable_source_manager.clear_state()
+
+
+def pardot_source(
+ environment: str,
+ business_unit_id: str,
+ access_token: str,
+ refresh_token: str | None,
+ instance_url: str | None,
+ endpoint: str,
+ api_version: str,
+ resumable_source_manager: ResumableSourceManager[PardotResumeConfig],
+ logger: FilteringBoundLogger,
+ should_use_incremental_field: bool = False,
+ db_incremental_field_last_value: Optional[Any] = None,
+ incremental_field: str | None = None,
+) -> SourceResponse:
+ config = PARDOT_ENDPOINTS[endpoint]
+
+ return SourceResponse(
+ name=endpoint,
+ items=lambda: get_rows(
+ environment=environment,
+ business_unit_id=business_unit_id,
+ access_token=access_token,
+ refresh_token=refresh_token,
+ instance_url=instance_url,
+ endpoint=endpoint,
+ api_version=api_version,
+ resumable_source_manager=resumable_source_manager,
+ logger=logger,
+ should_use_incremental_field=should_use_incremental_field,
+ db_incremental_field_last_value=db_incremental_field_last_value,
+ incremental_field=incremental_field,
+ ),
+ primary_keys=[config.primary_key],
+ partition_mode="datetime" if config.partition_key else None,
+ partition_format="month" if config.partition_key else None,
+ partition_keys=[config.partition_key] if config.partition_key else None,
+ sort_mode="asc",
+ )
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/pardot/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/pardot/settings.py
new file mode 100644
index 000000000000..ce4efa50b1b8
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/pardot/settings.py
@@ -0,0 +1,398 @@
+from dataclasses import dataclass, field
+from typing import Optional
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import incremental_field
+from products.warehouse_sources.backend.types import IncrementalField
+
+
+@dataclass
+class PardotEndpointConfig:
+ name: str
+ # Object path under /api/v5/objects/.
+ path: str
+ # Account Engagement v5 returns only the record id unless `fields` names the
+ # columns, so every endpoint carries an explicit scalar field list. Relationship
+ # fields (campaign, createdBy, folder, ...) are left out to keep rows flat.
+ fields: tuple[str, ...]
+ primary_key: str = "id"
+ # Sort applied on the first request of a page chain. `None` where the object's
+ # docs don't advertise a sortable field, so we don't risk a 400 on orderBy.
+ order_by: Optional[str] = None
+ incremental_fields: list[IncrementalField] = field(default_factory=list)
+ # Stable creation-time field for datetime partitioning — never updatedAt, which
+ # would rewrite partitions on every sync.
+ partition_key: Optional[str] = None
+
+
+_TIMESTAMPS = ("createdAt", "updatedAt", "createdById", "updatedById")
+
+# Endpoints that expose both createdAtAfterOrEqualTo/updatedAtAfterOrEqualTo filters
+# AND createdAt/updatedAt as orderBy values, which is what makes them safely
+# incremental: the transport filters and sorts on the same field so the pipeline's
+# watermark advances in step with the pages it consumes.
+_CREATED_AND_UPDATED = [incremental_field("createdAt"), incremental_field("updatedAt")]
+
+
+PARDOT_ENDPOINTS: dict[str, PardotEndpointConfig] = {
+ "prospects": PardotEndpointConfig(
+ name="prospects",
+ path="prospects",
+ order_by="id",
+ incremental_fields=_CREATED_AND_UPDATED,
+ partition_key="createdAt",
+ fields=(
+ "id",
+ "campaignId",
+ "salesforceId",
+ "salesforceAccountId",
+ "salesforceContactId",
+ "salesforceLeadId",
+ "salesforceOwnerId",
+ "salesforceCampaignId",
+ "salesforceUrl",
+ "salesforceLastSync",
+ "email",
+ "firstName",
+ "lastName",
+ "salutation",
+ "company",
+ "jobTitle",
+ "department",
+ "industry",
+ "website",
+ "addressOne",
+ "addressTwo",
+ "city",
+ "state",
+ "country",
+ "zip",
+ "territory",
+ "phone",
+ "fax",
+ "employees",
+ "annualRevenue",
+ "yearsInBusiness",
+ "source",
+ "score",
+ "grade",
+ "notes",
+ "comments",
+ "isDoNotCall",
+ "isDoNotEmail",
+ "isReviewed",
+ "isStarred",
+ "isDeleted",
+ "isEmailHardBounced",
+ "optedOut",
+ "doNotSell",
+ "emailBouncedAt",
+ "emailBouncedReason",
+ "firstActivityAt",
+ "firstAssignedAt",
+ "lastActivityAt",
+ "convertedAt",
+ "convertedFromObjectName",
+ "convertedFromObjectType",
+ "recentInteraction",
+ "campaignParameter",
+ "mediumParameter",
+ "sourceParameter",
+ "termParameter",
+ "contentParameter",
+ "firstReferrerQuery",
+ "firstReferrerType",
+ "firstReferrerUrl",
+ "prospectAccountId",
+ "lifecycleStageId",
+ "assignedToId",
+ "userId",
+ "profileId",
+ *_TIMESTAMPS,
+ ),
+ ),
+ "prospect_accounts": PardotEndpointConfig(
+ name="prospect_accounts",
+ path="prospect-accounts",
+ # Prospect accounts only sort by id/salesforceId and document no datetime
+ # filters, so this table is full refresh.
+ order_by="id",
+ fields=(
+ "id",
+ "name",
+ "salesforceId",
+ "isDeleted",
+ "annualRevenue",
+ "billingAddressOne",
+ "billingAddressTwo",
+ "billingCity",
+ "billingCountry",
+ "billingState",
+ "billingZip",
+ "description",
+ "employees",
+ "fax",
+ "industry",
+ "number",
+ "ownership",
+ "phone",
+ "rating",
+ "shippingAddressOne",
+ "shippingAddressTwo",
+ "shippingCity",
+ "shippingCountry",
+ "shippingState",
+ "shippingZip",
+ "sic",
+ "site",
+ "tickerSymbol",
+ "type",
+ "website",
+ "assignedToId",
+ *_TIMESTAMPS,
+ ),
+ ),
+ "lists": PardotEndpointConfig(
+ name="lists",
+ path="lists",
+ order_by="id",
+ incremental_fields=_CREATED_AND_UPDATED,
+ fields=(
+ "id",
+ "name",
+ "description",
+ "title",
+ "isPublic",
+ "isDynamic",
+ "isDeleted",
+ "folderId",
+ "campaignId",
+ *_TIMESTAMPS,
+ ),
+ ),
+ "list_memberships": PardotEndpointConfig(
+ name="list_memberships",
+ path="list-memberships",
+ order_by="id",
+ incremental_fields=_CREATED_AND_UPDATED,
+ partition_key="createdAt",
+ fields=(
+ "id",
+ "listId",
+ "prospectId",
+ "optedOut",
+ "isDeleted",
+ *_TIMESTAMPS,
+ ),
+ ),
+ "campaigns": PardotEndpointConfig(
+ name="campaigns",
+ path="campaigns",
+ order_by="id",
+ incremental_fields=_CREATED_AND_UPDATED,
+ fields=(
+ "id",
+ "name",
+ "cost",
+ "folderId",
+ "parentCampaignId",
+ "salesforceId",
+ "isDeleted",
+ *_TIMESTAMPS,
+ ),
+ ),
+ "opportunities": PardotEndpointConfig(
+ name="opportunities",
+ path="opportunities",
+ order_by="id",
+ incremental_fields=_CREATED_AND_UPDATED,
+ partition_key="createdAt",
+ fields=(
+ "id",
+ "name",
+ "stage",
+ "status",
+ "probability",
+ "value",
+ "type",
+ "closedAt",
+ "campaignId",
+ "salesforceId",
+ *_TIMESTAMPS,
+ ),
+ ),
+ "users": PardotEndpointConfig(
+ name="users",
+ path="users",
+ order_by="id",
+ incremental_fields=_CREATED_AND_UPDATED,
+ fields=(
+ "id",
+ "email",
+ "firstName",
+ "lastName",
+ "username",
+ "jobTitle",
+ "role",
+ "roleName",
+ "salesforceId",
+ "isDeleted",
+ "tagReplacementLanguage",
+ *_TIMESTAMPS,
+ ),
+ ),
+ "visits": PardotEndpointConfig(
+ name="visits",
+ path="visits",
+ order_by="id",
+ incremental_fields=_CREATED_AND_UPDATED,
+ partition_key="createdAt",
+ fields=(
+ "id",
+ "visitorId",
+ "prospectId",
+ "visitorPageViewCount",
+ "firstVisitorPageViewAt",
+ "lastVisitorPageViewAt",
+ "durationInSeconds",
+ "campaignParameter",
+ "mediumParameter",
+ "sourceParameter",
+ "termParameter",
+ "contentParameter",
+ "createdAt",
+ "updatedAt",
+ ),
+ ),
+ "visitors": PardotEndpointConfig(
+ name="visitors",
+ path="visitors",
+ order_by="id",
+ incremental_fields=_CREATED_AND_UPDATED,
+ partition_key="createdAt",
+ fields=(
+ "id",
+ "prospectId",
+ "hostname",
+ "ipAddress",
+ "pageViewCount",
+ "isIdentified",
+ "doNotSell",
+ "campaignParameter",
+ "mediumParameter",
+ "sourceParameter",
+ "termParameter",
+ "contentParameter",
+ "createdAt",
+ "updatedAt",
+ ),
+ ),
+ "visitor_activities": PardotEndpointConfig(
+ name="visitor_activities",
+ path="visitor-activities",
+ order_by="id",
+ incremental_fields=_CREATED_AND_UPDATED,
+ partition_key="createdAt",
+ fields=(
+ "id",
+ "type",
+ "typeName",
+ "details",
+ "prospectId",
+ "visitorId",
+ "visitId",
+ "visitorPageViewId",
+ "campaignId",
+ "customRedirectId",
+ "emailId",
+ "emailTemplateId",
+ "fileId",
+ "formId",
+ "formHandlerId",
+ "landingPageId",
+ "listEmailId",
+ "multivariateTestVariationId",
+ "opportunityId",
+ "paidSearchAdId",
+ "siteSearchQueryId",
+ "createdAt",
+ "updatedAt",
+ ),
+ ),
+ "custom_fields": PardotEndpointConfig(
+ name="custom_fields",
+ path="custom-fields",
+ order_by="id",
+ incremental_fields=_CREATED_AND_UPDATED,
+ fields=(
+ "id",
+ "name",
+ "fieldId",
+ "type",
+ "isRecordMultipleResponses",
+ "isUseValues",
+ "isRequired",
+ "isAnalyticsSynced",
+ "valuesPrefill",
+ "salesforceId",
+ *_TIMESTAMPS,
+ ),
+ ),
+ "forms": PardotEndpointConfig(
+ name="forms",
+ path="forms",
+ # Forms document no orderBy or datetime filters — full refresh in the API's
+ # own default order.
+ fields=(
+ "id",
+ "name",
+ "campaignId",
+ "folderId",
+ "layoutTemplateId",
+ "trackerDomainId",
+ "submitButtonText",
+ "redirectLocation",
+ "isUseRedirectLocation",
+ "isAlwaysDisplay",
+ "isCaptchaEnabled",
+ "isCookieless",
+ "showNotProspect",
+ "salesforceId",
+ "salesforceCmsId",
+ "url",
+ "embedCode",
+ "isDeleted",
+ *_TIMESTAMPS,
+ ),
+ ),
+ "list_emails": PardotEndpointConfig(
+ name="list_emails",
+ path="list-emails",
+ # List emails filter on createdAt/updatedAt/sentAt but advertise no orderBy, so
+ # page order isn't guaranteed — full refresh rather than an unordered watermark.
+ # The message bodies (htmlMessage/textMessage) are skipped to keep rows small.
+ fields=(
+ "id",
+ "name",
+ "subject",
+ "campaignId",
+ "emailTemplateId",
+ "trackerDomainId",
+ "folderId",
+ "clientType",
+ "type",
+ "isOperational",
+ "isPaused",
+ "isSent",
+ "isDeleted",
+ "scheduledTime",
+ "sentAt",
+ *_TIMESTAMPS,
+ ),
+ ),
+}
+
+ENDPOINTS = tuple(PARDOT_ENDPOINTS.keys())
+
+INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {
+ name: config.incremental_fields for name, config in PARDOT_ENDPOINTS.items() if config.incremental_fields
+}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/pardot/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/pardot/source.py
index c87921577d74..386595607018 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/pardot/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/pardot/source.py
@@ -1,23 +1,72 @@
-from typing import cast
+from typing import Optional, cast
from posthog.schema import (
DataWarehouseSourceCategory,
ExternalDataSourceType as SchemaExternalDataSourceType,
+ ReleaseStatus,
SourceConfig,
+ SourceFieldInputConfig,
+ SourceFieldInputConfigType,
+ SourceFieldOauthConfig,
+ SourceFieldSelectConfig,
+ SourceFieldSelectConfigOption,
)
-from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, SimpleSource
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, ResumableSource
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
+ CanonicalDescriptions,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.mixins import OAuthMixin
from products.warehouse_sources.backend.temporal.data_imports.sources.common.registry import SourceRegistry
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import (
+ SourceSchema,
+ build_endpoint_schemas,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceInputs, SourceResponse
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.pardot import PardotSourceConfig
+from products.warehouse_sources.backend.temporal.data_imports.sources.pardot.pardot import (
+ PardotResumeConfig,
+ pardot_source,
+ validate_credentials as validate_pardot_credentials,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.pardot.settings import (
+ ENDPOINTS,
+ INCREMENTAL_FIELDS,
+)
from products.warehouse_sources.backend.types import ExternalDataSourceType
@SourceRegistry.register
-class PardotSource(SimpleSource[PardotSourceConfig]):
+class PardotSource(ResumableSource[PardotSourceConfig, PardotResumeConfig], OAuthMixin):
+ lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
+ supported_versions = ("v5",)
+ default_version = "v5"
+ api_docs_url = "https://developer.salesforce.com/docs/marketing/pardot/guide/version5overview.html"
+
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.PARDOT
+ def get_canonical_descriptions(self) -> CanonicalDescriptions:
+ from products.warehouse_sources.backend.temporal.data_imports.sources.pardot.canonical_descriptions import (
+ CANONICAL_DESCRIPTIONS,
+ )
+
+ return CANONICAL_DESCRIPTIONS
+
+ def get_non_retryable_errors(self) -> dict[str, str | None]:
+ return {
+ # SalesforceAuthRequestError formats a failed token refresh as
+ # "<code> Client Error: <reason>: <error_description>", so key off the stable
+ # error_description Salesforce returns for a revoked or expired grant.
+ "expired access/refresh token": "Your Account Engagement connection has expired or been revoked. Please reconnect the source.",
+ "inactive user": "The Salesforce user for this connection is inactive. Reactivate it in Salesforce or reconnect the source with an active user.",
+ "Integration not found": "The linked Account Engagement integration no longer exists. Please reconnect the source.",
+ "401 Client Error: Unauthorized for url": "Account Engagement rejected the access token. Please reconnect the source.",
+ "403 Client Error: Forbidden for url": "Account Engagement denied access. Check that the connected user has API access and that the business unit ID is correct.",
+ }
+
@property
def get_source_config(self) -> SourceConfig:
return SourceConfig(
@@ -25,7 +74,109 @@ class PardotSource(SimpleSource[PardotSourceConfig]):
category=DataWarehouseSourceCategory.MARKETING___EMAIL,
keywords=["salesforce pardot", "marketing cloud account engagement"],
label="Pardot",
+ releaseStatus=ReleaseStatus.ALPHA,
+ caption="""Connect Salesforce Marketing Cloud Account Engagement (formerly Pardot) to pull your marketing data into the PostHog Data warehouse.
+
+Connect a Salesforce account that has access to Account Engagement, then enter the ID of the business unit you want to sync.""",
iconPath="/static/services/pardot.png",
- fields=cast(list[FieldType], []),
- unreleasedSource=True,
+ docsUrl="https://posthog.com/docs/cdp/sources/pardot",
+ fields=cast(
+ list[FieldType],
+ [
+ SourceFieldOauthConfig(
+ name="pardot_integration_id",
+ label="Salesforce account",
+ required=True,
+ kind="pardot",
+ requiredScopes="pardot_api refresh_token",
+ ),
+ SourceFieldSelectConfig(
+ name="environment",
+ label="Environment",
+ required=True,
+ defaultValue="production",
+ caption="Choose sandbox if your business unit belongs to a sandbox, demo or developer org.",
+ options=[
+ SourceFieldSelectConfigOption(label="Production", value="production"),
+ SourceFieldSelectConfigOption(label="Sandbox", value="sandbox"),
+ ],
+ ),
+ SourceFieldInputConfig(
+ name="business_unit_id",
+ label="Business unit ID",
+ type=SourceFieldInputConfigType.TEXT,
+ required=True,
+ placeholder="0Uv...",
+ caption="The 18-character ID starting with `0Uv`, in Salesforce Setup under Account Engagement Business Unit Setup.",
+ secret=False,
+ ),
+ ],
+ ),
+ )
+
+ def get_schemas(
+ self,
+ config: PardotSourceConfig,
+ team_id: int,
+ with_counts: bool = False,
+ names: list[str] | None = None,
+ force_refresh: bool = False,
+ api_version: str | None = None,
+ ) -> list[SourceSchema]:
+ return build_endpoint_schemas(ENDPOINTS, INCREMENTAL_FIELDS, names)
+
+ def validate_credentials(
+ self,
+ config: PardotSourceConfig,
+ team_id: int,
+ schema_name: Optional[str] = None,
+ api_version: str | None = None,
+ ) -> tuple[bool, str | None]:
+ try:
+ integration = self.get_oauth_integration(config.pardot_integration_id, team_id)
+ except ValueError:
+ return False, "Connect a Salesforce account with access to Account Engagement"
+
+ if not integration.access_token:
+ return False, "The Salesforce connection has no access token. Please reconnect it."
+
+ return validate_pardot_credentials(
+ environment=config.environment,
+ business_unit_id=config.business_unit_id,
+ access_token=integration.access_token,
+ refresh_token=integration.refresh_token,
+ instance_url=integration.config.get("instance_url"),
+ )
+
+ def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[PardotResumeConfig]:
+ # Each endpoint pages with its own opaque token, so isolate resume state per schema —
+ # a retry that switches endpoints must not replay another endpoint's token.
+ return ResumableSourceManager[PardotResumeConfig](inputs, PardotResumeConfig).with_namespace(inputs.schema_name)
+
+ def source_for_pipeline(
+ self,
+ config: PardotSourceConfig,
+ resumable_source_manager: ResumableSourceManager[PardotResumeConfig],
+ inputs: SourceInputs,
+ ) -> SourceResponse:
+ integration = self.get_oauth_integration(config.pardot_integration_id, inputs.team_id)
+
+ if not integration.access_token:
+ raise ValueError(f"Account Engagement access token not found for job {inputs.job_id}")
+
+ return pardot_source(
+ environment=config.environment,
+ business_unit_id=config.business_unit_id,
+ access_token=integration.access_token,
+ refresh_token=integration.refresh_token,
+ instance_url=integration.config.get("instance_url"),
+ endpoint=inputs.schema_name,
+ api_version=self.resolve_api_version(inputs.api_version),
+ resumable_source_manager=resumable_source_manager,
+ logger=inputs.logger,
+ should_use_incremental_field=inputs.should_use_incremental_field,
+ db_incremental_field_last_value=inputs.db_incremental_field_last_value
+ if inputs.should_use_incremental_field
+ else None,
+ incremental_field=inputs.incremental_field,
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/pardot/tests/test_pardot.py b/products/warehouse_sources/backend/temporal/data_imports/sources/pardot/tests/test_pardot.py
new file mode 100644
index 000000000000..8f825d525a68
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/pardot/tests/test_pardot.py
@@ -0,0 +1,489 @@
+import json
+from collections.abc import Iterable
+from datetime import UTC, date, datetime
+from typing import Any, cast
+
+import pytest
+from unittest import mock
+
+import requests
+from requests import Response
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
+from products.warehouse_sources.backend.temporal.data_imports.sources.pardot.pardot import (
+ PAGE_SIZE,
+ PardotPageTokenExpiredError,
+ PardotResumeConfig,
+ _build_query_params,
+ _format_datetime,
+ get_rows,
+ pardot_source,
+ validate_credentials,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.pardot.settings import PARDOT_ENDPOINTS
+
+SESSION_PATCH = "products.warehouse_sources.backend.temporal.data_imports.sources.pardot.pardot.make_tracked_session"
+REFRESH_PATCH = (
+ "products.warehouse_sources.backend.temporal.data_imports.sources.pardot.pardot.salesforce_refresh_access_token"
+)
+
+CREDENTIALS: dict[str, Any] = {
+ "environment": "production",
+ "business_unit_id": "0Uv000000000000000",
+ "access_token": "access",
+ "refresh_token": "refresh",
+ "instance_url": "https://acme.my.salesforce.com",
+}
+
+
+class FakeResumeManager(ResumableSourceManager[PardotResumeConfig]):
+ """In-memory stand-in for the Redis-backed manager."""
+
+ def __init__(self, state: PardotResumeConfig | None = None) -> None:
+ self.state = state
+ self.saved: list[PardotResumeConfig] = []
+ self.clear_count = 0
+
+ def can_resume(self) -> bool:
+ return self.state is not None
+
+ def load_state(self) -> PardotResumeConfig | None:
+ return self.state
+
+ def save_state(self, data: PardotResumeConfig) -> None:
+ self.saved.append(data)
+ self.state = data
+
+ def clear_state(self) -> None:
+ self.clear_count += 1
+ self.state = None
+
+
+def _response(payload: Any, status_code: int = 200) -> Response:
+ response = Response()
+ response.status_code = status_code
+ response.url = "https://pi.pardot.com/api/v5/objects/prospects"
+ response._content = json.dumps(payload).encode()
+ return response
+
+
+def _session(get_responses: list[Response]) -> mock.MagicMock:
+ session = mock.MagicMock()
+ session.get.side_effect = get_responses
+ return session
+
+
+def _collect(
+ session: mock.MagicMock,
+ manager: FakeResumeManager,
+ endpoint: str = "prospects",
+ **kwargs: Any,
+) -> list[dict[str, Any]]:
+ with mock.patch(SESSION_PATCH, return_value=session):
+ pages = get_rows(
+ endpoint=endpoint,
+ api_version="v5",
+ resumable_source_manager=manager,
+ logger=mock.MagicMock(),
+ **{**CREDENTIALS, **kwargs},
+ )
+ return [row for page in pages for row in page]
+
+
+def _get_params(session: mock.MagicMock) -> list[dict[str, Any]]:
+ return [call.kwargs["params"] for call in session.get.call_args_list]
+
+
+class TestFormatDatetime:
+ @pytest.mark.parametrize(
+ "value, expected",
+ [
+ (datetime(2024, 1, 2, 3, 4, 5, tzinfo=UTC), "2024-01-02T03:04:05Z"),
+ (datetime(2024, 1, 2, 3, 4, 5), "2024-01-02T03:04:05Z"),
+ (date(2024, 1, 2), "2024-01-02T00:00:00Z"),
+ ("2024-01-02T03:04:05Z", "2024-01-02T03:04:05Z"),
+ ],
+ )
+ def test_formats_cursor_values(self, value: Any, expected: str) -> None:
+ assert _format_datetime(value) == expected
+
+ def test_converts_non_utc_offsets(self) -> None:
+ naive = datetime.fromisoformat("2024-01-02T05:04:05+02:00")
+
+ assert _format_datetime(naive) == "2024-01-02T03:04:05Z"
+
+
+class TestBuildQueryParams:
+ def test_full_refresh_sorts_on_the_endpoint_default(self) -> None:
+ params = _build_query_params(
+ PARDOT_ENDPOINTS["prospects"],
+ should_use_incremental_field=False,
+ db_incremental_field_last_value=None,
+ incremental_field=None,
+ )
+
+ assert params["orderBy"] == "id"
+ assert params["limit"] == PAGE_SIZE
+ assert "id" in params["fields"].split(",")
+ assert not any(key.endswith("AfterOrEqualTo") for key in params)
+
+ def test_incremental_filters_and_sorts_on_the_chosen_cursor(self) -> None:
+ params = _build_query_params(
+ PARDOT_ENDPOINTS["prospects"],
+ should_use_incremental_field=True,
+ db_incremental_field_last_value=datetime(2024, 5, 1, tzinfo=UTC),
+ incremental_field="updatedAt",
+ )
+
+ assert params["orderBy"] == "updatedAt"
+ assert params["updatedAtAfterOrEqualTo"] == "2024-05-01T00:00:00Z"
+
+ def test_first_incremental_run_sorts_on_the_cursor_without_filtering(self) -> None:
+ params = _build_query_params(
+ PARDOT_ENDPOINTS["visits"],
+ should_use_incremental_field=True,
+ db_incremental_field_last_value=None,
+ incremental_field="createdAt",
+ )
+
+ assert params["orderBy"] == "createdAt"
+ assert "createdAtAfterOrEqualTo" not in params
+
+ @pytest.mark.parametrize(
+ "endpoint, incremental_field",
+ [
+ # The endpoint advertises no incremental field at all.
+ ("prospect_accounts", "createdAt"),
+ # The requested field isn't one this endpoint advertises.
+ ("prospects", "lastActivityAt"),
+ ],
+ )
+ def test_unsupported_cursor_falls_back_to_the_default_sort(self, endpoint: str, incremental_field: str) -> None:
+ params = _build_query_params(
+ PARDOT_ENDPOINTS[endpoint],
+ should_use_incremental_field=True,
+ db_incremental_field_last_value=datetime(2024, 5, 1, tzinfo=UTC),
+ incremental_field=incremental_field,
+ )
+
+ assert params["orderBy"] == "id"
+ assert not any(key.endswith("AfterOrEqualTo") for key in params)
+
+ def test_endpoint_without_documented_sort_omits_order_by(self) -> None:
+ params = _build_query_params(
+ PARDOT_ENDPOINTS["forms"],
+ should_use_incremental_field=False,
+ db_incremental_field_last_value=None,
+ incremental_field=None,
+ )
+
+ assert "orderBy" not in params
+
+
+class TestPagination:
+ def test_walks_pages_until_the_token_runs_out(self) -> None:
+ session = _session(
+ [
+ _response({"values": [{"id": 1}], "nextPageToken": "t1"}),
+ _response({"values": [{"id": 2}], "nextPageToken": "t2"}),
+ _response({"values": [{"id": 3}], "nextPageToken": None}),
+ ]
+ )
+ manager = FakeResumeManager()
+
+ rows = _collect(session, manager)
+
+ assert [row["id"] for row in rows] == [1, 2, 3]
+
+ def test_page_token_requests_drop_every_param_but_fields(self) -> None:
+ session = _session(
+ [
+ _response({"values": [{"id": 1}], "nextPageToken": "t1"}),
+ _response({"values": [{"id": 2}]}),
+ ]
+ )
+
+ _collect(session, FakeResumeManager())
+ first, second = _get_params(session)
+
+ assert first["limit"] == PAGE_SIZE
+ assert second == {"fields": first["fields"], "nextPageToken": "t1"}
+
+ def test_state_is_saved_per_page_and_cleared_when_the_endpoint_completes(self) -> None:
+ session = _session(
+ [
+ _response({"values": [{"id": 1}], "nextPageToken": "t1"}),
+ _response({"values": [{"id": 2}], "nextPageToken": None}),
+ ]
+ )
+ manager = FakeResumeManager()
+
+ _collect(session, manager)
+
+ assert [state.next_page_token for state in manager.saved] == ["t1"]
+ assert manager.clear_count == 1
+
+ def test_empty_page_yields_nothing(self) -> None:
+ session = _session([_response({"values": [], "nextPageToken": None})])
+
+ assert _collect(session, FakeResumeManager()) == []
+
+ def test_missing_values_key_is_treated_as_an_empty_page(self) -> None:
+ session = _session([_response({"nextPageToken": None})])
+
+ assert _collect(session, FakeResumeManager()) == []
+
+
+class TestResume:
+ def test_resumes_from_the_saved_page_token(self) -> None:
+ session = _session([_response({"values": [{"id": 9}]})])
+ manager = FakeResumeManager(PardotResumeConfig(next_page_token="saved-token"))
+
+ rows = _collect(session, manager)
+
+ assert [row["id"] for row in rows] == [9]
+ assert _get_params(session)[0]["nextPageToken"] == "saved-token"
+
+ def test_expired_resume_token_restarts_the_endpoint(self) -> None:
+ session = _session(
+ [
+ _response({"code": 184, "message": "Invalid page token"}, status_code=400),
+ _response({"values": [{"id": 1}]}),
+ ]
+ )
+ manager = FakeResumeManager(PardotResumeConfig(next_page_token="stale-token"))
+
+ rows = _collect(session, manager)
+
+ assert [row["id"] for row in rows] == [1]
+ assert manager.clear_count == 2 # once when the token is dropped, once on completion
+ assert "nextPageToken" not in _get_params(session)[1]
+
+ def test_expired_token_mid_sync_is_not_swallowed(self) -> None:
+ session = _session(
+ [
+ _response({"values": [{"id": 1}], "nextPageToken": "t1"}),
+ _response({"message": "page token expired"}, status_code=400),
+ ]
+ )
+
+ with pytest.raises(PardotPageTokenExpiredError):
+ _collect(session, FakeResumeManager())
+
+ def test_other_bad_requests_are_raised_rather_than_restarted(self) -> None:
+ session = _session([_response({"message": "Invalid field name"}, status_code=400)])
+ manager = FakeResumeManager(PardotResumeConfig(next_page_token="saved-token"))
+
+ with pytest.raises(requests.HTTPError):
+ _collect(session, manager)
+
+
+class TestAuth:
+ def test_the_integration_token_is_used_as_is(self) -> None:
+ session = _session([_response({"values": []})])
+
+ _collect(session, FakeResumeManager())
+
+ assert session.get.call_args.kwargs["headers"]["Authorization"] == "Bearer access"
+
+ def test_expired_access_token_is_refreshed_once(self) -> None:
+ session = _session(
+ [
+ _response({"message": "Session expired"}, status_code=401),
+ _response({"values": [{"id": 1}]}),
+ ]
+ )
+
+ with mock.patch(REFRESH_PATCH, return_value="refreshed") as refresh:
+ rows = _collect(session, FakeResumeManager())
+
+ assert [row["id"] for row in rows] == [1]
+ # capture=False keeps the refresh request body (refresh token, shared client secret) and
+ # its minted-access-token response out of HTTP sample capture.
+ refresh.assert_called_once_with(CREDENTIALS["refresh_token"], CREDENTIALS["instance_url"], capture=False)
+ assert session.get.call_args_list[1].kwargs["headers"]["Authorization"] == "Bearer refreshed"
+
+ def test_repeated_401_surfaces_the_error(self) -> None:
+ session = _session(
+ [
+ _response({"message": "Session expired"}, status_code=401),
+ _response({"message": "Session expired"}, status_code=401),
+ ]
+ )
+
+ with mock.patch(REFRESH_PATCH, return_value="refreshed"), pytest.raises(requests.HTTPError):
+ _collect(session, FakeResumeManager())
+
+ def test_401_without_a_refresh_token_asks_for_a_reconnect(self) -> None:
+ session = _session([_response({"message": "Session expired"}, status_code=401)])
+
+ with pytest.raises(ValueError, match="Reconnect"):
+ _collect(session, FakeResumeManager(), refresh_token=None)
+
+ def test_business_unit_header_and_secrets_redaction_are_wired(self) -> None:
+ session = _session([_response({"values": []})])
+
+ with mock.patch(SESSION_PATCH, return_value=session) as make_session:
+ list(
+ get_rows(
+ endpoint="prospects",
+ api_version="v5",
+ resumable_source_manager=FakeResumeManager(),
+ logger=mock.MagicMock(),
+ **CREDENTIALS,
+ )
+ )
+
+ kwargs = make_session.call_args.kwargs
+ assert kwargs["headers"]["Pardot-Business-Unit-Id"] == CREDENTIALS["business_unit_id"]
+ assert set(kwargs["redact_values"]) == {CREDENTIALS["access_token"], CREDENTIALS["refresh_token"]}
+
+ def test_every_request_path_disables_http_sample_capture(self) -> None:
+ # Prospect/visitor bodies carry PII the name-based scrubber can't redact, so both the
+ # sync and credential-validation paths must build capture-disabled sessions.
+ pull_session = _session([_response({"values": []})])
+ validate_session = _session([_response({"values": []}, status_code=200)])
+
+ with mock.patch(SESSION_PATCH) as make_session:
+ make_session.return_value = pull_session
+ list(
+ get_rows(
+ endpoint="prospects",
+ api_version="v5",
+ resumable_source_manager=FakeResumeManager(),
+ logger=mock.MagicMock(),
+ **CREDENTIALS,
+ )
+ )
+ make_session.return_value = validate_session
+ validate_credentials(**CREDENTIALS)
+
+ assert make_session.call_count == 2
+ assert all(call.kwargs["capture"] is False for call in make_session.call_args_list)
+
+ @pytest.mark.parametrize(
+ "environment, expected_host",
+ [
+ ("production", "https://pi.pardot.com"),
+ ("sandbox", "https://pi.demo.pardot.com"),
+ ],
+ )
+ def test_environment_selects_the_api_host(self, environment: str, expected_host: str) -> None:
+ session = _session([_response({"values": []})])
+ credentials = {**CREDENTIALS, "environment": environment}
+
+ with mock.patch(SESSION_PATCH, return_value=session):
+ list(
+ get_rows(
+ endpoint="prospects",
+ api_version="v5",
+ resumable_source_manager=FakeResumeManager(),
+ logger=mock.MagicMock(),
+ **credentials,
+ )
+ )
+
+ assert session.get.call_args.args[0] == f"{expected_host}/api/v5/objects/prospects"
+
+ def test_unknown_environment_is_rejected(self) -> None:
+ with pytest.raises(ValueError):
+ list(
+ get_rows(
+ **{**CREDENTIALS, "environment": "staging"},
+ endpoint="prospects",
+ api_version="v5",
+ resumable_source_manager=FakeResumeManager(),
+ logger=mock.MagicMock(),
+ )
+ )
+
+
+class TestValidateCredentials:
+ @pytest.mark.parametrize(
+ "status_code, expected_valid",
+ [(200, True), (403, False), (500, False)],
+ )
+ def test_probe_status_maps_to_validity(self, status_code: int, expected_valid: bool) -> None:
+ session = _session([_response({"values": []}, status_code=status_code)])
+
+ with mock.patch(SESSION_PATCH, return_value=session):
+ is_valid, message = validate_credentials(**CREDENTIALS)
+
+ assert is_valid is expected_valid
+ assert (message is None) is expected_valid
+
+ def test_stale_stored_token_is_refreshed_before_giving_up(self) -> None:
+ # The stored access token is often older than its lifetime by the time the source is
+ # configured, so a 401 must not be reported as a bad connection.
+ session = _session(
+ [
+ _response({"message": "Session expired"}, status_code=401),
+ _response({"values": []}),
+ ]
+ )
+
+ with mock.patch(SESSION_PATCH, return_value=session), mock.patch(REFRESH_PATCH, return_value="refreshed"):
+ is_valid, message = validate_credentials(**CREDENTIALS)
+
+ assert (is_valid, message) == (True, None)
+ assert session.get.call_args.kwargs["headers"]["Authorization"] == "Bearer refreshed"
+
+ def test_failed_refresh_asks_the_user_to_reconnect(self) -> None:
+ session = _session([_response({"message": "Session expired"}, status_code=401)])
+
+ with mock.patch(SESSION_PATCH, return_value=session), mock.patch(REFRESH_PATCH, side_effect=requests.HTTPError):
+ is_valid, message = validate_credentials(**CREDENTIALS)
+
+ assert is_valid is False
+ assert message is not None and "Reconnect" in message
+
+ def test_unknown_environment_is_reported_not_raised(self) -> None:
+ is_valid, message = validate_credentials(**{**CREDENTIALS, "environment": "staging"})
+
+ assert is_valid is False
+ assert message is not None and "staging" in message
+
+
+class TestPardotSourceResponse:
+ def test_partitions_high_volume_tables_on_creation_time(self) -> None:
+ response = pardot_source(
+ **CREDENTIALS,
+ endpoint="visitor_activities",
+ api_version="v5",
+ resumable_source_manager=FakeResumeManager(),
+ logger=mock.MagicMock(),
+ )
+
+ assert response.name == "visitor_activities"
+ assert response.primary_keys == ["id"]
+ assert response.partition_mode == "datetime"
+ assert response.partition_keys == ["createdAt"]
+ assert response.sort_mode == "asc"
+
+ def test_unpartitioned_table_declares_no_partition_keys(self) -> None:
+ response = pardot_source(
+ **CREDENTIALS,
+ endpoint="campaigns",
+ api_version="v5",
+ resumable_source_manager=FakeResumeManager(),
+ logger=mock.MagicMock(),
+ )
+
+ assert response.partition_mode is None
+ assert response.partition_keys is None
+
+ def test_items_are_lazy_until_iterated(self) -> None:
+ session = _session([_response({"values": [{"id": 1}]})])
+ response = pardot_source(
+ **CREDENTIALS,
+ endpoint="campaigns",
+ api_version="v5",
+ resumable_source_manager=FakeResumeManager(),
+ logger=mock.MagicMock(),
+ )
+
+ with mock.patch(SESSION_PATCH, return_value=session):
+ session.get.assert_not_called()
+ rows = [row for page in cast("Iterable[Any]", response.items()) for row in page]
+
+ assert rows == [{"id": 1}]
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/pardot/tests/test_pardot_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/pardot/tests/test_pardot_source.py
new file mode 100644
index 000000000000..214a2bb9a341
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/pardot/tests/test_pardot_source.py
@@ -0,0 +1,264 @@
+from typing import Any
+
+import pytest
+from unittest import mock
+
+from posthog.schema import (
+ ReleaseStatus,
+ SourceFieldInputConfig,
+ SourceFieldInputConfigType,
+ SourceFieldOauthConfig,
+ SourceFieldSelectConfig,
+)
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
+from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.pardot import PardotSourceConfig
+from products.warehouse_sources.backend.temporal.data_imports.sources.pardot.canonical_descriptions import (
+ CANONICAL_DESCRIPTIONS,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.pardot.pardot import PardotResumeConfig
+from products.warehouse_sources.backend.temporal.data_imports.sources.pardot.settings import (
+ ENDPOINTS,
+ INCREMENTAL_FIELDS,
+ PARDOT_ENDPOINTS,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.pardot.source import PardotSource
+from products.warehouse_sources.backend.types import ExternalDataSourceType
+
+INCREMENTAL_ENDPOINTS = sorted(INCREMENTAL_FIELDS)
+FULL_REFRESH_ENDPOINTS = sorted(set(ENDPOINTS) - set(INCREMENTAL_FIELDS))
+
+
+def _integration(access_token: str | None = "access") -> mock.MagicMock:
+ return mock.MagicMock(
+ access_token=access_token,
+ refresh_token="refresh",
+ config={"instance_url": "https://acme.my.salesforce.com"},
+ )
+
+
+def _make_inputs(schema_name: str = "prospects", **overrides: Any) -> mock.MagicMock:
+ defaults: dict[str, Any] = {
+ "schema_name": schema_name,
+ "schema_id": "schema-1",
+ "source_id": "source-1",
+ "team_id": 1,
+ "should_use_incremental_field": False,
+ "db_incremental_field_last_value": None,
+ "db_incremental_field_earliest_value": None,
+ "incremental_field": None,
+ "incremental_field_type": None,
+ "job_id": "job-1",
+ "logger": mock.MagicMock(),
+ "reset_pipeline": False,
+ "api_version": None,
+ }
+ defaults.update(overrides)
+ return mock.MagicMock(**defaults)
+
+
+class TestPardotSource:
+ def setup_method(self) -> None:
+ self.source = PardotSource()
+ self.team_id = 123
+ self.config = PardotSourceConfig(
+ business_unit_id="0Uv000000000000000",
+ pardot_integration_id=7,
+ environment="production",
+ )
+
+ def test_source_type(self) -> None:
+ assert self.source.source_type == ExternalDataSourceType.PARDOT
+
+ def test_get_source_config_is_released_as_alpha(self) -> None:
+ config = self.source.get_source_config
+
+ assert config.label == "Pardot"
+ assert config.releaseStatus == ReleaseStatus.ALPHA
+ assert not config.unreleasedSource
+ assert config.iconPath == "/static/services/pardot.png"
+
+ def test_source_config_authorizes_through_posthogs_salesforce_app(self) -> None:
+ # The user connects an account instead of pasting a connected app's own credentials,
+ # so no client id, client secret or refresh token field may come back.
+ fields = {field.name: field for field in self.source.get_source_config.fields}
+
+ assert set(fields) == {"pardot_integration_id", "environment", "business_unit_id"}
+
+ integration = fields["pardot_integration_id"]
+ assert isinstance(integration, SourceFieldOauthConfig)
+ assert integration.kind == "pardot"
+ assert integration.required is True
+ # Salesforce's `full` scope does not cover the Account Engagement API.
+ assert integration.requiredScopes is not None and "pardot_api" in integration.requiredScopes
+
+ environment = fields["environment"]
+ assert isinstance(environment, SourceFieldSelectConfig)
+ assert [option.value for option in environment.options] == ["production", "sandbox"]
+
+ def test_business_unit_id_is_required_and_not_a_secret(self) -> None:
+ field = next(f for f in self.source.get_source_config.fields if f.name == "business_unit_id")
+
+ assert isinstance(field, SourceFieldInputConfig)
+ assert field.required is True
+ assert field.type == SourceFieldInputConfigType.TEXT
+ assert field.secret is False
+
+ def test_api_version_defaults_to_the_path_the_transport_calls(self) -> None:
+ assert self.source.default_version == "v5"
+ assert self.source.supported_versions == ("v5",)
+ assert self.source.resolve_api_version(None) == "v5"
+
+ @pytest.mark.parametrize(
+ "observed_error",
+ [
+ "401 Client Error: Unauthorized for url: https://pi.pardot.com/api/v5/objects/prospects",
+ "403 Client Error: Forbidden for url: https://pi.pardot.com/api/v5/objects/prospects",
+ "400 Client Error: Bad Request: expired access/refresh token",
+ "Integration not found: 7",
+ ],
+ )
+ def test_auth_failures_are_non_retryable(self, observed_error: str) -> None:
+ assert any(key in observed_error for key in self.source.get_non_retryable_errors())
+
+ def test_get_schemas_lists_every_endpoint(self) -> None:
+ schemas = self.source.get_schemas(self.config, self.team_id)
+
+ assert {schema.name for schema in schemas} == set(ENDPOINTS)
+
+ @pytest.mark.parametrize("name", INCREMENTAL_ENDPOINTS)
+ def test_incremental_endpoints_advertise_both_timestamps(self, name: str) -> None:
+ schema = next(s for s in self.source.get_schemas(self.config, self.team_id) if s.name == name)
+
+ assert schema.supports_incremental is True
+ assert {f["field"] for f in schema.incremental_fields} == {"createdAt", "updatedAt"}
+
+ @pytest.mark.parametrize("name", FULL_REFRESH_ENDPOINTS)
+ def test_endpoints_without_a_server_side_filter_stay_full_refresh(self, name: str) -> None:
+ schema = next(s for s in self.source.get_schemas(self.config, self.team_id) if s.name == name)
+
+ assert schema.supports_incremental is False
+ assert schema.incremental_fields == []
+
+ def test_get_schemas_filtered_by_names(self) -> None:
+ schemas = self.source.get_schemas(self.config, self.team_id, names=["prospects", "campaigns"])
+
+ assert {s.name for s in schemas} == {"prospects", "campaigns"}
+
+ def test_get_schemas_needs_no_credentials(self) -> None:
+ # `lists_tables_without_credentials` promises the public docs can list tables from a
+ # placeholder config — that only holds while get_schemas does no I/O.
+ assert self.source.lists_tables_without_credentials is True
+ empty_config = PardotSourceConfig(business_unit_id="", pardot_integration_id=0, environment="production")
+
+ assert {s.name for s in self.source.get_schemas(empty_config, self.team_id)} == set(ENDPOINTS)
+
+ @pytest.mark.parametrize(
+ "probe_result",
+ [(True, None), (False, "Account Engagement rejected the connection")],
+ )
+ @mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.pardot.source.validate_pardot_credentials"
+ )
+ def test_validate_credentials_probes_with_the_integration_token(
+ self, mock_validate: mock.MagicMock, probe_result: tuple[bool, str | None]
+ ) -> None:
+ mock_validate.return_value = probe_result
+
+ with mock.patch.object(PardotSource, "get_oauth_integration", return_value=_integration()):
+ assert self.source.validate_credentials(self.config, self.team_id) == probe_result
+
+ mock_validate.assert_called_once_with(
+ environment="production",
+ business_unit_id="0Uv000000000000000",
+ access_token="access",
+ refresh_token="refresh",
+ instance_url="https://acme.my.salesforce.com",
+ )
+
+ @pytest.mark.parametrize(
+ "patched",
+ [
+ # The integration was disconnected, or none was selected.
+ {"side_effect": ValueError("Integration not found: 7")},
+ # It exists but has no stored access token.
+ {"return_value": _integration(access_token=None)},
+ ],
+ )
+ @mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.pardot.source.validate_pardot_credentials"
+ )
+ def test_validate_credentials_fails_cleanly_without_a_usable_integration(
+ self, mock_validate: mock.MagicMock, patched: dict[str, Any]
+ ) -> None:
+ with mock.patch.object(PardotSource, "get_oauth_integration", **patched):
+ is_valid, message = self.source.validate_credentials(self.config, self.team_id)
+
+ assert is_valid is False
+ assert message is not None
+ mock_validate.assert_not_called()
+
+ def test_resume_state_is_namespaced_per_endpoint(self) -> None:
+ prospects = self.source.get_resumable_source_manager(_make_inputs("prospects"))
+ visits = self.source.get_resumable_source_manager(_make_inputs("visits"))
+
+ assert isinstance(prospects, ResumableSourceManager)
+ assert prospects._data_class is PardotResumeConfig
+ assert prospects._key != visits._key
+
+ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.pardot.source.pardot_source")
+ def test_source_for_pipeline_syncs_with_the_integration_credentials(
+ self, mock_pardot_source: mock.MagicMock
+ ) -> None:
+ manager = mock.MagicMock()
+ inputs = _make_inputs(
+ "prospects",
+ should_use_incremental_field=True,
+ incremental_field="updatedAt",
+ db_incremental_field_last_value="2024-05-01T00:00:00Z",
+ )
+
+ with mock.patch.object(PardotSource, "get_oauth_integration", return_value=_integration()) as get_integration:
+ self.source.source_for_pipeline(self.config, manager, inputs)
+
+ get_integration.assert_called_once_with(7, inputs.team_id)
+ kwargs = mock_pardot_source.call_args.kwargs
+ assert kwargs["access_token"] == "access"
+ assert kwargs["refresh_token"] == "refresh"
+ assert kwargs["instance_url"] == "https://acme.my.salesforce.com"
+ assert kwargs["endpoint"] == "prospects"
+ assert kwargs["api_version"] == "v5"
+ assert kwargs["incremental_field"] == "updatedAt"
+ assert kwargs["db_incremental_field_last_value"] == "2024-05-01T00:00:00Z"
+ assert kwargs["resumable_source_manager"] is manager
+
+ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.pardot.source.pardot_source")
+ def test_full_refresh_run_drops_the_stored_watermark(self, mock_pardot_source: mock.MagicMock) -> None:
+ inputs = _make_inputs(
+ "prospects", should_use_incremental_field=False, db_incremental_field_last_value="2024-05-01T00:00:00Z"
+ )
+
+ with mock.patch.object(PardotSource, "get_oauth_integration", return_value=_integration()):
+ self.source.source_for_pipeline(self.config, mock.MagicMock(), inputs)
+
+ assert mock_pardot_source.call_args.kwargs["db_incremental_field_last_value"] is None
+
+ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.pardot.source.pardot_source")
+ def test_sync_stops_when_the_integration_has_no_token(self, mock_pardot_source: mock.MagicMock) -> None:
+ # Syncing on an empty token would fail every page with a 401 instead of naming the problem.
+ with mock.patch.object(PardotSource, "get_oauth_integration", return_value=_integration(access_token=None)):
+ with pytest.raises(ValueError, match="access token not found"):
+ self.source.source_for_pipeline(self.config, mock.MagicMock(), _make_inputs())
+
+ mock_pardot_source.assert_not_called()
+
+
+class TestCanonicalDescriptions:
+ def test_descriptions_cover_the_endpoints_they_key_on(self) -> None:
+ assert set(CANONICAL_DESCRIPTIONS) == set(ENDPOINTS)
+
+ @pytest.mark.parametrize("endpoint", sorted(ENDPOINTS))
+ def test_documented_columns_exist_on_the_endpoint(self, endpoint: str) -> None:
+ described = set(CANONICAL_DESCRIPTIONS[endpoint].get("columns", {}))
+
+ assert described <= set(PARDOT_ENDPOINTS[endpoint].fields)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/auth.py b/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/auth.py
index d39188d78af9..3645e55494c1 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/auth.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/auth.py
@@ -85,10 +85,14 @@ _TRANSIENT_TOKEN_REQUEST_ERROR = "token request is already being processed"
_MAX_TOKEN_REFRESH_ATTEMPTS = 4
-def salesforce_refresh_access_token(refresh_token: str, instance_url: str) -> str:
+def salesforce_refresh_access_token(refresh_token: str, instance_url: str, *, capture: bool = True) -> str:
+ # capture=False lets a caller keep this exchange out of HTTP sample capture: the request body
+ # carries the refresh token and the shared client secret, and the response carries a freshly
+ # minted access token, none of which the name-based scrubbers reliably redact.
+ session = make_tracked_session(redact_values=(refresh_token,), capture=capture)
attempt = 0
while True:
- res = make_tracked_session().post(
+ res = session.post(
f"{instance_url}/services/oauth2/token",
data={
"grant_type": "refresh_token",
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 7900adadd50a..106571d7cb48 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -5550,6 +5550,7 @@ export namespace Schemas {
Firebase: 'firebase',
Jira: 'jira',
PinterestAds: 'pinterest-ads',
+ Pardot: 'pardot',
CustomerioApp: 'customerio-app',
CustomerioWebhook: 'customerio-webhook',
CustomerioTrack: 'customerio-track',
@@ -36496,6 +36497,7 @@ export namespace Schemas {
* * `linear` - Linear
* * `linkedin-ads` - Linkedin Ads
* * `meta-ads` - Meta Ads
+ * * `pardot` - Pardot
* * `pinterest-ads` - Pinterest Ads
* * `postgresql` - Postgresql
* * `reddit-ads` - Reddit Ads
@@ -36542,6 +36544,7 @@ export namespace Schemas {
Linear: 'linear',
LinkedinAds: 'linkedin-ads',
MetaAds: 'meta-ads',
+ Pardot: 'pardot',
PinterestAds: 'pinterest-ads',
Postgresql: 'postgresql',
RedditAds: 'reddit-ads',
@@ -36588,6 +36591,7 @@ export namespace Schemas {
* * `linear` - Linear
* * `linkedin-ads` - Linkedin Ads
* * `meta-ads` - Meta Ads
+ * * `pardot` - Pardot
* * `pinterest-ads` - Pinterest Ads
* * `postgresql` - Postgresql
* * `reddit-ads` - Reddit Ads
@@ -78096,6 +78100,7 @@ export namespace Schemas {
* * `linear` - Linear
* * `linkedin-ads` - Linkedin Ads
* * `meta-ads` - Meta Ads
+ * * `pardot` - Pardot
* * `pinterest-ads` - Pinterest Ads
* * `postgresql` - Postgresql
* * `reddit-ads` - Reddit Ads
@@ -78153,6 +78158,7 @@ export namespace Schemas {
Linear: 'linear',
LinkedinAds: 'linkedin-ads',
MetaAds: 'meta-ads',
+ Pardot: 'pardot',
PinterestAds: 'pinterest-ads',
Postgresql: 'postgresql',
RedditAds: 'reddit-ads',
diff --git a/services/mcp/src/generated/integrations/api.ts b/services/mcp/src/generated/integrations/api.ts
index 0633b9faf730..91c2f6a1d4b7 100644
--- a/services/mcp/src/generated/integrations/api.ts
+++ b/services/mcp/src/generated/integrations/api.ts
@@ -46,6 +46,7 @@ export const IntegrationsListQueryParams = /* @__PURE__ */ zod.object({
'linear',
'linkedin-ads',
'meta-ads',
+ 'pardot',
'pinterest-ads',
'postgresql',
'reddit-ads',
@@ -63,7 +64,7 @@ export const IntegrationsListQueryParams = /* @__PURE__ */ zod.object({
])
.optional()
.describe(
- '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
+ '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel'
),
limit: zod.number().optional().describe('Number of results to return per page.'),
offset: zod.number().optional().describe('The initial index from which to return the results.'),
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/integrations-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/integrations-list.json
index d3bdc2fb7248..8ff687e3fa56 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/integrations-list.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/integrations-list.json
@@ -2,7 +2,7 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"kind": {
- "description": "* `anthropic` - Anthropic\n* `apns` - Apple Push\n* `aws-s3` - Aws S3\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-analytics` - Google Analytics\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-search-console` - Google Search Console\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `resend` - Resend\n* `s3-compatible` - S3 Compatible\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `snowflake` - Snowflake\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel",
+ "description": "* `anthropic` - Anthropic\n* `apns` - Apple Push\n* `aws-s3` - Aws S3\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-analytics` - Google Analytics\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-search-console` - Google Search Console\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pardot` - Pardot\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `reddit-ads` - Reddit Ads\n* `resend` - Resend\n* `s3-compatible` - S3 Compatible\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `snowflake` - Snowflake\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel",
"enum": [
"anthropic",
"apns",
@@ -31,6 +31,7 @@
"linear",
"linkedin-ads",
"meta-ads",
+ "pardot",
"pinterest-ads",
"postgresql",
"reddit-ads",