Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ samples, guidance on mobile development, and a full API reference.

Uploading sourcemaps needs [hog](https://posthog.com/docs/cli/migrating), PostHog's CLI. Install it with `npm install -g hog` or `brew install posthog/tap/hog`, then log in with `hog auth login`.

In GitHub Actions, install hog with the [PostHog/setup-hog](https://github.com/PostHog/setup-hog) action. The job can then upload with its OIDC token instead of a personal API key: run `hog ci setup --scope error_tracking:write` once in the repository, and give the job `permissions: id-token: write`.
In GitHub Actions, install hog with the [PostHog/setup-hog](https://github.com/PostHog/setup-hog) action. The job can then upload with its OIDC token instead of a personal API key:

1. Run `hog ci setup --scope error_tracking:write` once in the repository, and have an organization admin approve the request.
2. Put the project ID that `hog ci setup` prints in `posthog.json` as `"projectId"`, or set `HOG_PROJECT_ID` (and `HOG_HOST` outside US Cloud) in the job.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Step 2 drops the host from the posthog.json route, so an EU Cloud job that follows it literally can't get a token.

In the job, hog takes the exchange host from HOG_HOST, or from a Cloud host in posthog.json, and otherwise uses https://us.posthog.com (hog/src/posthog/credentials.ts:300-313, hog/README.md:505, pinned by workload.test.ts:198-223). With only "projectId" in posthog.json, an EU job asks for an OIDC token for US Cloud and exchanges it there for an EU project, which fails. The HOG_HOST note in this step only covers the env-var route. hog ci setup prints both values, e.g. { "host": "https://eu.posthog.com", "projectId": 123 } (setup.ts:49-58, 209-221). hog's README (L499) and the migration guide (posthog.com/contents/docs/cli/migrating.mdx:213) both say to add both, and this was part of the earlier suggestion on #752 (#752 (comment)).

Consider:

Suggested change
2. Put the project ID that `hog ci setup` prints in `posthog.json` as `"projectId"`, or set `HOG_PROJECT_ID` (and `HOG_HOST` outside US Cloud) in the job.
2. Add the `host` and `projectId` that `hog ci setup` prints to `posthog.json`, or set `HOG_HOST` and `HOG_PROJECT_ID` in the job. A self-hosted PostHog needs `HOG_HOST` either way.

(Checked against hog 1.0.0, PostHog/posthog@0441094.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Thanks! #754 merged before this landed, so it's in #755.

3. Give the job `permissions: id-token: write`.

```bash
# release mode
rm -rf build/web
flutter build web --source-maps
hog error-tracking inject build/web --release-name posthog_flutter_example --release-version 1.0.0 --build 42
# check the sourcemaps has chunk_id and release_id injected (*.js.map file)
# check the sourcemaps have chunk_id injected (*.js.map file). The release goes into the js file, not the map
# check the js file has _posthogChunkIds injected (*.js file)
Comment on lines +33 to 34

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Line 33 now says the release goes into the js file, but the js check below it still names only _posthogChunkIds. In event mode (the default, shared.ts:144-159), inject prepends a snippet that sets _posthogReleaseId next to _posthogChunkIds (hog/worker/src/constant.rs:7, pair.rs:447-457), while the map gets only chunk_id (pair.rs:376-378). Consider naming it, as suggested on #752 (#752 (comment)):

Suggested change
# check the sourcemaps have chunk_id injected (*.js.map file). The release goes into the js file, not the map
# check the js file has _posthogChunkIds injected (*.js file)
# check the sourcemaps have chunk_id injected (*.js.map file). The release goes into the js file, not the map
# check the js file has _posthogChunkIds and _posthogReleaseId injected (*.js file)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Thanks! #754 merged before this landed, so it's in #755.

# check the chunk_id and _posthogChunkIds match
hog error-tracking upload build/web --kind js --release-name posthog_flutter_example --release-version 1.0.0 --build 42
Expand Down
Loading