Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ run-name: Main

on:
pull_request:
branches: [main]
branches: [main, feature-v10/reliability]
# on-push trigger is required to analyse long-living branches on SonarCloud
push:
branches: [main]
branches: [main, feature-v10/reliability]
pull_request_target:
branches: [main]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use Adyen\Payment\Api\Data\AnalyticsEventInterface;

interface AdyenAnalyticsRepositoryInterface
interface AnalyticsEventRepositoryInterface
{
public function save(AnalyticsEventInterface $analyticsEvent): AnalyticsEventInterface;

Expand Down
30 changes: 24 additions & 6 deletions Api/Data/AnalyticsEventInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ interface AnalyticsEventInterface
const TYPE = 'type';
const TOPIC = 'topic';
const MESSAGE = 'message';
const ERROR_TYPE = 'error_type';
const ERROR_CODE = 'error_code';
const ERROR_COUNT = 'error_count';
const STATUS = 'status';
const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at';
const SCHEDULED_PROCESSING_TIME = 'scheduled_processing_time';
const MAX_ERROR_COUNT = 5;

public function getEntityId();

Expand All @@ -52,19 +56,33 @@ public function getMessage(): ?string;

public function setMessage(?string $message = null): AnalyticsEventInterface;

public function getErrorType(): ?string;

public function setErrorType(?string $errorType = null): AnalyticsEventInterface;

public function getErrorCode(): ?string;

public function setErrorCode(?string $errorCode = null): AnalyticsEventInterface;

public function getErrorCount(): int;

public function setErrorCount(int $errorCount): AnalyticsEventInterface;

public function getStatus(): int;
public function getStatus(): string;

public function setStatus(string $status): AnalyticsEventInterface;

public function getCreatedAt(): string;

public function setCreatedAt(string $createdAt): AnalyticsEventInterface;

public function setStatus(int $status): AnalyticsEventInterface;
public function getCreatedAtTimestamp(): int;

public function getCreatedAt(): DateTime;
public function getUpdatedAt(): ?string;

public function setCreatedAt(DateTime $createdAt): AnalyticsEventInterface;
public function setUpdatedAt(?string $updatedAt = null): AnalyticsEventInterface;

public function getUpdatedAt(): ?DateTime;
public function getScheduledProcessingTime(): ?string;

public function setUpdatedAt(?DateTime $updatedAt = null): AnalyticsEventInterface;
public function setScheduledProcessingTime(?string $scheduledProcessingTime = null): AnalyticsEventInterface;
}
20 changes: 20 additions & 0 deletions Api/Data/AnalyticsEventStatusEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
*
* Adyen Payment Module
*
* Copyright (c) 2025 Adyen N.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <[email protected]>
*/

namespace Adyen\Payment\Api\Data;

enum AnalyticsEventStatusEnum: int
{
case PENDING = 0;
case PROCESSING = 1;
case DONE = 2;
}
20 changes: 20 additions & 0 deletions Api/Data/AnalyticsEventTypeEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
*
* Adyen Payment Module
*
* Copyright (c) 2025 Adyen N.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <[email protected]>
*/

namespace Adyen\Payment\Api\Data;

enum AnalyticsEventTypeEnum: string
{
case EXPECTED_START = 'expectedStart';
case EXPECTED_END = 'expectedEnd';
case UNEXPECTED_END = 'unexpectedEnd';
}
34 changes: 34 additions & 0 deletions Cron/Providers/AnalyticsEventProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2025 Adyen N.V. (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <[email protected]>
*/

namespace Adyen\Payment\Cron\Providers;

use Adyen\Payment\Api\Data\AnalyticsEventInterface;

interface AnalyticsEventProviderInterface
{
const BATCH_SIZE = 1000;

/**
* @return AnalyticsEventInterface[]
*/
public function provide(): array;

/**
* @return string
*/
public function getAnalyticsContext(): string;

/**
* @return string
*/
public function getProviderName(): string;
}
60 changes: 60 additions & 0 deletions Cron/Providers/PendingErrorsAnalyticsEventsProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
/**
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2025 Adyen N.V. (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <[email protected]>
*/

namespace Adyen\Payment\Cron\Providers;

use Adyen\AdyenException;
use Adyen\Payment\Api\Data\AnalyticsEventInterface;
use Adyen\Payment\Api\Data\AnalyticsEventTypeEnum;
use Adyen\Payment\Helper\CheckoutAnalytics;
use Adyen\Payment\Model\ResourceModel\AnalyticsEvent\Collection as AnalyticsEventCollection;
use Adyen\Payment\Model\ResourceModel\AnalyticsEvent\CollectionFactory as AnalyticsEventCollectionFactory;

class PendingErrorsAnalyticsEventsProvider implements AnalyticsEventProviderInterface
{
const PROVIDER_NAME = 'Pending analytics events for `errors` context';

public function __construct(
private readonly AnalyticsEventCollectionFactory $analyticsEventCollectionFactory
) {}

/**
* @return AnalyticsEventInterface[]
* @throws AdyenException
*/
public function provide(): array
{
$analyticsEventCollection = $this->analyticsEventCollectionFactory->create();

/** @var AnalyticsEventCollection $analyticsEventCollection */
$analyticsEventCollection = $analyticsEventCollection->pendingAnalyticsEvents([
AnalyticsEventTypeEnum::UNEXPECTED_END
]);

return $analyticsEventCollection->getItems();
}

/**
* @return string
*/
public function getProviderName(): string
{
return self::PROVIDER_NAME;
}

/**
* @return string
*/
public function getAnalyticsContext(): string
{
return CheckoutAnalytics::CONTEXT_TYPE_ERRORS;
}
}
62 changes: 62 additions & 0 deletions Cron/Providers/PendingInfoAnalyticsEventsProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/**
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2025 Adyen N.V. (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <[email protected]>
*/

namespace Adyen\Payment\Cron\Providers;

use Adyen\AdyenException;
use Adyen\Payment\Api\Data\AnalyticsEventInterface;
use Adyen\Payment\Api\Data\AnalyticsEventTypeEnum;
use Adyen\Payment\Helper\CheckoutAnalytics;
use Adyen\Payment\Model\ResourceModel\AnalyticsEvent\Collection as AnalyticsEventCollection;
use Adyen\Payment\Model\ResourceModel\AnalyticsEvent\CollectionFactory as AnalyticsEventCollectionFactory;

class PendingInfoAnalyticsEventsProvider implements AnalyticsEventProviderInterface
{
const PROVIDER_NAME = 'Pending analytics events for `info` context';

public function __construct(
private readonly AnalyticsEventCollectionFactory $analyticsEventCollectionFactory
) {}

/**
* @return AnalyticsEventInterface[]
* @throws AdyenException
*/
public function provide(): array
{
$analyticsEventCollection = $this->analyticsEventCollectionFactory->create();

/** @var AnalyticsEventCollection $analyticsEventCollection */
$analyticsEventCollection = $analyticsEventCollection->pendingAnalyticsEvents([
AnalyticsEventTypeEnum::EXPECTED_START,
AnalyticsEventTypeEnum::EXPECTED_END,
AnalyticsEventTypeEnum::UNEXPECTED_END
]);

return $analyticsEventCollection->getItems();
}

/**
* @return string
*/
public function getProviderName(): string
{
return self::PROVIDER_NAME;
}

/**
* @return string
*/
public function getAnalyticsContext(): string
{
return CheckoutAnalytics::CONTEXT_TYPE_INFO;
}
}
Loading