Skip to content

feat(integration): add Java (Spring Boot) as a full example-based variant - #270

Merged
sarahxsanders merged 2 commits into
mainfrom
posthog-code/integration-java-variant
Aug 21, 2026
Merged

feat(integration): add Java (Spring Boot) as a full example-based variant#270
sarahxsanders merged 2 commits into
mainfrom
posthog-code/integration-java-variant

Conversation

@sarahxsanders

@sarahxsanders sarahxsanders commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Adds a full example-based Java integration variant (not docs-only), anchored on a real, compiling Spring Boot app at example-apps/java-spring-boot — the most common Java backend framework, called out specifically in review.

What's here:

  • example-apps/java-spring-boot/posthog-server client as a singleton @Bean configured from the environment, flushed + closed on shutdown via destroyMethod="close". A controller identifies users, captures events, evaluates feature flags with evaluateFlags, and reports errors as an explicit event (the Java server SDK has no automatic exception capture — documented, not faked). gradle compileJava clean.
  • config.yaml: new java full variant, tagged [java, java-server].
  • commandments.yaml: java-server block — keyed java-server (not java) so backend rules never fold into the Android skill, which carries the java tag.

Ships as a pair with the wizard detection PR PostHog/wizard#948.

@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci mcp-analytics
  • /wizard-ci revenue

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

…iant

Add a Java integration variant anchored on a real Spring Boot example app
(example-apps/java-spring-boot): the posthog-server client is exposed as a
singleton @bean configured from the environment, flushed and closed on
shutdown via destroyMethod="close". A controller identifies users, captures
events, evaluates feature flags with evaluateFlags, and reports errors as an
explicit event (the Java server SDK has no automatic exception capture,
documented honestly rather than faked).

Ships a full Spring Boot example rather than docs-only so the wizard has a
concrete shape to match for the most common Java backend framework. Adds a
java-server commandments block, keyed java-server (not java) so these backend
rules never fold into the Android skill, which carries the java tag; the
variant is tagged [java, java-server].

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sarahxsanders
sarahxsanders force-pushed the posthog-code/integration-java-variant branch from 7f36566 to 7dfb504 Compare July 23, 2026 19:23
@sarahxsanders sarahxsanders changed the title feat(integration): add java docs-only variant with wizard framework routing feat(integration): add Java (Spring Boot) as a full example-based variant Jul 23, 2026
@sarahxsanders
sarahxsanders marked this pull request as ready for review July 24, 2026 15:16
@sarahxsanders
sarahxsanders requested a review from a team as a code owner July 24, 2026 15:16
@gewenyu99

Copy link
Copy Markdown
Collaborator

Full e2e run of this PR pair (wizard #948 + context-mill #270, both with main merged in) against spring-projects/spring-petclinic.

Set up, one honest conflict — the runner has no JRE so the agent could not self-verify. Idiomatic Spring: @Bean(destroyMethod = "close") for shutdown flush, blank config disables cleanly, posthog-server 2.7.0 added to both pom.xml and build.gradle, exception handler wired, null-safe capture helper.

Dashboard and notebook created through prod MCP. Compiles clean, but petclinic's own spring-javaformat gate fails on PetController.java — shipped unverified because the runner lacks a JRE.

Note: the context-mill branch as filed fails at the dashboard step — its agent prompts predate the posthog_exec tool grant on main; works once main is merged (currently blocked on unsigned commits).

All 25 TUI frames 01-intro.png 02-run.png 03-run.png 04-run.png 05-run.png 06-run.png 07-run.png 08-run.png 09-run.png 10-run.png 11-run.png 12-run.png 13-run.png 14-run.png 15-run.png 16-run.png 17-run.png 18-run.png 19-run.png 20-run.png 21-outro.png 22-outro.png 23-mcp.png 24-slack-connect.png 25-keep-skills.png

evaluateFlags() makes a network call. Wrap it in try/catch so a slow or
down PostHog can't 500 the /dashboard page (fall back to the flag off),
matching the Elixir example's behavior. Add a note that a real app should
cache/bound the call rather than fetch per render.

Also document that distinctId must come from an authenticated principal, not
an unverified request parameter, so the copied pattern doesn't invite
person-property spoofing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sarahxsanders
sarahxsanders force-pushed the posthog-code/integration-java-variant branch from 2c4d668 to c566706 Compare August 21, 2026 13:56
@sarahxsanders
sarahxsanders merged commit 7ab67b4 into main Aug 21, 2026
13 checks passed
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