Skip to content

[build-tools] Add eas/posthog_flag_rollout workflow function#3944

Draft
gwdp wants to merge 1 commit into
gwdp/eng-21551-posthog-capture-eventfrom
gwdp/eng-21551-posthog-flag-rollout
Draft

[build-tools] Add eas/posthog_flag_rollout workflow function#3944
gwdp wants to merge 1 commit into
gwdp/eng-21551-posthog-capture-eventfrom
gwdp/eng-21551-posthog-flag-rollout

Conversation

@gwdp

@gwdp gwdp commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

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 from integrations:posthog:connect (POSTHOG_CLI_API_KEY/POSTHOG_CLI_PROJECT_ID), or the api_key/project_id inputs. There's no host input on purpose, so the personal key only ever goes to POSTHOG_CLI_HOST.

The rollout_percentage input updates the flag's catch-all release condition and leaves targeted groups alone. Failures fail the step. Set ignore_error: true to 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
name: PostHog flag rollout test

jobs:
  enable_flag:
    steps:
      - uses: eas/posthog_flag_rollout
        with:
          flag: eas-workflow-test-flag
          active: true

  gradual_rollout:
    steps:
      - uses: eas/posthog_flag_rollout
        with:
          flag: eas-workflow-test-flag
          rollout_percentage: 50

  ignored_failure:
    steps:
      - uses: eas/posthog_flag_rollout
        with:
          flag: eas-workflow-test-flag
          active: true
          api_key: phx_invalid_local_test
          ignore_error: true

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.

name: Ship a feature behind a PostHog flag

jobs:
  update:
    type: update
    params:
      branch: main
      message: Ship new-checkout behind a flag

  enable_flag:
    needs: [update]
    steps:
      - uses: eas/posthog_flag_rollout
        with:
          flag: new-checkout
          active: true
          rollout_percentage: 10
Kill switch

Disable the flag, record an audit event, and leave a note on the run.

name: Kill switch, disable new-checkout now

jobs:
  disable_flag:
    steps:
      - uses: eas/posthog_flag_rollout
        with:
          flag: new-checkout
          active: false

  audit_trail:
    needs: [disable_flag]
    steps:
      - uses: eas/posthog_capture_event
        with:
          event: kill_switch_pulled
          properties:
            flag: new-checkout
            source: eas-workflow

@linear-code

linear-code Bot commented Jul 3, 2026

Copy link
Copy Markdown

ENG-21551

@gwdp gwdp force-pushed the gwdp/eng-21551-posthog-flag-rollout branch from c50c7ce to 4f8d88f Compare July 3, 2026 06:48
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.33%. Comparing base (0d8006c) to head (3745235).

Additional details and impacted files
@@                           Coverage Diff                            @@
##           gwdp/eng-21551-posthog-capture-event    #3944      +/-   ##
========================================================================
+ Coverage                                 59.33%   59.33%   +0.01%     
========================================================================
  Files                                       937      938       +1     
  Lines                                     41144    41223      +79     
  Branches                                   8671     8685      +14     
========================================================================
+ Hits                                      24407    24454      +47     
- Misses                                    16643    16674      +31     
- Partials                                     94       95       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gwdp gwdp force-pushed the gwdp/eng-21551-posthog-flag-rollout branch from 4f8d88f to 17c3b91 Compare July 3, 2026 07:35
@gwdp gwdp force-pushed the gwdp/eng-21551-posthog-capture-event branch from c08213f to 0d8006c Compare July 3, 2026 07:35
@gwdp gwdp force-pushed the gwdp/eng-21551-posthog-flag-rollout branch from 17c3b91 to 3745235 Compare July 3, 2026 07:40
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

✅ Thank you for adding the changelog entry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant