Add PostHog API-key connector settings
Marshal the region (us/eu) for PostHog Cloud and the instance URL for PostHog Self-Hosted from the create-connector input, validating each, and add the matching GraphQL inputs and the POSTHOG_SELF_HOSTED enum value. Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com>
This commit is contained in:
@@ -93,11 +93,47 @@ func apiKeyConnectorSettings(input types.CreateAPIKeyConnectorInput) (json.RawMe
|
||||
}
|
||||
|
||||
return json.Marshal(&coredata.MetabaseConnectorSettings{InstanceURL: *input.MetabaseInstanceURL})
|
||||
case coredata.ConnectorProviderPostHog:
|
||||
if input.PosthogRegion == nil || *input.PosthogRegion == "" {
|
||||
return nil, fmt.Errorf("cannot create posthog connector: posthogRegion is required")
|
||||
}
|
||||
|
||||
baseURL, ok := posthogRegionBaseURL(*input.PosthogRegion)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("cannot create posthog connector: posthogRegion must be US or EU")
|
||||
}
|
||||
|
||||
return json.Marshal(&coredata.PostHogConnectorSettings{BaseURL: baseURL})
|
||||
case coredata.ConnectorProviderPostHogSelfHosted:
|
||||
if input.PosthogInstanceURL == nil || *input.PosthogInstanceURL == "" {
|
||||
return nil, fmt.Errorf("cannot create posthog self-hosted connector: posthogInstanceUrl is required")
|
||||
}
|
||||
|
||||
u, err := url.Parse(*input.PosthogInstanceURL)
|
||||
if err != nil || (u.Scheme != "http" && u.Scheme != "https") || u.Host == "" {
|
||||
return nil, fmt.Errorf("cannot create posthog self-hosted connector: posthogInstanceUrl must be an http(s) URL")
|
||||
}
|
||||
|
||||
return json.Marshal(&coredata.PostHogConnectorSettings{BaseURL: *input.PosthogInstanceURL})
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
@@ -23,6 +23,10 @@ enum ConnectorProvider
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.ConnectorProviderCloudflare")
|
||||
OPENAI @goEnum(value: "go.probo.inc/probo/pkg/coredata.ConnectorProviderOpenAI")
|
||||
POSTHOG @goEnum(value: "go.probo.inc/probo/pkg/coredata.ConnectorProviderPostHog")
|
||||
POSTHOG_SELF_HOSTED
|
||||
@goEnum(
|
||||
value: "go.probo.inc/probo/pkg/coredata.ConnectorProviderPostHogSelfHosted"
|
||||
)
|
||||
SENTRY @goEnum(value: "go.probo.inc/probo/pkg/coredata.ConnectorProviderSentry")
|
||||
SUPABASE
|
||||
@goEnum(value: "go.probo.inc/probo/pkg/coredata.ConnectorProviderSupabase")
|
||||
@@ -129,6 +133,8 @@ input CreateAPIKeyConnectorInput {
|
||||
grafanaBaseUrl: String
|
||||
onePasswordScimBridgeUrl: String
|
||||
metabaseInstanceUrl: String
|
||||
posthogRegion: String
|
||||
posthogInstanceUrl: String
|
||||
}
|
||||
|
||||
type CreateAPIKeyConnectorPayload {
|
||||
|
||||
Reference in New Issue
Block a user