generated from spatie/package-skeleton-php
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix CloudflareAnalytics + add default functions
- Loading branch information
1 parent
c184200
commit 1750200
Showing
2 changed files
with
155 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,57 @@ | ||
|
||
Add in your env file the following variables: | ||
Add in your .env file the following variables: | ||
|
||
```dotenv | ||
CLOUDFLARE_API_TOKEN='your_cloudflare_api_token' | ||
[//]: # (CLOUDFLARE_DEFAULT_ZONE_TAG='your_cloudflare_default_zone_tag') | ||
``` | ||
|
||
- ### Get views between two dates | ||
## Usage | ||
|
||
Default use: | ||
|
||
```php | ||
(new \The3LabsTeam\PhpCloudflareAnalytics\CloudflareAnalytics('zoneTag')) | ||
``` | ||
next you can use the following methods: | ||
|
||
```php | ||
->getLast6Hours($param, $paramType) | ||
|
||
->getLast24Hours($param, $paramType) | ||
|
||
->geLast7Days($param, $paramType) | ||
|
||
->getLastMonth($param, $paramType) | ||
``` | ||
|
||
and you can pass the following parameters to get the data: | ||
|
||
- PARAM => `sum` or `uniq` | ||
- PARAM TYPE | ||
- SUM: `request`, `pageViews`, `cachedBytes`, `cachedRequests`, `threats` | ||
- UNIQ: 'uniques' | ||
|
||
### Example | ||
|
||
Get the total number of requests in the last 6 hours: | ||
|
||
```php | ||
$cloudflare = new \The3LabsTeam\PhpCloudflareAnalytics\CloudflareAnalytics('29djm3nr...'); | ||
$cloudflare->getLast6Hours('sum', 'request'); | ||
``` | ||
|
||
Get the total number of unique visitors in the last 24 hours: | ||
|
||
```php | ||
(new \The3LabsTeam\PhpCloudflareAnalytics\CloudflareAnalytics()) | ||
->getViewsBetweenDates('start_date', 'end_date', 'zone_tag'); | ||
$cloudflare = new \The3LabsTeam\PhpCloudflareAnalytics\CloudflareAnalytics('29djm3nr...'); | ||
$cloudflare->getLast24Hours('uniq', 'uniques'); | ||
``` | ||
|
||
- ### Get total views between two dates | ||
Get the total number of page views in the last 7 days: | ||
|
||
```php | ||
(new \The3LabsTeam\PhpCloudflareAnalytics\CloudflareAnalytics()) | ||
->getTotalViewsBetweenDates('start_date', 'end_date', 'zone_tag'); | ||
$cloudflare = new \The3LabsTeam\PhpCloudflareAnalytics\CloudflareAnalytics('29djm3nr...'); | ||
$cloudflare->geLast7Days('sum', 'pageViews'); | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters