Runs every 1 days
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
34
35
import { fetch } from "https://esm.town/v/std/fetch";
import { set } from "https://esm.town/v/std/set?v=11";
import { postHogAPICapture } from "https://esm.town/v/ianvph/postHogAPICapture";
import { email } from "https://esm.town/v/ianvph/email";
import { phProjectAPIKey } from "https://esm.town/v/ianvph/phProjectAPIKey";
import { newestReleaseId } from "https://esm.town/v/ianvph/newestReleaseId";
import { parseXML } from "https://esm.town/v/stevekrouse/parseXML?v=1";
export async function gitHubReleaseTracker() {
// gets newest release from github
const githubProject = "https://github.com/posthog/posthog";
const response = await fetch(`${githubProject}/releases.atom`);
const newestEntry =
(await parseXML(await response.text())).feed
.entry[0];
// checks if different from last release
if (newestEntry.id == newestReleaseId) {
return "old release";
}
// captures event to posthog if so
const properties = {
title: newestEntry.title,
release_date: newestEntry.updated,
author: newestEntry.author.name,
};
const captureData = {
key: phProjectAPIKey,
event: "new release",
properties: properties,
distinct_id: email,
};
postHogAPICapture(captureData);
await set("newestReleaseId", newestEntry.id);
return "new release captured";
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
v29
October 23, 2023