diff --git a/fern/apis/fdr/definition/docs/v1/commons/commons.yml b/fern/apis/fdr/definition/docs/v1/commons/commons.yml index 10f0d9f565..24bbf26eab 100644 --- a/fern/apis/fdr/definition/docs/v1/commons/commons.yml +++ b/fern/apis/fdr/definition/docs/v1/commons/commons.yml @@ -39,6 +39,14 @@ types: - ts - js + AnalyticsConfig: + properties: + segment: optional + + SegmentConfig: + properties: + writeKey: string + DocsLayoutConfig: properties: pageWidth: optional diff --git a/fern/apis/fdr/definition/docs/v1/db/__package__.yml b/fern/apis/fdr/definition/docs/v1/db/__package__.yml index 18896b50c0..cf602bf2ab 100644 --- a/fern/apis/fdr/definition/docs/v1/db/__package__.yml +++ b/fern/apis/fdr/definition/docs/v1/db/__package__.yml @@ -50,6 +50,8 @@ types: title: optional defaultLanguage: optional + analyticsConfig: optional + # navigation navigation: NavigationConfig navbarLinks: optional> diff --git a/fern/apis/fdr/definition/docs/v1/read/__package__.yml b/fern/apis/fdr/definition/docs/v1/read/__package__.yml index f455267001..c8f924e7b0 100644 --- a/fern/apis/fdr/definition/docs/v1/read/__package__.yml +++ b/fern/apis/fdr/definition/docs/v1/read/__package__.yml @@ -87,6 +87,8 @@ types: title: optional defaultLanguage: optional + analyticsConfig: optional + # navigation navigation: NavigationConfig navbarLinks: optional> diff --git a/fern/apis/fdr/definition/docs/v1/write/__package__.yml b/fern/apis/fdr/definition/docs/v1/write/__package__.yml index 88dd239222..1b97902788 100644 --- a/fern/apis/fdr/definition/docs/v1/write/__package__.yml +++ b/fern/apis/fdr/definition/docs/v1/write/__package__.yml @@ -83,6 +83,8 @@ types: title: optional defaultLanguage: optional + analyticsConfig: optional + # navigation navigation: NavigationConfig navbarLinks: optional> diff --git a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/AnalyticsConfig.ts b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/AnalyticsConfig.ts new file mode 100644 index 0000000000..4924d2ac87 --- /dev/null +++ b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/AnalyticsConfig.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as FernRegistry from "../../../../../../../../../index"; + +export interface AnalyticsConfig { + segment?: FernRegistry.docs.v1.commons.SegmentConfig; +} diff --git a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/SegmentConfig.ts b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/SegmentConfig.ts new file mode 100644 index 0000000000..f9bdb454bd --- /dev/null +++ b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/SegmentConfig.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface SegmentConfig { + writeKey: string; +} diff --git a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/index.ts b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/index.ts index a4a0d72158..e4647c643c 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/index.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/commons/resources/commons/types/index.ts @@ -8,6 +8,8 @@ export * from "./WebhookId"; export * from "./FileIdOrUrl"; export * from "./RgbaColor"; export * from "./ProgrammingLanguage"; +export * from "./AnalyticsConfig"; +export * from "./SegmentConfig"; export * from "./DocsLayoutConfig"; export * from "./SearchbarPlacement"; export * from "./TabsPlacement"; diff --git a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/db/types/DocsDbConfig.ts b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/db/types/DocsDbConfig.ts index d4e6f93349..bcf2cff85b 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/db/types/DocsDbConfig.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/db/types/DocsDbConfig.ts @@ -7,6 +7,7 @@ import * as FernRegistry from "../../../../../../../index"; export interface DocsDbConfig { title?: string; defaultLanguage?: FernRegistry.docs.v1.commons.ProgrammingLanguage; + analyticsConfig?: FernRegistry.docs.v1.commons.AnalyticsConfig; navigation: FernRegistry.docs.v1.db.NavigationConfig; navbarLinks?: FernRegistry.docs.v1.commons.NavbarLink[]; footerLinks?: FernRegistry.docs.v1.commons.FooterLink[]; diff --git a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/read/types/DocsConfig.ts b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/read/types/DocsConfig.ts index d7e03b91bc..c0f7400d72 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/read/types/DocsConfig.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/read/types/DocsConfig.ts @@ -7,6 +7,7 @@ import * as FernRegistry from "../../../../../../../index"; export interface DocsConfig { title?: string; defaultLanguage?: FernRegistry.docs.v1.commons.ProgrammingLanguage; + analyticsConfig?: FernRegistry.docs.v1.commons.AnalyticsConfig; navigation: FernRegistry.docs.v1.read.NavigationConfig; navbarLinks?: FernRegistry.docs.v1.commons.NavbarLink[]; footerLinks?: FernRegistry.docs.v1.commons.FooterLink[]; diff --git a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/types/DocsConfig.ts b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/types/DocsConfig.ts index 0f3b43bd26..39aaadbd15 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/types/DocsConfig.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/docs/resources/v1/resources/write/types/DocsConfig.ts @@ -7,6 +7,7 @@ import * as FernRegistry from "../../../../../../../index"; export interface DocsConfig { title?: string; defaultLanguage?: FernRegistry.docs.v1.commons.ProgrammingLanguage; + analyticsConfig?: FernRegistry.docs.v1.commons.AnalyticsConfig; navigation: FernRegistry.docs.v1.write.NavigationConfig; navbarLinks?: FernRegistry.docs.v1.commons.NavbarLink[]; footerLinks?: FernRegistry.docs.v1.commons.FooterLink[]; diff --git a/packages/fdr-sdk/src/converters/db/convertDocsDefinitionToDb.ts b/packages/fdr-sdk/src/converters/db/convertDocsDefinitionToDb.ts index c06538e15c..6a85e66c11 100644 --- a/packages/fdr-sdk/src/converters/db/convertDocsDefinitionToDb.ts +++ b/packages/fdr-sdk/src/converters/db/convertDocsDefinitionToDb.ts @@ -108,6 +108,7 @@ export function convertDocsDefinitionToDb({ redirects: writeShape.config.redirects, integrations: writeShape.config.integrations, defaultLanguage: writeShape.config.defaultLanguage, + analyticsConfig: writeShape.config.analyticsConfig, }, pages: writeShape.pages, jsFiles: writeShape.jsFiles, diff --git a/packages/fdr-sdk/src/converters/read/convertDbDocsConfigToRead.ts b/packages/fdr-sdk/src/converters/read/convertDbDocsConfigToRead.ts index 03af673831..6ce36e375d 100644 --- a/packages/fdr-sdk/src/converters/read/convertDbDocsConfigToRead.ts +++ b/packages/fdr-sdk/src/converters/read/convertDbDocsConfigToRead.ts @@ -28,6 +28,7 @@ export function convertDbDocsConfigToRead({ redirects: dbShape.redirects, integrations: dbShape.integrations, defaultLanguage: dbShape.defaultLanguage, + analyticsConfig: dbShape.analyticsConfig, }; } diff --git a/packages/ui/app/src/analytics/CustomerAnalytics.tsx b/packages/ui/app/src/analytics/CustomerAnalytics.tsx index 875f66acb8..ee8e3f0632 100644 --- a/packages/ui/app/src/analytics/CustomerAnalytics.tsx +++ b/packages/ui/app/src/analytics/CustomerAnalytics.tsx @@ -2,16 +2,28 @@ import { GoogleAnalytics } from "@next/third-parties/google"; import { useAtomValue } from "jotai"; import { selectAtom } from "jotai/utils"; import { isEqual } from "lodash-es"; +import Script from "next/script"; import { ReactElement, memo } from "react"; -import { DOCS_ATOM } from "../atoms"; +import { DOCS_ATOM, DOMAIN_ATOM } from "../atoms"; import { GoogleTagManager } from "./GoogleTagManager"; +import { renderSegmentSnippet } from "./segment"; const ANALYTICS_ATOM = selectAtom(DOCS_ATOM, (docs) => docs.analytics ?? {}, isEqual); +const ANALYTICS_CONFIG_ATOM = selectAtom(DOCS_ATOM, (docs) => docs.analyticsConfig ?? {}, isEqual); export const CustomerAnalytics = memo(function CustomerAnalytics(): ReactElement | null { + const domain = useAtomValue(DOMAIN_ATOM); const { ga4, gtm } = useAtomValue(ANALYTICS_ATOM); + const { segment } = useAtomValue(ANALYTICS_CONFIG_ATOM); return ( <> + {/* renders either segment with our write key or segment with the customer's write key */} +