Skip to content

Commit

Permalink
Merge pull request #100 from Treblle/fix/treblle-debug-url
Browse files Browse the repository at this point in the history
Expanding URL option for debug for rare case that it is null
  • Loading branch information
JustSteveKing authored Oct 11, 2024
2 parents edee5ff + db24887 commit eeef8e3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Treblle.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class Treblle
*
* @throws ConfigurationException
*/
public static function log(string|Endpoint $endpoint, Data $data, ?string $projectId = null): void
public static function log(null|string|Endpoint $endpoint, Data $data, ?string $projectId = null): void
{
$treblleConfig = (array) config('treblle');

Expand Down Expand Up @@ -61,12 +61,18 @@ public static function log(string|Endpoint $endpoint, Data $data, ?string $proje
]
);

if (null === $endpoint) {
$finalEndpoint = Endpoint::random()->value;
} else {
$finalEndpoint = is_string($endpoint) ? $endpoint : $endpoint->value;
}

Http::withHeaders(
headers: ['X-API-KEY' => $apiKey],
)->withUserAgent(
userAgent: 'Treblle\Laravel/'.self::VERSION,
)->acceptJson()->asJson()->post(
url: is_string($endpoint) ? $endpoint : $endpoint->value,
url: $finalEndpoint,
data: $data,
);
}
Expand Down

0 comments on commit eeef8e3

Please sign in to comment.