//native
type Vercel = {
token: string;
};
/**
* List User Events
* Retrieves a list of "events" generated by the User on Vercel. Events are generated when the User performs a particular action, such as logging in, creating a deployment, and joining a Team (just to name a few). When the `teamId` parameter is supplied, then the events that are returned will be in relation to the Team that was specified.
*/
export async function main(
auth: Vercel,
limit: string | undefined,
since: string | undefined,
until: string | undefined,
types: string | undefined,
userId: string | undefined,
withPayload: string | undefined,
teamId: string | undefined,
slug: string | undefined,
) {
const url = new URL(`https://api.vercel.com/v3/events`);
for (const [k, v] of [
["limit", limit],
["since", since],
["until", until],
["types", types],
["userId", userId],
["withPayload", withPayload],
["teamId", teamId],
["slug", slug],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago