Versions

  • v9

    8/24/2023
    Open: Version
    Changes from v8 to v9
    +15
    -2
    ⦚ 4 unchanged lines ⦚
    "distinct_id": @me.email,
    };
    let result = await fetch("https://app.posthog.com/capture", {
    method: "POST",
    headers: {
    ⦚ 8 unchanged lines ⦚
    return result;
    }
    })();
    ⦚ 4 unchanged lines ⦚
    "distinct_id": @me.email,
    };
    let result = await fetch("https://app.posthog.com/capture/", {
    method: "POST",
    headers: {
    ⦚ 8 unchanged lines ⦚
    return result;
    }
    })();
    // POST https://[your-instance].com/capture/
    // Content-Type: application/json
    // Body:
    // {
    // "api_key": "<ph_project_api_key>",
    // "event": "[event name]",
    // "distinct_id": "[your users' distinct id]",
    // "properties": {
    // "key1": "value1",
    // "key2": "value2"
    // },
    // "timestamp": "[optional timestamp in ISO 8601 format]"
    // }
  • v8

    8/24/2023
    Open: Version
    Changes from v7 to v8
    +0
    -1
    ⦚ 11 unchanged lines ⦚
    body: JSON.stringify(body),
    }).then((r) => r.json());
    console.log("hi");
    if (result.error) {
    throw new Error("PH error " + result.error.message);
    }
    ⦚ 4 unchanged lines ⦚
    ⦚ 11 unchanged lines ⦚
    body: JSON.stringify(body),
    }).then((r) => r.json());
    if (result.error) {
    throw new Error("PH error " + result.error.message);
    }
    ⦚ 4 unchanged lines ⦚
  • v7

    8/24/2023
    Open: Version
    Changes from v6 to v7
    +1
    -1
    ⦚ 18 unchanged lines ⦚
    return result;
    }
    });
    ⦚ 18 unchanged lines ⦚
    return result;
    }
    })();
  • v6

    8/24/2023
    Open: Version
    Changes from v5 to v6
    +2
    -2
    async function postHogAPICapture() {
    const body = {
    "api_key": @me.phProjectAPIKey,
    ⦚ 15 unchanged lines ⦚
    return result;
    }
    }
    let postHogAPICapture = (async () => {
    const body = {
    "api_key": @me.phProjectAPIKey,
    ⦚ 15 unchanged lines ⦚
    return result;
    }
    });
  • v5

    8/24/2023
    Open: Version
    Changes from v4 to v5
    +0
    -0
    ⦚ 21 unchanged lines ⦚
    ⦚ 21 unchanged lines ⦚
  • v4

    8/24/2023
    Open: Version
    Changes from v3 to v4
    +1
    -0
    ⦚ 11 unchanged lines ⦚
    body: JSON.stringify(body),
    }).then((r) => r.json());
    if (result.error) {
    throw new Error("PH error " + result.error.message);
    }
    ⦚ 4 unchanged lines ⦚
    ⦚ 11 unchanged lines ⦚
    body: JSON.stringify(body),
    }).then((r) => r.json());
    console.log("hi");
    if (result.error) {
    throw new Error("PH error " + result.error.message);
    }
    ⦚ 4 unchanged lines ⦚
  • v3

    8/24/2023
    Open: Version
    Changes from v2 to v3
    +4
    -1
    ⦚ 6 unchanged lines ⦚
    let result = await fetch("https://app.posthog.com/capture", {
    method: "POST",
    body: body,
    }).then((r) => r.json());
    if (result.error) {
    ⦚ 6 unchanged lines ⦚
    ⦚ 6 unchanged lines ⦚
    let result = await fetch("https://app.posthog.com/capture", {
    method: "POST",
    headers: {
    "Content-Type": "application/json",
    },
    body: JSON.stringify(body),
    }).then((r) => r.json());
    if (result.error) {
    ⦚ 6 unchanged lines ⦚
  • v2

    8/24/2023
    Open: Version
    Changes from v1 to v2
    +0
    -0
    ⦚ 17 unchanged lines ⦚
    ⦚ 17 unchanged lines ⦚
  • v1

    8/24/2023
    Open: Version
    +17
    -0

    async function postHogAPICapture() {
    const body = {
    "api_key": @me.phProjectAPIKey,
    "event": "val API ran",
    "distinct_id": @me.email,
    };
    let result = await fetch("https://app.posthog.com/capture", {
    method: "POST",
    body: body,
    }).then((r) => r.json());
    if (result.error) {
    throw new Error("PH error " + result.error.message);
    }
    else {
    return result;
    }
    }
Updated: October 23, 2023