Loading...
PostHog's Java SDK brings product analytics and feature flags together, but Java's verbosity means each flag check adds significant boilerplate. FlagShark cuts through the ceremony to identify flags ready for removal.
FlagShark generates a PR that removes the dead branch and keeps only the winning code path
@Service
public class PricingService {
private final PostHog posthog;
public PricingService(PostHog posthog) {
this.posthog = posthog;
}
public PricingPlan getPlan(String userId) {
boolean useNewPricing = posthog.isFeatureEnabled("new-pricing-model", userId);
if (useNewPricing) {
return calculateTieredPricing(userId);
}
return calculateFlatPricing(userId);
}
}@Service
public class PricingService {
public PricingPlan getPlan(String userId) {
return calculateTieredPricing(userId);
}
}FlagShark uses Annotation scanning and Java AST for SDK method detection to find every call to isFeatureEnabled(), getFeatureFlag(), getAllFlags()across your Spring Boot, Micronaut codebase.
Each detected flag key is matched against your PostHog project to check rollout status, last evaluation date, and whether the flag is archived or still active.
For each stale flag, FlagShark creates a pull request that removes the SDK call, eliminates the dead code branch, and preserves the winning path. Every PR includes a before/after diff you can review.
PostHog's Java SDK is often initialized with a personal API key for server-side flag evaluation — removing all flags doesn't mean you should remove the PostHog client, since it may still be used for event tracking and analytics.
Grep misses flags behind abstractions. AST-level scanning catches SDK calls that regex can't.
Every cleanup goes through code review. No surprises, no broken builds.
Only flags at 100% rollout for your configured threshold are suggested for removal.
New stale flags are detected automatically. Your codebase stays clean without manual audits.
isFeatureEnabled()getFeatureFlag()getAllFlags()Plus custom patterns you define in .flagshark.yaml
FlagShark scans for `PostHog` client injections and traces every `isFeatureEnabled()` and `getFeatureFlag()` call. It follows the client through Spring's DI container to find usage across the entire application.
Yes. FlagShark differentiates between flag evaluation methods (`isFeatureEnabled`, `getFeatureFlag`) and event tracking methods (`capture`). Only flag-related code is targeted for cleanup.
FlagShark detects flag checks inside `@Scheduled` methods and `TimerTask` implementations. It warns you when flag removal would change the behavior of periodic processing.
Connect your repo, see stale flags in minutes, and get cleanup PRs automatically.
Free tier available • No credit card required • 5-minute setup
Practical guide to removing stale LaunchDarkly flags from Spring Boot and Micronaut applications.
Systematically find and remove stale Split.io treatments from Spring Boot and Micronaut applications.
Find and remove dead Unleash toggles from Spring Boot applications and Java microservices.
Find and safely remove stale ConfigCat feature flags from Spring Boot and Java enterprise applications.