Skip to content

Commit 74911f3

Browse files
rothgarIheanacho-ai
authored andcommitted
feat: enable posthog configuration for docs.json
Signed-off-by: Justin Garrison <[email protected]>
1 parent 62a0830 commit 74911f3

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

docs-gen/main.go

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,20 @@ type Footer struct {
7676
}
7777

7878
type Integrations struct {
79-
GA4 *GA4Integration `yaml:"ga4,omitempty" json:"ga4,omitempty"`
79+
GA4 *GA4Integration `yaml:"ga4,omitempty" json:"ga4,omitempty"`
80+
Posthog *PosthogIntegration `yaml:"posthog,omitempty" json:"posthog,omitempty"`
8081
}
8182

8283
type GA4Integration struct {
8384
MeasurementId string `yaml:"measurementId" json:"measurementId"`
8485
}
8586

87+
type PosthogIntegration struct {
88+
ApiKey string `yaml:"apiKey" json:"apiKey"`
89+
ApiHost *string `yaml:"apiHost,omitempty" json:"apiHost,omitempty"`
90+
SessionRecording *bool `yaml:"sessionRecording,omitempty" json:"sessionRecording,omitempty"`
91+
}
92+
8693
type SEO struct {
8794
Metatags map[string]string `yaml:"metatags,omitempty" json:"metatags,omitempty"`
8895
Indexing string `yaml:"indexing,omitempty" json:"indexing,omitempty"`
@@ -238,6 +245,9 @@ func main() {
238245
return
239246
}
240247

248+
// Process integrations with defaults
249+
processedIntegrations := processIntegrations(mergedConfig.Integrations)
250+
241251
// Generate Mintlify config
242252
mintlifyConfig := MintlifyConfig{
243253
Schema: mergedConfig.Schema,
@@ -255,7 +265,7 @@ func main() {
255265
Errors: mergedConfig.Errors,
256266
Navbar: mergedConfig.Navbar,
257267
Footer: mergedConfig.Footer,
258-
Integrations: mergedConfig.Integrations,
268+
Integrations: processedIntegrations,
259269
Redirects: mergedConfig.Redirects,
260270
Navigation: MintlifyNavigation{
261271
Global: mergedConfig.Navigation.Global,
@@ -608,6 +618,30 @@ func validateAgainstSchema(jsonData []byte, schemaURL string) error {
608618
return nil
609619
}
610620

621+
// processIntegrations processes integrations and sets default values
622+
func processIntegrations(integrations *Integrations) *Integrations {
623+
if integrations == nil {
624+
return nil
625+
}
626+
627+
// Create a copy to avoid modifying the original
628+
processed := &Integrations{
629+
GA4: integrations.GA4,
630+
Posthog: integrations.Posthog,
631+
}
632+
633+
// Set PostHog defaults
634+
if processed.Posthog != nil {
635+
// Default sessionRecording to true if not specified
636+
if processed.Posthog.SessionRecording == nil {
637+
defaultSessionRecording := true
638+
processed.Posthog.SessionRecording = &defaultSessionRecording
639+
}
640+
}
641+
642+
return processed
643+
}
644+
611645
// processManualPages processes manually defined pages and subgroups
612646
func processManualPages(pageEntries []PageEntry, basePath string) (interface{}, error) {
613647
var pages []interface{}

0 commit comments

Comments
 (0)