0

List User Events

by
Published Apr 8, 2025

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.

Script vercel Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Vercel = {
3
  token: string;
4
};
5
/**
6
 * List User Events
7
 * 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.
8
 */
9
export async function main(
10
  auth: Vercel,
11
  limit: string | undefined,
12
  since: string | undefined,
13
  until: string | undefined,
14
  types: string | undefined,
15
  userId: string | undefined,
16
  withPayload: string | undefined,
17
  teamId: string | undefined,
18
  slug: string | undefined,
19
) {
20
  const url = new URL(`https://api.vercel.com/v3/events`);
21
  for (const [k, v] of [
22
    ["limit", limit],
23
    ["since", since],
24
    ["until", until],
25
    ["types", types],
26
    ["userId", userId],
27
    ["withPayload", withPayload],
28
    ["teamId", teamId],
29
    ["slug", slug],
30
  ]) {
31
    if (v !== undefined && v !== "" && k !== undefined) {
32
      url.searchParams.append(k, v);
33
    }
34
  }
35
  const response = await fetch(url, {
36
    method: "GET",
37
    headers: {
38
      Authorization: "Bearer " + auth.token,
39
    },
40
    body: undefined,
41
  });
42
  if (!response.ok) {
43
    const text = await response.text();
44
    throw new Error(`${response.status} ${text}`);
45
  }
46
  return await response.json();
47
}
48