Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit 6b995fd

Browse files
author
atran
committed
refac: update readme and better access token handling
1 parent 1890329 commit 6b995fd

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

tags-transformer/README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1-
# Rollbar PHP Examples: LaunchDarklyTransformer
1+
# Rollbar PHP Examples: TagsTransformer
22

3-
This project is an example of how to set up a custom transformer for Rollbar
4-
reporting for your PHP application. We use this functionality to move the extra
5-
data sent with the payload to the root level under the `tags` object.
6-
7-
## Installation
8-
9-
1. `cp config/secret.example.php config/secret.php`
10-
2. Fill out `config/secret.php` with your Rollbar server-side access token.
3+
This project is an example of how to set up a custom transformer to modify the payload sent by the PHP SDK to match
4+
what is expected from our beta LaunchDarkly integration. The integration is expecting the feature flag key to be sent
5+
as a tag object in the `tags` section of the payload. By following this example, you should be able to do just that.
116

127
## Steps used in this example
138
1. Set up `rollbar/rollbar` as a dependency with `composer require rollbar/rollbar`.
149
2a. Create your transformer class in `src/TagsTransformer.php` which implements `TransformerInterface`.
1510
2b. Create your data class which implements `Data` (is found in `src/TagsTransformer.php`).
1611
3. Implement `transform` method in your `TagsTransformer` with desired business logic. Make sure you return the $payload object from this method.
1712
4. Set up Rollbar with your `TagsTransformer` class in `example.php` using `transformer` configuration option.
18-
5. Run `composer test` and verify that the extra data is sent under the `tags` key in Rollbar.
13+
5. Set your API token into the environment.
14+
On Mac/Linux/UNIX, try `export ROLLBAR_TOKEN=the-access-token`.
15+
On Windows CMD, use set `ROLLBAR_TOKEN="the-access-token"`.
16+
For Windows PowerShell, use `$env:ROLLBAR_TOKEN="the-access-token"`.
17+
6. Run `composer test` and verify that the extra data is sent under the `tags` key in Rollbar.
1918

2019
## Help / Support
2120

2221
If you run into any issues, please email us at [support@rollbar.com](mailto:support@rollbar.com)
2322

2423
## Testing
25-
To run the example: `composer test`
24+
To run the example:
25+
Make sure to set your Rollbar API access token in the ROLLBAR_TOKEN environment variable in step 5.
26+
And then run: `composer test`.

tags-transformer/config/secret.example.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

tags-transformer/example.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Rollbar\Payload\Level;
88

99
$config = array(
10-
'access_token' => $_SECRET['access_token'],
10+
'access_token' => $_ENV['ROLLBAR_TOKEN'],
1111
'environment' => 'local',
1212
/**
1313
* 4. Set up Rollbar with your `TagsTransformer` class in `example.php`.

0 commit comments

Comments
 (0)