Skip to content

feat: add featureUsageCallback and fix trackingCallback exception handling#63

Closed
vazarkevych wants to merge 2 commits into
growthbook:masterfrom
vazarkevych:fix/rethrow-tracking-callback-error
Closed

feat: add featureUsageCallback and fix trackingCallback exception handling#63
vazarkevych wants to merge 2 commits into
growthbook:masterfrom
vazarkevych:fix/rethrow-tracking-callback-error

Conversation

@vazarkevych

Copy link
Copy Markdown
Collaborator

Summary

  • Fixes Exception should NOT be swallowed if the logger is not set #22: re-throw exception in trackingCallback when logger is not set (previously swallowed silently)
  • Adds featureUsageCallback — fires on every getFeature() call, mirrors TypeScript onFeatureUsage
  • Fixes trackingCallback deduplication — callback no longer fires twice for the same user/experiment/variation

Changes

  • src/Growthbook.php: re-throw in catch block if $this->logger is null
  • src/Growthbook.php: add featureUsageCallback with deduplication via trackedFeatures
  • src/Growthbook.php: add trackingCallback deduplication using hashAttribute+hashValue+experimentKey+variationId key
  • tests/GrowthbookTest.php: add tests for exception re-throw with and without logger
  • README.md: document featureUsageCallback

@vazarkevych vazarkevych closed this Jun 9, 2026
@vazarkevych vazarkevych deleted the fix/rethrow-tracking-callback-error branch June 9, 2026 09:45
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.

Exception should NOT be swallowed if the logger is not set

2 participants