[build-tools] Add eas/posthog_flag_rollout workflow function#3944
Conversation
c50c7ce to
4f8d88f
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## gwdp/eng-21551-posthog-capture-event #3944 +/- ##
========================================================================
+ Coverage 59.55% 59.63% +0.09%
========================================================================
Files 940 941 +1
Lines 41414 41498 +84
Branches 8725 8746 +21
========================================================================
+ Hits 24661 24745 +84
Misses 16659 16659
Partials 94 94 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
4f8d88f to
17c3b91
Compare
c08213f to
0d8006c
Compare
3745235 to
e006085
Compare
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
0d8006c to
5263ea7
Compare
e006085 to
021c85f
Compare
|
Subscribed to pull request
Generated by CodeMention Warning: The preamble and epilogue options in commentConfiguration are deprecated. Use template instead. |
| let updateResponse: Response; | ||
| try { | ||
| updateResponse = await fetch(`${flagsUrl}/${flag.id}/`, { | ||
| method: 'PATCH', | ||
| headers, | ||
| body: JSON.stringify(patch), | ||
| }); | ||
| } catch (error) { | ||
| failOrIgnore({ | ||
| logger, | ||
| ignoreError, | ||
| message: `Updating PostHog flag "${flagKey}" failed.`, | ||
| err: error, | ||
| }); | ||
| return; | ||
| } | ||
| if (updateResponse.status === 403) { | ||
| throw new Error( | ||
| `Updating PostHog flag "${flagKey}" was forbidden (403). The personal API key likely lacks the "feature_flag:write" scope.` | ||
| ); | ||
| } | ||
| if (!updateResponse.ok) { | ||
| failOrIgnore({ | ||
| logger, | ||
| ignoreError, | ||
| message: `Updating PostHog flag "${flagKey}" failed with ${await readPostHogErrorAsync(updateResponse)}.`, |
There was a problem hiding this comment.
ok now i think we might want a PostHogClient
There was a problem hiding this comment.
100%, that got way cleaner now, thank you!
021c85f to
7d5471d
Compare
5263ea7 to
32884c8
Compare
7d5471d to
2a9777a
Compare
32884c8 to
090b547
Compare
2a9777a to
05251fe
Compare
090b547 to
f3d1c98
Compare
05251fe to
84eab00
Compare
f3d1c98 to
194afc1
Compare
84eab00 to
21a614d
Compare
1c7e9db to
e28aa8f
Compare
21a614d to
c84289b
Compare
e28aa8f to
dcd93a6
Compare
c84289b to
f37a747
Compare
|
✅ Thank you for adding the changelog entry! |

Why
Manage a PostHog feature flag straight from an EAS workflow. Flip it on or ramp its rollout as part of a deploy, instead of doing it by hand in PostHog.
How
Adds
eas/posthog_flag_rollout. It uses the personal API key fromintegrations:posthog:connect(POSTHOG_CLI_API_KEY/POSTHOG_CLI_PROJECT_ID), or theapi_key/project_idinputs. There's nohostinput on purpose, so the personal key only ever goes toPOSTHOG_CLI_HOST.The
rollout_percentageinput updates the flag's catch-all release condition and leaves targeted groups alone. Failures fail the step. Setignore_error: trueto log a warning and continue instead. Bad inputs, unknown flags and 403 scope errors always fail. Lookup and update aren't atomic, so a parallel dashboard edit can be lost.Test Plan
CI passes. Enabled a real flag from a local run with this workflow. It needs a personal key with feature-flag scopes. The last job fails the lookup on purpose and just warns.
Test workflow
(Validate posthog side, feature flag is updated with enw values)
Examples
These are simple workflows just to exercise the step. More fun and useful ones, mixed with EAS Update and deploys, are coming in the docs.
Ship a feature behind a flag
Publish the update, then enable the flag at 10% once the code is out.
Kill switch
Disable the flag, record an audit event, and leave a note on the run.