Skip to content

Commit

Permalink
ref: Use constant for the SDK version (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
cleptric committed Oct 11, 2022
1 parent f3fbf70 commit 70dcc0b
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 7 deletions.
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

0 comments on commit 70dcc0b

Please sign in to comment.