feat: replace sentry with posthog
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import posthog from "posthog-js";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { checkEnkaStatus, submitArtifact } from "@/lib/api";
|
||||
@@ -38,6 +39,10 @@ export function ArtifactFormWrapper({
|
||||
setDataHold(data);
|
||||
if (check) return setDialog(check);
|
||||
}
|
||||
posthog.capture("artifact_submitted", {
|
||||
character: data.get("character")?.toString(),
|
||||
is_edit: !!edit,
|
||||
});
|
||||
submitArtifact(data, edit)
|
||||
.then((q) => {
|
||||
if (typeof q === "string") return toast.error(q);
|
||||
|
||||
@@ -2,7 +2,6 @@ import { ViewTransition } from "react";
|
||||
import { Toaster } from "sonner";
|
||||
import Background from "#/bg.webp";
|
||||
import Image from "@/components/image";
|
||||
import { SentryDevToolbar } from "@/components/sentry";
|
||||
import { StarsRenderer } from "@/components/stars";
|
||||
import Providers, { VersionCheck } from "../client";
|
||||
import { Navbar } from "./navbar";
|
||||
@@ -23,7 +22,6 @@ export default async function UiLayout({
|
||||
<Providers>
|
||||
<ViewTransition>{children}</ViewTransition>
|
||||
<VersionCheck />
|
||||
<SentryDevToolbar />
|
||||
<Navbar />
|
||||
</Providers>
|
||||
<Toaster theme="dark" richColors closeButton />
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { Loader2, UserLock } from "lucide-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import posthog from "posthog-js";
|
||||
import { type FormEvent, use, useEffect, useState } from "react";
|
||||
import { useSessionStorage } from "react-use";
|
||||
import { toast } from "sonner";
|
||||
@@ -68,13 +69,18 @@ export default function LoginPage({
|
||||
.catch(() => toast.error("Failed to login"));
|
||||
if (typeof r !== "object") {
|
||||
setLoading(false);
|
||||
posthog.capture("login_failed", { reason: "invalid_response" });
|
||||
return toast.error("Invalid email or password");
|
||||
}
|
||||
if (r.error) {
|
||||
setLoading(false);
|
||||
setFailed(failed + 1);
|
||||
posthog.capture("login_failed", { reason: r.error.message });
|
||||
return toast.error(r.error.message);
|
||||
}
|
||||
const email = (data.get("email") as string) || "";
|
||||
posthog.identify(r.data?.user?.id || email, { email });
|
||||
posthog.capture("user_logged_in", { email });
|
||||
router.push(cb);
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
+16
-1
@@ -19,6 +19,7 @@ import {
|
||||
settings,
|
||||
} from "@/lib/db/schema";
|
||||
import { sse } from "@/lib/db/sse-endpoints";
|
||||
import { getPostHogClient } from "@/lib/posthog-server";
|
||||
import type { TypedFormData } from "./type";
|
||||
|
||||
const {
|
||||
@@ -227,6 +228,11 @@ export async function submitEndgame(formData: EndgameFormData) {
|
||||
.returning({ queue: endgameSubmissions.queue, id: endgameSubmissions.id });
|
||||
revalidatePath("/rubgram/admin");
|
||||
sse.rubgram.pub("update", { type: "submit", sub: queue.id });
|
||||
getPostHogClient().capture({
|
||||
distinctId: user,
|
||||
event: "rubgram_registration_completed",
|
||||
properties: { queue_position: queue.queue, server, services: service },
|
||||
});
|
||||
return queue;
|
||||
}
|
||||
|
||||
@@ -296,8 +302,17 @@ export async function submitEndgamePayment(formData: EndgamePaymentFormData) {
|
||||
.where(eq(endgameSubmissions.id, sid));
|
||||
});
|
||||
revalidatePath("/rubgram/admin");
|
||||
if (Array.isArray(queue))
|
||||
if (Array.isArray(queue)) {
|
||||
sse.rubgram.pub("update", { type: "paid", sub: queue[0].id });
|
||||
getPostHogClient().capture({
|
||||
distinctId: sid,
|
||||
event: "rubgram_payment_completed",
|
||||
properties: {
|
||||
submission_id: queue[0].id,
|
||||
queue_position: queue[0].queue,
|
||||
},
|
||||
});
|
||||
}
|
||||
return Array.isArray(queue) ? queue[0] : queue;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { ArrowRight, Check, Download, LogIn, ScrollText } from "lucide-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import posthog from "posthog-js";
|
||||
import { type ReactNode, useEffect, useRef, useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { Blocker } from "@/components/blocker";
|
||||
@@ -61,7 +62,12 @@ export function WelcomeScreening({
|
||||
) : (
|
||||
<div className="grid gap-2">
|
||||
โปรดล็อคอินผ่าน Discord เพื่อดำเนินการต่อ
|
||||
<Button onClick={loginDiscord}>
|
||||
<Button
|
||||
onClick={() => {
|
||||
posthog.capture("rubgram_discord_login_initiated");
|
||||
loginDiscord();
|
||||
}}
|
||||
>
|
||||
<span className="flex justify-between w-full items-center">
|
||||
ล็อคอินผ่าน Discord
|
||||
<LogIn />
|
||||
@@ -240,6 +246,7 @@ export function CancelButton({ sid }: { sid: string }) {
|
||||
variant="destructive"
|
||||
onClick={() => {
|
||||
setLoading(true);
|
||||
posthog.capture("rubgram_cancelled", { sid });
|
||||
cancel(sid).then(() => toast.success("คิวยกเลิกแล้ว"));
|
||||
setServices([]);
|
||||
}}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useProgress } from "@bprogress/next";
|
||||
import { useRouter } from "next/navigation";
|
||||
import posthog from "posthog-js";
|
||||
import { toast } from "sonner";
|
||||
import {
|
||||
type EndgameFormData,
|
||||
@@ -18,6 +19,11 @@ export function EndgameFormWrapper({
|
||||
const { start, stop } = useProgress();
|
||||
async function submit(data: FormData) {
|
||||
start();
|
||||
posthog.capture(
|
||||
type === "registration"
|
||||
? "rubgram_registration_submitted"
|
||||
: "rubgram_payment_submitted",
|
||||
);
|
||||
|
||||
({ registration: submitEndgame, payment: submitEndgamePayment })
|
||||
[type](data as unknown as EndgameFormData & EndgamePaymentFormData)
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
X,
|
||||
} from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import posthog from "posthog-js";
|
||||
import {
|
||||
Fragment,
|
||||
type ReactNode,
|
||||
@@ -333,6 +334,12 @@ export function TierList({
|
||||
}
|
||||
|
||||
setPlacements(newPlacements);
|
||||
posthog.capture("tierlist_character_placed", {
|
||||
character_id: charId.split("#")[0],
|
||||
target_cell: typeof over.id === "string" ? over.id : undefined,
|
||||
tierlist_version: version.id,
|
||||
tierlist_type: type.id,
|
||||
});
|
||||
setEvStatus((x) => ({ ...x, upload: true }));
|
||||
tlPlacements(version.id, newPlacements)
|
||||
.catch((e) => toast.error(`Sync ล้มเหลว: ${e.message || e}`))
|
||||
|
||||
Reference in New Issue
Block a user