11import type { LinksFunction , LoaderFunctionArgs , MetaFunction } from "@remix-run/node" ;
22import type { ShouldRevalidateFunction } from "@remix-run/react" ;
33import { Links , LiveReload , Meta , Outlet , Scripts , ScrollRestoration } from "@remix-run/react" ;
4- import { UseDataFunctionReturn , typedjson , useTypedLoaderData } from "remix-typedjson" ;
4+ import { type UseDataFunctionReturn , typedjson , useTypedLoaderData } from "remix-typedjson" ;
55import { ExternalScripts } from "remix-utils/external-scripts" ;
6- import type { ToastMessage } from "~/models/message.server" ;
76import { commitSession , getSession } from "~/models/message.server" ;
7+ import type { ToastMessage } from "~/models/message.server" ;
88import tailwindStylesheetUrl from "~/tailwind.css" ;
99import { RouteErrorDisplay } from "./components/ErrorDisplay" ;
1010import { AppContainer , MainCenteredContainer } from "./components/layout/AppLayout" ;
@@ -14,6 +14,8 @@ import { featuresForRequest } from "./features.server";
1414import { usePostHog } from "./hooks/usePostHog" ;
1515import { getUser } from "./services/session.server" ;
1616import { appEnvTitleTag } from "./utils" ;
17+ import { type Handle } from "./utils/handle" ;
18+ import { useEffect } from "react" ;
1719
1820export const links : LinksFunction = ( ) => {
1921 return [ { rel : "stylesheet" , href : tailwindStylesheetUrl } ] ;
@@ -40,6 +42,10 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
4042 const posthogProjectKey = env . POSTHOG_PROJECT_KEY ;
4143 const features = featuresForRequest ( request ) ;
4244
45+ const kapa = {
46+ websiteId : env . KAPA_AI_WEBSITE_ID ,
47+ } ;
48+
4349 return typedjson (
4450 {
4551 user : await getUser ( request ) ,
@@ -48,6 +54,7 @@ export const loader = async ({ request }: LoaderFunctionArgs) => {
4854 features,
4955 appEnv : env . APP_ENV ,
5056 appOrigin : env . APP_ORIGIN ,
57+ kapa,
5158 } ,
5259 { headers : { "Set-Cookie" : await commitSession ( session ) } }
5360 ) ;
@@ -86,8 +93,8 @@ export function ErrorBoundary() {
8693 ) ;
8794}
8895
89- function App ( ) {
90- const { posthogProjectKey } = useTypedLoaderData < typeof loader > ( ) ;
96+ export default function App ( ) {
97+ const { posthogProjectKey, kapa , features } = useTypedLoaderData < typeof loader > ( ) ;
9198 usePostHog ( posthogProjectKey ) ;
9299
93100 return (
@@ -96,6 +103,17 @@ function App() {
96103 < head >
97104 < Meta />
98105 < Links />
106+ { features . isManagedCloud && (
107+ < script
108+ src = "/resources/kapa-widget"
109+ crossOrigin = "anonymous"
110+ async
111+ data-website-id = { kapa . websiteId }
112+ data-project-name = "Trigger.dev"
113+ data-project-color = "#ff9900"
114+ data-project-logo = "content.trigger.dev/trigger-logo-triangle.png"
115+ />
116+ ) }
99117 </ head >
100118 < body className = "bg-darkBackground h-full overflow-hidden" >
101119 < Outlet />
@@ -109,5 +127,3 @@ function App() {
109127 </ >
110128 ) ;
111129}
112-
113- export default App ;
0 commit comments