PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.17
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.17
1.10.25 1.10.24 1.10.23 1.10.22 1.10.21 1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 All 169 releases
woocommerce-pos / vendor_prefixed / sentry / sentry / src / Integration / EnvironmentIntegration.php

EnvironmentIntegration.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.17, at vendor_prefixed/sentry/sentry/src/Integration/EnvironmentIntegration.php

69 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare (strict_types=1);
4 namespace WCPOS\Vendor\Sentry\Integration;
5
6 use WCPOS\Vendor\Sentry\Context\OsContext;
7 use WCPOS\Vendor\Sentry\Context\RuntimeContext;
8 use WCPOS\Vendor\Sentry\Event;
9 use WCPOS\Vendor\Sentry\SentrySdk;
10 use WCPOS\Vendor\Sentry\State\Scope;
11 use WCPOS\Vendor\Sentry\Util\PHPVersion;
12 /**
13 * This integration fills the event data with runtime and server OS information.
14 *
15 * @author Stefano Arlandini <[email protected]>
16 */
17 final class EnvironmentIntegration implements IntegrationInterface
18 {
19 /**
20 * {@inheritdoc}
21 */
22 public function setupOnce() : void
23 {
24 Scope::addGlobalEventProcessor(static function (Event $event) : Event {
25 $integration = SentrySdk::getCurrentHub()->getIntegration(self::class);
26 if ($integration !== null) {
27 $event->setRuntimeContext($integration->updateRuntimeContext($event->getRuntimeContext()));
28 $event->setOsContext($integration->updateServerOsContext($event->getOsContext()));
29 }
30 return $event;
31 });
32 }
33 private function updateRuntimeContext(?RuntimeContext $runtimeContext) : RuntimeContext
34 {
35 if ($runtimeContext === null) {
36 $runtimeContext = new RuntimeContext('php');
37 }
38 if ($runtimeContext->getVersion() === null) {
39 $runtimeContext->setVersion(PHPVersion::parseVersion());
40 }
41 if ($runtimeContext->getSAPI() === null) {
42 $runtimeContext->setSAPI(\PHP_SAPI);
43 }
44 return $runtimeContext;
45 }
46 private function updateServerOsContext(?OsContext $osContext) : ?OsContext
47 {
48 if (!\function_exists('php_uname')) {
49 return $osContext;
50 }
51 if ($osContext === null) {
52 $osContext = new OsContext(\php_uname('s'));
53 }
54 if ($osContext->getVersion() === null) {
55 $osContext->setVersion(\php_uname('r'));
56 }
57 if ($osContext->getBuild() === null) {
58 $osContext->setBuild(\php_uname('v'));
59 }
60 if ($osContext->getKernelVersion() === null) {
61 $osContext->setKernelVersion(\php_uname('a'));
62 }
63 if ($osContext->getMachineType() === null) {
64 $osContext->setMachineType(\php_uname('m'));
65 }
66 return $osContext;
67 }
68 }
69