Runs every 1 hrs
Fork
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
36
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 { newestStatusGuid } from "https://esm.town/v/ianvph/newestStatusGuid";
import { parseXML } from "https://esm.town/v/stevekrouse/parseXML?v=1";
export async function posthogStatusTracker() {
// gets newest status update from rss feed
const statusRSSLink = "https://status.posthog.com/history.rss";
const response = await fetch(statusRSSLink);
const newestEntry =
(await parseXML(await response.text())).rss.channel
.item[0];
// checks if different from last status captured
console.log(newestEntry);
if (newestEntry.guid == newestStatusGuid) {
return "old status";
}
// captures event to posthog if so
const properties = {
title: newestEntry.title,
published_date: newestEntry.pubDate,
link: newestEntry.link,
};
const captureData = {
key: phProjectAPIKey,
event: "posthog status update",
properties: properties,
distinct_id: email,
};
postHogAPICapture(captureData);
await set("newestStatusGuid", newestEntry.guid);
return "posthog status update captured";
}