-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Niko/PHP-Docs-to-new-template #552
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for eppo-data-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Niko,
Thanks for reorganizing our docs! I know there's a lot (and all written by different people). Big undertaking 💪
I apologize that the docs you had to start with were out of date. When the PHP SDK was last touched, the updated APIs were captured only in the repository's README and EppoClient.php
I copied over a number of code samples as suggestions you should hopefully be able to just drop in.
--- | ||
import FeatureCard from '/src/components/FeatureCard'; | ||
|
||
The Eppo PHP SDK allows you to manage feature flags and experiments in your PHP applications. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SDKs allow developers to use feature flags and experiments within their applications. "manage" implies being able to edit or make changes to the flags.
$eppoClient = EppoClient::init( | ||
"<your_sdk_key>", | ||
"<base_url>", // optional, default https://eppo.cloud/api | ||
$assignmentLogger, // optional, must be an instance of Eppo\LoggerInterface | ||
$cache // optional, must be an instance of PSR-6 CacheInterface. If not passed, FileSystem cache will be used | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$eppoClient = EppoClient::init( | |
"<your_sdk_key>", | |
"<base_url>", // optional, default https://eppo.cloud/api | |
$assignmentLogger, // optional, must be an instance of Eppo\LoggerInterface | |
$cache // optional, must be an instance of PSR-6 CacheInterface. If not passed, FileSystem cache will be used | |
); | |
$eppoClient = EppoClient::init( | |
'<your_api_key>', | |
'<base_url>', // optional, default https://fscdn.eppo.cloud/api | |
$assignmentLogger, // optional, must be an instance of Eppo\Logger\LoggerInterface | |
$cache // optional, must be an instance of PSR-16 SimpleCache\CacheInterface. If not passed, FileSystem cache will be used | |
$httpClient // optional, must be an instance of PSR-18 ClientInterface. If not passed, Discovery will be used to find a suitable implementation | |
$requestFactory // optional, must be an instance of PSR-17 Factory. If not passed, Discovery will be used to find a suitable implementation | |
); |
$subjectAttributes = []; | ||
$variation = $eppoClient->getStringAssignment('subject-1', 'experiment_5', $subjectAttributes); | ||
|
||
if ($variation === 'control') { | ||
// do something | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$subjectAttributes = []; | |
$variation = $eppoClient->getStringAssignment('subject-1', 'experiment_5', $subjectAttributes); | |
if ($variation === 'control') { | |
// do something | |
} | |
$subjectAttributes = [ 'tier' => 2 ]; | |
$assignment = $eppoClient->getStringAssignment('experimentalBackground', 'user123', $subjectAttributes, 'control'); | |
if ($assignment !== 'control') { | |
// do something special | |
} else { | |
// Show the default treatment | |
} |
|
||
## Experiments | ||
|
||
For experiments, you'll need to implement logging. Here's a basic example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is an example which logs to Segment
https://github.com/Eppo-exp/php-sdk/blob/main/README.md#assignment-logger
use Eppo\Logger\LoggerInterface; | ||
|
||
class Logger implements LoggerInterface { | ||
public function logAssignment( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logAssignment
just takes an AssignmentEvent
parameter (see example above). The AssignmentEvent class has the following shape
public string $experiment,
public string $variation,
public string $allocation,
public string $featureFlag,
public string $subject,
public float $timestamp,
public array $subjectAttributes = [],
public array $sdkMetadata = [],
public array $extraLogging = []
public function logAssignment( | ||
string $experiment, | ||
string $variation, | ||
string $subject, | ||
string $timestamp, | ||
array $subjectAttributes = [] | ||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public function logAssignment( | |
string $experiment, | |
string $variation, | |
string $subject, | |
string $timestamp, | |
array $subjectAttributes = [] | |
) { | |
public function logAssignment(AssignmentEvent $assignmentEvent) { |
} | ||
``` | ||
|
||
The logger receives these parameters: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See AssignmentEvent
It may take up to 10 seconds for changes to Eppo experiments to be reflected by the SDK assignments. | ||
::: | ||
|
||
## Assignment Logger Schema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please update to schema in AssignmentEvent
getBooleanAssignment(...) | ||
getNumericAssignment(...) | ||
getJSONStringAssignment(...) | ||
getParsedJSONAssignment(...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getBooleanAssignment(...) | |
getNumericAssignment(...) | |
getJSONStringAssignment(...) | |
getParsedJSONAssignment(...) | |
getBooleanAssignment(...) | |
getNumericAssignment(...) | |
getIntegerAssignment(...) | |
getStringAssignment(...) | |
getJSONAssignment(...) |
|
||
### Logging Examples | ||
|
||
[Placeholder: Need PHP-specific examples for logging to different services (Segment, Rudderstack, mParticle, Snowplow)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
segment logger example: https://github.com/Eppo-exp/php-sdk/blob/main/README.md#assignment-logger
What
Updated the PHP docs to follow a similar template to the node docs.
Why?
Review Instructions
Todo before merge