Skip to content

Commit 4636ce9

Browse files
Fixes
1 parent d025b05 commit 4636ce9

3 files changed

Lines changed: 29 additions & 9 deletions

File tree

src/Observability/SentryLogger.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function initialize(object $config): void
3333

3434
private function getEnvironment(): string
3535
{
36-
if ($_SERVER['SERVER_NAME'] === 'localhost') {
36+
if (!isset($_SERVER['SERVER_NAME']) || $_SERVER['SERVER_NAME'] === 'localhost') {
3737
return 'development';
3838
}
3939

src/Observability/SimpleFileIO.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ final class SimpleFileIO {
99
public function writeActivationFile(BluemConfiguration $data): bool
1010
{
1111
$path = __DIR__ . '/../../logs/';
12-
$filename = "activations_" . date("Ymd") . ".json";
12+
$filename = $this->createFileName();
13+
14+
$allData = [
15+
'config'=>$data,
16+
'php_version'=>PHP_VERSION,
17+
'bluem_php_version'=>BLUEM_PHP_LIBRARY_VERSION
18+
];
1319

1420
try {
15-
$fileContent = json_encode($data, JSON_THROW_ON_ERROR) . "\r\n";
21+
$fileContent = json_encode($allData, JSON_THROW_ON_ERROR) . "\r\n";
1622
} catch (JsonException $e) {
1723
return false;
1824
}
@@ -23,10 +29,15 @@ public function writeActivationFile(BluemConfiguration $data): bool
2329
public function activationFileExists(): bool
2430
{
2531
$path = __DIR__ . '/../../logs/';
26-
# consider a new file every month
27-
$filename = "activations_" . date("Ym") . ".json";
32+
$filename = $this->createFileName();
2833

2934
return file_exists($path . $filename);
3035
}
36+
37+
# consider a new file every month
38+
private function createFileName(): string
39+
{
40+
return "activations_" . date("Ym") . ".json";
41+
}
3142
}
3243

src/Observability/SimpleMailer.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,27 @@ public function notifyConfiguration(object $configuration): bool {
99
foreach ($configuration as $key => $value) {
1010
$message .= strtoupper($key) . ": " . $value . "\n";
1111
}
12-
$message .= "Environment: ". $_SERVER['SERVER_NAME'] === 'localhost' ? 'development' : 'production';
12+
$message .= "Environment: ". $this->getEnvironment();
13+
$message.= 'php_version'.PHP_VERSION;
14+
$message .= "Bluem PHP library version: ".BLUEM_PHP_LIBRARY_VERSION;
15+
16+
$adminEmail = "pluginsupport@bluem.nl";
1317

1418
// Additional headers
15-
$headers = "From: sender@example.com\r\n";
16-
$headers .= "Reply-To: sender@example.com\r\n";
19+
$headers = "From: $adminEmail\r\n";
20+
$headers .= "Reply-To: $adminEmail\r\n";
1721
$headers .= "X-Mailer: PHP/" . phpversion();
1822

19-
$to = "pluginsupport@bluem.nl";
23+
$to = $adminEmail;
2024
$subject = "Library Bluem-php instantiatie";
2125

2226
// Send the email
2327
return mail($to, $subject, $message, $headers);
2428
}
29+
30+
private function getEnvironment()
31+
{
32+
return (!isset($_SERVER['SERVER_NAME']) || $_SERVER['SERVER_NAME'] === 'localhost' ? 'development' : 'production');
33+
}
2534
}
2635

0 commit comments

Comments
 (0)