Backend php + Sentry + Identity

Does anybody know if it's possible to integrate identity as a sentry context?

Let me explain, I have an old project which works well, but once in a while throws some errors.
The problem is that I can't identify, who is dealing with that.

Tried this with the simplelogin security provider on a server connect:

\Sentry\init(['dsn' => 'https://dns' ]);
$userId = $_SESSION['simpleloginId'];

\Sentry\configureScope(function (\Sentry\State\Scope $scope) use ($userId): void {
    $scope->setUser(['id' => $userId]);
});

And it doesn't work: message": "Undefined global variable $_SESSION",
But

$userId = '123';

Does...
So my question is, it's possible to send {{identity}} to a sentry event?

Thanks in advance everyone

The error you have is because you have to call the function session_start() to initialize $_SESSION

But then you run into another problem, because Wappler code will also attempt to session_start(), and an error might be thrown due to double session_start()...

You probably have to look into Wappler extensions documentation to figure how to do this (if it's possible)

Hello my friend, thanks for the reply!

Yes, I saw a post from famousmag and it's not possible to call session_start:
"message": "session_start(): Ignoring session_start() because a session is already active"

@patrick can ask you what do you think about editing session.php?

I was searching session_start() and:
$_SESSION[$name] = $value;
if
$name === 'simpleloginId'
then:
$scope->setUser(['id' => $value]);

Working, but should avoid doing this? There's another way?

Someone know how to get this?
Thanks

Not an expert here, but get this workaround without edit any main file, in case anybody needs it:

<?php
require'../../dmxConnectLib/dmxConnect.php';
require '../../../vendor/autoload.php';
use lib\core\Session;
$session = new Session();

function usuario() {
    global $session; 
    if ($session->has('simpleloginId')) {
        $userId = $session->get('simpleloginId');
        return $userId;
    } 
}
$userId = usuario();
echo "usuario: " . $userId;

//SENTRY 
\Sentry\init(['dsn' => '###']);
\Sentry\configureScope(function (\Sentry\State\Scope $scope) use ($userId): void {
$scope->setUser(['id' => $userId]);
});

//REST OF THE CODE 
$app = new \lib\App();

$app->define(<<<'JSON'

image


Forcing an error and:
image

Please let me know if this looks ugly, trying my best here..