Public
HTTP
Forked from ianvph/posthogGitHubStarCapture
wallbreaker-posthoggithubstarcapture.web.val.run
June 11, 2024
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { capturePostHogEvent } from "https://esm.town/v/ianvph/capturePostHogEvent";
export default async function(req: Request): Promise<Response> {
if (req.method !== "POST") {
return Response.json({ ok: "only post request" });
}
const webhookPayload = await req.json();
if (webhookPayload.action !== "created") {
return Response.json({ ok: "only stars" });
}
console.log(webhookPayload);
const eventProperties = {
repository: webhookPayload.repository.full_name,
starred_at: webhookPayload.starred_at,
user: webhookPayload.sender.login,
user_id: webhookPayload.sender.id,
user_url: webhookPayload.sender.url,
avatar: webhookPayload.sender.avatar_url,
};
capturePostHogEvent(
Deno.env.get("phProjectAPIKey"),
webhookPayload.sender.login,
"GitHub Star",
eventProperties,
);
return Response.json({
ok: true,
});
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
June 11, 2024