Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/platforms/php/common/feature-flags/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Set Up Feature Flags
sidebar_title: Feature Flags
sidebar_order: 7000
description: With Feature Flags, Sentry tracks feature flag evaluations in your application, keeps an audit log of feature flag changes, and reports any suspicious updates that may have caused an error.
---

## Prerequisites

- [Sentry SDK](/) version `4.18.0` or above.

## Enable Evaluation Tracking

<PlatformContent includePath="feature-flags/evaluation-tracking-index" />
10 changes: 10 additions & 0 deletions platform-includes/feature-flags/evaluation-tracking-index/php.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
### Generic API
You can use the generic API to manually track feature flag evaluations. These evaluations are held in memory and are sent to Sentry on error and transaction events. **At the moment, we only support boolean flag evaluations.**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to call out how many feature flags you can set.


```php
\Sentry\addFeatureFlag('test-flag', false);

captureException(new \RuntimeException("Something went wrong!"));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The PHP example calls captureException() without a namespace or use statement, leading to a fatal error if copied directly.
Severity: CRITICAL | Confidence: 0.95

🔍 Detailed Analysis

The PHP example for feature flags calls captureException() without a namespace prefix or a use statement. If a user copies this code into a PHP environment without use function Sentry\captureException;, it will result in a Fatal Error: Call to undefined function captureException(), causing the application to terminate.

💡 Suggested Fix

Prefix captureException() with the \Sentry\ namespace, changing captureException(new \RuntimeException("Something went wrong!")); to \Sentry\captureException(new \RuntimeException("Something went wrong!")); for consistency with other examples.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: platform-includes/feature-flags/evaluation-tracking-index/php.mdx#L7

Potential issue: The PHP example for feature flags calls `captureException()` without a
namespace prefix or a `use` statement. If a user copies this code into a PHP environment
without `use function Sentry\captureException;`, it will result in a Fatal Error: Call
to undefined function `captureException()`, causing the application to terminate.

Did we get this right? 👍 / 👎 to inform future reviews.

```

Go to your Sentry project and confirm that your error event has recorded the feature flag "test-flag" and its value "false".
Loading