Replies: 3 comments
-
|
Probably the best thing to check for, but we can also look at raising an error event on our end as well, which would work outside the queue. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
This would be great,
With this information, I can then check which integration failed and send an email to the right person. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I noticed that you've already written a plugin for something similar. Event::on(Queue::class, Queue::EVENT_AFTER_ERROR, function (ExecEvent $event) {
QueueServices::sendFailedJobEmail($event);
});<?php
namespace modules\ExtendFormie\services;
use Craft;
use craft\base\Component;
use verbb\formie\jobs\TriggerIntegration;
use verbb\formie\integrations\crm\HubSpot;
use verbb\formie\integrations\crm\HubSpotLegacy;
use yii\queue\ExecEvent;
class QueueServices extends Component
{
// Public Methods
// =========================================================================
public static function sendFailedJobEmail(ExecEvent $event): void
{
// Only send on first attempt, else we just get hassled
if ((int)$event->attempt !== 1) {
return;
}
// only for formie
if (! $event->job instanceof TriggerIntegration) {
return;
}
// only for specific integration
$shouldSend = match (true) {
$event->job->integration instanceof HubSpot,
$event->job instanceof HubSpotLegacy => true,
default => false,
};
if ($shouldSend === false) {
return;
}
Craft::$app->getMailer()
->composeFromKey('extend_formie_failed_job')
->setTo('admin@test.com')
->send();
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Catch failed Integration
My customer needs to be notified immediately when an integration (e.g. HubSpot) fails.
Would adding an
Event::onforyii\queue\Queue::EVENT_AFTER_ERRORbe the right approach, or is there a specific event for integration failures?Thanks for your help.
Beta Was this translation helpful? Give feedback.
All reactions