Skip to content

Commit

Permalink
Merge pull request #125 from codelitdev/issue-122
Browse files Browse the repository at this point in the history
Added /config endpoint
  • Loading branch information
rajat1saxena authored Apr 11, 2024
2 parents 6009762 + 46e19c9 commit 27517d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
8 changes: 8 additions & 0 deletions apps/web/app/config/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const dynamic = "force-dynamic";

export function GET(request: Request, response: Response) {
return Response.json({
posthog: process.env.POSTHOG_ID,
crisp: process.env.CRISP_ID,
});
}
21 changes: 6 additions & 15 deletions apps/web/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,32 @@ export default async function RootLayout({
}: {
children: React.ReactNode;
}) {
const response = await fetch(`${process.env.AUTH_URL}/config`);
const result = await response.json();
return (
<html lang="en">
<head>
<Script strategy="lazyOnload" id="posthog-analytics">
{`
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys onSessionId".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init('phc_gUsiknwRdJTfxuwTvIXspsmHhg7idUnnoJ0zOHBs12d',{api_host:'https://app.posthog.com'})
posthog.init('${result.posthog}',{api_host:'https://app.posthog.com'})
`}
</Script>
<Script strategy="lazyOnload" id="posthog-session-recording">
{`
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys onSessionId".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init('phc_gUsiknwRdJTfxuwTvIXspsmHhg7idUnnoJ0zOHBs12d',{api_host:'https://app.posthog.com'})
posthog.init('${result.posthog}',{api_host:'https://app.posthog.com'})
`}
</Script>
<Script strategy="lazyOnload" id="posthog-survey">
{`
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys onSessionId".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init('phc_gUsiknwRdJTfxuwTvIXspsmHhg7idUnnoJ0zOHBs12d',{api_host:'https://app.posthog.com'})
`}
</Script>
<Script strategy="lazyOnload" id="microsoft-clarity">
{`
if (!window.location.host.includes('localhost')) {
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "khzsjjff0s");
}
posthog.init('${result.posthog}',{api_host:'https://app.posthog.com'})
`}
</Script>
<Script strategy="lazyOnload" id="crisp-chat">
{`
window.$crisp=[];window.CRISP_WEBSITE_ID="8048ca09-d44e-44a3-ad68-922fff5fd1fa";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();
window.$crisp=[];window.CRISP_WEBSITE_ID="${result.crisp}";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();
`}
</Script>
</head>
Expand Down

0 comments on commit 27517d4

Please sign in to comment.