Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

refactor(web): remove Intercom components and API endpoint

Richie McIlroy0dc3668ed147
diff --git a/apps/web/app/Layout/Intercom/Client.tsx b/apps/web/app/Layout/Intercom/Client.tsx
deleted file mode 100644
index fc469aea2..000000000
--- a/apps/web/app/Layout/Intercom/Client.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-"use client";
-
-import Intercom from "@intercom/messenger-js-sdk";
-import { usePathname } from "next/navigation";
-import { useEffect } from "react";
-import { useCurrentUser } from "../AuthContext";
-
-export function Client(props: { hash?: string }) {
- const user = useCurrentUser();
- const pathname = usePathname();
- const isSharePage = pathname?.startsWith("/s/");
- const isBlogPage = pathname?.startsWith("/blog");
-
- useEffect(() => {
- if (!isSharePage && !isBlogPage) {
- if (props.hash && user) {
- Intercom({
- app_id: "efxq71cv",
- user_id: user.id,
- user_hash: props.hash,
- name: user.name ?? "",
- email: user.email,
- utm_source: "web",
- });
- } else {
- Intercom({
- app_id: "efxq71cv",
- utm_source: "web",
- });
- }
- }
- }, [props.hash, user, isBlogPage, isSharePage]);
-
- return null;
-}
diff --git a/apps/web/app/Layout/Intercom/index.tsx b/apps/web/app/Layout/Intercom/index.tsx
deleted file mode 100644
index 9f6b29133..000000000
--- a/apps/web/app/Layout/Intercom/index.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import { createHmac } from "node:crypto";
-import { getCurrentUser } from "@cap/database/auth/session";
-import { serverEnv } from "@cap/env";
-import { Suspense } from "react";
-import { Client } from "./Client";
-
-async function IntercomInner() {
- const user = await getCurrentUser();
-
- const intercomSecret = serverEnv().INTERCOM_SECRET;
- let hash;
- if (intercomSecret && user)
- hash = createHmac("sha256", intercomSecret).update(user.id).digest("hex");
-
- return <Client hash={hash} />;
-}
-
-export async function Intercom() {
- return (
- <Suspense>
- <IntercomInner />
- </Suspense>
- );
-}
diff --git a/apps/web/app/api/desktop/[...route]/root.ts b/apps/web/app/api/desktop/[...route]/root.ts
index 955aa7041..5216a3198 100644
--- a/apps/web/app/api/desktop/[...route]/root.ts
+++ b/apps/web/app/api/desktop/[...route]/root.ts
@@ -1,4 +1,3 @@
-import * as crypto from "node:crypto";
import { db } from "@cap/database";
import { sendEmail } from "@cap/database/emails/config";
import { Feedback } from "@cap/database/emails/feedback";
@@ -344,19 +343,9 @@ app.get("/plan", withAuth, async (c) => {
}
}
- let intercomHash = "";
- const intercomSecret = serverEnv().INTERCOM_SECRET;
- if (intercomSecret) {
- intercomHash = crypto
- .createHmac("sha256", intercomSecret)
- .update(user?.id ?? "")
- .digest("hex");
- }
-
return c.json({
upgraded: isSubscribed,
stripeSubscriptionStatus: user.stripeSubscriptionStatus,
- intercomHash: intercomHash,
});
});