Skip to content

Instantly share code, notes, and snippets.

@o0h
Created October 16, 2022 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save o0h/1684f51506e7d6919c200c8493c5ea1d to your computer and use it in GitHub Desktop.
Save o0h/1684f51506e7d6919c200c8493c5ea1d to your computer and use it in GitHub Desktop.
<?php
$dsn = getenv('SENTRY_DSN');
$urlParts = parse_url($dsn);
$baseUrl = 'http://localhost:3000'; // @see https://docs.sentry.io/product/relay/ for localhost:3000
# $baseUrl = "{$urlParts['scheme']}://{$urlParts['host']}";
$endpoint = "{$baseUrl}/api{$urlParts['path']}/store/";
$headers = [
'Content-Type: application/json',
"X-Sentry-Auth: Sentry sentry_version=7,sentry_client=watashidakenoclient/1.0,sentry_key={$urlParts['user']}",
];
// @see https://github.com/getsentry/sentry/blob/master/src/sentry/data/samples/php.json
$data = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . 'data/php.json');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, 1);
$result = curl_exec($ch);
$info = curl_getinfo($ch);
$error = curl_error($ch);
xdebug_break();
curl_close($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment