Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: Use constant for the SDK version #662

Merged
merged 5 commits into from Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .craft.yml
Expand Up @@ -2,7 +2,6 @@ minVersion: 0.23.1
changelogPolicy: simple
artifactProvider:
name: none
preReleaseCommand: ''
targets:
- name: github
- name: registry
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,7 @@

- Add support for tracing of the Symfony HTTP client requests (#606)
- Support logging the impersonator user, if any (#647)
- ref: Use constant for the SDK version (#662)

## 4.3.1 (2022-10-10)

Expand Down
24 changes: 24 additions & 0 deletions scripts/bump-version.sh
@@ -0,0 +1,24 @@
#!/bin/bash
set -eux

# if [ "$(uname -s)" != "Linux" ]; then
# echo "Please use the GitHub Action."
# exit 1
# fi

SCRIPT_DIR="$( dirname "$0" )"
cd $SCRIPT_DIR/..

OLD_VERSION="${1}"
NEW_VERSION="${2}"

echo "Current version: $OLD_VERSION"
echo "Bumping version: $NEW_VERSION"

function replace() {
! grep "$2" $3
perl -i -pe "s/$1/$2/g" $3
grep "$2" $3 # verify that replacement was successful
}

replace "SDK_VERSION = '[0-9.]+'" "SDK_VERSION = '$NEW_VERSION'" ./src/SentryBundle.php
3 changes: 1 addition & 2 deletions src/DependencyInjection/SentryExtension.php
Expand Up @@ -5,7 +5,6 @@
namespace Sentry\SentryBundle\DependencyInjection;

use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Jean85\PrettyVersions;
use LogicException;
use Psr\Log\NullLogger;
use Sentry\Client;
Expand Down Expand Up @@ -140,7 +139,7 @@ private function registerConfiguration(ContainerBuilder $container, array $confi
$clientBuilderDefinition = (new Definition(ClientBuilder::class))
->setArgument(0, new Reference('sentry.client.options'))
->addMethodCall('setSdkIdentifier', [SentryBundle::SDK_IDENTIFIER])
->addMethodCall('setSdkVersion', [PrettyVersions::getVersion('sentry/sentry-symfony')->getPrettyVersion()])
->addMethodCall('setSdkVersion', [SentryBundle::SDK_VERSION])
->addMethodCall('setTransportFactory', [new Reference($config['transport_factory'])])
->addMethodCall('setSerializer', [$serializer])
->addMethodCall('setRepresentationSerializer', [$representationSerializerDefinition])
Expand Down
2 changes: 2 additions & 0 deletions src/SentryBundle.php
Expand Up @@ -14,6 +14,8 @@ final class SentryBundle extends Bundle
{
public const SDK_IDENTIFIER = 'sentry.php.symfony';

public const SDK_VERSION = '4.3.1';

public function build(ContainerBuilder $container): void
{
parent::build($container);
Expand Down
4 changes: 2 additions & 2 deletions src/Transport/TransportFactory.php
Expand Up @@ -6,14 +6,14 @@

use Http\Client\HttpAsyncClient as HttpAsyncClientInterface;
use Http\Discovery\Psr17FactoryDiscovery;
use Jean85\PrettyVersions;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\UriFactoryInterface;
use Psr\Log\LoggerInterface;
use Sentry\HttpClient\HttpClientFactory;
use Sentry\Options;
use Sentry\SentryBundle\SentryBundle;
use Sentry\Transport\DefaultTransportFactory;
use Sentry\Transport\TransportFactoryInterface;
use Sentry\Transport\TransportInterface;
Expand Down Expand Up @@ -52,7 +52,7 @@ public function __construct(
$streamFactory,
$httpClient,
'sentry.php.symfony',
PrettyVersions::getVersion('sentry/sentry-symfony')->getPrettyVersion()
SentryBundle::SDK_VERSION
),
$logger
);
Expand Down
3 changes: 1 addition & 2 deletions tests/DependencyInjection/SentryExtensionTest.php
Expand Up @@ -5,7 +5,6 @@
namespace Sentry\SentryBundle\Tests\DependencyInjection;

use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Jean85\PrettyVersions;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
use Sentry\ClientInterface;
Expand Down Expand Up @@ -244,7 +243,7 @@ public function testClientIsCreatedFromOptions(): void

$this->assertCount(6, $methodCalls);
$this->assertDefinitionMethodCallAt($methodCalls[0], 'setSdkIdentifier', [SentryBundle::SDK_IDENTIFIER]);
$this->assertDefinitionMethodCallAt($methodCalls[1], 'setSdkVersion', [PrettyVersions::getVersion('sentry/sentry-symfony')->getPrettyVersion()]);
$this->assertDefinitionMethodCallAt($methodCalls[1], 'setSdkVersion', [SentryBundle::SDK_VERSION]);
$this->assertDefinitionMethodCallAt($methodCalls[2], 'setTransportFactory', [new Reference('App\\Sentry\\Transport\\TransportFactory')]);
$this->assertDefinitionMethodCallAt($methodCalls[5], 'setLogger', [new Reference('app.logger')]);

Expand Down