Skip to content

fix: Allow endpoint customization based on new Betterstack Source Config#4

Open
ioannis-papikas wants to merge 1 commit intogoedemiddag:masterfrom
esatisfaction:master
Open

fix: Allow endpoint customization based on new Betterstack Source Config#4
ioannis-papikas wants to merge 1 commit intogoedemiddag:masterfrom
esatisfaction:master

Conversation

@ioannis-papikas
Copy link

No description provided.

@ioannis-papikas ioannis-papikas changed the title Allow endpoint customization based on new Betterstack Source Config fix: Allow endpoint customization based on new Betterstack Source Config Jan 8, 2026
Copy link
Member

@dvdheiden dvdheiden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ioannis-papikas Thank you for the merge request; we appreciate your effort! 👍

My colleague @johankrijt did most of the work on this package, so he's probably the one that can help you out the best.

A comment from my side: I would like this upgrade to be as smooth as possible for current users (including a lot of our own website/applications), so I already would like to give some suggestions to achieve that by handling the missing .env entry and falling back to the default without suppressing any errors. Would you mind taking a look at those comments?

Comment on lines 12 to 17
public function __construct(
private readonly string $sourceToken,
private readonly string $endpoint,
private CurlHandle|false $handle = false,
) {
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To prevent a breaking change, we could move the endpoint parameter to be the third parameter and assign the self::URL in the constructor.

Suggested change
public function __construct(
private readonly string $sourceToken,
private readonly string $endpoint,
private CurlHandle|false $handle = false,
) {
}
public function __construct(
private readonly string $sourceToken,
private CurlHandle|false $handle = false,
private readonly string $endpoint = self::URL,
) {
}

Comment on lines +44 to +45
$url = @$this->endpoint ?: self::URL;
curl_setopt($this->handle, CURLOPT_URL, $url);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With my constructor suggestion, you can change this to:

Suggested change
$url = @$this->endpoint ?: self::URL;
curl_setopt($this->handle, CURLOPT_URL, $url);
curl_setopt($this->handle, CURLOPT_URL, $endpoint);

class BetterStackHandler extends BufferHandler
{
public function __construct(string $sourceToken, ?string $appName = null, int|string|Level $level = Level::Debug)
public function __construct(string $sourceToken, string $endpoint, ?string $appName = null, int|string|Level $level = Level::Debug)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function __construct(string $sourceToken, string $endpoint, ?string $appName = null, int|string|Level $level = Level::Debug)
public function __construct(string $sourceToken, ?string $endpoint = null, ?string $appName = null, int|string|Level $level = Level::Debug)

As the endpoint might not be set by every user of this package, it should be nullable and null by default, I think.


public function __construct(
string $sourceToken,
string $endpoint,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
string $endpoint,
?string $endpoint = null,

See: https://github.com/goedemiddag/betterstack-logs/pull/4/changes#r2672524685

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants