2021-09-26 21:55:27 +00:00
|
|
|
import { IdProvider } from "@radix-ui/react-id";
|
2021-09-27 14:47:55 +00:00
|
|
|
import { httpBatchLink } from "@trpc/client/links/httpBatchLink";
|
|
|
|
import { loggerLink } from "@trpc/client/links/loggerLink";
|
|
|
|
import { withTRPC } from "@trpc/next";
|
2021-08-27 12:11:24 +00:00
|
|
|
import { Provider } from "next-auth/client";
|
2021-09-27 14:47:55 +00:00
|
|
|
import { AppProps } from "next/dist/shared/lib/router/router";
|
2021-09-22 19:52:38 +00:00
|
|
|
import React from "react";
|
2021-08-27 12:11:24 +00:00
|
|
|
|
2021-09-24 20:02:03 +00:00
|
|
|
import DynamicIntercomProvider from "@ee/lib/intercom/providerDynamic";
|
|
|
|
|
2021-09-22 19:52:38 +00:00
|
|
|
import { createTelemetryClient, TelemetryProvider } from "@lib/telemetry";
|
|
|
|
|
2021-09-27 14:47:55 +00:00
|
|
|
const AppProviders = (props: AppProps) => {
|
2021-08-27 12:11:24 +00:00
|
|
|
return (
|
|
|
|
<TelemetryProvider value={createTelemetryClient()}>
|
2021-09-27 14:47:55 +00:00
|
|
|
<IdProvider>
|
|
|
|
<DynamicIntercomProvider>
|
|
|
|
<Provider session={props.pageProps.session}>{props.children}</Provider>
|
|
|
|
</DynamicIntercomProvider>
|
|
|
|
</IdProvider>
|
2021-08-27 12:11:24 +00:00
|
|
|
</TelemetryProvider>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2021-09-27 14:47:55 +00:00
|
|
|
export default withTRPC({
|
|
|
|
config() {
|
|
|
|
/**
|
|
|
|
* If you want to use SSR, you need to use the server's full URL
|
|
|
|
* @link https://trpc.io/docs/ssr
|
|
|
|
*/
|
|
|
|
return {
|
|
|
|
/**
|
|
|
|
* @link https://trpc.io/docs/links
|
|
|
|
*/
|
|
|
|
links: [
|
|
|
|
// adds pretty logs to your console in development and logs errors in production
|
|
|
|
loggerLink({
|
|
|
|
enabled: (opts) =>
|
|
|
|
process.env.NODE_ENV === "development" ||
|
|
|
|
(opts.direction === "down" && opts.result instanceof Error),
|
|
|
|
}),
|
|
|
|
httpBatchLink({
|
|
|
|
url: `/api/trpc`,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
/**
|
|
|
|
* @link https://react-query.tanstack.com/reference/QueryClient
|
|
|
|
*/
|
|
|
|
// queryClientConfig: { defaultOptions: { queries: { staleTime: 6000 } } },
|
|
|
|
};
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* @link https://trpc.io/docs/ssr
|
|
|
|
*/
|
|
|
|
ssr: false,
|
|
|
|
})(AppProviders);
|