-
Notifications
You must be signed in to change notification settings - Fork 221
Reliability tracking framework #3206
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
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
d8c8881
[ECP-9414] Generate event dispatcher/observer mechanism for reliabili…
khushboo-singhvi cab10f6
[ECP-9413] Create CheckoutAnalytics helper class
candemiralp 7c952c3
[ECP-9750] Implement configuration field for metrics data collection …
candemiralp 7cc4068
[ECP-9745] Update the DB schema and refactor related classes (#3024)
candemiralp ef583a9
[ECP-9746] Refactoring Checkout Analytics event requests (#3079)
khushboo-singhvi 1577b5d
Remote tracking main into the feature branch
candemiralp c566cd6
Remote tracking main into feature branch
candemiralp bab5747
[ECP-9751] Implement a cronjob to submit pending events (#3087)
candemiralp 8357536
[ECP-9417] Implement event dispatchers (#3113)
candemiralp 581bc10
[ECP-9727] Implement an event dispatcher for plugin installation even…
candemiralp 4cad31e
Remote track main into feature branch
candemiralp 907ce99
[ECP-9835] Add the version field to the adyen_analytics_event entity …
candemiralp 376a8ed
Merge branch 'main' into feature/reliability
candemiralp f3fb6bd
Add unit tests (#3207)
candemiralp 8344942
Fix several issues
candemiralp c84361c
Remove unexpectedEnd event from the info event batch
candemiralp 9aea1fd
Truncate the topic if necessary
candemiralp 09ecab0
Implement data clean-up functionality (#3209)
candemiralp 4df7fca
Merge branch 'main' into feature/reliability
candemiralp 2c14aff
Update .github/workflows/e2e-test.yml
candemiralp 6e242b0
Update .github/workflows/main.yml
candemiralp 5a5f1d2
Update .github/workflows/main.yml
candemiralp b089b42
Merge branch 'main' into feature/reliability
candemiralp 5f04efe
Reformat the message in case of errors
candemiralp 969363d
Merge branch 'main' into feature/reliability
candemiralp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <?php | ||
| namespace Adyen\Payment\Api; | ||
|
|
||
| use Adyen\Payment\Api\Data\AnalyticsEventInterface; | ||
|
|
||
| interface AnalyticsEventRepositoryInterface | ||
| { | ||
| public function save(AnalyticsEventInterface $analyticsEvent): AnalyticsEventInterface; | ||
|
|
||
| public function getById(int $id): AnalyticsEventInterface; | ||
|
|
||
| public function delete(AnalyticsEventInterface $analyticsEvent): void; | ||
|
|
||
| public function deleteById(int $id): void; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| <?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 <magento@adyen.com> | ||
| */ | ||
|
|
||
| namespace Adyen\Payment\Api\Data; | ||
|
|
||
| use DateTime; | ||
|
|
||
| interface AnalyticsEventInterface | ||
| { | ||
| const ADYEN_ANALYTICS_EVENT = 'adyen_analytics_event'; | ||
| const TABLE_NAME_ALIAS = 'analytics_event'; | ||
| const ENTITY_ID = 'entity_id'; | ||
| const UUID = 'uuid'; | ||
| const RELATION_ID = 'relation_id'; | ||
| const TYPE = 'type'; | ||
| const TOPIC = 'topic'; | ||
| const MESSAGE = 'message'; | ||
| const VERSION = 'version'; | ||
| 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(); | ||
|
|
||
| public function setEntityId($entityId); | ||
|
|
||
| public function getRelationId(): string; | ||
|
|
||
| public function setRelationId(string $relationId): AnalyticsEventInterface; | ||
|
|
||
| public function getUuid(): string; | ||
|
|
||
| public function setUuid(string $uuid): AnalyticsEventInterface; | ||
|
|
||
| public function getType(): string; | ||
|
|
||
| public function setType(string $type): AnalyticsEventInterface; | ||
|
|
||
| public function getTopic(): string; | ||
|
|
||
| public function setTopic(string $topic): AnalyticsEventInterface; | ||
|
|
||
| public function getMessage(): ?string; | ||
|
|
||
| public function setMessage(?string $message = null): AnalyticsEventInterface; | ||
|
|
||
| public function getVersion(): string; | ||
|
|
||
| public function setVersion(string $version): 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(): string; | ||
|
|
||
| public function setStatus(string $status): AnalyticsEventInterface; | ||
|
|
||
| public function getCreatedAt(): string; | ||
|
|
||
| public function setCreatedAt(string $createdAt): AnalyticsEventInterface; | ||
|
|
||
| public function getCreatedAtTimestamp(): int; | ||
|
|
||
| public function getUpdatedAt(): ?string; | ||
|
|
||
| public function setUpdatedAt(?string $updatedAt = null): AnalyticsEventInterface; | ||
|
|
||
| public function getScheduledProcessingTime(): ?string; | ||
|
|
||
| public function setScheduledProcessingTime(?string $scheduledProcessingTime = null): AnalyticsEventInterface; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 <magento@adyen.com> | ||
| */ | ||
|
|
||
| namespace Adyen\Payment\Api\Data; | ||
|
|
||
| enum AnalyticsEventStatusEnum: int | ||
| { | ||
| case PENDING = 0; | ||
| case PROCESSING = 1; | ||
| case DONE = 2; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 <magento@adyen.com> | ||
| */ | ||
|
|
||
| namespace Adyen\Payment\Api\Data; | ||
|
|
||
| enum AnalyticsEventTypeEnum: string | ||
| { | ||
| case EXPECTED_START = 'expectedStart'; | ||
| case EXPECTED_END = 'expectedEnd'; | ||
| case UNEXPECTED_END = 'unexpectedEnd'; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <?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 <magento@adyen.com> | ||
| */ | ||
|
|
||
| namespace Adyen\Payment\Api\Data; | ||
|
|
||
| enum ConfigurationEventType: string | ||
| { | ||
| case PLUGIN_INSTALLATION = 'plugin_installation'; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| <?php | ||
| /** | ||
| * | ||
| * Adyen Payment module (https://www.adyen.com/) | ||
| * | ||
| * Copyright (c) 2026 Adyen NV (https://www.adyen.com/) | ||
| * See LICENSE.txt for license details. | ||
| * | ||
| * Author: Adyen <magento@adyen.com> | ||
| */ | ||
|
|
||
| namespace Adyen\Payment\Cron; | ||
|
|
||
| use Adyen\Payment\Api\Data\AnalyticsEventInterface; | ||
| use Adyen\Payment\Logger\AdyenLogger; | ||
| use Adyen\Payment\Model\ResourceModel\AnalyticsEvent; | ||
| use Adyen\Payment\Model\ResourceModel\AnalyticsEvent\CollectionFactory; | ||
| use Exception; | ||
|
|
||
| class AnalyticsEventsCleanUp | ||
| { | ||
| /** | ||
| * @param CollectionFactory $analyticsEventCollectionFactory | ||
| * @param AnalyticsEvent $analyticsEventResourceModel | ||
| * @param AdyenLogger $adyenLogger | ||
| */ | ||
| public function __construct( | ||
| private readonly CollectionFactory $analyticsEventCollectionFactory, | ||
| private readonly AnalyticsEvent $analyticsEventResourceModel, | ||
| private readonly AdyenLogger $adyenLogger | ||
| ) {} | ||
|
|
||
| /** | ||
| * This method is executed by the cron job `adyen_payment_clean_up_analytics_events` and deletes | ||
| * the analytics events that are older than 45 days OR are in the done state. | ||
| * | ||
| * @return void | ||
| */ | ||
| public function execute(): void | ||
| { | ||
| try { | ||
| $collection = $this->analyticsEventCollectionFactory->create()->analyticsEventsToCleanUp(); | ||
|
|
||
| $ids = $collection->getColumnValues(AnalyticsEventInterface::ENTITY_ID); | ||
| if (!empty($ids)) { | ||
| $this->analyticsEventResourceModel->deleteByIds($ids); | ||
| } | ||
| } catch (Exception $e) { | ||
| $this->adyenLogger->error( | ||
| sprintf("An error occurred while cleaning up the analytics events: %s", $e->getMessage()) | ||
| ); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <?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 <magento@adyen.com> | ||
| */ | ||
|
|
||
| namespace Adyen\Payment\Cron\Providers; | ||
|
|
||
| use Adyen\Payment\Api\Data\AnalyticsEventInterface; | ||
|
|
||
| interface AnalyticsEventProviderInterface | ||
| { | ||
| const BATCH_SIZE = 1000; | ||
| const CLEAN_UP_BATCH_SIZE = 5000; | ||
|
|
||
| /** | ||
| * @return AnalyticsEventInterface[] | ||
| */ | ||
| public function provide(): array; | ||
|
|
||
| /** | ||
| * @return string | ||
| */ | ||
| public function getAnalyticsContext(): string; | ||
|
|
||
| /** | ||
| * @return string | ||
| */ | ||
| public function getProviderName(): string; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 <magento@adyen.com> | ||
| */ | ||
|
|
||
| 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; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| <?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 <magento@adyen.com> | ||
| */ | ||
|
|
||
| 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 | ||
| ]); | ||
|
|
||
| return $analyticsEventCollection->getItems(); | ||
| } | ||
|
|
||
| /** | ||
| * @return string | ||
| */ | ||
| public function getProviderName(): string | ||
| { | ||
| return self::PROVIDER_NAME; | ||
| } | ||
|
|
||
| /** | ||
| * @return string | ||
| */ | ||
| public function getAnalyticsContext(): string | ||
| { | ||
| return CheckoutAnalytics::CONTEXT_TYPE_INFO; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.