diff --git a/packages/ui/app/src/api-reference/endpoints/EndpointParameter.tsx b/packages/ui/app/src/api-reference/endpoints/EndpointParameter.tsx index aa034deede..acfed70f46 100644 --- a/packages/ui/app/src/api-reference/endpoints/EndpointParameter.tsx +++ b/packages/ui/app/src/api-reference/endpoints/EndpointParameter.tsx @@ -5,7 +5,8 @@ import * as FernNavigation from "@fern-api/fdr-sdk/navigation"; import { EMPTY_ARRAY } from "@fern-api/ui-core-utils"; import cn from "clsx"; import { compact } from "lodash-es"; -import { FC, PropsWithChildren, ReactNode, memo, useRef, useState } from "react"; +import { FC, PropsWithChildren, ReactNode, memo, useEffect, useRef, useState } from "react"; +import { capturePosthogEvent } from "../../analytics/posthog"; import { useIsApiReferencePaginated, useRouteListener } from "../../atoms"; import { FernAnchor } from "../../components/FernAnchor"; import { useHref } from "../../hooks/useHref"; @@ -98,6 +99,21 @@ export const EndpointParameterContent: FC { + if (descriptions.length > 0) { + capturePosthogEvent("api_reference_multiple_descriptions", { + name, + slug, + anchorIdParts, + count: descriptions.length, + descriptions, + }); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [descriptions]); + return (
} - + {children}
); diff --git a/packages/ui/app/src/api-reference/types/discriminated-union/DiscriminatedUnionVariant.tsx b/packages/ui/app/src/api-reference/types/discriminated-union/DiscriminatedUnionVariant.tsx index 646c0075a8..3a3b16c6fb 100644 --- a/packages/ui/app/src/api-reference/types/discriminated-union/DiscriminatedUnionVariant.tsx +++ b/packages/ui/app/src/api-reference/types/discriminated-union/DiscriminatedUnionVariant.tsx @@ -4,7 +4,8 @@ import type * as FernNavigation from "@fern-api/fdr-sdk/navigation"; import titleCase from "@fern-api/ui-core-utils/titleCase"; import cn from "clsx"; import { compact } from "lodash-es"; -import { useCallback, useMemo } from "react"; +import { useCallback, useEffect, useMemo } from "react"; +import { capturePosthogEvent } from "../../../analytics/posthog"; import { Markdown } from "../../../mdx/Markdown"; import { EndpointAvailabilityTag } from "../../endpoints/EndpointAvailabilityTag"; import { @@ -33,7 +34,7 @@ export const DiscriminatedUnionVariant: React.FC { const { isRootTypeDefinition } = useTypeDefinitionContext(); - const [shape, descriptions] = useMemo((): [ApiDefinition.TypeShape.Object_, FernDocs.MarkdownText[]] => { + const [shape, additionalDescriptions] = useMemo((): [ApiDefinition.TypeShape.Object_, FernDocs.MarkdownText[]] => { const unwrapped = ApiDefinition.unwrapDiscriminatedUnionVariant({ discriminant }, unionVariant, types); return [ { @@ -62,6 +63,22 @@ export const DiscriminatedUnionVariant: React.FC { + if (descriptions.length > 0) { + capturePosthogEvent("api_reference_multiple_descriptions", { + slug, + anchorIdParts, + discriminant, + discriminantValue: unionVariant.discriminantValue, + count: descriptions.length, + descriptions, + }); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [descriptions]); + return (
)}
- + { + if (descriptions.length > 0) { + capturePosthogEvent("api_reference_multiple_descriptions", { + name: property.key, + slug, + anchorIdParts, + count: descriptions.length, + descriptions, + }); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [descriptions]); + return (
)} - + {hasInternalTypeReference(property.valueShape, types) && !hasInlineEnum(property.valueShape, types) && ( diff --git a/packages/ui/app/src/mdx/Markdown.tsx b/packages/ui/app/src/mdx/Markdown.tsx index 66cccd231d..dc2b53c2c1 100644 --- a/packages/ui/app/src/mdx/Markdown.tsx +++ b/packages/ui/app/src/mdx/Markdown.tsx @@ -7,7 +7,8 @@ export declare namespace Markdown { export interface Props { title?: ReactNode; - mdx: FernDocs.MarkdownText | FernDocs.MarkdownText[] | undefined; + // mdx: FernDocs.MarkdownText | FernDocs.MarkdownText[] | undefined; + mdx: FernDocs.MarkdownText | undefined; className?: string; size?: "xs" | "sm" | "lg"; @@ -20,7 +21,10 @@ export declare namespace Markdown { export const Markdown = memo(({ title, mdx, className, size, fallback }) => { // If the MDX is empty, return null - if (!fallback && (mdx == null || (typeof mdx === "string" && mdx.trim().length === 0))) { + if ( + !fallback && + (mdx == null || (typeof mdx === "string" ? mdx.trim().length === 0 : mdx.code.trim().length === 0)) + ) { return null; }