Skip to content

Commit

Permalink
remove circular deps
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity committed Dec 19, 2024
1 parent 2424a8b commit 7d29ebf
Show file tree
Hide file tree
Showing 48 changed files with 212 additions and 237 deletions.
8 changes: 4 additions & 4 deletions packages/ui/app/src/analytics/amplitude.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as amplitude from "@amplitude/analytics-browser";
import { init, track } from "@amplitude/analytics-browser";
import { ReactNode, useEffect } from "react";
import { useSafeListenTrackEvents } from "./track";

export default function AmplitudeScript({ apiKey }: { apiKey: string }): ReactNode {
export function AmplitudeScript({ apiKey }: { apiKey: string }): ReactNode {
useEffect(() => {
try {
amplitude.init(apiKey, undefined, {
init(apiKey, undefined, {
autocapture: true,
});
} catch (e) {
Expand All @@ -15,7 +15,7 @@ export default function AmplitudeScript({ apiKey }: { apiKey: string }): ReactNo
}, [apiKey]);

useSafeListenTrackEvents(({ event, properties }) => {
amplitude.track(event, properties);
track(event, properties);
});

return false;
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/app/src/analytics/clearbit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Script from "next/script";
import { ReactNode } from "react";

// TODO: send events to clearbit
export default function ClearbitScript({ apiKey }: { apiKey: string }): ReactNode {
export function ClearbitScript({ apiKey }: { apiKey: string }): ReactNode {
return (
<Script
id="clearbit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,24 @@ declare global {
}
}

const AmplitudeScript = dynamic(() => import("./amplitude").then((mod) => mod.default), { ssr: true });
const ClearbitScript = dynamic(() => import("./clearbit").then((mod) => mod.default), { ssr: true });
const AmplitudeScript = dynamic(() => import("./amplitude").then((mod) => mod.AmplitudeScript), { ssr: true });
const ClearbitScript = dynamic(() => import("./clearbit").then((mod) => mod.ClearbitScript), { ssr: true });
const CustomerPosthogScript = dynamic(() => import("./posthog").then((mod) => mod.CustomerPosthog), { ssr: true });
const DatadogRumScript = dynamic(() => import("./datadog-rum").then((mod) => mod.default), { ssr: true });
const DatadogRumScript = dynamic(() => import("./datadog-rum").then((mod) => mod.DatadogRumScript), { ssr: true });
const FathomScript = dynamic(() => import("./fathom").then((mod) => mod.FathomScript), { ssr: true });
const FullstoryScript = dynamic(() => import("./fullstory").then((mod) => mod.default), { ssr: true });
const GoogleAnalytics = dynamic(() => import("./ga").then((mod) => mod.default), {
ssr: true,
});
const GoogleTagManager = dynamic(() => import("./gtm").then((mod) => mod.default), {
ssr: true,
});
const HeapScript = dynamic(() => import("./heap").then((mod) => mod.default), { ssr: true });
const HotjarScript = dynamic(() => import("./hotjar").then((mod) => mod.default), { ssr: true });
const IntercomScript = dynamic(() => import("./intercom").then((mod) => mod.default), { ssr: true });
const KoalaScript = dynamic(() => import("./koala").then((mod) => mod.default), { ssr: true });
const LogRocketScript = dynamic(() => import("./logrocket").then((mod) => mod.default), { ssr: true });
const MixpanelScript = dynamic(() => import("./mixpanel").then((mod) => mod.default), { ssr: true });
const PirschScript = dynamic(() => import("./pirsch").then((mod) => mod.default), { ssr: true });
const PlausibleScript = dynamic(() => import("./plausible").then((mod) => mod.default), { ssr: true });
const PosthogScript = dynamic(() => import("./posthog").then((mod) => mod.default), { ssr: true });
const SegmentScript = dynamic(() => import("./segment").then((mod) => mod.default), { ssr: true });
const FullstoryScript = dynamic(() => import("./fullstory").then((mod) => mod.FullstoryScript), { ssr: true });
const GoogleAnalytics = dynamic(() => import("./ga").then((mod) => mod.GoogleAnalytics), { ssr: true });
const GoogleTagManager = dynamic(() => import("./gtm").then((mod) => mod.GoogleTagManager), { ssr: true });
const HeapScript = dynamic(() => import("./heap").then((mod) => mod.HeapScript), { ssr: true });
const HotjarScript = dynamic(() => import("./hotjar").then((mod) => mod.HotjarScript), { ssr: true });
const IntercomScript = dynamic(() => import("./intercom").then((mod) => mod.IntercomScript), { ssr: true });
const KoalaScript = dynamic(() => import("./koala").then((mod) => mod.KoalaScript), { ssr: true });
const LogRocketScript = dynamic(() => import("./logrocket").then((mod) => mod.LogRocketScript), { ssr: true });
const MixpanelScript = dynamic(() => import("./mixpanel").then((mod) => mod.MixpanelScript), { ssr: true });
const PirschScript = dynamic(() => import("./pirsch").then((mod) => mod.PirschScript), { ssr: true });
const PlausibleScript = dynamic(() => import("./plausible").then((mod) => mod.PlausibleScript), { ssr: true });
const PosthogScript = dynamic(() => import("./posthog").then((mod) => mod.Posthog), { ssr: true });
const SegmentScript = dynamic(() => import("./segment").then((mod) => mod.SegmentScript), { ssr: true });

export const CustomerAnalytics = memo(function CustomerAnalytics(): ReactElement | null {
const config = useAnalyticsConfig();
Expand Down Expand Up @@ -68,5 +64,3 @@ export const CustomerAnalytics = memo(function CustomerAnalytics(): ReactElement
</>
);
});

export { track, trackInternal } from "./track";
2 changes: 1 addition & 1 deletion packages/ui/app/src/analytics/datadog-rum.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ReactNode, useEffect } from "react";
import { useFernUser } from "../atoms";
import { useSafeListenTrackEvents } from "./track";

export default function DatadogRumScript(props: RumInitConfiguration): ReactNode {
export function DatadogRumScript(props: RumInitConfiguration): ReactNode {
useEffect(() => {
datadogRum.init(props);
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/app/src/analytics/fullstory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ReactNode, useEffect } from "react";
import { useFernUser } from "../atoms";
import { useSafeListenTrackEvents } from "./track";

export default function FullstoryScript(props: { orgId: string }): ReactNode {
export function FullstoryScript(props: { orgId: string }): ReactNode {
useSafeListenTrackEvents(({ event, properties }) => {
if (typeof window.FS === "function") {
// https://developer.fullstory.com/browser/capture-events/analytics-events/
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/app/src/analytics/ga.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type GAParams = {
nonce?: string;
};

export default function GoogleAnalytics(props: GAParams): ReactNode {
export function GoogleAnalytics(props: GAParams): ReactNode {
const { gaId, debugMode, dataLayerName = "dataLayer", nonce } = props;
useEffect(() => {
// performance.mark is being used as a feature use signal. While it is traditionally used for performance
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/app/src/analytics/gtm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type GTMParams = {
nonce?: string;
};

export default function GoogleTagManager(props: GTMParams): ReactNode {
export function GoogleTagManager(props: GTMParams): ReactNode {
const { gtmId, dataLayerName = "dataLayer", nonce } = props;

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/app/src/analytics/heap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ReactNode, useEffect } from "react";
import { useFernUser } from "../atoms";
import { useSafeListenTrackEvents } from "./track";

export default function HeapScript({ appId }: { appId: string }): ReactNode {
export function HeapScript({ appId }: { appId: string }): ReactNode {
useSafeListenTrackEvents(({ event, properties }) => {
if (window.heap) {
window.heap.track(event, properties);
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/app/src/analytics/hotjar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useFernUser } from "../atoms";
import { useRouteChangeComplete } from "../hooks/useRouteChanged";
import { useSafeListenTrackEvents } from "./track";

export default function HotjarScript({ id, version }: { id: string; version: string }): ReactNode {
export function HotjarScript({ id, version }: { id: string; version: string }): ReactNode {
useEffect(() => {
Hotjar.init(Number(id), Number(version));
}, [id, version]);
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/app/src/analytics/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { CustomerAnalytics } from "./customer-analytics";
export { track, trackInternal } from "./track";
2 changes: 1 addition & 1 deletion packages/ui/app/src/analytics/intercom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface IntercomSettings {
installation_type?: string;
}

export default function IntercomScript(props: IntercomSettings): ReactElement {
export function IntercomScript(props: IntercomSettings): ReactElement {
useIntercomInitializer(props);
return <Script id="intercom" dangerouslySetInnerHTML={{ __html: widgetBootstrapScript(props.app_id) }} />;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/app/src/analytics/koala.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ReactNode, useEffect } from "react";
import { useFernUser } from "../atoms";
import { useSafeListenTrackEvents } from "./track";

export default function KoalaScript({ apiKey }: { apiKey: string }): ReactNode {
export function KoalaScript({ apiKey }: { apiKey: string }): ReactNode {
const user = useFernUser();

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/app/src/analytics/logrocket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import LogRocket from "logrocket";
import { ReactNode, useEffect } from "react";
import { useSafeListenTrackEvents } from "./track";

export default function LogRocketScript({ appId }: { appId: string }): ReactNode {
export function LogRocketScript({ appId }: { appId: string }): ReactNode {
useEffect(() => {
LogRocket.init(appId);
}, [appId]);
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/app/src/analytics/mixpanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ReactNode, useEffect } from "react";
import { useFernUser } from "../atoms";
import { useSafeListenTrackEvents } from "./track";

export default function MixpanelScript({ token }: { token: string }): ReactNode {
export function MixpanelScript({ token }: { token: string }): ReactNode {
useEffect(() => {
mixpanel.init(token, {
track_pageview: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/app/src/analytics/pirsch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import Script from "next/script";
import { ReactNode } from "react";

// TODO: send events to pirsch
export default function PirschScript({ identificationCode }: { identificationCode: string }): ReactNode {
export function PirschScript({ identificationCode }: { identificationCode: string }): ReactNode {
return <Script defer src="https://api.pirsch.io/pa.js" id="pianjs" data-code={identificationCode} />;
}
2 changes: 1 addition & 1 deletion packages/ui/app/src/analytics/plausible.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import Script from "next/script";
import { ReactNode } from "react";

// TODO: send events to plausible
export default function PlausibleScript({ domain }: { domain: string }): ReactNode {
export function PlausibleScript({ domain }: { domain: string }): ReactNode {
return <Script id="plausible" defer src="https://plausible.io/js/script.js" data-domain={domain} />;
}
2 changes: 1 addition & 1 deletion packages/ui/app/src/analytics/posthog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function posthogHasCustomer(instance: PostHog): instance is PostHogWithCustomer
return Boolean((instance as PostHogWithCustomer).customer);
}

export default function Posthog(): ReactNode {
export function Posthog(): ReactNode {
const route = useApiRoute("/api/fern-docs/analytics/posthog");

// initialize the posthog instance
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/app/src/analytics/segment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ReactNode, useEffect } from "react";
import { useFernUser } from "../atoms";
import { useSafeListenTrackEvents } from "./track";

export default function SegmentScript(props: snippet.Options): ReactNode {
export function SegmentScript(props: snippet.Options): ReactNode {
const user = useFernUser();

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type * as FernNavigation from "@fern-api/fdr-sdk/navigation";
import clsx from "clsx";
import { ReactElement, memo, useRef } from "react";
import { useHref } from "../hooks/useHref";
import { useHref } from "../atoms";
import { LayoutEvaluator } from "../layouts/LayoutEvaluator";
import { DocsContent } from "../resolver/DocsContent";
import { useApiPageCenterElement } from "./useApiPageCenterElement";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {
MOBILE_SIDEBAR_ENABLED_ATOM,
store,
useAtomEffect,
useHref,
} from "../../atoms";
import { useHref } from "../../hooks/useHref";
import { JsonPropertyPath } from "../examples/JsonPropertyPath";
import { useApiPageCenterElement } from "../useApiPageCenterElement";
import { EndpointContentHeader } from "./EndpointContentHeader";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import cn from "clsx";
import { compact } from "es-toolkit/array";
import { FC, PropsWithChildren, ReactNode, memo, useEffect, useRef, useState } from "react";
import { trackInternal } from "../../analytics";
import { useIsApiReferencePaginated, useRouteListener } from "../../atoms";
import { useHref, useIsApiReferencePaginated, useRouteListener } from "../../atoms";
import { FernAnchor } from "../../components/FernAnchor";
import { useHref } from "../../hooks/useHref";
import { Markdown } from "../../mdx/Markdown";
import { renderTypeShorthandRoot } from "../../type-shorthand";
import { getAnchorId } from "../../util/anchor";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type * as FernDocs from "@fern-api/fdr-sdk/docs";
import * as FernNavigation from "@fern-api/fdr-sdk/navigation";
import dynamic from "next/dynamic";
import { ReactNode, createElement, useRef } from "react";
import { useHref } from "../../atoms";
import { FernAnchor } from "../../components/FernAnchor";
import { FernErrorBoundary } from "../../components/FernErrorBoundary";
import { useHref } from "../../hooks/useHref";
import { getAnchorId } from "../../util/anchor";

const Markdown = dynamic(() => import("../../mdx/Markdown").then(({ Markdown }) => Markdown), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import cn from "clsx";
import { compact } from "es-toolkit/array";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { trackInternal } from "../../../analytics";
import { useIsApiReferencePaginated, useRouteListener } from "../../../atoms";
import { useHref, useIsApiReferencePaginated, useRouteListener } from "../../../atoms";
import { FernAnchor } from "../../../components/FernAnchor";
import { useHref } from "../../../hooks/useHref";
import { Markdown } from "../../../mdx/Markdown";
import { getAnchorId } from "../../../util/anchor";
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import cn from "clsx";
import { compact } from "es-toolkit/array";
import { forwardRef, memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
import { trackInternal } from "../../../analytics";
import { useIsApiReferencePaginated, useRouteListener } from "../../../atoms";
import { useHref, useIsApiReferencePaginated, useRouteListener } from "../../../atoms";
import { FernAnchor } from "../../../components/FernAnchor";
import { FernErrorBoundary } from "../../../components/FernErrorBoundary";
import { useHref } from "../../../hooks/useHref";
import { Markdown } from "../../../mdx/Markdown";
import { renderTypeShorthandRoot } from "../../../type-shorthand";
import { getAnchorId } from "../../../util/anchor";
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/app/src/api-reference/web-socket/WebSocket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { AvailabilityBadge } from "@fern-ui/components/badges";
import cn from "clsx";
import { ArrowDown, ArrowUp, Wifi } from "iconoir-react";
import { Children, FC, HTMLAttributes, ReactNode, useMemo, useRef } from "react";
import { useHref } from "../../atoms";
import { FernAnchor } from "../../components/FernAnchor";
import { FernBreadcrumbs } from "../../components/FernBreadcrumbs";
import { useHref } from "../../hooks/useHref";
import { Markdown } from "../../mdx/Markdown";
import { PlaygroundButton } from "../../playground/PlaygroundButton";
import { usePlaygroundBaseUrl } from "../../playground/utils/select-environment";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import * as ApiDefinition from "@fern-api/fdr-sdk/api-definition";
import * as FernNavigation from "@fern-api/fdr-sdk/navigation";
import cn from "clsx";
import { memo, useCallback, useRef } from "react";
import { useHref } from "../../atoms";
import { FernBreadcrumbs } from "../../components/FernBreadcrumbs";
import { useHref } from "../../hooks/useHref";
import { Markdown } from "../../mdx/Markdown";
import { EndpointParameter } from "../endpoints/EndpointParameter";
import { EndpointSection } from "../endpoints/EndpointSection";
Expand Down
1 change: 0 additions & 1 deletion packages/ui/app/src/atoms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export * from "./flags";
export * from "./hooks";
export * from "./lang";
export * from "./layout";
export * from "./location";
export * from "./logo";
export * from "./navigation";
export * from "./playground";
Expand Down
Loading

0 comments on commit 7d29ebf

Please sign in to comment.