Skip to content

Commit 3349073

Browse files
committed
feat: sdk upgrade (#19)
1 parent 4d50997 commit 3349073

File tree

12 files changed

+611
-86
lines changed

12 files changed

+611
-86
lines changed

CHANGELOG.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [3.0.0] - 2025-10-10
9+
10+
### Added
11+
- Support for `excluded_headers` configuration option to exclude specific headers from tracking
12+
- Full compatibility with treblle-php v5.0.0
13+
- Support for Guzzle v9.0
14+
- Support for Symfony 8.x (forward compatibility)
15+
- Support for PHP 8.3 and 8.4
16+
- Enhanced configuration documentation in README
17+
- Detailed upgrade guide (UPGRADE.md)
18+
- Requirements section in README
19+
- Now uses `SensitiveDataMasker` from treblle-php package for better consistency
20+
21+
### Changed
22+
- **BREAKING**: Configuration parameter names updated to match treblle-php v5.0 conventions:
23+
- `project_id` renamed to `api_key` (this holds your project ID)
24+
- `api_key` renamed to `sdk_token` (this holds your API key/SDK token)
25+
- Environment variables: `TREBLLE_PROJECT_ID``TREBLLE_API_KEY`, `TREBLLE_API_KEY``TREBLLE_SDK_TOKEN`
26+
- **BREAKING**: Updated to treblle-php v5.0.0
27+
- **BREAKING**: Minimum Symfony version raised from 4.4 to 6.4 (LTS)
28+
- **BREAKING**: Removed custom `Normalise` helper in favor of inline normalization
29+
- **BREAKING**: Removed `api_key` from default masked fields list
30+
- PHP requirement updated to ^8.2|^8.3|^8.4 (added 8.3 and 8.4 support)
31+
- Symfony requirement updated to ^6.4|^7.0|^8.0 (added Symfony 8 support)
32+
- Refactored DataProviders to use `SensitiveDataMasker` from treblle-php instead of `FieldMasker`
33+
- Updated exception messages to reflect new naming (missingSdkToken instead of missingProjectId)
34+
- Improved configuration options documentation
35+
- Updated bundle registration example for modern Symfony
36+
37+
### Removed
38+
- **BREAKING**: `src/Helpers/Normalise.php` - functionality moved inline to DataProviders
39+
- **BREAKING**: Default masking of `api_key` field (removed from default list)
40+
41+
### Fixed
42+
- Aligned masked fields with treblle-php v5.0.0 defaults
43+
44+
## [2.0.0] - Previous Release
45+
46+
### Added
47+
- Initial stable release with treblle-php v4.x support
48+
- Custom masked fields configuration
49+
- Debug mode support
50+
- Ignored environments configuration
51+
- Custom URL endpoint support
52+
53+
[3.0.0]: https://github.com/Treblle/treblle-symfony/compare/v2.0.0...v3.0.0
54+
[2.0.0]: https://github.com/Treblle/treblle-symfony/releases/tag/v2.0.0

README.md

Lines changed: 200 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,41 +75,64 @@ This means data masking is super fast and happens on a programming level before
7575
composer require treblle/treblle-symfony
7676
```
7777

78-
Enable it by adding it to the list of registered bundles depending on the Symfony version you’re using.
78+
Enable it by adding it to the list of registered bundles in `config/bundles.php`:
7979

8080
```php
8181
// config/bundles.php
82-
{
83-
return [
84-
// ...
85-
new Treblle\Symfony\TreblleBundle(),
86-
];
87-
}
82+
return [
83+
// ...
84+
Treblle\Symfony\TreblleBundle::class => ['all' => true],
85+
];
8886
```
8987

90-
Configure the SDK by adding the following snippet to your project configuration. If you have Symfony 3.4 add it to `app/config/config_prod.yml`. For Symfony 4 or newer add the value to `config/packages/treblle.yaml`.
88+
Configure the SDK by adding the following snippet to `config/packages/treblle.yaml`:
9189

9290
```yaml
9391
treblle:
94-
project_id: "%env(TREBLLE_PROJECT_ID)%"
9592
api_key: "%env(TREBLLE_API_KEY)%"
93+
sdk_token: "%env(TREBLLE_SDK_TOKEN)%"
9694
debug: false
97-
ignored_environments: dev
95+
ignored_environments: dev,test,testing
9896
masked_fields:
9997
- password
100-
- api_key
98+
- pwd
10199
- secret
100+
- password_confirmation
101+
- cc
102+
- card_number
103+
- ccv
104+
- ssn
105+
- credit_score
106+
excluded_headers:
107+
- Authorization
108+
- X-Api-Key
102109
```
103110
111+
### Configuration Options
112+
113+
- `api_key` (required): Your Treblle API key (project ID)
114+
- `sdk_token` (required): Your Treblle SDK token
115+
- `debug` (optional, default: `false`): Enable debug mode for development
116+
- `ignored_environments` (optional, default: `dev,test,testing`): Comma-separated list of environments to ignore
117+
- `masked_fields` (optional): Array of field names to mask in request/response data
118+
- `excluded_headers` (optional): Array of header patterns to exclude from tracking
119+
- `url` (optional): Custom Treblle endpoint URL for self-hosted instances
120+
121+
### Requirements
122+
123+
- PHP 8.2, 8.3, or 8.4
124+
- Symfony 6.4, 7.x, or 8.x
125+
- JSON extension
126+
104127
> See the [docs](https://docs.treblle.com/en/integrations/symfony) for this SDK to learn more.
105128

106129
## Available SDKs
107130

108131
Treblle provides [open-source SDKs](https://docs.treblle.com/en/integrations) that let you seamlessly integrate Treblle with your REST-based APIs.
109132

133+
- [`treblle-symfony`](https://github.com/Treblle/treblle-symfony): SDK for Symfony
110134
- [`treblle-laravel`](https://github.com/Treblle/treblle-laravel): SDK for Laravel
111135
- [`treblle-php`](https://github.com/Treblle/treblle-php): SDK for PHP
112-
- [`treblle-symfony`](https://github.com/Treblle/treblle-symfony): SDK for Symfony
113136
- [`treblle-lumen`](https://github.com/Treblle/treblle-lumen): SDK for Lumen
114137
- [`treblle-sails`](https://github.com/Treblle/treblle-sails): SDK for Sails
115138
- [`treblle-adonisjs`](https://github.com/Treblle/treblle-adonisjs): SDK for AdonisJS
@@ -124,17 +147,6 @@ Treblle provides [open-source SDKs](https://docs.treblle.com/en/integrations) th
124147

125148
> See the [docs](https://docs.treblle.com/en/integrations) for more on SDKs and Integrations.
126149

127-
## Other Packages
128-
129-
Besides the SDKs, we also provide helpers and configuration used for SDK
130-
development. If you're thinking about contributing to or creating a SDK, have a look at the resources
131-
below:
132-
133-
- [`treblle-utils`](https://github.com/Treblle/treblle-utils): A set of helpers and
134-
utility functions useful for the JavaScript SDKs.
135-
- [`php-utils`](https://github.com/Treblle/php-utils): A set of helpers and
136-
utility functions useful for the PHP SDKs.
137-
138150
## Community 💙
139151

140152
First and foremost: **Star and watch this repository** to stay up-to-date.
@@ -157,6 +169,171 @@ Here are some ways of contributing to making Treblle better:
157169
- Join our [Discord](https://treblle.com/chat) and connect with other members to share and learn from.
158170
- Send a pull request to any of our [open source repositories](https://github.com/Treblle) on Github. Check the contribution guide on the repo you want to contribute to for more details about how to contribute. We're looking forward to your contribution!
159171

172+
## Upgrading
173+
174+
### Upgrading from v2.x to v3.0
175+
176+
Version 3.0 introduces **breaking changes** to align with treblle-php v5.0 naming conventions. This is a major release that requires configuration updates.
177+
178+
#### What's New in v3.0
179+
180+
1. **New Configuration Option: `excluded_headers`**
181+
- You can now exclude specific headers from being tracked
182+
- Supports exact matching, wildcards, and regex patterns
183+
184+
2. **Support for Guzzle v9.0**
185+
- The SDK now supports Guzzle HTTP client versions 7.x, 8.x, and 9.x
186+
187+
3. **Better Integration with treblle-php**
188+
- Now uses `SensitiveDataMasker` from treblle-php package
189+
- Removed custom helpers in favor of treblle-php utilities
190+
191+
4. **Updated Default Masked Fields**
192+
- Removed `api_key` from default masked fields
193+
- Updated to match treblle-php v5.0 defaults exactly
194+
195+
#### Breaking Changes
196+
197+
##### 1. Configuration Parameter Names (BREAKING)
198+
199+
The configuration parameter names have been updated to match treblle-php v5.0 conventions:
200+
201+
**Before (v2.x):**
202+
```yaml
203+
treblle:
204+
project_id: "%env(TREBLLE_PROJECT_ID)%"
205+
api_key: "%env(TREBLLE_API_KEY)%"
206+
```
207+
208+
**After (v3.0):**
209+
```yaml
210+
treblle:
211+
api_key: "%env(TREBLLE_API_KEY)%"
212+
sdk_token: "%env(TREBLLE_SDK_TOKEN)%"
213+
```
214+
215+
##### 2. Environment Variable Names (BREAKING)
216+
217+
You need to update your environment variables:
218+
219+
**Before (v2.x):**
220+
- `TREBLLE_PROJECT_ID` - Your project ID
221+
- `TREBLLE_API_KEY` - Your API key
222+
223+
**After (v3.0):**
224+
- `TREBLLE_API_KEY` - Your project ID (this is what was TREBLLE_PROJECT_ID)
225+
- `TREBLLE_SDK_TOKEN` - Your SDK token (this is what was TREBLLE_API_KEY)
226+
227+
**Important:** The *values* stay the same, only the variable names change:
228+
```bash
229+
# Before
230+
TREBLLE_PROJECT_ID=your-project-id
231+
TREBLLE_API_KEY=your-api-key
232+
233+
# After
234+
TREBLLE_API_KEY=your-project-id # Same value as old TREBLLE_PROJECT_ID
235+
TREBLLE_SDK_TOKEN=your-api-key # Same value as old TREBLLE_API_KEY
236+
```
237+
238+
##### 3. Default Masked Fields (BREAKING)
239+
240+
The field `api_key` is no longer masked by default. If you need to mask it, add it explicitly:
241+
242+
```yaml
243+
treblle:
244+
masked_fields:
245+
- api_key # Add this if you need it masked
246+
```
247+
248+
#### Step-by-Step Upgrade Instructions
249+
250+
1. **Update your composer.json**
251+
252+
```bash
253+
composer require treblle/treblle-symfony:^3.0
254+
```
255+
256+
2. **Update your configuration file**
257+
258+
Update `config/packages/treblle.yaml`:
259+
260+
```yaml
261+
treblle:
262+
api_key: "%env(TREBLLE_API_KEY)%" # Was project_id
263+
sdk_token: "%env(TREBLLE_SDK_TOKEN)%" # Was api_key
264+
debug: false
265+
ignored_environments: dev,test,testing
266+
masked_fields:
267+
- password
268+
- pwd
269+
- secret
270+
- password_confirmation
271+
- cc
272+
- card_number
273+
- ccv
274+
- ssn
275+
- credit_score
276+
excluded_headers: # NEW in v3.0 (optional)
277+
- Authorization
278+
- X-Api-Key
279+
```
280+
281+
3. **Update your .env file**
282+
283+
```bash
284+
# Update variable names (keep the same values!)
285+
TREBLLE_API_KEY=your-project-id # This is your old TREBLLE_PROJECT_ID value
286+
TREBLLE_SDK_TOKEN=your-api-key-token # This is your old TREBLLE_API_KEY value
287+
```
288+
289+
4. **Clear your cache**
290+
291+
```bash
292+
php bin/console cache:clear
293+
```
294+
295+
5. **Test your application**
296+
297+
Verify that Treblle is tracking your API requests correctly by checking your Treblle dashboard.
298+
299+
#### Troubleshooting
300+
301+
**Issue: SDK not tracking requests after upgrade**
302+
303+
**Solution:** Clear your application cache and restart your web server:
304+
305+
```bash
306+
php bin/console cache:clear
307+
# If using PHP-FPM
308+
sudo service php-fpm restart
309+
# If using Symfony server
310+
symfony server:restart
311+
```
312+
313+
**Issue: Headers still being tracked despite excluded_headers**
314+
315+
**Solution:** Make sure the header names match exactly (case-sensitive) and clear your cache.
316+
317+
#### Need Help?
318+
319+
If you encounter any issues during the upgrade:
320+
321+
1. Check the [CHANGELOG.md](CHANGELOG.md) for detailed changes
322+
2. Review the configuration examples above
323+
3. Open an issue on [GitHub](https://github.com/Treblle/treblle-symfony/issues)
324+
4. Join our [Discord community](https://treblle.com/chat)
325+
326+
#### Rollback Instructions
327+
328+
If you need to rollback to v2.x:
329+
330+
```bash
331+
composer require treblle/treblle-symfony:^2.0
332+
php bin/console cache:clear
333+
```
334+
335+
Note that v2.x configuration will continue to work in v3.0, so you can upgrade without immediately changing your config files.
336+
160337
### Contributors
161338
<!-- Replace link with the link of the SDK contributors-->
162339
<a href="https://github.com/Treblle/treblle-symfony/graphs/contributors">

composer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
},
3232
"require": {
3333
"ext-json": "*",
34-
"php": "^8.2",
35-
"treblle/treblle-php": "^4.0.2",
36-
"symfony/config": "^4.4|^5.0|^6.0|^7.0",
37-
"symfony/console": "^4.4|^5.0|^6.0|^7.0",
38-
"symfony/routing": "^4.4|^5.0|^6.0|^7.0",
39-
"symfony/dependency-injection": "^4.4|^5.0|^6.0|^7.0",
40-
"symfony/event-dispatcher": "^4.4|^5.0|^6.0|^7.0",
41-
"symfony/http-kernel": "^4.4|^5.0|^6.0|^7.0"
34+
"php": "^8.2|^8.3|^8.4",
35+
"treblle/treblle-php": "^5.0",
36+
"symfony/config": "^6.4|^7.0|^8.0",
37+
"symfony/console": "^6.4|^7.0|^8.0",
38+
"symfony/routing": "^6.4|^7.0|^8.0",
39+
"symfony/dependency-injection": "^6.4|^7.0|^8.0",
40+
"symfony/event-dispatcher": "^6.4|^7.0|^8.0",
41+
"symfony/http-kernel": "^6.4|^7.0|^8.0"
4242
},
4343
"require-dev": {
4444
"laravel/pint": "^1.15"

0 commit comments

Comments
 (0)