Skip to content

feat: add PostHog analytics API fake service#34

Merged
AdamGold merged 1 commit intomainfrom
feat/posthog
Feb 26, 2026
Merged

feat: add PostHog analytics API fake service#34
AdamGold merged 1 commit intomainfrom
feat/posthog

Conversation

@assaf-benjosef
Copy link
Contributor

Summary

Add a PostHog fake service for testing AI agents that interact with analytics and feature flags without hitting the real PostHog API.

  • Event capture via /batch/ — supports capture(), set(), set_once(), group_identify() with person/group profile side effects
  • Feature flag evaluation via /flags/ — boolean flags, multivariate (variant) flags, and payloads
  • Local flag evaluation via /api/feature_flag/local_evaluation/ — flag definitions for SDK-side evaluation
  • Legacy /decide/ endpoint for backwards compatibility
Endpoint SDK methods
POST /batch/ capture(), set(), set_once(), group_identify()
POST /flags/ feature_enabled(), get_feature_flag(), get_all_flags(), get_feature_flag_payload()
GET /api/feature_flag/local_evaluation/ load_feature_flags()
POST /decide/ legacy fallback

PostHog's SDK is unusual: auth is via api_key in the JSON body (not headers), and all events flow through a single /batch/ endpoint.

Test plan

  • doubleagent contract posthog — 19 contract tests pass using the official PostHog Python SDK v7.9
  • 9 capture tests: basic, properties, groups, $set, set(), set_once(), group_identify(), multi-event, filtering
  • 10 feature flag tests: enabled/disabled, missing, boolean, multivariate, payload, get_all_flags(), groups, load_feature_flags() local evaluation, local payload

Generated with Claude Code

Add a PostHog fake implementing event capture, feature flag evaluation,
and user/group identification for AI agent testing.

Endpoints:
- POST /batch/ (capture, set, set_once, group_identify)
- POST /flags/ (feature_enabled, get_feature_flag, get_all_flags)
- POST /decide/ (legacy flag evaluation)
- GET /api/feature_flag/local_evaluation/ (load_feature_flags)

19 contract tests verify all endpoints using the official PostHog
Python SDK v7.9.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@AdamGold AdamGold merged commit 12d1a6b into main Feb 26, 2026
15 checks passed
@AdamGold AdamGold deleted the feat/posthog branch February 26, 2026 09:00
rotemtam pushed a commit that referenced this pull request Feb 26, 2026
Add a PostHog fake implementing event capture, feature flag evaluation,
and user/group identification for AI agent testing.

Endpoints:
- POST /batch/ (capture, set, set_once, group_identify)
- POST /flags/ (feature_enabled, get_feature_flag, get_all_flags)
- POST /decide/ (legacy flag evaluation)
- GET /api/feature_flag/local_evaluation/ (load_feature_flags)

19 contract tests verify all endpoints using the official PostHog
Python SDK v7.9.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
rotemtam added a commit that referenced this pull request Feb 26, 2026
* feat: add PostHog analytics API fake service (#34)

Add a PostHog fake implementing event capture, feature flag evaluation,
and user/group identification for AI agent testing.

Endpoints:
- POST /batch/ (capture, set, set_once, group_identify)
- POST /flags/ (feature_enabled, get_feature_flag, get_all_flags)
- POST /decide/ (legacy flag evaluation)
- GET /api/feature_flag/local_evaluation/ (load_feature_flags)

19 contract tests verify all endpoints using the official PostHog
Python SDK v7.9.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add Todoist REST API v2 fake service

Adds a stateful fake of the Todoist REST API v2 with 10 contract test
modules covering tasks, projects, sections, labels, comments, subtasks,
due dates, filtering, and cross-resource agent workflows.

Generated by da-agent (multi-phase pipeline).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: add .mise.toml for todoist service

Missing tool declaration caused CI to fail with "No such file or
directory" because uv/python weren't installed by mise.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Assaf Ben Josef <80702314+assaf-benjosef@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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.

2 participants