Share PostHog region mapping and tidy pagination

The us/eu host strings lived in the driver and were duplicated in the
connector-settings resolver. Expose drivers.PostHogRegionBaseURL as the
single source and call it from the resolver.

Also parse the base URL only inside the absolute-next branch of
resolveNextURL, where it is actually used for the host check.

Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
Aurélien Sibiril
2026-05-29 13:57:37 +02:00
parent 13f9234604
commit e4f247a20d
2 changed files with 22 additions and 20 deletions

View File

@@ -19,6 +19,7 @@ import (
"fmt"
"net/url"
"go.probo.inc/probo/pkg/accessreview/drivers"
"go.probo.inc/probo/pkg/coredata"
"go.probo.inc/probo/pkg/server/api/console/v1/types"
)
@@ -98,7 +99,7 @@ func apiKeyConnectorSettings(input types.CreateAPIKeyConnectorInput) (json.RawMe
return nil, fmt.Errorf("cannot create posthog connector: posthogRegion is required")
}
baseURL, ok := posthogRegionBaseURL(*input.PosthogRegion)
baseURL, ok := drivers.PostHogRegionBaseURL(*input.PosthogRegion)
if !ok {
return nil, fmt.Errorf("cannot create posthog connector: posthogRegion must be US or EU")
}
@@ -120,20 +121,6 @@ func apiKeyConnectorSettings(input types.CreateAPIKeyConnectorInput) (json.RawMe
return nil, nil
}
// posthogRegionBaseURL maps a PostHog Cloud region selector to its data-API
// base host. Only US and EU clouds exist; self-hosted instances use the
// dedicated POSTHOG_SELF_HOSTED provider with a full instance URL instead.
func posthogRegionBaseURL(region string) (string, bool) {
switch region {
case "US", "us":
return "https://us.posthog.com", true
case "EU", "eu":
return "https://eu.posthog.com", true
default:
return "", false
}
}
// clientCredentialsConnectorSettings marshals the provider-specific
// extra settings for a client-credentials connector. See
// apiKeyConnectorSettings for the error contract.