Skip to content

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

Open
sarahxsanders wants to merge 2 commits into
mainfrom
posthog-code/integration-java-variant
Open

feat(integration): add Java (Spring Boot) as a full example-based variant#270
sarahxsanders wants to merge 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
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 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
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