admin.analytics.getFile: daily member or public-channel analytics for an Enterprise organization. Scope: admin.analytics:read.

Functions

file-result

fn (response: Result): Any

Turn a getFile response into its result: the gzip bytes on success, otherwise the Err(SlackError) from the JSON error body. Exposed for testing.

Example

res ::hot::http/HttpResponse({status: 200, headers: {content-type: "application/json"}, body: {ok: false, error: "file_not_yet_available"}})
if-err(::slack::admin::analytics/file-result(res), (e) { e.error })  // "file_not_yet_available"

get-file

fn (request: GetFileRequest): Bytes
fn (request: GetFileRequest, opts: Map): Bytes

admin.analytics.getFile - Analytics for one day (date, YYYY-MM-DD UTC; data is kept for 13 months). type is member or public_channel. Returns the file as Bytes: gzip-compressed, newline-delimited JSON, one record per member or channel. Use get-records to get the records, or ::hot::gzip/decode-stream to read a file too big to hold decompressed.

With type: "public_channel" and metadata_only: true (and no date) Slack returns channel metadata, also as gzipped JSON lines.

Failures (file_not_yet_available, data_not_available, invalid_date, ...) come back as an Err(SlackError).

Example

::analytics ::slack::admin::analytics

gz ::analytics/get-file(::analytics/GetFileRequest({type: "member", date: "2026-10-31"}))
::hot::file/write-file-bytes("member-2026-10-31.json.gz", gz)

// With a per-call token
::analytics/get-file(::analytics/GetFileRequest({type: "member", date: "2026-10-31"}), {token: ::hot::ctx/get("tenant-b.slack.admin.token")})

get-records

fn (request: GetFileRequest): Vec<Map>
fn (request: GetFileRequest, opts: Map): Vec<Map>

get-file, decompressed and parsed: one Map per member or channel. A file that decompresses past compression.max-output-bytes (64 MiB by default) is an Err, as are the failures get-file returns. Use get-file and ::hot::gzip/decode-stream for a larger file.

Example

::analytics ::slack::admin::analytics

records ::analytics/get-records(::analytics/GetFileRequest({type: "member", date: "2026-10-31"}))
length(records)

parse-records

fn (gz: Bytes): Vec<Map>

Decompress a getFile file and parse its JSON lines into records. Exposed for testing.

Example

gz ::hot::gzip/encode("{\"id\":\"U1\"}\n{\"id\":\"U2\"}\n")
::slack::admin::analytics/parse-records(gz)  // [{id: "U1"}, {id: "U2"}]

Types

GetFileRequest

GetFileRequest type {
    type: Str,
    date: Str?,
    metadata_only: Bool?
}