mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-26 14:53:48 +03:00
Do not dispatch async job for matomo if disabled
This commit is contained in:
parent
9dbd15bc0c
commit
f88d57b2b6
4 changed files with 12 additions and 4 deletions
|
@ -11,6 +11,7 @@ use Shlinkio\Shlink\Common\Cache\RedisPublishingHelper;
|
||||||
use Shlinkio\Shlink\Common\Mercure\MercureHubPublishingHelper;
|
use Shlinkio\Shlink\Common\Mercure\MercureHubPublishingHelper;
|
||||||
use Shlinkio\Shlink\Common\Mercure\MercureOptions;
|
use Shlinkio\Shlink\Common\Mercure\MercureOptions;
|
||||||
use Shlinkio\Shlink\Common\RabbitMq\RabbitMqPublishingHelper;
|
use Shlinkio\Shlink\Common\RabbitMq\RabbitMqPublishingHelper;
|
||||||
|
use Shlinkio\Shlink\Core\Matomo\MatomoOptions;
|
||||||
use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlStringifier;
|
use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlStringifier;
|
||||||
use Shlinkio\Shlink\Core\Visit\Geolocation\VisitLocator;
|
use Shlinkio\Shlink\Core\Visit\Geolocation\VisitLocator;
|
||||||
use Shlinkio\Shlink\Core\Visit\Geolocation\VisitToLocationHelper;
|
use Shlinkio\Shlink\Core\Visit\Geolocation\VisitToLocationHelper;
|
||||||
|
@ -188,6 +189,7 @@ return (static function (): array {
|
||||||
MercureOptions::class,
|
MercureOptions::class,
|
||||||
Options\WebhookOptions::class,
|
Options\WebhookOptions::class,
|
||||||
GeoLite2Options::class,
|
GeoLite2Options::class,
|
||||||
|
MatomoOptions::class,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace Shlinkio\Shlink\Core\EventDispatcher\Helper;
|
||||||
|
|
||||||
use Shlinkio\Shlink\Common\Mercure\MercureOptions;
|
use Shlinkio\Shlink\Common\Mercure\MercureOptions;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher;
|
use Shlinkio\Shlink\Core\EventDispatcher;
|
||||||
|
use Shlinkio\Shlink\Core\Matomo\MatomoOptions;
|
||||||
use Shlinkio\Shlink\Core\Options\RabbitMqOptions;
|
use Shlinkio\Shlink\Core\Options\RabbitMqOptions;
|
||||||
use Shlinkio\Shlink\Core\Options\WebhookOptions;
|
use Shlinkio\Shlink\Core\Options\WebhookOptions;
|
||||||
use Shlinkio\Shlink\EventDispatcher\Listener\EnabledListenerCheckerInterface;
|
use Shlinkio\Shlink\EventDispatcher\Listener\EnabledListenerCheckerInterface;
|
||||||
|
@ -19,6 +20,7 @@ class EnabledListenerChecker implements EnabledListenerCheckerInterface
|
||||||
private readonly MercureOptions $mercureOptions,
|
private readonly MercureOptions $mercureOptions,
|
||||||
private readonly WebhookOptions $webhookOptions,
|
private readonly WebhookOptions $webhookOptions,
|
||||||
private readonly GeoLite2Options $geoLiteOptions,
|
private readonly GeoLite2Options $geoLiteOptions,
|
||||||
|
private readonly MatomoOptions $matomoOptions,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +37,7 @@ class EnabledListenerChecker implements EnabledListenerCheckerInterface
|
||||||
EventDispatcher\RedisPubSub\NotifyNewShortUrlToRedis::class => $this->redisPubSubEnabled,
|
EventDispatcher\RedisPubSub\NotifyNewShortUrlToRedis::class => $this->redisPubSubEnabled,
|
||||||
EventDispatcher\Mercure\NotifyVisitToMercure::class,
|
EventDispatcher\Mercure\NotifyVisitToMercure::class,
|
||||||
EventDispatcher\Mercure\NotifyNewShortUrlToMercure::class => $this->mercureOptions->isEnabled(),
|
EventDispatcher\Mercure\NotifyNewShortUrlToMercure::class => $this->mercureOptions->isEnabled(),
|
||||||
|
EventDispatcher\Matomo\SendVisitToMatomo::class => $this->matomoOptions->enabled,
|
||||||
EventDispatcher\NotifyVisitToWebHooks::class => $this->webhookOptions->hasWebhooks(),
|
EventDispatcher\NotifyVisitToWebHooks::class => $this->webhookOptions->hasWebhooks(),
|
||||||
EventDispatcher\UpdateGeoLiteDb::class => $this->geoLiteOptions->hasLicenseKey(),
|
EventDispatcher\UpdateGeoLiteDb::class => $this->geoLiteOptions->hasLicenseKey(),
|
||||||
default => false, // Any unknown async listener should not be enabled by default
|
default => false, // Any unknown async listener should not be enabled by default
|
||||||
|
|
|
@ -7,11 +7,11 @@ namespace Shlinkio\Shlink\Core\Matomo;
|
||||||
class MatomoOptions
|
class MatomoOptions
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public readonly bool $enabled,
|
public readonly bool $enabled = false,
|
||||||
public readonly ?string $baseUrl,
|
public readonly ?string $baseUrl = null,
|
||||||
/** @var numeric-string|int|null */
|
/** @var numeric-string|int|null */
|
||||||
private readonly string|int|null $siteId,
|
private readonly string|int|null $siteId = null,
|
||||||
public readonly ?string $apiToken,
|
public readonly ?string $apiToken = null,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ use Shlinkio\Shlink\Core\EventDispatcher\RabbitMq\NotifyVisitToRabbitMq;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\RedisPubSub\NotifyNewShortUrlToRedis;
|
use Shlinkio\Shlink\Core\EventDispatcher\RedisPubSub\NotifyNewShortUrlToRedis;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\RedisPubSub\NotifyVisitToRedis;
|
use Shlinkio\Shlink\Core\EventDispatcher\RedisPubSub\NotifyVisitToRedis;
|
||||||
use Shlinkio\Shlink\Core\EventDispatcher\UpdateGeoLiteDb;
|
use Shlinkio\Shlink\Core\EventDispatcher\UpdateGeoLiteDb;
|
||||||
|
use Shlinkio\Shlink\Core\Matomo\MatomoOptions;
|
||||||
use Shlinkio\Shlink\Core\Options\RabbitMqOptions;
|
use Shlinkio\Shlink\Core\Options\RabbitMqOptions;
|
||||||
use Shlinkio\Shlink\Core\Options\WebhookOptions;
|
use Shlinkio\Shlink\Core\Options\WebhookOptions;
|
||||||
use Shlinkio\Shlink\IpGeolocation\GeoLite2\GeoLite2Options;
|
use Shlinkio\Shlink\IpGeolocation\GeoLite2\GeoLite2Options;
|
||||||
|
@ -149,6 +150,7 @@ class EnabledListenerCheckerTest extends TestCase
|
||||||
bool $mercureEnabled = false,
|
bool $mercureEnabled = false,
|
||||||
bool $webhooksEnabled = false,
|
bool $webhooksEnabled = false,
|
||||||
bool $geoLiteEnabled = false,
|
bool $geoLiteEnabled = false,
|
||||||
|
bool $matomoEnabled = false,
|
||||||
): EnabledListenerChecker {
|
): EnabledListenerChecker {
|
||||||
return new EnabledListenerChecker(
|
return new EnabledListenerChecker(
|
||||||
new RabbitMqOptions(enabled: $rabbitMqEnabled),
|
new RabbitMqOptions(enabled: $rabbitMqEnabled),
|
||||||
|
@ -156,6 +158,7 @@ class EnabledListenerCheckerTest extends TestCase
|
||||||
new MercureOptions(publicHubUrl: $mercureEnabled ? 'the-url' : null),
|
new MercureOptions(publicHubUrl: $mercureEnabled ? 'the-url' : null),
|
||||||
new WebhookOptions(['webhooks' => $webhooksEnabled ? ['foo', 'bar'] : []]),
|
new WebhookOptions(['webhooks' => $webhooksEnabled ? ['foo', 'bar'] : []]),
|
||||||
new GeoLite2Options(licenseKey: $geoLiteEnabled ? 'the-key' : null),
|
new GeoLite2Options(licenseKey: $geoLiteEnabled ? 'the-key' : null),
|
||||||
|
new MatomoOptions(enabled: $matomoEnabled),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue