agentleFS
PostHogKnown publisherPostHog/posthog-foss/.agents/skills/exporting-recordings-to-customer-s3/SKILL.md

exporting-recordings-to-customer-s3

Skill733 starsChanged 6 days agoMITView on GitHub

Runs a paid, staff-triggered export of a team's session recordings into an S3 bucket the customer owns, with the export_recordings_to_s3 management command. Use when a customer needs recordings kept past retention (litigation, legal hold, forensics, compliance archive), when asked to quote, price, start, monitor or check an export of recordings to a customer's bucket, or when a customer asks how to play back an exported .phrec file. Covers the quote, the customer's IAM role and KMS setup, starting the run, monitoring it and handing over the result.

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 6 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read the export README first.

    line 14
  2. Distinctive:

    Stop and ask the person you work for before you:

    line 22
  3. Distinctive:

    Start an export: Only start one when a person confirms the customer accepted the quote and billing cleared it.

    line 24
  4. Very specific:

    Run every command in a toolbox pod in the team's region (prod-us or prod-eu).

    line 32
  5. Very specific:

    Run each command with kubectl exec <pod> -- python manage.py export_recordings_to_s3 ....

    line 37
  6. Distinctive:

    Before the start, confirm with the person that the customer has:

    line 71
  7. Distinctive:

    Keep the printed workflow ID.

    line 94
  8. Distinctive:

    When a run is far slower than the quote's estimate, check worker CPU as the README's Throughput section describes before you suggest more …

    line 103
  9. Very specific:

    Ask the person before you rerun them.

    line 110
  10. Very specific:

    When the status is completed, summary.json is in the bucket under {prefix}/{team_id}/{run_id}/manifests/.

    line 116

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Exporting recordings to a customer's S3 bucket

Read the export README first. It explains the run, the bucket layout, the file format and what the customer sets up.

The export costs us real money and the customer pays for it. So the job has two halves with a person in between: quote, then wait for a go-ahead, then start.

Decisions that are not yours

Stop and ask the person you work for before you:

  • Start an export. Only start one when a person confirms the customer accepted the quote and billing cleared it. A request to "export recordings for X" means quote first.
  • Name a price or share the quote with anyone. The command prints our cost. Sales sets the price.
  • Pass --allow-cross-region. Cross-region transfer adds cost the customer must have agreed to.
  • Raise --max-parallel-shards above the default on a large export. More shards load the session replay workers and recording-api harder, and they only go faster while the workers have room. Read Throughput before you suggest a value.

Where to run

Run every command in a toolbox pod in the team's region (prod-us or prod-eu). The toolbox CLI claims one. A toolbox pod has what the command needs: ClickHouse for the quote, object storage for quotes and session lists, and Temporal to start the workflow. The shards run on the session replay workers, not in the pod.

Run each command with kubectl exec <pod> -- python manage.py export_recordings_to_s3 .... For a session list, first copy the file into the pod with kubectl cp.

Steps

1. Pin down the selection

You need the team ID, the region (US or EU), the date range (UTC days, inclusive) and the bucket's AWS region. To export only some sessions in the range, you also need one of:

  • a saved recordings filter (--playlist <short id>), for a selection like "sessions that visited this URL" or "sessions from this country". Have the customer, or the person, build the filter in the recordings list and save it, so the customer sees exactly what they get. The short ID is in the filter's URL (savedFilterId=). The filter's own date range is ignored: the quote's range applies.
  • a file of session IDs (--session-ids-file).

Filters on event properties, such as country, scan events over the whole range and can take minutes on a large team. The quote saves the list of sessions it priced, and the run exports exactly that list. Sessions that arrive after the quote are not exported. Each day is split into --shards-per-day shards (default 16), and a shard holds at most 100,000 sessions. When the quote names a shard that goes over, quote again with a higher --shards-per-day. A session ID file or saved filter can select at most 1,000,000 sessions per quote. Split a larger selection by date range. A session belongs to the day it started on. The range must end before today (UTC). The command refuses a range that includes today. Recordings past their retention are gone and cannot be exported.

2. Quote

python manage.py export_recordings_to_s3 --quote --team-id <id> --region <bucket region> \
    --date-from <yyyy-mm-dd> --date-to <yyyy-mm-dd> [--playlist <short id> | --session-ids-file ids.txt]

Report the quote ID, the session count, our cost, the estimated duration, the best-effort session count and the valid-until time. Best-effort sessions expire within days and may expire before their shard runs. Say so plainly. A quote is valid for 7 days. After that, quote again: more data moves to Glacier IR and the cost rises.

3. Check the customer's setup

Before the start, confirm with the person that the customer has:

  • an IAM role whose ARN came from an admin of that customer's PostHog organization, not from an unverified sender, that trusts PostHog's recording-exports role for the region and requires the external ID posthog-<organization id> (the README lists the ARNs),
  • a role that allows s3:PutObject and s3:AbortMultipartUpload on the bucket and prefix,
  • for a KMS-encrypted bucket, KMS permissions on the role and a key policy that allows the role, plus the key ID or ARN (not an alias),
  • the bucket in the same AWS account as the role,
  • a lifecycle rule that aborts incomplete multipart uploads, so a failed shard's unfinished parts do not stay in their bucket.

The README lists the exact requirements to send them.

4. Start, after the go-ahead

python manage.py export_recordings_to_s3 --quote-id <quote id> --role-arn <role ARN> --bucket <bucket> \
    --region <bucket region> --prefix <prefix> --approved-by <admin email> [--kms-key-id <key id or ARN>]

--approved-by is the organization admin who sent the role ARN. The command refuses anyone who is not an admin of the team's organization, and a role another organization registered. The start writes a Replay entry to the organization's activity log with the role, bucket and approver, so the customer can see where their recordings went.

Without --yes, the command prints the quote and the destination and stops, because an exec has no terminal to answer its prompt. Show that output to the person. Rerun with --yes only after they confirm that exact quote and destination. Keep the printed workflow ID.

5. Monitor

python manage.py export_recordings_to_s3 --status <workflow id>

A large export runs for hours or days. When a run is far slower than the quote's estimate, check worker CPU as the README's Throughput section describes before you suggest more shards. A run checks the role and a test upload (one small part, then aborted, so nothing is left) before its first shard. A failure there names the missing permission in --status. Once the customer fixes the role, start the same quote again while it is valid. A credentials failure during a shard is permanent in the same way. Other shard failures retry on their own and resume from their last checkpoint.

A shard that still fails after its retries does not stop the run. The run writes its summary and then ends as failed, with the failed shards in the error and in summary.json under failed_shards. Ask the person before you rerun them. Then start the same quote again with --shards <the failed list>. The command refuses --shards unless the quote's last run failed, so a first start always covers the whole selection. A quote can start again only after a failed run, so a second start of a running or finished export is refused.

6. Hand over

When the status is completed, summary.json is in the bucket under {prefix}/{team_id}/{run_id}/manifests/. Each run, including a rerun of failed shards, has its own run_id folder. Report its session totals: exported, deleted, expired, missing, and deleted_before_run. Explain any non-zero count other than exported. Tell the customer they can check each file against the sha256 in the manifests, and play a file back in Replay's file playback page.

Done means

  • The person has the quote figures, and you started nothing without their go-ahead.
  • Or the run completed and you reported the summary totals.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.