# Analyze Bluesky activity

[Read this page in HTML](https://www.scopedb.io/docs/guides/analyze-bluesky-activity)

What happened in a community activity window: organic conversations, reaction bursts, or automated bot traffic?

In this guide, you run a Go collector that subscribes to the public Bluesky Jetstream firehose and appends arriving JSON events into ScopeDB through the Go SDK. While the live stream accumulates in the background, you first verify your analytical queries against a deterministic 16-event sample (`capture_id = 'first'`) where every count is known (**six new posts, including two replies, and five like or repost creations**), then run the same ScopeQL pipelines against the live firehose (`capture_id = 'live-first'`) to chart event volume, profile high-frequency actors directly from nested JSON fields, and compare capture windows without double-counting replayed batches.

Allow about 15 minutes after workspace setup.

## 1. Get the collector and connect

You need a ready [ScopeDB Cloud workspace](https://console.scopedb.cloud), [Go 1.26 or later](https://go.dev/doc/install), Git, and a terminal (macOS, Linux, or WSL). Use a test workspace: this guide creates `guide_bluesky.events_raw` and the `guide_bluesky.events` view in the default `scopedb` database.

Clone the [Demo Scene repository](https://github.com/scopedb/demo-scene) and enter the `bluesky-events` directory, which contains the collector, the 16-event sample (`sample.ndjson`), saved queries, and tests:

```bash
git clone https://github.com/scopedb/demo-scene.git scopedb-demos
cd scopedb-demos/bluesky-events
go mod download
```

Keep this terminal open. In Console, open **Home** in your workspace and copy **ScopeDB API**.

[![Light-mode Console Home page for Northstar Analytics, showing the workspace connection bar with the example API address ap-southeast-1.aws.scopedb.cloud and Create API key.](https://www.scopedb.io/content/docs/console/connect.jpg "Find your workspace connection")](https://www.scopedb.io/content/docs/console/connect.jpg)

Copy the ScopeDB API address from your own workspace, then choose Create API key. The account and address shown are demonstration values.

Choose **Create API key**, give it a name such as `event-tutorial`, and choose an expiration. Select **Create Key** and copy the one-time secret. You can follow the [connection walkthrough](https://www.scopedb.io/docs/guides/connect-to-scopedb.md) for additional setup details.

[![Light-mode Create API Key dialog with the name event-tutorial and a 90-day expiration.](https://www.scopedb.io/content/docs/console/api-key-create.jpg "Create a tutorial API key")](https://www.scopedb.io/content/docs/console/api-key-create.jpg)

Give the key a recognizable name, choose an expiration, and select Create Key. Save the secret when it appears.

Export the endpoint and API key in your terminal:

```bash
export SCOPEDB_ENDPOINT="https://<endpoint>"
export SCOPEDB_API_KEY="<api-key>"
```

Keep credentials in your local environment, outside source control. The live collector reads from the public [Bluesky Jetstream service](https://bsky.network/docs/jetstream/) without requiring a Bluesky account or token, and the fixed sample remains available offline.

## 2. Create the schema and start the collector

The collector writes promoted envelope columns (`capture_id`, `event_id`, `event_time`, `ingested_at`, `collection`, `operation`) alongside the complete upstream payload in a single `raw object` column. Create the `guide_bluesky` schema, the append-only `events_raw` table, and the deduplicated `events` view using [`scope catalog`](https://www.scopedb.io/docs/guides/scopedb-cli/catalog.md) (or in Console **Data**):

```bash
scope catalog apply --schema scopedb.guide_bluesky -f - --yes <<'JSON'
{
  "name": "guide_bluesky",
  "tables": [
    {
      "name": "events_raw",
      "columns": [
        { "name": "capture_id", "data_type": "string" },
        { "name": "event_id", "data_type": "string" },
        { "name": "event_time", "data_type": "timestamp" },
        { "name": "ingested_at", "data_type": "timestamp" },
        { "name": "collection", "data_type": "string" },
        { "name": "operation", "data_type": "string" },
        { "name": "raw", "data_type": "object" }
      ]
    }
  ],
  "views": [
    {
      "name": "events",
      "statement": "FROM guide_bluesky.events_raw DISTINCT ON capture_id, event_id BY ingested_at DESC"
    }
  ]
}
JSON
```

`events_raw` retains every imported delivery, while `events` selects the latest delivery of each `(capture_id, event_id)` pair by `ingested_at DESC`. Query `guide_bluesky.events` for all downstream analysis so that replaying a file or recovering an interrupted batch never inflates your counts.

Start the collector and leave this terminal running while you work in Console:

```bash
go run .
```

On startup, the program ensures the 16-event constructed sample is loaded under `capture_id = 'first'`, then connects to Jetstream and continuously appends live events under `capture_id = 'live-first'` (flushing every 500 events or at least once per second). Press **Ctrl+C** whenever you want to stop; the collector flushes its active buffer before exiting.

Verify the deterministic sample window in Console **Query**:

```scopeql
FROM guide_bluesky.events
WHERE capture_id = 'first'
AGGREGATE count() AS unique_events,
    min(event_time) AS first_seen, max(event_time) AS last_seen
```

| unique\_events | first\_seen          | last\_seen           |
| -------------- | -------------------- | -------------------- |
| 16             | 2026-10-01T09:00:00Z | 2026-10-01T09:00:15Z |

## 3. Calibrate the queries on the fixed sample

Before querying a moving firehose, verify how each query separates record creations, nested reply metadata, and reaction targets on the 16-event sample.

First, count new record creations by collection:

```scopeql
FROM guide_bluesky.events
WHERE capture_id = 'first' AND operation = 'create'
GROUP BY collection
AGGREGATE count() AS creates
ORDER BY creates DESC, collection
```

| collection            | creates |
| --------------------- | ------- |
| app.bsky.feed.post    | 6       |
| app.bsky.feed.like    | 3       |
| app.bsky.feed.repost  | 2       |
| app.bsky.graph.follow | 2       |

Filtering to `operation = 'create'` excludes the sample's remaining three mutations (one post update and two deletes) so edits and deletions are not miscounted as new posts.

Next, inspect the six post creations by traversing directly into the semi-structured `raw` object column—checking `raw['record']['reply']` to distinguish replies from top-level posts, and `TRY(raw['record']['embed']['$type']::string)` to extract the attached media type without failing when `embed` is absent:

```scopeql
FROM guide_bluesky.events
WHERE capture_id = 'first'
    AND collection = 'app.bsky.feed.post' AND operation = 'create'
SELECT raw['record']['reply'] IS NOT NULL AS is_reply,
    TRY(raw['record']['embed']['$type']::string) AS embed_type
GROUP BY is_reply, embed_type
AGGREGATE count() AS posts
ORDER BY posts DESC, is_reply, embed_type
```

| is\_reply | embed\_type             | posts |
| --------- | ----------------------- | ----- |
| FALSE     | NULL                    | 2     |
| FALSE     | app.bsky.embed.external | 1     |
| FALSE     | app.bsky.embed.images   | 1     |
| TRUE      | app.bsky.embed.images   | 1     |
| TRUE      | app.bsky.embed.video    | 1     |

Two of the six new posts are replies (`is_reply = TRUE`), and four of the six carry an image, external link, or video embed.

## 4. Join reactions to captured posts and inspect raw payloads

Dividing three likes by six posts does not produce a true engagement rate: reactions in an event stream often target posts created hours or days before your capture window opened. To check how many reactions reference posts created within the same capture, reconstruct each post's AT URI (`at://<did>/<collection>/<rkey>`) from `raw` and `LEFT JOIN` reaction targets against observed post creations:

```scopeql
FROM guide_bluesky.events
WHERE capture_id = 'first' AND operation = 'create'
    AND collection IN ('app.bsky.feed.like', 'app.bsky.feed.repost')
SELECT collection, TRY(raw['record']['subject']['uri']::string) AS target_uri
LEFT JOIN (
    FROM guide_bluesky.events
    WHERE capture_id = 'first'
        AND collection = 'app.bsky.feed.post' AND operation = 'create'
    SELECT 'at://' || raw['did']::string || '/' || collection
        || '/' || raw['rkey']::string AS post_uri
    DISTINCT ON post_uri
) AS posts ON target_uri = posts.post_uri
GROUP BY collection
AGGREGATE count() AS interactions,
    sum(if(posts.post_uri IS NOT NULL, 1, 0)) AS targets_observed,
    sum(if(posts.post_uri IS NULL, 1, 0)) AS targets_not_observed
ORDER BY collection
```

| collection           | interactions | targets\_observed | targets\_not\_observed |
| -------------------- | ------------ | ----------------- | ---------------------- |
| app.bsky.feed.like   | 3            | 2                 | 1                      |
| app.bsky.feed.repost | 2            | 1                 | 1                      |

Three of the five reactions match posts created inside the `first` window; the other two target older or external posts.

To inspect the underlying JSON document for any post mutation in Console, select the `raw` column:

```scopeql
FROM guide_bluesky.events
WHERE capture_id = 'first' AND collection = 'app.bsky.feed.post'
SELECT event_time, operation, raw
ORDER BY event_time
```

Click the `raw` cell in row 4 (`2026-10-01T09:00:03Z`) to open **Row details**. The side panel formats the complete semi-structured object so you can inspect nested paths such as `raw['record']['text']` (`"A constructed reply."`) and `raw['record']['reply']` before promoting or filtering on them in ScopeQL.

[![Light-mode Console Query view showing the 8 post mutations in capture first and the Row details drawer open on row 4, displaying the formatted raw JSON object including record.text and record.reply.](https://www.scopedb.io/content/docs/bluesky-activity/raw-details.jpg "Inspect the nested JSON payload in Row details")](https://www.scopedb.io/content/docs/bluesky-activity/raw-details.jpg)

Click any raw cell to open Row details and inspect nested fields such as record.text and record.reply directly alongside the query results.

## 5. Investigate live Bluesky traffic

While you calibrated the queries on `first`, the collector has been continuously streaming public Bluesky activity into `capture_id = 'live-first'`. Because ScopeDB evaluates path expressions directly on the `raw object` column alongside promoted tags, you can pivot from high-level volume charts to ad-hoc actor profiling without altering the table schema.

### Chart the live event mix

Start by breaking down all captured live deliveries by shortened collection and operation:

```scopeql
FROM guide_bluesky.events
WHERE capture_id = 'live-first'
SELECT replace(collection, 'app.bsky.', '') || ' · ' || operation AS event_type
GROUP BY event_type
AGGREGATE count() AS events
ORDER BY events DESC, event_type
```

Switch the results toolbar from **Table** to **Chart** (**Bar**) to visualize the distribution across event types. In a typical multi-minute capture (`344,603` events in the example below), `feed.like · create` dominates volume (`223,061`), followed by `feed.post · create` (`51,831`), `feed.repost · create` (`35,300`), and `graph.follow · create` (`20,768`), while `delete` operations form a long tail of unlikes, unfollows, and post removals.

[![Light-mode Console Chart view displaying a bar chart of live-first events by collection and operation, led by feed.like create above 220K events, followed by feed.post create, feed.repost create, and graph.follow create.](https://www.scopedb.io/content/docs/bluesky-activity/live-event-mix.jpg "Chart the live Bluesky event distribution")](https://www.scopedb.io/content/docs/bluesky-activity/live-event-mix.jpg)

Switch to Chart view to compare event volume across collections and operations. Likes and posts lead creation volume, while delete events capture unlikes, unfollows, and post removals.

### Profile high-frequency actors and bots via ad-hoc JSON paths

Even though `did` (the decentralized account identifier) was never extracted into a dedicated table column, you can group directly by `raw['did']::string` and use ScopeQL's pipelined `SELECT ... GROUP BY ... AGGREGATE` flow to inspect the behavior of the most active accounts in `live-first`:

```scopeql
FROM guide_bluesky.events
WHERE capture_id = 'live-first' AND raw['did'] IS NOT NULL
SELECT replace(collection, 'app.bsky.', '') || '.' || operation AS kind, raw['did']::string AS did
GROUP BY did
AGGREGATE count() AS events,
    sum(if(kind = 'graph.follow.create', 1, 0)) AS follows,
    sum(if(kind = 'feed.like.create', 1, 0)) AS likes,
    sum(if(kind = 'feed.post.create', 1, 0)) AS posts,
    sum(if(kind = 'graph.follow.delete', 1, 0)) AS unfollows
ORDER BY events DESC LIMIT 5
```

[![Light-mode Console Table view showing the top 5 most active DIDs in live-first, with column histograms and per-actor counts for events, follows, likes, posts, and unfollows.](https://www.scopedb.io/content/docs/bluesky-activity/live-top-actors.jpg "Profile top actors directly from raw\['did'\]")](https://www.scopedb.io/content/docs/bluesky-activity/live-top-actors.jpg)

Grouping directly by raw\['did']::string reveals distinct automation signatures at the top of the firehose: dedicated follow bots (1,619 follows, 0 other actions), like bots (1,295 likes), high-volume posters (748 posts), and mass-unfollow accounts (600 unfollows).

Breaking each actor's total volume into `follows`, `likes`, `posts`, and `unfollows` immediately exposes automated behavior in the live stream—such as accounts that emit exclusively `graph.follow.create` (`1,619` follows and zero posts or likes) or exclusively `graph.follow.delete` (`600` unfollows).

### Compare two live capture windows

To compare activity across separate observation windows, press **Ctrl+C** in the collector terminal and start a second live capture with `-capture-id live-second`:

```bash
go run . -capture-id live-second
```

Earlier captures remain intact. Run the following query to compare the observation boundaries, new post volume, and reply share between `live-first` and `live-second`:

```scopeql
FROM guide_bluesky.events
WHERE capture_id IN ('live-first', 'live-second')
    AND collection = 'app.bsky.feed.post' AND operation = 'create'
GROUP BY capture_id
AGGREGATE min(event_time) AS first_seen, max(event_time) AS last_seen,
    count() AS posts,
    sum(if(raw['record']['reply'] IS NOT NULL, 1, 0)) AS replies
SELECT *, round(100.0 * replies / posts, 1) AS reply_percent
ORDER BY capture_id
```

[![Light-mode Console Table view comparing live-first and live-second observation boundaries, new post counts (1842 and 1910), reply counts (833 and 825), and rounded reply percentages (45.2 and 43.2).](https://www.scopedb.io/content/docs/bluesky-activity/live-windows.jpg "Compare two live capture windows")](https://www.scopedb.io/content/docs/bluesky-activity/live-windows.jpg)

Compare reply\_percent alongside each window's first\_seen and last\_seen boundaries. Re-run the query at any time to include newly committed batches in the active window.

Always evaluate `posts` and `reply_percent` alongside `first_seen` and `last_seen` so differences in capture duration are not mistaken for changes in posting rate.

## 6. Verify idempotent replay and delivery semantics

In production ingestion pipelines, network interruptions or client retries can deliver the same batch more than once. To see how the `guide_bluesky.events` view protects your queries from duplicate deliveries, replay `sample.ndjson` into `capture_id = 'first'`:

```bash
go run . load -file sample.ndjson -capture-id first
```

Then compare the row count in the base table (`events_raw`) against the deduplicated view (`events`):

```scopeql
FROM guide_bluesky.events_raw
WHERE capture_id = 'first'
AGGREGATE count() AS stored_rows
```

```scopeql
FROM guide_bluesky.events
WHERE capture_id = 'first'
AGGREGATE count() AS unique_events
```

| Target                     | Count before replay | Count after replay | Behavior                                                                        |
| -------------------------- | ------------------- | ------------------ | ------------------------------------------------------------------------------- |
| `guide_bluesky.events_raw` | 16                  | 32                 | Appends every delivery so raw ingestion history and audit trails remain intact. |
| `guide_bluesky.events`     | 16                  | 16                 | Deduplicates on `(capture_id, event_id)` by `ingested_at DESC` at query time.   |

Keep these four ingestion contracts in mind when adapting this pattern to your own streams:

* **Idempotent batch recovery**: If an SDK append fails or returns an unknown outcome, the collector stops and writes the unconfirmed batch to a local recovery file instead of blindly retrying. Once you resolve the underlying issue, replay the file under the original capture ID (`go run . load -file <recovery-file> -capture-id live-first`).
* **Capture-scoped deduplication**: `event_id` combines the Jetstream source instance and sequence number, and `events` deduplicates within each `capture_id`. Keep the same `capture_id` when replaying a recovery file, and avoid summing overlapping capture IDs without deduplicating across `event_id`.
* **Observation vs. author timestamps**: `event_time` records the relay's observation timestamp (`witnessedAt`, falling back to `time`) rather than the client-supplied `record.createdAt`, which can be clock-skewed or backdated. `ingested_at` records when the loader processed the event.
* **Append-only mutation log**: Creating, updating, and deleting a post are distinct events with distinct sequence numbers. A `delete` event carries no record body and does not erase earlier `create` payloads from `events_raw`.

Continue with [Query events](https://www.scopedb.io/docs/guides/query-events.md) to explore more ScopeQL patterns, [Model event data](https://www.scopedb.io/docs/guides/model-flexible-events.md) to decide when to promote hot JSON paths into typed columns, or [Set data retention](https://www.scopedb.io/docs/guides/data-retention.md) to manage historical storage.

## Troubleshooting

| Symptom                     | Next step                                                                                                                               |
| --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| Connection unavailable      | Check outbound WebSocket access. The producer retries the same source; stop it and use a new capture ID before switching sources.       |
| `401` or `403` during write | Verify `SCOPEDB_ENDPOINT`, `SCOPEDB_API_KEY`, key expiration, and the target workspace.                                                 |
| Setup query fails           | Run the setup statements in the workspace matching your API key, then click **Refresh catalog** if the tree is stale.                   |
| Counts do not change        | Confirm the collector is still printing `Committed ... events`, check your `capture_id` filter, and click **Run** again.                |
| SDK append fails            | Keep the printed recovery file path, fix the connectivity or auth issue, and replay with `go run . load -file <path> -capture-id <id>`. |
| Sample replay has 32 rows   | Query `guide_bluesky.events` instead of `guide_bluesky.events_raw` so duplicate deliveries are collapsed.                               |

## Related contents

* [Connect a client](https://www.scopedb.io/docs/guides/connect-to-scopedb.md)

* [Model event data](https://www.scopedb.io/docs/guides/model-flexible-events.md)

* [Query events](https://www.scopedb.io/docs/guides/query-events.md)
