Skip to content

Commit 2a08d00

Browse files
authored
Merge pull request #1 from shimulckbt/main
fix: filter hook name mismatch and updated readme doc
2 parents 60668ed + e1b453a commit 2a08d00

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

readme.md

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ composer require bitapps/wp-telemetry
1414

1515
### 2. Create a Telemetry Client
1616

17-
Initialize the telemetry client in your plugin.
17+
Initialize the telemetry client in your plugin's bootstrap file.
1818

1919
```php
2020
function initialize_telemetry_client() {
@@ -24,6 +24,9 @@ function initialize_telemetry_client() {
2424
TelemetryConfig::setVersion($version);
2525
TelemetryConfig::setServerBaseUrl( 'https://api.example.com/' );
2626

27+
TelemetryConfig::setTermsUrl( 'https://example.com/terms' ); // optional
28+
TelemetryConfig::setPolicyUrl( 'https://example.com/privacy' ); // optional
29+
2730
// initialize tracking and reporting
2831
Telemetry::report()->init();
2932

@@ -40,20 +43,6 @@ You are good to go! The telemetry client will start sending data to the default
4043

4144
All the configuration should be done in the `initialize_telemetry_client()` function.
4245

43-
### # Telemetry Client Config
44-
45-
Set custom terms URL
46-
47-
```php
48-
TelemetryConfig::setTermsUrl( 'https://example.com/terms' );
49-
```
50-
51-
Set custom privacy policy URL
52-
53-
```php
54-
TelemetryConfig::setPolicyUrl( 'https://example.com/privacy' );
55-
```
56-
5746
### # Tracking Report Modify
5847

5948
Add plugin information in tracking data
@@ -64,12 +53,14 @@ TelemetryConfig::report()
6453
->init();
6554
```
6655

67-
Add additional data in tracking data
56+
**Filter Hook to Add Additional Data :**
57+
58+
This filter allows adding additional data to track information used by the plugin. You can modify the `additional_data` array to include any custom data needed.
6859

6960
```php
7061
$plugin_prefix = 'my_plugin_prefix_';
7162

72-
add_filter($plugin_prefix . 'tracking_additional_data', function($additional_data) {
63+
add_filter($plugin_prefix . 'telemetry_additional_data', function($additional_data) {
7364

7465
// example: add custom data
7566
$additional_data['my_custom_data'] = 'My Custom Data';
@@ -78,17 +69,22 @@ add_filter($plugin_prefix . 'tracking_additional_data', function($additional_dat
7869
});
7970
```
8071

81-
Filter tracking data before sending
72+
**Filter Hook To Modify Telemetry Data :**
73+
74+
This filter allows modification of the telemetry data array before it is sent.
8275

8376
```php
8477
$plugin_prefix = 'my_plugin_prefix_';
8578

86-
add_filter($plugin_prefix . 'tracking_data', function($tracking_data) {
79+
add_filter($plugin_prefix . 'telemetry_data', function($telemetry_data) {
8780

8881
// example: remove some data
89-
unset($tracking_data['some_data']);
82+
unset($telemetry_data['some_data']);
83+
84+
// example: add custom data
85+
$telemetry_data['my_custom_data'] = 'My Custom Data';
9086

91-
return $tracking_data;
87+
return $telemetry_data;
9288
});
9389
```
9490

src/Telemetry/Report/Report.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ public function getTrackingData()
206206
$data['previously_skipped'] = true;
207207
}
208208

209-
$data['additional_data'] = apply_filters(TelemetryConfig::getPrefix() . 'tracker_additional_data', []);
209+
$data['additional_data'] = apply_filters(TelemetryConfig::getPrefix() . 'telemetry_additional_data', []);
210210

211-
return apply_filters(TelemetryConfig::getPrefix() . 'tracker_data', $data);
211+
return apply_filters(TelemetryConfig::getPrefix() . 'telemetry_data', $data);
212212
}
213213

214214
protected function dataWeCollect()

0 commit comments

Comments
 (0)