-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RELEASE] - Release to 1.3.0 is coming! π (#12)
- Loading branch information
Showing
14 changed files
with
306 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
"use client"; | ||
|
||
import posthog from "posthog-js"; | ||
import { PostHogProvider as Provider } from "posthog-js/react"; | ||
import { usePathname, useSearchParams } from "next/navigation"; | ||
import { useEffect } from "react"; | ||
import { env } from "../env"; | ||
if (typeof window !== "undefined") { | ||
posthog.init(env.NEXT_PUBLIC_POSTHOG_KEY, { | ||
api_host: env.NEXT_PUBLIC_POSTHOG_HOST, | ||
capture_pageview: true, | ||
person_profiles: "always", | ||
autocapture: true, | ||
capture_heatmaps: true, | ||
}); | ||
} | ||
|
||
export default function PostHogProvider({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
const pathname = usePathname(); | ||
const searchParams = useSearchParams(); | ||
|
||
useEffect(() => { | ||
if (pathname) { | ||
let url = window.origin + pathname; | ||
if (searchParams?.toString()) { | ||
url = `${url}?${searchParams.toString()}`; | ||
} | ||
posthog.capture("$pageview", { | ||
$current_url: url, | ||
}); | ||
} | ||
}, [pathname, searchParams]); | ||
|
||
return <Provider client={posthog}>{children}</Provider>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,15 @@ | ||
"use client"; | ||
|
||
import posthog from "posthog-js"; | ||
import { PostHogProvider as Provider } from "posthog-js/react"; | ||
import { usePathname, useSearchParams } from "next/navigation"; | ||
import { useEffect } from "react"; | ||
import { env } from "../env"; | ||
if (typeof window !== "undefined") { | ||
posthog.init(env.NEXT_PUBLIC_POSTHOG_KEY, { | ||
api_host: env.NEXT_PUBLIC_POSTHOG_HOST, | ||
capture_pageview: true, | ||
person_profiles: "always", | ||
autocapture: true, | ||
capture_heatmaps: true, | ||
}); | ||
} | ||
|
||
export function PostHogProvider({ children }: { children: React.ReactNode }) { | ||
const pathname = usePathname(); | ||
const searchParams = useSearchParams(); | ||
|
||
useEffect(() => { | ||
if (pathname) { | ||
let url = window.origin + pathname; | ||
if (searchParams?.toString()) { | ||
url = url + `?${searchParams.toString()}`; | ||
} | ||
posthog.capture("$pageview", { | ||
$current_url: url, | ||
}); | ||
} | ||
}, [pathname, searchParams]); | ||
|
||
return <Provider client={posthog}>{children}</Provider>; | ||
} | ||
import PostHogProvider from "./PostHogProvider"; | ||
|
||
export const ClientProviders = ({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) => { | ||
return ( | ||
<> | ||
<PostHogProvider>{children}</PostHogProvider> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const typography = { | ||
h1: "text-2xl font-bold", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { NextResponse } from "next/server"; | ||
import { clerkClient } from "@clerk/nextjs/server"; | ||
|
||
export async function POST(req: Request) { | ||
try { | ||
const payload = await req.json(); | ||
|
||
// Verificar o evento do webhook | ||
if (payload.type === "user.created") { | ||
const userId = payload.data.id; | ||
|
||
// Atualizar os metadata do usuΓ‘rio | ||
await ( | ||
await clerkClient() | ||
).users.updateUser(userId, { | ||
publicMetadata: { | ||
stripeCustomerId: null, // Adicione isso quando integrar o Stripe | ||
subscriptionStatus: "free", // Defina o plano inicial como "free" | ||
}, | ||
}); | ||
|
||
return NextResponse.json({ | ||
message: "User metadata updated successfully", | ||
}); | ||
} | ||
|
||
return NextResponse.json( | ||
{ error: "Unhandled event type" }, | ||
{ status: 400 }, | ||
); | ||
} catch (error) { | ||
console.error("Erro ao processar webhook Clerk:", error); | ||
return NextResponse.json( | ||
{ error: "Internal Server Error" }, | ||
{ status: 500 }, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.