|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit...
|
PhpStorm
|
faVsco.js – MatchActivityCrmData.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV
Export Data…
Copy to Database…
Compare Data
View as
Show Options Menu
Sync Changes
Hide This Notification
Code changed:
Hide
8
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Jobs\Crm;
use Exception;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Database\Connection;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Jobs\Job;
use Jiminny\Models\Activity;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Repositories\ActivityRepository;
use Jiminny\Services\Crm\CrmActivityService;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Throwable;
class MatchActivityCrmData extends Job implements ShouldQueue, ShouldBeUnique
{
use InteractsWithQueue;
use SerializesModels;
public int $tries = 3;
private int $activityId;
private ?Configuration $fromConfiguration;
private bool $remoteSearch;
public function __construct(
int $activityId,
?Configuration $fromConfiguration = null,
bool $remoteSearch = false,
) {
$this->activityId = $activityId;
$this->fromConfiguration = $fromConfiguration;
$this->remoteSearch = $remoteSearch;
$this->onQueue(Constants::QUEUE_ANALYTICS_LOW);
}
public function uniqueId(): string
{
$configId = $this->fromConfiguration?->getId() ?? 0;
$remote = $this->remoteSearch ? 'remote' : 'local';
return "$this->activityId:$configId:$remote";
}
public function timeout(): int
{
return 300; // 5 minutes max execution time
}
public function uniqueFor(): int
{
return $this->timeout() + 60; // timeout + 1 minute buffer
}
public function backoff(): array
{
return [30, 90, 180];
}
/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws Exception|Throwable
*/
public function handle(
ActivityRepository $activityRepository,
CrmActivityService $crmActivityService,
Connection $connection,
): void {
$activity = $activityRepository->findById($this->activityId);
if ($activity === null) {
throw new InvalidArgumentException('[MatchActivityCrmData] Cannot find activity.');
}
try {
$connection->transaction(function () use ($activity, $crmActivityService, $activityRepository) {
Log::info('[MatchActivityCrmData] Starting CRM data matching', [
'activity' => $this->activityId,
'remote_search' => $this->remoteSearch,
'set_configuration' => $this->fromConfiguration?->getId(),
'old_state' => [
'lead_id' => $activity->getLead()?->getId(),
'contact_id' => $activity->getContact()?->getId(),
'account_id' => $activity->getAccount()?->getId(),
'opportunity_id' => $activity->getOpportunity()?->getId(),
'stage_id' => $activity->getStage()?->getId(),
],
]);
$this->resetCrmMappings($activity, $activityRepository);
$this->switchCrmConfigurationIfNeeded($activity);
$activity->refresh();
$crmActivityService->updateCrmData(
activity: $activity,
remoteSearch: $this->remoteSearch,
);
$hasMatch = $activity->getLead() !== null
|| $activity->getContact() !== null
|| $activity->getAccount() !== null
|| $activity->getOpportunity() !== null;
if ($hasMatch) {
Log::info('[MatchActivityCrmData] Successfully matched CRM data', [
'activity' => $this->activityId,
'remote_search' => $this->remoteSearch,
'lead_id' => $activity->getLead()?->getId(),
'contact_id' => $activity->getContact()?->getId(),
'account_id' => $activity->getAccount()?->getId(),
'opportunity_id' => $activity->getOpportunity()?->getId(),
'stage_id' => $activity->getStage()?->getId(),
]);
} else {
Log::info('[MatchActivityCrmData] No CRM match found', [
'activity' => $this->activityId,
'remote_search' => $this->remoteSearch,
]);
}
});
} catch (Throwable $e) {
Log::error('[MatchActivityCrmData] Failed to match CRM data', [
'activity' => $this->activityId,
'remote_search' => $this->remoteSearch,
'exception' => $e->getMessage(),
'trace' => $e->getTraceAsString(),
]);
throw $e;
}
}
public function failed(Throwable $exception): void
{
Log::error('[MatchActivityCrmData] Job permanently failed after all retries', [
'activity' => $this->activityId,
'remote_search' => $this->remoteSearch,
'from_configuration' => $this->fromConfiguration?->getId(),
'exception' => $exception->getMessage(),
'attempts' => $this->attempts(),
]);
}
private function resetCrmMappings(
Activity $activity,
ActivityRepository $activityRepository
): void {
$activity->update([
'lead_id' => null,
'contact_id' => null,
'account_id' => null,
'opportunity_id' => null,
'stage_id' => null,
]);
$participantsOldState = $activityRepository->getActivityParticipants($activity)
->map(function ($participant) {
return [
'id' => $participant->id,
'user_id' => $participant->user_id,
'contact_id' => $participant->contact_id,
'lead_id' => $participant->lead_id,
];
});
if ($participantsOldState->isNotEmpty()) {
Log::info('[MatchActivityCrmData] Participants old state', [
'activity' => $this->activityId,
'participants' => $participantsOldState->toArray(),
]);
}
$activity->participants()->update([
'user_id' => null,
'contact_id' => null,
'lead_id' => null,
]);
}
private function switchCrmConfigurationIfNeeded(Activity $activity): void
{
if ($this->fromConfiguration === null) {
return;
}
if ($activity->getCrm()?->getId() === $this->fromConfiguration->getId()) {
return;
}
Log::info('[MatchActivityCrmData] Switching CRM configuration', [
'activity' => $this->activityId,
'old_configuration' => $activity->getCrm()?->getId(),
'new_configuration' => $this->fromConfiguration->getId(),
]);
$activity->update([
'crm_configuration_id' => $this->fromConfiguration->getId(),
'crm_provider_id' => null,
]);
}
}...
|
PhpStorm
|
faVsco.js – MatchActivityCrmData.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV
Export Data…
Copy to Database…
Compare Data
View as
Show Options Menu
Sync Changes
Hide This Notification
Code changed:
Hide
8
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Jobs\Crm;
use Exception;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Database\Connection;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Jobs\Job;
use Jiminny\Models\Activity;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Repositories\ActivityRepository;
use Jiminny\Services\Crm\CrmActivityService;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Throwable;
class MatchActivityCrmData extends Job implements ShouldQueue, ShouldBeUnique
{
use InteractsWithQueue;
use SerializesModels;
public int $tries = 3;
private int $activityId;
private ?Configuration $fromConfiguration;
private bool $remoteSearch;
public function __construct(
int $activityId,
?Configuration $fromConfiguration = null,
bool $remoteSearch = false,
) {
$this->activityId = $activityId;
$this->fromConfiguration = $fromConfiguration;
$this->remoteSearch = $remoteSearch;
$this->onQueue(Constants::QUEUE_ANALYTICS_LOW);
}
public function uniqueId(): string
{
$configId = $this->fromConfiguration?->getId() ?? 0;
$remote = $this->remoteSearch ? 'remote' : 'local';
return "$this->activityId:$configId:$remote";
}
public function timeout(): int
{
return 300; // 5 minutes max execution time
}
public function uniqueFor(): int
{
return $this->timeout() + 60; // timeout + 1 minute buffer
}
public function backoff(): array
{
return [30, 90, 180];
}
/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws Exception|Throwable
*/
public function handle(
ActivityRepository $activityRepository,
CrmActivityService $crmActivityService,
Connection $connection,
): void {
$activity = $activityRepository->findById($this->activityId);
if ($activity === null) {
throw new InvalidArgumentException('[MatchActivityCrmData] Cannot find activity.');
}
try {
$connection->transaction(function () use ($activity, $crmActivityService, $activityRepository) {
Log::info('[MatchActivityCrmData] Starting CRM data matching', [
'activity' => $this->activityId,
'remote_search' => $this->remoteSearch,
'set_configuration' => $this->fromConfiguration?->getId(),
'old_state' => [
'lead_id' => $activity->getLead()?->getId(),
'contact_id' => $activity->getContact()?->getId(),
'account_id' => $activity->getAccount()?->getId(),
'opportunity_id' => $activity->getOpportunity()?->getId(),
'stage_id' => $activity->getStage()?->getId(),
],
]);
$this->resetCrmMappings($activity, $activityRepository);
$this->switchCrmConfigurationIfNeeded($activity);
$activity->refresh();
$crmActivityService->updateCrmData(
activity: $activity,
remoteSearch: $this->remoteSearch,
);
$hasMatch = $activity->getLead() !== null
|| $activity->getContact() !== null
|| $activity->getAccount() !== null
|| $activity->getOpportunity() !== null;
if ($hasMatch) {
Log::info('[MatchActivityCrmData] Successfully matched CRM data', [
'activity' => $this->activityId,
'remote_search' => $this->remoteSearch,
'lead_id' => $activity->getLead()?->getId(),
'contact_id' => $activity->getContact()?->getId(),
'account_id' => $activity->getAccount()?->getId(),
'opportunity_id' => $activity->getOpportunity()?->getId(),
'stage_id' => $activity->getStage()?->getId(),
]);
} else {
Log::info('[MatchActivityCrmData] No CRM match found', [
'activity' => $this->activityId,
'remote_search' => $this->remoteSearch,
]);
}
});
} catch (Throwable $e) {
Log::error('[MatchActivityCrmData] Failed to match CRM data', [
'activity' => $this->activityId,
'remote_search' => $this->remoteSearch,
'exception' => $e->getMessage(),
'trace' => $e->getTraceAsString(),
]);
throw $e;
}
}
public function failed(Throwable $exception): void
{
Log::error('[MatchActivityCrmData] Job permanently failed after all retries', [
'activity' => $this->activityId,
'remote_search' => $this->remoteSearch,
'from_configuration' => $this->fromConfiguration?->getId(),
'exception' => $exception->getMessage(),
'attempts' => $this->attempts(),
]);
}
private function resetCrmMappings(
Activity $activity,
ActivityRepository $activityRepository
): void {
$activity->update([
'lead_id' => null,
'contact_id' => null,
'account_id' => null,
'opportunity_id' => null,
'stage_id' => null,
]);
$participantsOldState = $activityRepository->getActivityParticipants($activity)
->map(function ($participant) {
return [
'id' => $participant->id,
'user_id' => $participant->user_id,
'contact_id' => $participant->contact_id,
'lead_id' => $participant->lead_id,
];
});
if ($participantsOldState->isNotEmpty()) {
Log::info('[MatchActivityCrmData] Participants old state', [
'activity' => $this->activityId,
'participants' => $participantsOldState->toArray(),
]);
}
$activity->participants()->update([
'user_id' => null,
'contact_id' => null,
'lead_id' => null,
]);
}
private function switchCrmConfigurationIfNeeded(Activity $activity): void
{
if ($this->fromConfiguration === null) {
return;
}
if ($activity->getCrm()?->getId() === $this->fromConfiguration->getId()) {
return;
}
Log::info('[MatchActivityCrmData] Switching CRM configuration', [
'activity' => $this->activityId,
'old_configuration' => $activity->getCrm()?->getId(),
'new_configuration' => $this->fromConfiguration->getId(),
]);
$activity->update([
'crm_configuration_id' => $this->fromConfiguration->getId(),
'crm_provider_id' => null,
]);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – MatchActivityCrmData.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV
Export Data…
Copy to Database…
Compare Data
View as
Show Options Menu
Sync Changes
Hide This Notification
Code changed:
Hide
8
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Jobs\Crm;
use Exception;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Database\Connection;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
use Jiminny\Component\Queue\Constants;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Jobs\Job;
use Jiminny\Models\Activity;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Repositories\ActivityRepository;
use Jiminny\Services\Crm\CrmActivityService;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Throwable;
class MatchActivityCrmData extends Job implements ShouldQueue, ShouldBeUnique
{
use InteractsWithQueue;
use SerializesModels;
public int $tries = 3;
private int $activityId;
private ?Configuration $fromConfiguration;
private bool $remoteSearch;
public function __construct(
int $activityId,
?Configuration $fromConfiguration = null,
bool $remoteSearch = false,
) {
$this->activityId = $activityId;
$this->fromConfiguration = $fromConfiguration;
$this->remoteSearch = $remoteSearch;
$this->onQueue(Constants::QUEUE_ANALYTICS_LOW);
}
public function uniqueId(): string
{
$configId = $this->fromConfiguration?->getId() ?? 0;
$remote = $this->remoteSearch ? 'remote' : 'local';
return "$this->activityId:$configId:$remote";
}
public function timeout(): int
{
return 300; // 5 minutes max execution time
}
public function uniqueFor(): int
{
return $this->timeout() + 60; // timeout + 1 minute buffer
}
public function backoff(): array
{
return [30, 90, 180];
}
/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws Exception|Throwable
*/
public function handle(
ActivityRepository $activityRepository,
CrmActivityService $crmActivityService,
Connection $connection,
): void {
$activity = $activityRepository->findById($this->activityId);
if ($activity === null) {
throw new InvalidArgumentException('[MatchActivityCrmData] Cannot find activity.');
}
try {
$connection->transaction(function () use ($activity, $crmActivityService, $activityRepository) {
Log::info('[MatchActivityCrmData] Starting CRM data matching', [
'activity' => $this->activityId,
'remote_search' => $this->remoteSearch,
'set_configuration' => $this->fromConfiguration?->getId(),
'old_state' => [
'lead_id' => $activity->getLead()?->getId(),
'contact_id' => $activity->getContact()?->getId(),
'account_id' => $activity->getAccount()?->getId(),
'opportunity_id' => $activity->getOpportunity()?->getId(),
'stage_id' => $activity->getStage()?->getId(),
],
]);
$this->resetCrmMappings($activity, $activityRepository);
$this->switchCrmConfigurationIfNeeded($activity);
$activity->refresh();
$crmActivityService->updateCrmData(
activity: $activity,
remoteSearch: $this->remoteSearch,
);
$hasMatch = $activity->getLead() !== null
|| $activity->getContact() !== null
|| $activity->getAccount() !== null
|| $activity->getOpportunity() !== null;
if ($hasMatch) {
Log::info('[MatchActivityCrmData] Successfully matched CRM data', [
'activity' => $this->activityId,
'remote_search' => $this->remoteSearch,
'lead_id' => $activity->getLead()?->getId(),
'contact_id' => $activity->getContact()?->getId(),
'account_id' => $activity->getAccount()?->getId(),
'opportunity_id' => $activity->getOpportunity()?->getId(),
'stage_id' => $activity->getStage()?->getId(),
]);
} else {
Log::info('[MatchActivityCrmData] No CRM match found', [
'activity' => $this->activityId,
'remote_search' => $this->remoteSearch,
]);
}
});
} catch (Throwable $e) {
Log::error('[MatchActivityCrmData] Failed to match CRM data', [
'activity' => $this->activityId,
'remote_search' => $this->remoteSearch,
'exception' => $e->getMessage(),
'trace' => $e->getTraceAsString(),
]);
throw $e;
}
}
public function failed(Throwable $exception): void
{
Log::error('[MatchActivityCrmData] Job permanently failed after all retries', [
'activity' => $this->activityId,
'remote_search' => $this->remoteSearch,
'from_configuration' => $this->fromConfiguration?->getId(),
'exception' => $exception->getMessage(),
'attempts' => $this->attempts(),
]);
}
private function resetCrmMappings(
Activity $activity,
ActivityRepository $activityRepository
): void {
$activity->update([
'lead_id' => null,
'contact_id' => null,
'account_id' => null,
'opportunity_id' => null,
'stage_id' => null,
]);
$participantsOldState = $activityRepository->getActivityParticipants($activity)
->map(function ($participant) {
return [
'id' => $participant->id,
'user_id' => $participant->user_id,
'contact_id' => $participant->contact_id,
'lead_id' => $participant->lead_id,
];
});
if ($participantsOldState->isNotEmpty()) {
Log::info('[MatchActivityCrmData] Participants old state', [
'activity' => $this->activityId,
'participants' => $participantsOldState->toArray(),
]);
}
$activity->participants()->update([
'user_id' => null,
'contact_id' => null,
'lead_id' => null,
]);
}
private function switchCrmConfigurationIfNeeded(Activity $activity): void
{
if ($this->fromConfiguration === null) {
return;
}
if ($activity->getCrm()?->getId() === $this->fromConfiguration->getId()) {
return;
}
Log::info('[MatchActivityCrmData] Switching CRM configuration', [
'activity' => $this->activityId,
'old_configuration' => $activity->getCrm()?->getId(),
'new_configuration' => $this->fromConfiguration->getId(),
]);
$activity->update([
'crm_configuration_id' => $this->fromConfiguration->getId(),
'crm_provider_id' => null,
]);
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – MatchActivityCrmData.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV
Export Data…
Copy to Database…
Compare Data
View as
Show Options Menu
Sync Changes
Hide This Notification
Code changed:
Hide
1
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm;
use Illuminate\Support\Collection;
use Jiminny\Contracts\Repositories\TeamRepository;
use Jiminny\Contracts\Services\Crm\ServiceInterface;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Exceptions\SocialAccountTokenInvalidException;
use Jiminny\Models\Account;
use Jiminny\Models\Activity;
use Jiminny\Models\Contact;
use Jiminny\Models\Lead;
use Jiminny\Models\Opportunity;
use Jiminny\Models\Participant;
use Jiminny\Models\Stage;
use Jiminny\Models\Team;
use Jiminny\Models\User;
use Jiminny\Services\ResolveTeamCrmConnection;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Log\LoggerInterface;
use Exception;
use Throwable;
class CrmActivityService
{
public function __construct(
private readonly TeamRepository $teamRepository,
private readonly CachedCrmServiceDecorator $decorator,
private readonly EmailHelper $emailHelper,
private readonly ResolveTeamCrmConnection $teamCrmResolver,
private readonly LoggerInterface $logger,
) {
}
/**
* Updates CRM data for an activity and its participants.
*
* NOTE: This method performs multiple database writes and should be called
* within a transaction by the caller to ensure atomicity.
*
* @param Activity $activity
* @param bool $remoteSearch
*
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws Exception
*/
public function updateCrmData(
Activity $activity,
bool $remoteSearch = false,
): void {
$crmService = null;
$participants = $activity->getParticipants();
$team = $activity->getTeam();
$prospectSearchStrategy = ProspectSearchStrategyFactory::match($team);
if ($prospectSearchStrategy->ignoreCrmMatchData()) {
$this->logger->info('[CrmActivityService] Ignoring crm data because of prospect strategy', [
'activity_id' => $activity->getId(),
'strategy' => get_class($prospectSearchStrategy),
]);
return;
}
if ($remoteSearch) {
try {
$crmService = $this->teamCrmResolver->resolveForTeam($team);
} catch (SocialAccountTokenInvalidException) {
$this->logger->warning('[CrmActivityService] CRM token expired, falling back to local search', [
'activity_id' => $activity->getId(),
'team_id' => $team->getId(),
]);
}
}
$records = $this->updateParticipantsCrmData(
team: $team,
activity: $activity,
participants: $participants,
crmService: $crmService,
);
if (! empty($records)) {
$activity->updateActivityCrmData($records);
}
$activity->refresh();
}
/**
* @param Collection<Participant> $participants
*
* @throws Exception
*
* @return array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
*}|array{}
*/
private function updateParticipantsCrmData(
Team $team,
Activity $activity,
Collection $participants,
?ServiceInterface $crmService = null,
): array {
$matchedRecords = [];
$matchedDomainRecords = [];
$this->validateCrmConfiguration($activity);
$this->decorator->setConfiguration($activity->getCrm());
$this->decorator->setCrmService($crmService);
foreach ($participants as $participant) {
if ($this->shouldSkipParticipant($participant)) {
continue;
}
if (! $this->shouldPerformLookup($participant, $team)) {
$this->logger->info('[CrmActivityService] Email domain belongs to the team, skipping crm lookup', [
'activity_id' => $activity->getId(),
'team_id' => $team->getId(),
'email' => $participant->getEmailAddress(),
]);
$this->attachUserIfExists($participant, $team);
continue;
}
$records = $this->findCrmRecords($participant, $activity);
if (! empty($records)) {
$matchedRecords[] = $records;
} else {
$records = $this->findCrmDomainRecords(
crmService: $crmService,
participant: $participant,
activity: $activity,
);
if (! empty($records)) {
$matchedDomainRecords[] = $records;
}
}
if (empty($records)) {
continue;
}
try {
$activity->updateParticipantCrmData($records, $participant);
} catch (Throwable $ex) {
$this->logger->error('[CrmActivityService] Failed to update participant CRM data', [
'activity_id' => $activity->getId(),
'participant_id' => $participant->getId(),
'exception' => $ex->getMessage(),
]);
continue;
}
}
$bestMatch = $this->getBestMatch(
matchedRecords : $matchedRecords,
matchedDomainRecords: $matchedDomainRecords,
);
$this->logger->info('[CrmActivityService] CRM matching completed', [
'activity_id' => $activity->getId(),
'participants_processed' => $participants->count(),
'exact_matches' => count($matchedRecords),
'domain_matches' => count($matchedDomainRecords),
'best_match_found' => ! empty($bestMatch),
]);
return $bestMatch;
}
private function shouldPerformLookup(Participant $participant, Team $team): bool
{
if ($participant->hasEmailAddress()) {
return $this->emailHelper->shouldPerformLookup($team, $participant->getEmailAddress());
}
return true;
}
private function validateCrmConfiguration(Activity $activity): void
{
if ($activity->getCrm() === null) {
throw new InvalidArgumentException('Cannot find CRM configuration');
}
}
private function getBestMatch(?array $matchedRecords, ?array $matchedDomainRecords): array
{
return RecordSelector::pickBestFromLists($matchedRecords, $matchedDomainRecords);
}
private function findCrmRecords(Participant $participant, Activity $activity): ?array
{
$records = null;
if ($participant->hasEmailAddress()) {
$records = $this->decorator->matchExactlyByEmail(
email: $participant->getEmailAddress(),
userId: $activity->getUser()->getId()
);
}
if (empty($records) && $participant->getPhoneNumber() !== null) {
$records = $this->decorator->matchByPhone(
phone: $participant->getPhoneNumber(),
userId: $activity->getUser()->getId(),
);
}
if (empty($records) && $participant->getName() !== null) {
$records = $this->decorator->matchByName(
name: $participant->getName(),
userId: $activity->getUser()->getId(),
);
}
return $records;
}
private function shouldSkipParticipant(Participant $participant): bool
{
return $participant->hasUser();
}
private function attachUserIfExists(Participant $participant, Team $team): void
{
if ($participant->hasEmailAddress() === false) {
return;
}
$user = $this->teamRepository->findActiveTeamMemberByEmail($team, $participant->getEmailAddress());
if ($user instanceof User) {
$participant->user_id = $user->getId();
$participant->save();
}
}
private function findCrmDomainRecords(
?ServiceInterface $crmService,
Participant $participant,
Activity $activity,
): array {
if ($participant->hasEmailAddress()) {
$this->decorator->setConfiguration($activity->getCrm());
$this->decorator->setCrmService($crmService);
$records = $this->decorator->matchByDomain(
email: $participant->getEmailAddress(),
userId: $activity->getUser()->getId()
);
if (! empty($records)) {
return $records;
}
}
return [];
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – CrmActivityService.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV
Export Data…
Copy to Database…
Compare Data
View as
Show Options Menu
Sync Changes
Hide This Notification...
|
PhpStorm
|
faVsco.js – CrmActivityService.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV
Export Data…
Copy to Database…
Compare Data
View as
Show Options Menu
Sync Changes
Hide This Notification
Code changed:
Hide
1
5
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm;
use Illuminate\Support\Collection;
use Jiminny\Contracts\Repositories\TeamRepository;
use Jiminny\Contracts\Services\Crm\ServiceInterface;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Exceptions\SocialAccountTokenInvalidException;
use Jiminny\Models\Account;
use Jiminny\Models\Activity;
use Jiminny\Models\Contact;
use Jiminny\Models\Lead;
use Jiminny\Models\Opportunity;
use Jiminny\Models\Participant;
use Jiminny\Models\Stage;
use Jiminny\Models\Team;
use Jiminny\Models\User;
use Jiminny\Services\ResolveTeamCrmConnection;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Log\LoggerInterface;
use Exception;
use Throwable;
class CrmActivityService
{
public function __construct(
private readonly TeamRepository $teamRepository,
private readonly CachedCrmServiceDecorator $decorator,
private readonly EmailHelper $emailHelper,
private readonly ResolveTeamCrmConnection $teamCrmResolver,
private readonly LoggerInterface $logger,
) {
}
/**
* Updates CRM data for an activity and its participants.
*
* NOTE: This method performs multiple database writes and should be called
* within a transaction by the caller to ensure atomicity.
*
* @param Activity $activity
* @param bool $remoteSearch
*
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws Exception
*/
public function updateCrmData(
Activity $activity,
bool $remoteSearch = false,
): void {
$crmService = null;
$participants = $activity->getParticipants();
$team = $activity->getTeam();
$prospectSearchStrategy = ProspectSearchStrategyFactory::match($team);
if ($prospectSearchStrategy->ignoreCrmMatchData()) {
$this->logger->info('[CrmActivityService] Ignoring crm data because of prospect strategy', [
'activity_id' => $activity->getId(),
'strategy' => get_class($prospectSearchStrategy),
]);
return;
}
if ($remoteSearch) {
try {
$crmService = $this->teamCrmResolver->resolveForTeam($team);
} catch (SocialAccountTokenInvalidException) {
$this->logger->warning('[CrmActivityService] CRM token expired, falling back to local search', [
'activity_id' => $activity->getId(),
'team_id' => $team->getId(),
]);
}
}
$records = $this->updateParticipantsCrmData(
team: $team,
activity: $activity,
participants: $participants,
crmService: $crmService,
);
if (! empty($records)) {
$activity->updateActivityCrmData($records);
}
$activity->refresh();
}
/**
* @param Collection<Participant> $participants
*
* @throws Exception
*
* @return array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
*}|array{}
*/
private function updateParticipantsCrmData(
Team $team,
Activity $activity,
Collection $participants,
?ServiceInterface $crmService = null,
): array {
$matchedRecords = [];
$matchedDomainRecords = [];
$this->validateCrmConfiguration($activity);
$this->decorator->setConfiguration($activity->getCrm());
$this->decorator->setCrmService($crmService);
foreach ($participants as $participant) {
if ($this->shouldSkipParticipant($participant)) {
continue;
}
if (! $this->shouldPerformLookup($participant, $team)) {
$this->logger->info('[CrmActivityService] Email domain belongs to the team, skipping crm lookup', [
'activity_id' => $activity->getId(),
'team_id' => $team->getId(),
'email' => $participant->getEmailAddress(),
]);
$this->attachUserIfExists($participant, $team);
continue;
}
$records = $this->findCrmRecords($participant, $activity);
if (! empty($records)) {
$matchedRecords[] = $records;
} else {
$records = $this->findCrmDomainRecords(
crmService: $crmService,
participant: $participant,
activity: $activity,
);
if (! empty($records)) {
$matchedDomainRecords[] = $records;
}
}
if (empty($records)) {
continue;
}
try {
$activity->updateParticipantCrmData($records, $participant);
} catch (Throwable $ex) {
$this->logger->error('[CrmActivityService] Failed to update participant CRM data', [
'activity_id' => $activity->getId(),
'participant_id' => $participant->getId(),
'exception' => $ex->getMessage(),
]);
continue;
}
}
$bestMatch = $this->getBestMatch(
matchedRecords : $matchedRecords,
matchedDomainRecords: $matchedDomainRecords,
);
$this->logger->info('[CrmActivityService] CRM matching completed', [
'activity_id' => $activity->getId(),
'participants_processed' => $participants->count(),
'exact_matches' => count($matchedRecords),
'domain_matches' => count($matchedDomainRecords),
'best_match_found' => ! empty($bestMatch),
]);
return $bestMatch;
}
private function shouldPerformLookup(Participant $participant, Team $team): bool
{
if ($participant->hasEmailAddress()) {
return $this->emailHelper->shouldPerformLookup($team, $participant->getEmailAddress());
}
return true;
}
private function validateCrmConfiguration(Activity $activity): void
{
if ($activity->getCrm() === null) {
throw new InvalidArgumentException('Cannot find CRM configuration');
}
}
private function getBestMatch(?array $matchedRecords, ?array $matchedDomainRecords): array
{
return RecordSelector::pickBestFromLists($matchedRecords, $matchedDomainRecords);
}
private function findCrmRecords(Participant $participant, Activity $activity): ?array
{
$records = null;
if ($participant->hasEmailAddress()) {
$records = $this->decorator->matchExactlyByEmail(
email: $participant->getEmailAddress(),
userId: $activity->getUser()->getId()
);
}
if (empty($records) && $participant->getPhoneNumber() !== null) {
$records = $this->decorator->matchByPhone(
phone: $participant->getPhoneNumber(),
userId: $activity->getUser()->getId(),
);
}
if (empty($records) && $participant->getName() !== null) {
$records = $this->decorator->matchByName(
name: $participant->getName(),
userId: $activity->getUser()->getId(),
);
}
return $records;
}
private function shouldSkipParticipant(Participant $participant): bool
{
return $participant->hasUser();
}
private function attachUserIfExists(Participant $participant, Team $team): void
{
if ($participant->hasEmailAddress() === false) {
return;
}
$user = $this->teamRepository->findActiveTeamMemberByEmail($team, $participant->getEmailAddress());
if ($user instanceof User) {
$participant->user_id = $user->getId();
$participant->save();
}
}
private function findCrmDomainRecords(
?ServiceInterface $crmService,
Participant $participant,
Activity $activity,
): array {
if ($participant->hasEmailAddress()) {
$this->decorator->setConfiguration($activity->getCrm());
$this->decorator->setCrmService($crmService);
$records = $this->decorator->matchByDomain(
email: $participant->getEmailAddress(),
userId: $activity->getUser()->getId()
);
if (! empty($records)) {
return $records;
}
}
return [];
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – CrmActivityService.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV
Export Data…
Copy to Database…
Compare Data
View as
Show Options Menu
Sync Changes
Hide This Notification
Code changed:
Hide
1
5
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm;
use Illuminate\Support\Collection;
use Jiminny\Contracts\Repositories\TeamRepository;
use Jiminny\Contracts\Services\Crm\ServiceInterface;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Exceptions\SocialAccountTokenInvalidException;
use Jiminny\Models\Account;
use Jiminny\Models\Activity;
use Jiminny\Models\Contact;
use Jiminny\Models\Lead;
use Jiminny\Models\Opportunity;
use Jiminny\Models\Participant;
use Jiminny\Models\Stage;
use Jiminny\Models\Team;
use Jiminny\Models\User;
use Jiminny\Services\ResolveTeamCrmConnection;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Log\LoggerInterface;
use Exception;
use Throwable;
class CrmActivityService
{
public function __construct(
private readonly TeamRepository $teamRepository,
private readonly CachedCrmServiceDecorator $decorator,
private readonly EmailHelper $emailHelper,
private readonly ResolveTeamCrmConnection $teamCrmResolver,
private readonly LoggerInterface $logger,
) {
}
/**
* Updates CRM data for an activity and its participants.
*
* NOTE: This method performs multiple database writes and should be called
* within a transaction by the caller to ensure atomicity.
*
* @param Activity $activity
* @param bool $remoteSearch
*
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws Exception
*/
public function updateCrmData(
Activity $activity,
bool $remoteSearch = false,
): void {
$crmService = null;
$participants = $activity->getParticipants();
$team = $activity->getTeam();
$prospectSearchStrategy = ProspectSearchStrategyFactory::match($team);
if ($prospectSearchStrategy->ignoreCrmMatchData()) {
$this->logger->info('[CrmActivityService] Ignoring crm data because of prospect strategy', [
'activity_id' => $activity->getId(),
'strategy' => get_class($prospectSearchStrategy),
]);
return;
}
if ($remoteSearch) {
try {
$crmService = $this->teamCrmResolver->resolveForTeam($team);
} catch (SocialAccountTokenInvalidException) {
$this->logger->warning('[CrmActivityService] CRM token expired, falling back to local search', [
'activity_id' => $activity->getId(),
'team_id' => $team->getId(),
]);
}
}
$records = $this->updateParticipantsCrmData(
team: $team,
activity: $activity,
participants: $participants,
crmService: $crmService,
);
if (! empty($records)) {
$activity->updateActivityCrmData($records);
}
$activity->refresh();
}
/**
* @param Collection<Participant> $participants
*
* @throws Exception
*
* @return array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
*}|array{}
*/
private function updateParticipantsCrmData(
Team $team,
Activity $activity,
Collection $participants,
?ServiceInterface $crmService = null,
): array {
$matchedRecords = [];
$matchedDomainRecords = [];
$this->validateCrmConfiguration($activity);
$this->decorator->setConfiguration($activity->getCrm());
$this->decorator->setCrmService($crmService);
foreach ($participants as $participant) {
if ($this->shouldSkipParticipant($participant)) {
continue;
}
if (! $this->shouldPerformLookup($participant, $team)) {
$this->logger->info('[CrmActivityService] Email domain belongs to the team, skipping crm lookup', [
'activity_id' => $activity->getId(),
'team_id' => $team->getId(),
'email' => $participant->getEmailAddress(),
]);
$this->attachUserIfExists($participant, $team);
continue;
}
$records = $this->findCrmRecords($participant, $activity);
if (! empty($records)) {
$matchedRecords[] = $records;
} else {
$records = $this->findCrmDomainRecords(
crmService: $crmService,
participant: $participant,
activity: $activity,
);
if (! empty($records)) {
$matchedDomainRecords[] = $records;
}
}
if (empty($records)) {
continue;
}
try {
$activity->updateParticipantCrmData($records, $participant);
} catch (Throwable $ex) {
$this->logger->error('[CrmActivityService] Failed to update participant CRM data', [
'activity_id' => $activity->getId(),
'participant_id' => $participant->getId(),
'exception' => $ex->getMessage(),
]);
continue;
}
}
$bestMatch = $this->getBestMatch(
matchedRecords : $matchedRecords,
matchedDomainRecords: $matchedDomainRecords,
);
$this->logger->info('[CrmActivityService] CRM matching completed', [
'activity_id' => $activity->getId(),
'participants_processed' => $participants->count(),
'exact_matches' => count($matchedRecords),
'domain_matches' => count($matchedDomainRecords),
'best_match_found' => ! empty($bestMatch),
]);
return $bestMatch;
}
private function shouldPerformLookup(Participant $participant, Team $team): bool
{
if ($participant->hasEmailAddress()) {
return $this->emailHelper->shouldPerformLookup($team, $participant->getEmailAddress());
}
return true;
}
private function validateCrmConfiguration(Activity $activity): void
{
if ($activity->getCrm() === null) {
throw new InvalidArgumentException('Cannot find CRM configuration');
}
}
private function getBestMatch(?array $matchedRecords, ?array $matchedDomainRecords): array
{
return RecordSelector::pickBestFromLists($matchedRecords, $matchedDomainRecords);
}
private function findCrmRecords(Participant $participant, Activity $activity): ?array
{
$records = null;
if ($participant->hasEmailAddress()) {
$records = $this->decorator->matchExactlyByEmail(
email: $participant->getEmailAddress(),
userId: $activity->getUser()->getId()
);
}
if (empty($records) && $participant->getPhoneNumber() !== null) {
$records = $this->decorator->matchByPhone(
phone: $participant->getPhoneNumber(),
userId: $activity->getUser()->getId(),
);
}
if (empty($records) && $participant->getName() !== null) {
$records = $this->decorator->matchByName(
name: $participant->getName(),
userId: $activity->getUser()->getId(),
);
}
return $records;
}
private function shouldSkipParticipant(Participant $participant): bool
{
return $participant->hasUser();
}
private function attachUserIfExists(Participant $participant, Team $team): void
{
if ($participant->hasEmailAddress() === false) {
return;
}
$user = $this->teamRepository->findActiveTeamMemberByEmail($team, $participant->getEmailAddress());
if ($user instanceof User) {
$participant->user_id = $user->getId();
$participant->save();
}
}
private function findCrmDomainRecords(
?ServiceInterface $crmService,
Participant $participant,
Activity $activity,
): array {
if ($participant->hasEmailAddress()) {
$this->decorator->setConfiguration($activity->getCrm());
$this->decorator->setCrmService($crmService);
$records = $this->decorator->matchByDomain(
email: $participant->getEmailAddress(),
userId: $activity->getUser()->getId()
);
if (! empty($records)) {
return $records;
}
}
return [];
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All...
|
PhpStorm
|
faVsco.js – CrmActivityService.php
|
NULL
|
|
Platform Sprint 3 Q2 - Platform Team - Scrum Board Platform Sprint 3 Q2 - Platform Team - Scrum Board - Jira
Platform Sprint 3 Q2 - Platform Team - Scrum Board - Jira
SevenShores\Hubspot\Exceptions\BadRequest: Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT
SevenShores\Hubspot\Exceptions\BadRequest: Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT
Close tab
Service-Desk - Queues - Platform team - Service space - Jira
Service-Desk - Queues - Platform team - Service space - Jira
Jy 20807 check various issues with stages by nikolaybiaivanov · Pull Request #12041 · jiminny/app
Jy 20807 check various issues with stages by nikolaybiaivanov · Pull Request #12041 · jiminny/app
Sentry
Sentry
Pull requests · jiminny/app
Pull requests · jiminny/app
Userpilot | Ask Jiminny Report Generated
Userpilot | Ask Jiminny Report Generated
JY-20773 fix user pilot tracking ofr automated report generated by LakyLak · Pull Request #12024 · jiminny/app
JY-20773 fix user pilot tracking ofr automated report generated by LakyLak · Pull Request #12024 · jiminny/app
Jiminny
Jiminny
Search the CRM - HubSpot docs
Search the CRM - HubSpot docs
New Tab
Customize sidebar
Open Google Gemini (⌃X)
Tabs from other devices
Open history (⇧⌘H)
Open bookmarks (⌘B)
Skip to main content
Skip to main content
Toggle organization menu
Issues
Issues
Explore
Explore
Dashboards
Dashboards
Monitors
Monitors
Settings
Settings
Try Business
What's New
Help
[EMAIL]
Issues
Expand
Feed
Feed
Errors & Outages
Errors & Outages
Breached Metrics
Breached Metrics
Warnings
Warnings
User Feedback
User Feedback
Autofix
Autofix
Recently Run
Recently Run
All Views
All Views
Configure
Alerts Moved
Alerts
Moved
Issues
Issues
View Project Details
APP-1EED
Ask Seer
Ask Seer
/
Give Feedback
SevenShores\Hubspot\Exceptions\BadRequest
View events
Events (total)
Users (90d)
Level: Error
Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT","correlationId":"019dffc4-4 (truncated...)
17K
0
Ongoing
/app/Services/Crm/Hubspot/Pagination/HubspotPaginationService.php in Jiminny\Services\Crm\Hubspot\Pagination\HubspotPaginationService::executeSearchRequest
Resolve
Resolve
More resolve options
Archive
Archive
Archive options
Subscribe
Share
More Actions
Priority
Modify issue priority
High
Assignee
Modify issue assignee
Lukas Kovalik
production, production-eu
production, production-eu
90D
90D
Add a search term
Add a search term
Close sidebar
Toggle graph series - Events
Events
17K
Toggle graph series - Users
Users
0
release 68% 874599
release
68%
874599
environment 92% production
environment
92%
production
os.name 100% Linux
os.name
100%
Linux
runtime 94% php 8.3.30
runtime
94%
php 8.3.30
View all tags
View all tags
Select issue content
Events
Previous Event
Next Event
First
First
First
Latest
Latest
Latest
Recommended
Recommended
View More Events
View More Events
Copy as
Copy as
ID: b2e90a6e
13 hours ago
JSON
JSON
Highlights
Highlights
Stack Trace
Stack Trace
Trace
Trace
Tags
Tags
Context
Context
php
8.3.30
Linux
6.1.164-196.303.amzn2023.aarch64
882306
882306
production
Collapse Highlights Section
Highlights
Edit
Edit
handled
yes
level
error
transaction
--
url
--
Trace: Trace ID
76712d464c1e4764be8cc81c504d471e
76712d464c1e4764be8cc81c504d471e
Collapse Stack Trace Section
Stack Trace
Display options
Display
Copy as
Copy as
There are 2 chained exceptions in this event.
SevenShores\Hubspot\Exceptions\BadRequest
SevenShores\Hubspot\Exceptions\BadRequest
SevenShores\Hubspot\Exceptions\BadRequest
Client error: `POST
https://api.hubapi.com/crm/v3/objects/contact/search
https://api.hubapi.com/crm/v3/objects/contact/search
` resulted in a `429 Too Many Requests` response:
{"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT","correlationId":"019dffc4-4 (truncated...)
mechanism
generic
handled
true
code
429
Crashed in non-app
:
/vendor/hubspot/hubspot-php/src/Exceptions/HubspotException.php
:24
in
SevenShores\Hubspot\Exceptions\HubspotException::create
Show 1 more frame
Show 1 more frame
/app/Services/Crm/Hubspot/Pagination/HubspotPaginationService.php
:163
in
Jiminny\Services\Crm\Hubspot\Pagination\HubspotPaginationService::executeSearchRequest
In App
/app/Services/Crm/Hubspot/Pagination/HubspotPaginationService.php
:51
in
Jiminny\Services\Crm\Hubspot\Pagination\HubspotPaginationService::getPaginatedDataGenerator
In App
/app/Services/Crm/Hubspot/Client.php
:94
in
Jiminny\Services\Crm\Hubspot\Client::getPaginatedData
In App
/app/Services/Crm/Hubspot/Service.php
:1212
in
Jiminny\Services\Crm\Hubspot\Service::Jiminny\Services\Crm\Hubspot\{closure}
In App
Called from
:
/vendor/laravel/framework/src/Illuminate/Cache/Repository.php
:564
in
Illuminate\Cache\Repository::remember
Show 2 more frames
Show 2 more frames
/app/Services/Crm/Hubspot/Service.php
:1206
in
Jiminny\Services\Crm\Hubspot\Service::matchByName
In App
/app/Services/Crm/CachedCrmServiceDecorator.php
:167
in
Jiminny\Services\Crm\CachedCrmServiceDecorator::matchByName
In App
/app/Services/Crm/CrmActivityService.php
:227
in
Jiminny\Services\Crm\CrmActivityService::findCrmRecords
In App
/app/Services/Crm/CrmActivityService.php
:139
in
Jiminny\Services\Crm\CrmActivityService::updateParticipantsCrmData
In App
/app/Services/Crm/CrmActivityService.php
:81
in
Jiminny\Services\Crm\CrmActivityService::updateCrmData
In App
/app/Jobs/Crm/MatchActivityCrmData.php
:107
in
Jiminny\Jobs\Crm\MatchActivityCrmData::Jiminny\Jobs\Crm\{closure}
In App
Called from
:
/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php
:35
in
Illuminate\Database\Connection::transaction
/app/Jobs/Crm/MatchActivityCrmData.php
:87
in
Jiminny\Jobs\Crm\MatchActivityCrmData::handle
Copy file path
Open this line in GitHub
In App
82
if
(
$activity
===
null
)
{
83
throw
new
InvalidArgumentException
(
'[MatchActivityCrmData] Cannot find activity.'
)
;
84
}
85
86
try
{
87
$connection
->
transaction
(
function
(
)
use
(
$activity
,
$crmActivityService
,
$activityRepository
)
{
88
Log
::
info
(
'[MatchActivityCrmData] Starting CRM data matching'
,
[
89
'activity'
=>
$this
->
activityId
,
90
'remote_search'
=>
$this
->
remoteSearch
,
91
'set_configuration'
=>
$this
->
fromConfiguration
?->
getId
(
)
,
92
'old_state'
=>
[
activityRepository
Object Jiminny\Repositories\ActivityRepository
connection
Object Illuminate\Database\MariaDbConnection
crmActivityService
Object Jiminny\Services\Crm\CrmActivityService
Called from
:
/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php
:36
in
Illuminate\Container\BoundMethod::Illuminate\Container\{closure}
Show 14 more frames
Show 14 more frames
/app/Queue/Worker/Worker.php
:71
in
Jiminny\Queue\Worker\Worker::process
In App
Called from
:
/vendor/laravel/framework/src/Illuminate/Queue/Worker.php
:435
in
Illuminate\Queue\Worker::runJob
Show 17 more frames
Show 17 more frames
GuzzleHttp\Exception\ClientException
GuzzleHttp\Exception\ClientException
GuzzleHttp\Exception\ClientException
Collapse Trace Preview Section
Trace Preview
View Full Trace
View Full Trace
0.00ms
0.00ms
0s
0s
0s
0s
0s
0s
0s
0s
0s...
|
Firefox
|
SevenShores\Hubspot\Exceptions\BadRequest: Client SevenShores\Hubspot\Exceptions\BadRequest: Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT — Work...
|
jiminny.sentry.io/issues/7007366572/?environment=p jiminny.sentry.io/issues/7007366572/?environment=production&environment=production-eu&project=82419&query=is%3Aunresolved&referrer=issue-stream&sort=freq...
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0...
|
PhpStorm
|
faVsco.js – CrmActivityService.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV
Export Data…
Copy to Database…
Compare Data
View as
Show Options Menu
Sync Changes
Hide This Notification
Code changed:
Hide
1
5
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm;
use Illuminate\Support\Collection;
use Jiminny\Contracts\Repositories\TeamRepository;
use Jiminny\Contracts\Services\Crm\ServiceInterface;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Exceptions\SocialAccountTokenInvalidException;
use Jiminny\Models\Account;
use Jiminny\Models\Activity;
use Jiminny\Models\Contact;
use Jiminny\Models\Lead;
use Jiminny\Models\Opportunity;
use Jiminny\Models\Participant;
use Jiminny\Models\Stage;
use Jiminny\Models\Team;
use Jiminny\Models\User;
use Jiminny\Services\ResolveTeamCrmConnection;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Log\LoggerInterface;
use Exception;
use Throwable;
class CrmActivityService
{
public function __construct(
private readonly TeamRepository $teamRepository,
private readonly CachedCrmServiceDecorator $decorator,
private readonly EmailHelper $emailHelper,
private readonly ResolveTeamCrmConnection $teamCrmResolver,
private readonly LoggerInterface $logger,
) {
}
/**
* Updates CRM data for an activity and its participants.
*
* NOTE: This method performs multiple database writes and should be called
* within a transaction by the caller to ensure atomicity.
*
* @param Activity $activity
* @param bool $remoteSearch
*
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws Exception
*/
public function updateCrmData(
Activity $activity,
bool $remoteSearch = false,
): void {
$crmService = null;
$participants = $activity->getParticipants();
$team = $activity->getTeam();
$prospectSearchStrategy = ProspectSearchStrategyFactory::match($team);
if ($prospectSearchStrategy->ignoreCrmMatchData()) {
$this->logger->info('[CrmActivityService] Ignoring crm data because of prospect strategy', [
'activity_id' => $activity->getId(),
'strategy' => get_class($prospectSearchStrategy),
]);
return;
}
if ($remoteSearch) {
try {
$crmService = $this->teamCrmResolver->resolveForTeam($team);
} catch (SocialAccountTokenInvalidException) {
$this->logger->warning('[CrmActivityService] CRM token expired, falling back to local search', [
'activity_id' => $activity->getId(),
'team_id' => $team->getId(),
]);
}
}
$records = $this->updateParticipantsCrmData(
team: $team,
activity: $activity,
participants: $participants,
crmService: $crmService,
);
if (! empty($records)) {
$activity->updateActivityCrmData($records);
}
$activity->refresh();
}
/**
* @param Collection<Participant> $participants
*
* @throws Exception
*
* @return array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
*}|array{}
*/
private function updateParticipantsCrmData(
Team $team,
Activity $activity,
Collection $participants,
?ServiceInterface $crmService = null,
): array {
$matchedRecords = [];
$matchedDomainRecords = [];
$this->validateCrmConfiguration($activity);
$this->decorator->setConfiguration($activity->getCrm());
$this->decorator->setCrmService($crmService);
foreach ($participants as $participant) {
if ($this->shouldSkipParticipant($participant)) {
continue;
}
if (! $this->shouldPerformLookup($participant, $team)) {
$this->logger->info('[CrmActivityService] Email domain belongs to the team, skipping crm lookup', [
'activity_id' => $activity->getId(),
'team_id' => $team->getId(),
'email' => $participant->getEmailAddress(),
]);
$this->attachUserIfExists($participant, $team);
continue;
}
$records = $this->findCrmRecords($participant, $activity);
if (! empty($records)) {
$matchedRecords[] = $records;
} else {
$records = $this->findCrmDomainRecords(
crmService: $crmService,
participant: $participant,
activity: $activity,
);
if (! empty($records)) {
$matchedDomainRecords[] = $records;
}
}
if (empty($records)) {
continue;
}
try {
$activity->updateParticipantCrmData($records, $participant);
} catch (Throwable $ex) {
$this->logger->error('[CrmActivityService] Failed to update participant CRM data', [
'activity_id' => $activity->getId(),
'participant_id' => $participant->getId(),
'exception' => $ex->getMessage(),
]);
continue;
}
}
$bestMatch = $this->getBestMatch(
matchedRecords : $matchedRecords,
matchedDomainRecords: $matchedDomainRecords,
);
$this->logger->info('[CrmActivityService] CRM matching completed', [
'activity_id' => $activity->getId(),
'participants_processed' => $participants->count(),
'exact_matches' => count($matchedRecords),
'domain_matches' => count($matchedDomainRecords),
'best_match_found' => ! empty($bestMatch),
]);
return $bestMatch;
}
private function shouldPerformLookup(Participant $participant, Team $team): bool
{
if ($participant->hasEmailAddress()) {
return $this->emailHelper->shouldPerformLookup($team, $participant->getEmailAddress());
}
return true;
}
private function validateCrmConfiguration(Activity $activity): void
{
if ($activity->getCrm() === null) {
throw new InvalidArgumentException('Cannot find CRM configuration');
}
}
private function getBestMatch(?array $matchedRecords, ?array $matchedDomainRecords): array
{
return RecordSelector::pickBestFromLists($matchedRecords, $matchedDomainRecords);
}
private function findCrmRecords(Participant $participant, Activity $activity): ?array
{
$records = null;
if ($participant->hasEmailAddress()) {
$records = $this->decorator->matchExactlyByEmail(
email: $participant->getEmailAddress(),
userId: $activity->getUser()->getId()
);
}
if (empty($records) && $participant->getPhoneNumber() !== null) {
$records = $this->decorator->matchByPhone(
phone: $participant->getPhoneNumber(),
userId: $activity->getUser()->getId(),
);
}
if (empty($records) && $participant->getName() !== null) {
$records = $this->decorator->matchByName(
name: $participant->getName(),
userId: $activity->getUser()->getId(),
);
}
return $records;
}
private function shouldSkipParticipant(Participant $participant): bool
{
return $participant->hasUser();
}
private function attachUserIfExists(Participant $participant, Team $team): void
{
if ($participant->hasEmailAddress() === false) {
return;
}
$user = $this->teamRepository->findActiveTeamMemberByEmail($team, $participant->getEmailAddress());
if ($user instanceof User) {
$participant->user_id = $user->getId();
$participant->save();
}
}
private function findCrmDomainRecords(
?ServiceInterface $crmService,
Participant $participant,
Activity $activity,
): array {
if ($participant->hasEmailAddress()) {
$this->decorator->setConfiguration($activity->getCrm());
$this->decorator->setCrmService($crmService);
$records = $this->decorator->matchByDomain(
email: $participant->getEmailAddress(),
userId: $activity->getUser()->getId()
);
if (! empty($records)) {
return $records;
}
}
return [];
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – CrmActivityService.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV
Export Data…
Copy to Database…
Compare Data
View as
Show Options Menu
Sync Changes
Hide This Notification
Code changed:
Hide
1
5
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm;
use Illuminate\Support\Collection;
use Jiminny\Contracts\Repositories\TeamRepository;
use Jiminny\Contracts\Services\Crm\ServiceInterface;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Exceptions\SocialAccountTokenInvalidException;
use Jiminny\Models\Account;
use Jiminny\Models\Activity;
use Jiminny\Models\Contact;
use Jiminny\Models\Lead;
use Jiminny\Models\Opportunity;
use Jiminny\Models\Participant;
use Jiminny\Models\Stage;
use Jiminny\Models\Team;
use Jiminny\Models\User;
use Jiminny\Services\ResolveTeamCrmConnection;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Log\LoggerInterface;
use Exception;
use Throwable;
class CrmActivityService
{
public function __construct(
private readonly TeamRepository $teamRepository,
private readonly CachedCrmServiceDecorator $decorator,
private readonly EmailHelper $emailHelper,
private readonly ResolveTeamCrmConnection $teamCrmResolver,
private readonly LoggerInterface $logger,
) {
}
/**
* Updates CRM data for an activity and its participants.
*
* NOTE: This method performs multiple database writes and should be called
* within a transaction by the caller to ensure atomicity.
*
* @param Activity $activity
* @param bool $remoteSearch
*
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws Exception
*/
public function updateCrmData(
Activity $activity,
bool $remoteSearch = false,
): void {
$crmService = null;
$participants = $activity->getParticipants();
$team = $activity->getTeam();
$prospectSearchStrategy = ProspectSearchStrategyFactory::match($team);
if ($prospectSearchStrategy->ignoreCrmMatchData()) {
$this->logger->info('[CrmActivityService] Ignoring crm data because of prospect strategy', [
'activity_id' => $activity->getId(),
'strategy' => get_class($prospectSearchStrategy),
]);
return;
}
if ($remoteSearch) {
try {
$crmService = $this->teamCrmResolver->resolveForTeam($team);
} catch (SocialAccountTokenInvalidException) {
$this->logger->warning('[CrmActivityService] CRM token expired, falling back to local search', [
'activity_id' => $activity->getId(),
'team_id' => $team->getId(),
]);
}
}
$records = $this->updateParticipantsCrmData(
team: $team,
activity: $activity,
participants: $participants,
crmService: $crmService,
);
if (! empty($records)) {
$activity->updateActivityCrmData($records);
}
$activity->refresh();
}
/**
* @param Collection<Participant> $participants
*
* @throws Exception
*
* @return array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
*}|array{}
*/
private function updateParticipantsCrmData(
Team $team,
Activity $activity,
Collection $participants,
?ServiceInterface $crmService = null,
): array {
$matchedRecords = [];
$matchedDomainRecords = [];
$this->validateCrmConfiguration($activity);
$this->decorator->setConfiguration($activity->getCrm());
$this->decorator->setCrmService($crmService);
foreach ($participants as $participant) {
if ($this->shouldSkipParticipant($participant)) {
continue;
}
if (! $this->shouldPerformLookup($participant, $team)) {
$this->logger->info('[CrmActivityService] Email domain belongs to the team, skipping crm lookup', [
'activity_id' => $activity->getId(),
'team_id' => $team->getId(),
'email' => $participant->getEmailAddress(),
]);
$this->attachUserIfExists($participant, $team);
continue;
}
$records = $this->findCrmRecords($participant, $activity);
if (! empty($records)) {
$matchedRecords[] = $records;
} else {
$records = $this->findCrmDomainRecords(
crmService: $crmService,
participant: $participant,
activity: $activity,
);
if (! empty($records)) {
$matchedDomainRecords[] = $records;
}
}
if (empty($records)) {
continue;
}
try {
$activity->updateParticipantCrmData($records, $participant);
} catch (Throwable $ex) {
$this->logger->error('[CrmActivityService] Failed to update participant CRM data', [
'activity_id' => $activity->getId(),
'participant_id' => $participant->getId(),
'exception' => $ex->getMessage(),
]);
continue;
}
}
$bestMatch = $this->getBestMatch(
matchedRecords : $matchedRecords,
matchedDomainRecords: $matchedDomainRecords,
);
$this->logger->info('[CrmActivityService] CRM matching completed', [
'activity_id' => $activity->getId(),
'participants_processed' => $participants->count(),
'exact_matches' => count($matchedRecords),
'domain_matches' => count($matchedDomainRecords),
'best_match_found' => ! empty($bestMatch),
]);
return $bestMatch;
}
private function shouldPerformLookup(Participant $participant, Team $team): bool
{
if ($participant->hasEmailAddress()) {
return $this->emailHelper->shouldPerformLookup($team, $participant->getEmailAddress());
}
return true;
}
private function validateCrmConfiguration(Activity $activity): void
{
if ($activity->getCrm() === null) {
throw new InvalidArgumentException('Cannot find CRM configuration');
}
}
private function getBestMatch(?array $matchedRecords, ?array $matchedDomainRecords): array
{
return RecordSelector::pickBestFromLists($matchedRecords, $matchedDomainRecords);
}
private function findCrmRecords(Participant $participant, Activity $activity): ?array
{
$records = null;
if ($participant->hasEmailAddress()) {
$records = $this->decorator->matchExactlyByEmail(
email: $participant->getEmailAddress(),
userId: $activity->getUser()->getId()
);
}
if (empty($records) && $participant->getPhoneNumber() !== null) {
$records = $this->decorator->matchByPhone(
phone: $participant->getPhoneNumber(),
userId: $activity->getUser()->getId(),
);
}
if (empty($records) && $participant->getName() !== null) {
$records = $this->decorator->matchByName(
name: $participant->getName(),
userId: $activity->getUser()->getId(),
);
}
return $records;
}
private function shouldSkipParticipant(Participant $participant): bool
{
return $participant->hasUser();
}
private function attachUserIfExists(Participant $participant, Team $team): void
{
if ($participant->hasEmailAddress() === false) {
return;
}
$user = $this->teamRepository->findActiveTeamMemberByEmail($team, $participant->getEmailAddress());
if ($user instanceof User) {
$participant->user_id = $user->getId();
$participant->save();
}
}
private function findCrmDomainRecords(
?ServiceInterface $crmService,
Participant $participant,
Activity $activity,
): array {
if ($participant->hasEmailAddress()) {
$this->decorator->setConfiguration($activity->getCrm());
$this->decorator->setCrmService($crmService);
$records = $this->decorator->matchByDomain(
email: $participant->getEmailAddress(),
userId: $activity->getUser()->getId()
);
if (! empty($records)) {
return $records;
}
}
return [];
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – CrmActivityService.php
|
NULL
|
|
Platform Sprint 3 Q2 - Platform Team - Scrum Board Platform Sprint 3 Q2 - Platform Team - Scrum Board - Jira
Platform Sprint 3 Q2 - Platform Team - Scrum Board - Jira
SevenShores\Hubspot\Exceptions\BadRequest: Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT
SevenShores\Hubspot\Exceptions\BadRequest: Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT
Close tab
Service-Desk - Queues - Platform team - Service space - Jira
Service-Desk - Queues - Platform team - Service space - Jira
Jy 20807 check various issues with stages by nikolaybiaivanov · Pull Request #12041 · jiminny/app
Jy 20807 check various issues with stages by nikolaybiaivanov · Pull Request #12041 · jiminny/app
Sentry
Sentry
Pull requests · jiminny/app
Pull requests · jiminny/app
Userpilot | Ask Jiminny Report Generated
Userpilot | Ask Jiminny Report Generated
JY-20773 fix user pilot tracking ofr automated report generated by LakyLak · Pull Request #12024 · jiminny/app
JY-20773 fix user pilot tracking ofr automated report generated by LakyLak · Pull Request #12024 · jiminny/app
Jiminny
Jiminny
Search the CRM - HubSpot docs
Search the CRM - HubSpot docs
New Tab
Customize sidebar
Open Google Gemini (⌃X)
Tabs from other devices
Open history (⇧⌘H)
Open bookmarks (⌘B)
Skip to main content
Skip to main content
Toggle organization menu
Issues
Issues
Explore
Explore
Dashboards
Dashboards
Monitors
Monitors
Settings
Settings
Try Business
What's New
Help
[EMAIL]
Issues
Expand
Feed
Feed
Errors & Outages
Errors & Outages
Breached Metrics
Breached Metrics
Warnings
Warnings
User Feedback
User Feedback
Autofix
Autofix
Recently Run
Recently Run
All Views
All Views
Configure
Alerts Moved
Alerts
Moved
Issues
Issues
View Project Details
APP-1EED
Ask Seer
Ask Seer
/
Give Feedback
SevenShores\Hubspot\Exceptions\BadRequest
View events
Events (total)
Users (90d)
Level: Error
Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT","correlationId":"019dffc4-4 (truncated...)
17K
0
Ongoing
/app/Services/Crm/Hubspot/Pagination/HubspotPaginationService.php in Jiminny\Services\Crm\Hubspot\Pagination\HubspotPaginationService::executeSearchRequest
Resolve
Resolve
More resolve options
Archive
Archive
Archive options
Subscribe
Share
More Actions
Priority
Modify issue priority
High
Assignee
Modify issue assignee
Lukas Kovalik
production, production-eu
production, production-eu
90D
90D
Add a search term
Add a search term
Close sidebar
Toggle graph series - Events
Events
17K
Toggle graph series - Users
Users
0
release 68% 874599
release
68%
874599
environment 92% production
environment
92%
production
os.name 100% Linux
os.name
100%
Linux
runtime 94% php 8.3.30
runtime
94%
php 8.3.30
View all tags
View all tags
Select issue content
Events
Previous Event
Next Event
First
First
First
Latest
Latest
Latest
Recommended
Recommended
View More Events
View More Events
Copy as
Copy as
ID: b2e90a6e
13 hours ago
JSON
JSON
Highlights
Highlights
Stack Trace
Stack Trace
Trace
Trace
Tags
Tags
Context
Context
php
8.3.30
Linux
6.1.164-196.303.amzn2023.aarch64
882306
882306
production
Collapse Highlights Section
Highlights
Edit
Edit
handled
yes
level
error
transaction
--
url
--
Trace: Trace ID
76712d464c1e4764be8cc81c504d471e
76712d464c1e4764be8cc81c504d471e
Collapse Stack Trace Section
Stack Trace
Display options
Display
Copy as
Copy as
There are 2 chained exceptions in this event.
SevenShores\Hubspot\Exceptions\BadRequest
SevenShores\Hubspot\Exceptions\BadRequest
SevenShores\Hubspot\Exceptions\BadRequest
Client error: `POST
https://api.hubapi.com/crm/v3/objects/contact/search
https://api.hubapi.com/crm/v3/objects/contact/search
` resulted in a `429 Too Many Requests` response:
{"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT","correlationId":"019dffc4-4 (truncated...)
mechanism
generic
handled
true
code
429
Crashed in non-app
:
/vendor/hubspot/hubspot-php/src/Exceptions/HubspotException.php
:24
in
SevenShores\Hubspot\Exceptions\HubspotException::create
Show 1 more frame
Show 1 more frame
/app/Services/Crm/Hubspot/Pagination/HubspotPaginationService.php
:163
in
Jiminny\Services\Crm\Hubspot\Pagination\HubspotPaginationService::executeSearchRequest
In App
/app/Services/Crm/Hubspot/Pagination/HubspotPaginationService.php
:51
in
Jiminny\Services\Crm\Hubspot\Pagination\HubspotPaginationService::getPaginatedDataGenerator
In App
/app/Services/Crm/Hubspot/Client.php
:94
in
Jiminny\Services\Crm\Hubspot\Client::getPaginatedData
In App
/app/Services/Crm/Hubspot/Service.php
:1212
in
Jiminny\Services\Crm\Hubspot\Service::Jiminny\Services\Crm\Hubspot\{closure}
In App
Called from
:
/vendor/laravel/framework/src/Illuminate/Cache/Repository.php
:564
in
Illuminate\Cache\Repository::remember
Show 2 more frames
Show 2 more frames
/app/Services/Crm/Hubspot/Service.php
:1206
in
Jiminny\Services\Crm\Hubspot\Service::matchByName
In App
/app/Services/Crm/CachedCrmServiceDecorator.php
:167
in
Jiminny\Services\Crm\CachedCrmServiceDecorator::matchByName
In App
/app/Services/Crm/CrmActivityService.php
:227
in
Jiminny\Services\Crm\CrmActivityService::findCrmRecords
In App
/app/Services/Crm/CrmActivityService.php
:139
in
Jiminny\Services\Crm\CrmActivityService::updateParticipantsCrmData
In App
/app/Services/Crm/CrmActivityService.php
:81
in
Jiminny\Services\Crm\CrmActivityService::updateCrmData
In App
/app/Jobs/Crm/MatchActivityCrmData.php
:107
in
Jiminny\Jobs\Crm\MatchActivityCrmData::Jiminny\Jobs\Crm\{closure}
In App
Called from
:...
|
Firefox
|
SevenShores\Hubspot\Exceptions\BadRequest: Client SevenShores\Hubspot\Exceptions\BadRequest: Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT — Work...
|
jiminny.sentry.io/issues/7007366572/?environment=p jiminny.sentry.io/issues/7007366572/?environment=production&environment=production-eu&project=82419&query=is%3Aunresolved&referrer=issue-stream&sort=freq...
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0...
|
PhpStorm
|
faVsco.js – CrmActivityService.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
iTerm2ShellEditViewSessionScriptsProfilesWindowHelp$0ld6]Lukas/Stefka 121 - in 1h 47 m100% [8DEV (docker)DOCKERO 81DEV (docker)H82artisan-schedule:artisan-schedule_00:stoppedworker-es-update:worker-es-update_00: stoppedartisan-schedule:artisan-schedule_00: startedjiminny-worker-processing-1:jiminny-worker-processing-1_00: startedjiminny-worker-processing-2: jiminny-worker-processing-2_00: startedjiminny-worker-processing-3:jiminny-worker-processing-3_00: startedjiminny-worker-processing-4:jiminny-worker-processing-4_00: startedjiminny-worker-processing-5:jiminny-worker-processing-5_00: startedjiminny-worker-processing-delayed: jiminny-worker-processing-delayed_00:worker:worker_00: startedworker-analytics:worker-analytics_00:startedworker-audio:worker-audio_00: startedworker-calendar:worker-calendar_00:startedworker-conferences:worker-conferences_00: startedworker-crm-sync:worker-crm-sync_00:startedworker-crm-update:worker-crm-update_00: startedworker-download:worker-download_00: startedworker-emails:worker-emails_00:startedworker-es-update:worker-es-update_00: startedworker-nudges:worker-nudges_00: startedroot@docker_Lamp_1:/home/jiminny# php artisan jiminny: debugMatching contact 0root@docker_lamp_1:/home/jiminny# php artisan jiminny: debugMatching contact 0Matching contact 1Matchingcontact 2Matchingcontact 3Matching contact 4Matching contact 5Matching contact6Matching contact 7Matching contact 8Matching contact 9root@docker_lamp_1:/home/jiminny# php artisan jiminny:debugMatching contact 0Matching contact 1Matching contact 2Matching contact 3Matchingcontact 4Matchingcontact 5Matching contact 6Matching contact 7Matching contact 8Matching contact 9root@docker_lamp_1:/home/jiminny# ]APP (-zsh)-zsh• $4screenpipe*•$5-zshThu 7 May 15:43:19T81₴6DEVstarted...
|
PhpStorm
|
faVsco.js – CrmActivityService.php
|
NULL
|
|
Platform Sprint 3 Q2 - Platform Team - Scrum Board Platform Sprint 3 Q2 - Platform Team - Scrum Board - Jira
Platform Sprint 3 Q2 - Platform Team - Scrum Board - Jira
SevenShores\Hubspot\Exceptions\BadRequest: Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT
SevenShores\Hubspot\Exceptions\BadRequest: Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT
Close tab
Service-Desk - Queues - Platform team - Service space - Jira
Service-Desk - Queues - Platform team - Service space - Jira
Jy 20807 check various issues with stages by nikolaybiaivanov · Pull Request #12041 · jiminny/app
Jy 20807 check various issues with stages by nikolaybiaivanov · Pull Request #12041 · jiminny/app
Sentry
Sentry
Pull requests · jiminny/app
Pull requests · jiminny/app
Userpilot | Ask Jiminny Report Generated
Userpilot | Ask Jiminny Report Generated
JY-20773 fix user pilot tracking ofr automated report generated by LakyLak · Pull Request #12024 · jiminny/app
JY-20773 fix user pilot tracking ofr automated report generated by LakyLak · Pull Request #12024 · jiminny/app
Jiminny
Jiminny
Search the CRM - HubSpot docs
Search the CRM - HubSpot docs
New Tab
Customize sidebar
Open Google Gemini (⌃X)
Tabs from other devices
Open history (⇧⌘H)
Open bookmarks (⌘B)
Skip to main content
Skip to main content
Toggle organization menu
Issues
Issues
Explore
Explore
Dashboards
Dashboards
Monitors
Monitors
Settings
Settings
Try Business
What's New
Help
[EMAIL]
Issues
Expand
Feed
Feed
Errors & Outages
Errors & Outages
Breached Metrics
Breached Metrics
Warnings
Warnings
User Feedback
User Feedback
Autofix
Autofix
Recently Run
Recently Run
All Views
All Views
Configure
Alerts Moved
Alerts
Moved
Issues
Issues
View Project Details
APP-1EED
Ask Seer
Ask Seer
/
Give Feedback
SevenShores\Hubspot\Exceptions\BadRequest
View events
Events (total)
Users (90d)
Level: Error
Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT","correlationId":"019dffc4-4 (truncated...)
17K
0
Ongoing
/app/Services/Crm/Hubspot/Pagination/HubspotPaginationService.php in Jiminny\Services\Crm\Hubspot\Pagination\HubspotPaginationService::executeSearchRequest
Resolve
Resolve
More resolve options
Archive
Archive
Archive options
Subscribe
Share
More Actions
Priority
Modify issue priority
High
Assignee
Modify issue assignee
Lukas Kovalik
production, production-eu
production, production-eu
90D
90D
Add a search term
Add a search term
Close sidebar
Toggle graph series - Events
Events
17K
Toggle graph series - Users
Users
0
release 68% 874599
release
68%
874599
environment 92% production
environment
92%
production
os.name 100% Linux
os.name
100%
Linux
runtime 94% php 8.3.30
runtime
94%
php 8.3.30
View all tags
View all tags
Select issue content
Events
Previous Event
Next Event
First
First
First
Latest
Latest
Latest
Recommended
Recommended
View More Events
View More Events
Copy as
Copy as
ID: b2e90a6e
13 hours ago
JSON
JSON
Highlights
Highlights
Stack Trace
Stack Trace
Trace
Trace
Tags
Tags
Context
Context
php
8.3.30
Linux
6.1.164-196.303.amzn2023.aarch64
882306
882306
production
Collapse Highlights Section
Highlights
Edit
Edit
handled
yes
level
error
transaction
--
url
--
Trace: Trace ID
76712d464c1e4764be8cc81c504d471e
76712d464c1e4764be8cc81c504d471e
Collapse Stack Trace Section
Stack Trace
Display options
Display
Copy as
Copy as
There are 2 chained exceptions in this event.
SevenShores\Hubspot\Exceptions\BadRequest
SevenShores\Hubspot\Exceptions\BadRequest
SevenShores\Hubspot\Exceptions\BadRequest
Client error: `POST
https://api.hubapi.com/crm/v3/objects/contact/search
https://api.hubapi.com/crm/v3/objects/contact/search
` resulted in a `429 Too Many Requests` response:
{"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT","correlationId":"019dffc4-4 (truncated...)
mechanism
generic
handled
true
code
429
Crashed in non-app
:
/vendor/hubspot/hubspot-php/src/Exceptions/HubspotException.php
:24
in
SevenShores\Hubspot\Exceptions\HubspotException::create
Show 1 more frame
Show 1 more frame
/app/Services/Crm/Hubspot/Pagination/HubspotPaginationService.php
:163
in
Jiminny\Services\Crm\Hubspot\Pagination\HubspotPaginationService::executeSearchRequest
In App
/app/Services/Crm/Hubspot/Pagination/HubspotPaginationService.php
:51
in
Jiminny\Services\Crm\Hubspot\Pagination\HubspotPaginationService::getPaginatedDataGenerator
In App
/app/Services/Crm/Hubspot/Client.php
:94
in
Jiminny\Services\Crm\Hubspot\Client::getPaginatedData
In App
/app/Services/Crm/Hubspot/Service.php
:1212
in
Jiminny\Services\Crm\Hubspot\Service::Jiminny\Services\Crm\Hubspot\{closure}
In App
Called from
:
/vendor/laravel/framework/src/Illuminate/Cache/Repository.php
:564
in
Illuminate\Cache\Repository::remember
Show 2 more frames
Show 2 more frames
/app/Services/Crm/Hubspot/Service.php
:1206
in
Jiminny\Services\Crm\Hubspot\Service::matchByName
In App
/app/Services/Crm/CachedCrmServiceDecorator.php
:167
in
Jiminny\Services\Crm\CachedCrmServiceDecorator::matchByName
Copy file path
Open this line in GitHub
In App
/app/Services/Crm/CrmActivityService.php
:227
in
Jiminny\Services\Crm\CrmActivityService::findCrmRecords
In App
/app/Services/Crm/CrmActivityService.php
:139
in
Jiminny\Services\Crm\CrmActivityService::updateParticipantsCrmData
In App
/app/Services/Crm/CrmActivityService.php
:81
in
Jiminny\Services\Crm\CrmActivityService::updateCrmData
In App
/app/Jobs/Crm/MatchActivityCrmData.php
:107
in
Jiminny\Jobs\Crm\MatchActivityCrmData::Jiminny\Jobs\Crm\{closure}
In App
Called from
:
/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php
:35
in
Illuminate\Database\Connection::transaction
/app/Jobs/Crm/MatchActivityCrmData.php
:87
in
Jiminny\Jobs\Crm\MatchActivityCrmData::handle
Copy file path...
|
Firefox
|
SevenShores\Hubspot\Exceptions\BadRequest: Client SevenShores\Hubspot\Exceptions\BadRequest: Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT — Work...
|
jiminny.sentry.io/issues/7007366572/?environment=p jiminny.sentry.io/issues/7007366572/?environment=production&environment=production-eu&project=82419&query=is%3Aunresolved&referrer=issue-stream&sort=freq...
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter...
|
PhpStorm
|
faVsco.js – CrmActivityService.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25...
|
PhpStorm
|
faVsco.js – CrmActivityService.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190...
|
PhpStorm
|
faVsco.js – CrmActivityService.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV
Export Data…
Copy to Database…
Compare Data
View as
Show Options Menu
Sync Changes
Hide This Notification
Code changed:
Hide
1
5
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm;
use Illuminate\Support\Collection;
use Jiminny\Contracts\Repositories\TeamRepository;
use Jiminny\Contracts\Services\Crm\ServiceInterface;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Exceptions\SocialAccountTokenInvalidException;
use Jiminny\Models\Account;
use Jiminny\Models\Activity;
use Jiminny\Models\Contact;
use Jiminny\Models\Lead;
use Jiminny\Models\Opportunity;
use Jiminny\Models\Participant;
use Jiminny\Models\Stage;
use Jiminny\Models\Team;
use Jiminny\Models\User;
use Jiminny\Services\ResolveTeamCrmConnection;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Log\LoggerInterface;
use Exception;
use Throwable;
class CrmActivityService
{
public function __construct(
private readonly TeamRepository $teamRepository,
private readonly CachedCrmServiceDecorator $decorator,
private readonly EmailHelper $emailHelper,
private readonly ResolveTeamCrmConnection $teamCrmResolver,
private readonly LoggerInterface $logger,
) {
}
/**
* Updates CRM data for an activity and its participants.
*
* NOTE: This method performs multiple database writes and should be called
* within a transaction by the caller to ensure atomicity.
*
* @param Activity $activity
* @param bool $remoteSearch
*
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws Exception
*/
public function updateCrmData(
Activity $activity,
bool $remoteSearch = false,
): void {
$crmService = null;
$participants = $activity->getParticipants();
$team = $activity->getTeam();
$prospectSearchStrategy = ProspectSearchStrategyFactory::match($team);
if ($prospectSearchStrategy->ignoreCrmMatchData()) {
$this->logger->info('[CrmActivityService] Ignoring crm data because of prospect strategy', [
'activity_id' => $activity->getId(),
'strategy' => get_class($prospectSearchStrategy),
]);
return;
}
if ($remoteSearch) {
try {
$crmService = $this->teamCrmResolver->resolveForTeam($team);
} catch (SocialAccountTokenInvalidException) {
$this->logger->warning('[CrmActivityService] CRM token expired, falling back to local search', [
'activity_id' => $activity->getId(),
'team_id' => $team->getId(),
]);
}
}
$records = $this->updateParticipantsCrmData(
team: $team,
activity: $activity,
participants: $participants,
crmService: $crmService,
);
if (! empty($records)) {
$activity->updateActivityCrmData($records);
}
$activity->refresh();
}
/**
* @param Collection<Participant> $participants
*
* @throws Exception
*
* @return array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
*}|array{}
*/
private function updateParticipantsCrmData(
Team $team,
Activity $activity,
Collection $participants,
?ServiceInterface $crmService = null,
): array {
$matchedRecords = [];
$matchedDomainRecords = [];
$this->validateCrmConfiguration($activity);
$this->decorator->setConfiguration($activity->getCrm());
$this->decorator->setCrmService($crmService);
foreach ($participants as $participant) {
if ($this->shouldSkipParticipant($participant)) {
continue;
}
if (! $this->shouldPerformLookup($participant, $team)) {
$this->logger->info('[CrmActivityService] Email domain belongs to the team, skipping crm lookup', [
'activity_id' => $activity->getId(),
'team_id' => $team->getId(),
'email' => $participant->getEmailAddress(),
]);
$this->attachUserIfExists($participant, $team);
continue;
}
$records = $this->findCrmRecords($participant, $activity);
if (! empty($records)) {
$matchedRecords[] = $records;
} else {
$records = $this->findCrmDomainRecords(
crmService: $crmService,
participant: $participant,
activity: $activity,
);
if (! empty($records)) {
$matchedDomainRecords[] = $records;
}
}
if (empty($records)) {
continue;
}
try {
$activity->updateParticipantCrmData($records, $participant);
} catch (Throwable $ex) {
$this->logger->error('[CrmActivityService] Failed to update participant CRM data', [
'activity_id' => $activity->getId(),
'participant_id' => $participant->getId(),
'exception' => $ex->getMessage(),
]);
continue;
}
}
$bestMatch = $this->getBestMatch(
matchedRecords : $matchedRecords,
matchedDomainRecords: $matchedDomainRecords,
);
$this->logger->info('[CrmActivityService] CRM matching completed', [
'activity_id' => $activity->getId(),
'participants_processed' => $participants->count(),
'exact_matches' => count($matchedRecords),
'domain_matches' => count($matchedDomainRecords),
'best_match_found' => ! empty($bestMatch),
]);
return $bestMatch;
}
private function shouldPerformLookup(Participant $participant, Team $team): bool
{
if ($participant->hasEmailAddress()) {
return $this->emailHelper->shouldPerformLookup($team, $participant->getEmailAddress());
}
return true;
}
private function validateCrmConfiguration(Activity $activity): void
{
if ($activity->getCrm() === null) {
throw new InvalidArgumentException('Cannot find CRM configuration');
}
}
private function getBestMatch(?array $matchedRecords, ?array $matchedDomainRecords): array
{
return RecordSelector::pickBestFromLists($matchedRecords, $matchedDomainRecords);
}
private function findCrmRecords(Participant $participant, Activity $activity): ?array
{
$records = null;
if ($participant->hasEmailAddress()) {
$records = $this->decorator->matchExactlyByEmail(
email: $participant->getEmailAddress(),
userId: $activity->getUser()->getId()
);
}
if (empty($records) && $participant->getPhoneNumber() !== null) {
$records = $this->decorator->matchByPhone(
phone: $participant->getPhoneNumber(),
userId: $activity->getUser()->getId(),
);
}
if (empty($records) && $participant->getName() !== null) {
$records = $this->decorator->matchByName(
name: $participant->getName(),
userId: $activity->getUser()->getId(),
);
}
return $records;
}
private function shouldSkipParticipant(Participant $participant): bool
{
return $participant->hasUser();
}
private function attachUserIfExists(Participant $participant, Team $team): void
{
if ($participant->hasEmailAddress() === false) {
return;
}
$user = $this->teamRepository->findActiveTeamMemberByEmail($team, $participant->getEmailAddress());
if ($user instanceof User) {
$participant->user_id = $user->getId();
$participant->save();
}
}
private function findCrmDomainRecords(
?ServiceInterface $crmService,
Participant $participant,
Activity $activity,
): array {
if ($participant->hasEmailAddress()) {
$this->decorator->setConfiguration($activity->getCrm());
$this->decorator->setCrmService($crmService);
$records = $this->decorator->matchByDomain(
email: $participant->getEmailAddress(),
userId: $activity->getUser()->getId()
);
if (! empty($records)) {
return $records;
}
}
return [];
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – CrmActivityService.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV...
|
PhpStorm
|
faVsco.js – CrmActivityService.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer...
|
PhpStorm
|
faVsco.js – CrmActivityService.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV
Export Data…
Copy to Database…
Compare Data
View as
Show Options Menu
Sync Changes
Hide This Notification
Code changed:
Hide
1
5
Previous Highlighted Error
Next Highlighted Error...
|
PhpStorm
|
faVsco.js – CrmActivityService.php
|
NULL
|
|
Platform Sprint 3 Q2 - Platform Team - Scrum Board Platform Sprint 3 Q2 - Platform Team - Scrum Board - Jira
Platform Sprint 3 Q2 - Platform Team - Scrum Board - Jira
SevenShores\Hubspot\Exceptions\BadRequest: Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT
SevenShores\Hubspot\Exceptions\BadRequest: Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT
Close tab
Service-Desk - Queues - Platform team - Service space - Jira
Service-Desk - Queues - Platform team - Service space - Jira
Jy 20807 check various issues with stages by nikolaybiaivanov · Pull Request #12041 · jiminny/app
Jy 20807 check various issues with stages by nikolaybiaivanov · Pull Request #12041 · jiminny/app
Sentry
Sentry
Pull requests · jiminny/app
Pull requests · jiminny/app
Userpilot | Ask Jiminny Report Generated
Userpilot | Ask Jiminny Report Generated
JY-20773 fix user pilot tracking ofr automated report generated by LakyLak · Pull Request #12024 · jiminny/app
JY-20773 fix user pilot tracking ofr automated report generated by LakyLak · Pull Request #12024 · jiminny/app
Jiminny
Jiminny
Search the CRM - HubSpot docs
Search the CRM - HubSpot docs
New Tab
Customize sidebar
Open Google Gemini (⌃X)
Tabs from other devices
Open history (⇧⌘H)
Open bookmarks (⌘B)
Skip to main content
Skip to main content
Toggle organization menu
Issues
Issues
Explore
Explore
Dashboards
Dashboards
Monitors
Monitors
Settings
Settings
Try Business
What's New
Help
[EMAIL]
Issues
Expand
Feed
Feed
Errors & Outages
Errors & Outages
Breached Metrics
Breached Metrics
Warnings
Warnings
User Feedback
User Feedback
Autofix
Autofix
Recently Run
Recently Run
All Views
All Views
Configure
Alerts Moved
Alerts
Moved
Issues
Issues
View Project Details
APP-1EED
Ask Seer
Ask Seer
/
Give Feedback
SevenShores\Hubspot\Exceptions\BadRequest
View events
Events (total)
Users (90d)
Level: Error
Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT","correlationId":"019dffc4-4 (truncated...)
17K
0
Ongoing
/app/Services/Crm/Hubspot/Pagination/HubspotPaginationService.php in Jiminny\Services\Crm\Hubspot\Pagination\HubspotPaginationService::executeSearchRequest
Resolve
Resolve
More resolve options
Archive
Archive
Archive options
Subscribe
Share
More Actions
Priority
Modify issue priority
High
Assignee
Modify issue assignee
Lukas Kovalik
production, production-eu
production, production-eu
90D
90D
Add a search term
Add a search term
Close sidebar
Toggle graph series - Events
Events
17K
Toggle graph series - Users
Users
0
release 68% 874599
release
68%
874599
environment 92% production
environment
92%
production
os.name 100% Linux
os.name
100%
Linux
runtime 94% php 8.3.30
runtime
94%
php 8.3.30
View all tags
View all tags
Select issue content
Events
Previous Event
Next Event
First
First
First
Latest
Latest
Latest
Recommended
Recommended
View More Events
View More Events
Copy as
Copy as
ID: b2e90a6e
13 hours ago
JSON
JSON
Highlights
Highlights
Stack Trace
Stack Trace
Trace
Trace
Tags
Tags
Context
Context
php
8.3.30
Linux
6.1.164-196.303.amzn2023.aarch64
882306
882306
production
Collapse Highlights Section
Highlights
Edit
Edit
handled
yes
level
error
transaction
--
url
--
Trace: Trace ID
76712d464c1e4764be8cc81c504d471e
76712d464c1e4764be8cc81c504d471e
Collapse Stack Trace Section
Stack Trace
Display options
Display
Copy as
Copy as
There are 2 chained exceptions in this event.
SevenShores\Hubspot\Exceptions\BadRequest
SevenShores\Hubspot\Exceptions\BadRequest
SevenShores\Hubspot\Exceptions\BadRequest
Client error: `POST
https://api.hubapi.com/crm/v3/objects/contact/search
https://api.hubapi.com/crm/v3/objects/contact/search
` resulted in a `429 Too Many Requests` response:
{"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT","correlationId":"019dffc4-4 (truncated...)
mechanism
generic
handled
true
code
429
Crashed in non-app
:
/vendor/hubspot/hubspot-php/src/Exceptions/HubspotException.php
:24
in
SevenShores\Hubspot\Exceptions\HubspotException::create
Show 1 more frame
Show 1 more frame
/app/Services/Crm/Hubspot/Pagination/HubspotPaginationService.php
:163
in
Jiminny\Services\Crm\Hubspot\Pagination\HubspotPaginationService::executeSearchRequest
In App
/app/Services/Crm/Hubspot/Pagination/HubspotPaginationService.php
:51
in
Jiminny\Services\Crm\Hubspot\Pagination\HubspotPaginationService::getPaginatedDataGenerator
In App
/app/Services/Crm/Hubspot/Client.php
:94
in
Jiminny\Services\Crm\Hubspot\Client::getPaginatedData
In App
/app/Services/Crm/Hubspot/Service.php
:1212
in
Jiminny\Services\Crm\Hubspot\Service::Jiminny\Services\Crm\Hubspot\{closure}
In App
Called from
:
/vendor/laravel/framework/src/Illuminate/Cache/Repository.php
:564
in
Illuminate\Cache\Repository::remember
Show 2 more frames
Show 2 more frames
/app/Services/Crm/Hubspot/Service.php
:1206
in
Jiminny\Services\Crm\Hubspot\Service::matchByName
Copy file path
Open this line in GitHub
In App
/app/Services/Crm/CachedCrmServiceDecorator.php
:167
in
Jiminny\Services\Crm\CachedCrmServiceDecorator::matchByName
In App
/app/Services/Crm/CrmActivityService.php
:227
in
Jiminny\Services\Crm\CrmActivityService::findCrmRecords
In App
/app/Services/Crm/CrmActivityService.php
:139
in
Jiminny\Services\Crm\CrmActivityService::updateParticipantsCrmData
In App
/app/Services/Crm/CrmActivityService.php
:81
in
Jiminny\Services\Crm\CrmActivityService::updateCrmData
In App
/app/Jobs/Crm/MatchActivityCrmData.php
:107
in
Jiminny\Jobs\Crm\MatchActivityCrmData::Jiminny\Jobs\Crm\{closure}
In App
Called from
:
/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php
:35
in
Illuminate\Database\Connection::transaction
/app/Jobs/Crm/MatchActivityCrmData.php
:87
in
Jiminny\Jobs\Crm\MatchActivityCrmData::handle
Copy file path
Open this line in GitHub
In App
82
if
(
$activity
===
null
)
{
83
throw
new
InvalidArgumentException
(
'[MatchActivityCrmData] Cannot find activity.'
)
;
84
}
85
86
try
{
87
$connection
->
transaction
(
function
(
)
use
(
$activity
,
$crmActivityService
,
$activityRepository
)
{
88
Log
::
info
(
'[MatchActivityCrmData] Starting CRM data matching'
,
[
89
'activity'
=>
$this
->
activityId
,
90
'remote_search'
=>
$this
->
remoteSearch
,
91
'set_configuration'
=>
$this
->
fromConfiguration
?->
getId
(
)
,
92
'old_state'
=>
[
activityRepository
Object Jiminny\Repositories\ActivityRepository
connection
Object Illuminate\Database\MariaDbConnection
crmActivityService
Object Jiminny\Services\Crm\CrmActivityService
Called from
:
/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php
:36
in
Illuminate\Container\BoundMethod::Illuminate\Container\{closure}
Show 14 more frames
Show 14 more frames
/app/Queue/Worker/Worker.php
:71
in
Jiminny\Queue\Worker\Worker::process
In App
Called from
:
/vendor/laravel/framework/src/Illuminate/Queue/Worker.php
:435
in
Illuminate\Queue\Worker::runJob
Show 17 more frames
Show 17 more frames
GuzzleHttp\Exception\ClientException...
|
Firefox
|
SevenShores\Hubspot\Exceptions\BadRequest: Client SevenShores\Hubspot\Exceptions\BadRequest: Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT — Work...
|
jiminny.sentry.io/issues/7007366572/?environment=p jiminny.sentry.io/issues/7007366572/?environment=production&environment=production-eu&project=82419&query=is%3Aunresolved&referrer=issue-stream&sort=freq...
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>...
|
PhpStorm
|
faVsco.js – CrmActivityService.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV
Export Data…
Copy to Database…
Compare Data
View as
Show Options Menu
Sync Changes
Hide This Notification
Code changed:
Hide
1
5
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm;
use Illuminate\Support\Collection;
use Jiminny\Contracts\Repositories\TeamRepository;
use Jiminny\Contracts\Services\Crm\ServiceInterface;
use Jiminny\Exceptions\InvalidArgumentException;
use Jiminny\Exceptions\SocialAccountTokenInvalidException;
use Jiminny\Models\Account;
use Jiminny\Models\Activity;
use Jiminny\Models\Contact;
use Jiminny\Models\Lead;
use Jiminny\Models\Opportunity;
use Jiminny\Models\Participant;
use Jiminny\Models\Stage;
use Jiminny\Models\Team;
use Jiminny\Models\User;
use Jiminny\Services\ResolveTeamCrmConnection;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\Log\LoggerInterface;
use Exception;
use Throwable;
class CrmActivityService
{
public function __construct(
private readonly TeamRepository $teamRepository,
private readonly CachedCrmServiceDecorator $decorator,
private readonly EmailHelper $emailHelper,
private readonly ResolveTeamCrmConnection $teamCrmResolver,
private readonly LoggerInterface $logger,
) {
}
/**
* Updates CRM data for an activity and its participants.
*
* NOTE: This method performs multiple database writes and should be called
* within a transaction by the caller to ensure atomicity.
*
* @param Activity $activity
* @param bool $remoteSearch
*
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws Exception
*/
public function updateCrmData(
Activity $activity,
bool $remoteSearch = false,
): void {
$crmService = null;
$participants = $activity->getParticipants();
$team = $activity->getTeam();
$prospectSearchStrategy = ProspectSearchStrategyFactory::match($team);
if ($prospectSearchStrategy->ignoreCrmMatchData()) {
$this->logger->info('[CrmActivityService] Ignoring crm data because of prospect strategy', [
'activity_id' => $activity->getId(),
'strategy' => get_class($prospectSearchStrategy),
]);
return;
}
if ($remoteSearch) {
try {
$crmService = $this->teamCrmResolver->resolveForTeam($team);
} catch (SocialAccountTokenInvalidException) {
$this->logger->warning('[CrmActivityService] CRM token expired, falling back to local search', [
'activity_id' => $activity->getId(),
'team_id' => $team->getId(),
]);
}
}
$records = $this->updateParticipantsCrmData(
team: $team,
activity: $activity,
participants: $participants,
crmService: $crmService,
);
if (! empty($records)) {
$activity->updateActivityCrmData($records);
}
$activity->refresh();
}
/**
* @param Collection<Participant> $participants
*
* @throws Exception
*
* @return array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
*}|array{}
*/
private function updateParticipantsCrmData(
Team $team,
Activity $activity,
Collection $participants,
?ServiceInterface $crmService = null,
): array {
$matchedRecords = [];
$matchedDomainRecords = [];
$this->validateCrmConfiguration($activity);
$this->decorator->setConfiguration($activity->getCrm());
$this->decorator->setCrmService($crmService);
foreach ($participants as $participant) {
if ($this->shouldSkipParticipant($participant)) {
continue;
}
if (! $this->shouldPerformLookup($participant, $team)) {
$this->logger->info('[CrmActivityService] Email domain belongs to the team, skipping crm lookup', [
'activity_id' => $activity->getId(),
'team_id' => $team->getId(),
'email' => $participant->getEmailAddress(),
]);
$this->attachUserIfExists($participant, $team);
continue;
}
$records = $this->findCrmRecords($participant, $activity);
if (! empty($records)) {
$matchedRecords[] = $records;
} else {
$records = $this->findCrmDomainRecords(
crmService: $crmService,
participant: $participant,
activity: $activity,
);
if (! empty($records)) {
$matchedDomainRecords[] = $records;
}
}
if (empty($records)) {
continue;
}
try {
$activity->updateParticipantCrmData($records, $participant);
} catch (Throwable $ex) {
$this->logger->error('[CrmActivityService] Failed to update participant CRM data', [
'activity_id' => $activity->getId(),
'participant_id' => $participant->getId(),
'exception' => $ex->getMessage(),
]);
continue;
}
}
$bestMatch = $this->getBestMatch(
matchedRecords : $matchedRecords,
matchedDomainRecords: $matchedDomainRecords,
);
$this->logger->info('[CrmActivityService] CRM matching completed', [
'activity_id' => $activity->getId(),
'participants_processed' => $participants->count(),
'exact_matches' => count($matchedRecords),
'domain_matches' => count($matchedDomainRecords),
'best_match_found' => ! empty($bestMatch),
]);
return $bestMatch;
}
private function shouldPerformLookup(Participant $participant, Team $team): bool
{
if ($participant->hasEmailAddress()) {
return $this->emailHelper->shouldPerformLookup($team, $participant->getEmailAddress());
}
return true;
}
private function validateCrmConfiguration(Activity $activity): void
{
if ($activity->getCrm() === null) {
throw new InvalidArgumentException('Cannot find CRM configuration');
}
}
private function getBestMatch(?array $matchedRecords, ?array $matchedDomainRecords): array
{
return RecordSelector::pickBestFromLists($matchedRecords, $matchedDomainRecords);
}
private function findCrmRecords(Participant $participant, Activity $activity): ?array
{
$records = null;
if ($participant->hasEmailAddress()) {
$records = $this->decorator->matchExactlyByEmail(
email: $participant->getEmailAddress(),
userId: $activity->getUser()->getId()
);
}
if (empty($records) && $participant->getPhoneNumber() !== null) {
$records = $this->decorator->matchByPhone(
phone: $participant->getPhoneNumber(),
userId: $activity->getUser()->getId(),
);
}
if (empty($records) && $participant->getName() !== null) {
$records = $this->decorator->matchByName(
name: $participant->getName(),
userId: $activity->getUser()->getId(),
);
}
return $records;
}
private function shouldSkipParticipant(Participant $participant): bool
{
return $participant->hasUser();
}
private function attachUserIfExists(Participant $participant, Team $team): void
{
if ($participant->hasEmailAddress() === false) {
return;
}
$user = $this->teamRepository->findActiveTeamMemberByEmail($team, $participant->getEmailAddress());
if ($user instanceof User) {
$participant->user_id = $user->getId();
$participant->save();
}
}
private function findCrmDomainRecords(
?ServiceInterface $crmService,
Participant $participant,
Activity $activity,
): array {
if ($participant->hasEmailAddress()) {
$this->decorator->setConfiguration($activity->getCrm());
$this->decorator->setCrmService($crmService);
$records = $this->decorator->matchByDomain(
email: $participant->getEmailAddress(),
userId: $activity->getUser()->getId()
);
if (! empty($records)) {
return $records;
}
}
return [];
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – CrmActivityService.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190...
|
PhpStorm
|
faVsco.js – CrmActivityService.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV
Export Data…
Copy to Database…
Compare Data
View as
Show Options Menu
Code changed:
Hide
Sync Changes
Hide This Notification
8
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm;
use Jiminny\Contracts\Services\Crm\ConnectionStateInterface;
use Jiminny\Contracts\Services\Crm\MatchCrmEntitiesWithCacheInterface;
use Jiminny\Contracts\Services\Crm\ServiceInterface;
use Jiminny\Exceptions\ApplicationException;
use Jiminny\Models\Account;
use Jiminny\Models\Contact;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Lead;
use Jiminny\Models\Opportunity;
use Jiminny\Models\Stage;
use Psr\Log\LoggerInterface;
class CachedCrmServiceDecorator implements MatchCrmEntitiesWithCacheInterface
{
private ?ServiceInterface $crmService = null;
private ProspectCache $prospectCache;
private LoggerInterface $logger;
private ?Configuration $configuration;
public function __construct(
ProspectCache $prospectCache,
LoggerInterface $logger
) {
$this->prospectCache = $prospectCache;
$this->logger = $logger;
$this->configuration = null;
}
public function setCrmService(?ServiceInterface $crmService = null): void
{
$this->crmService = $crmService;
}
public function setConfiguration(Configuration $configuration): void
{
$this->configuration = $configuration;
}
/**
* @return null|array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
*}
*/
public function matchExactlyByEmail(string $email, ?int $userId = null): ?array
{
if (! filter_var($email, FILTER_VALIDATE_EMAIL)) {
$this->logger->warning('[Prospect match] Invalid email address', [
'identifier_type' => ProspectCache::PROSPECT_TYPE_EMAIL,
'identifier' => $email,
]);
// The email address of the prospect is invalid.
// Return null, so we can try to match by phone or name.
return null;
}
return $this->matchByProspectIdentifier(
identifierType: ProspectCache::PROSPECT_TYPE_EMAIL,
identifierValue: $email,
userId: $userId
);
}
public function matchByDomain(string $email, ?int $userId = null): ?array
{
if (! $this->crmService instanceof MatchDomainByEmailInterface) {
$this->logger->info('[Prospect match] Service does not support matching by domain', [
'identifier_type' => ProspectCache::PROSPECT_TYPE_DOMAIN,
'crm' => $this->crmService?->getDisplayName() ?? 'Not set',
'email' => $email,
]);
return null;
}
$domain = $this->crmService->getDomain($email);
if (empty($domain)) {
$this->logger->info('[Prospect match] Empty domain name', [
'identifier_type' => ProspectCache::PROSPECT_TYPE_DOMAIN,
'email' => $email,
]);
return null;
}
$this->logger->info('[Prospect match] Resolved company domain from email', [
'email' => $email,
'domain' => $domain,
]);
$configuration = $this->getConfiguration();
// try the cache
$cachedValue = $this->prospectCache->findDomainMatch(
configuration: $configuration,
identifier: $domain,
userId: $userId
);
if ($cachedValue !== null) {
return $cachedValue;
}
$this->logger->info('[Prospect match] Cache miss, calling the API', [
'identifier_type' => ProspectCache::PROSPECT_TYPE_DOMAIN,
'identifier' => $domain,
]);
$apiResult = $this->crmService->matchByDomain(domain: $domain, userId: $userId);
if (empty($apiResult)) {
$this->logger->info(
'[Prospect match] API returned empty result, caching the miss with empty prospect data',
[
'identifier_type' => ProspectCache::PROSPECT_TYPE_DOMAIN,
'identifier' => $domain,
]
);
// cache the miss with empty prospect data
$apiResult = [null, null, null, null, null, null];
}
$this->prospectCache->set(
configuration: $configuration,
identifier: $domain,
prospectData: $apiResult,
userId: $userId
);
return $apiResult;
}
/**
* @return null|array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
* }
*/
public function matchByName(string $name, ?int $userId = null): ?array
{
if (! $this->isConnected()) {
$this->logger->info('[Prospect match] Service is not connected, remote search is currently not available', [
'identifier_type' => 'name',
'identifier' => $name,
]);
return null;
}
return $this->crmService->matchByName(
name: $name,
userId: $userId
);
}
/**
* @return null|array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
*}
*/
public function matchByPhone(string $phone, ?string $rawPhoneNumber = null, ?int $userId = null): ?array
{
return $this->matchByProspectIdentifier(
identifierType: ProspectCache::PROSPECT_TYPE_PHONE,
identifierValue: $phone,
identifierSecondaryValue: $rawPhoneNumber,
userId: $userId
);
}
/**
* @throws ApplicationException
*/
private function matchByProspectIdentifier(
string $identifierType,
string $identifierValue,
?string $identifierSecondaryValue = null,
?int $userId = null,
): ?array {
$configuration = $this->getConfiguration();
$profile = $this->crmService->profile ?? null;
// Normalize phone number BEFORE cache lookup
if ($identifierType === ProspectCache::PROSPECT_TYPE_PHONE) {
$identifierValue = $this->prospectCache->normalizePhoneNumber($identifierValue);
}
$prospectData = $this->prospectCache->findByProspectIdentifier(
configuration: $configuration,
profile: $profile,
identifierType: $identifierType,
identifierValue: $identifierValue,
userId: $userId,
crmService: $this->crmService
);
if ($prospectData !== null) {
$this->logger->info('[Prospect match] Cache / local search hit', [
'identifier_type' => $identifierType,
'identifier' => $identifierValue,
]);
if (empty(array_filter($prospectData))) {
$this->logger->info('[Prospect match] cached empty result - no API calls, try next matching method', [
'identifier_type' => $identifierType,
'identifier' => $identifierValue,
]);
/**
* @IMPORTANT This is a cached empty result, i.e. there's no prospect with this email.
* We cache the empty result, so we don't keep querying the database and the API
* for non-existing prospects.
* However, we need to return null from this method
* in order to trigger the next matching method (e.g. matchByPhone or matchByName).
* This is because an array with null values is not considered empty.
*/
return null;
}
return $prospectData;
}
$this->logger->info('[Prospect match] Cache miss, calling the API', [
'identifier_type' => $identifierType,
'identifier' => $identifierValue,
]);
if (! $this->isConnected()) {
$this->logger->info('[Prospect match] Service is not connected, remote search is currently not available', [
'identifier_type' => $identifierType,
'identifier' => $identifierValue,
]);
return null;
}
/** @var 'email'|'phone' $identifierType */
$apiResult = match($identifierType) {
ProspectCache::PROSPECT_TYPE_EMAIL => $this->crmService->matchExactlyByEmail(
email: $identifierValue,
userId: $userId
),
ProspectCache::PROSPECT_TYPE_PHONE => $this->crmService->matchByPhone(
phone: $identifierValue,
rawPhoneNumber: $identifierSecondaryValue,
userId: $userId
),
};
$cachedResult = $apiResult;
if (empty($apiResult)) {
// In case the result is null or an empty array,
// cache the missing prospect, so we don't keep calling the API
$this->logger->info(
'[Prospect match] API returned empty result, caching the miss with empty prospect data',
[
'identifier_type' => $identifierType,
'identifier' => $identifierValue,
]
);
$cachedResult = [null, null, null, null, null, null];
}
// Set the cache even if the result is empty,
// so we don't keep querying the database and the API
$this->prospectCache->set($configuration, $identifierValue, $cachedResult, $userId);
return $apiResult;
}
private function isConnected(): bool
{
if ($this->crmService instanceof ConnectionStateInterface) {
return $this->crmService->isConnected();
}
return $this->crmService !== null;
}
/**
* @throws ApplicationException
*/
private function getConfiguration(): Configuration
{
if ($this->configuration) {
return $this->configuration;
}
if ($this->crmService?->getConfiguration()) {
return $this->crmService->getConfiguration();
}
throw new ApplicationException('Missing team configuration. Cannot set team prospect cache');
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – CachedCrmServiceDecorator.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV
Export Data…
Copy to Database…
Compare Data
View as
Show Options Menu
Code changed:
Hide
Sync Changes...
|
PhpStorm
|
faVsco.js – CachedCrmServiceDecorator.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV
Export Data…
Copy to Database…
Compare Data
View as
Show Options Menu
Code changed:
Hide
Sync Changes
Hide This Notification
8
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm;
use Jiminny\Contracts\Services\Crm\ConnectionStateInterface;
use Jiminny\Contracts\Services\Crm\MatchCrmEntitiesWithCacheInterface;
use Jiminny\Contracts\Services\Crm\ServiceInterface;
use Jiminny\Exceptions\ApplicationException;
use Jiminny\Models\Account;
use Jiminny\Models\Contact;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Lead;
use Jiminny\Models\Opportunity;
use Jiminny\Models\Stage;
use Psr\Log\LoggerInterface;
class CachedCrmServiceDecorator implements MatchCrmEntitiesWithCacheInterface
{
private ?ServiceInterface $crmService = null;
private ProspectCache $prospectCache;
private LoggerInterface $logger;
private ?Configuration $configuration;
public function __construct(
ProspectCache $prospectCache,
LoggerInterface $logger
) {
$this->prospectCache = $prospectCache;
$this->logger = $logger;
$this->configuration = null;
}
public function setCrmService(?ServiceInterface $crmService = null): void
{
$this->crmService = $crmService;
}
public function setConfiguration(Configuration $configuration): void
{
$this->configuration = $configuration;
}
/**
* @return null|array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
*}
*/
public function matchExactlyByEmail(string $email, ?int $userId = null): ?array
{
if (! filter_var($email, FILTER_VALIDATE_EMAIL)) {
$this->logger->warning('[Prospect match] Invalid email address', [
'identifier_type' => ProspectCache::PROSPECT_TYPE_EMAIL,
'identifier' => $email,
]);
// The email address of the prospect is invalid.
// Return null, so we can try to match by phone or name.
return null;
}
return $this->matchByProspectIdentifier(
identifierType: ProspectCache::PROSPECT_TYPE_EMAIL,
identifierValue: $email,
userId: $userId
);
}
public function matchByDomain(string $email, ?int $userId = null): ?array
{
if (! $this->crmService instanceof MatchDomainByEmailInterface) {
$this->logger->info('[Prospect match] Service does not support matching by domain', [
'identifier_type' => ProspectCache::PROSPECT_TYPE_DOMAIN,
'crm' => $this->crmService?->getDisplayName() ?? 'Not set',
'email' => $email,
]);
return null;
}
$domain = $this->crmService->getDomain($email);
if (empty($domain)) {
$this->logger->info('[Prospect match] Empty domain name', [
'identifier_type' => ProspectCache::PROSPECT_TYPE_DOMAIN,
'email' => $email,
]);
return null;
}
$this->logger->info('[Prospect match] Resolved company domain from email', [
'email' => $email,
'domain' => $domain,
]);
$configuration = $this->getConfiguration();
// try the cache
$cachedValue = $this->prospectCache->findDomainMatch(
configuration: $configuration,
identifier: $domain,
userId: $userId
);
if ($cachedValue !== null) {
return $cachedValue;
}
$this->logger->info('[Prospect match] Cache miss, calling the API', [
'identifier_type' => ProspectCache::PROSPECT_TYPE_DOMAIN,
'identifier' => $domain,
]);
$apiResult = $this->crmService->matchByDomain(domain: $domain, userId: $userId);
if (empty($apiResult)) {
$this->logger->info(
'[Prospect match] API returned empty result, caching the miss with empty prospect data',
[
'identifier_type' => ProspectCache::PROSPECT_TYPE_DOMAIN,
'identifier' => $domain,
]
);
// cache the miss with empty prospect data
$apiResult = [null, null, null, null, null, null];
}
$this->prospectCache->set(
configuration: $configuration,
identifier: $domain,
prospectData: $apiResult,
userId: $userId
);
return $apiResult;
}
/**
* @return null|array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
* }
*/
public function matchByName(string $name, ?int $userId = null): ?array
{
if (! $this->isConnected()) {
$this->logger->info('[Prospect match] Service is not connected, remote search is currently not available', [
'identifier_type' => 'name',
'identifier' => $name,
]);
return null;
}
return $this->crmService->matchByName(
name: $name,
userId: $userId
);
}
/**
* @return null|array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
*}
*/
public function matchByPhone(string $phone, ?string $rawPhoneNumber = null, ?int $userId = null): ?array
{
return $this->matchByProspectIdentifier(
identifierType: ProspectCache::PROSPECT_TYPE_PHONE,
identifierValue: $phone,
identifierSecondaryValue: $rawPhoneNumber,
userId: $userId
);
}
/**
* @throws ApplicationException
*/
private function matchByProspectIdentifier(
string $identifierType,
string $identifierValue,
?string $identifierSecondaryValue = null,
?int $userId = null,
): ?array {
$configuration = $this->getConfiguration();
$profile = $this->crmService->profile ?? null;
// Normalize phone number BEFORE cache lookup
if ($identifierType === ProspectCache::PROSPECT_TYPE_PHONE) {
$identifierValue = $this->prospectCache->normalizePhoneNumber($identifierValue);
}
$prospectData = $this->prospectCache->findByProspectIdentifier(
configuration: $configuration,
profile: $profile,
identifierType: $identifierType,
identifierValue: $identifierValue,
userId: $userId,
crmService: $this->crmService
);
if ($prospectData !== null) {
$this->logger->info('[Prospect match] Cache / local search hit', [
'identifier_type' => $identifierType,
'identifier' => $identifierValue,
]);
if (empty(array_filter($prospectData))) {
$this->logger->info('[Prospect match] cached empty result - no API calls, try next matching method', [
'identifier_type' => $identifierType,
'identifier' => $identifierValue,
]);
/**
* @IMPORTANT This is a cached empty result, i.e. there's no prospect with this email.
* We cache the empty result, so we don't keep querying the database and the API
* for non-existing prospects.
* However, we need to return null from this method
* in order to trigger the next matching method (e.g. matchByPhone or matchByName).
* This is because an array with null values is not considered empty.
*/
return null;
}
return $prospectData;
}
$this->logger->info('[Prospect match] Cache miss, calling the API', [
'identifier_type' => $identifierType,
'identifier' => $identifierValue,
]);
if (! $this->isConnected()) {
$this->logger->info('[Prospect match] Service is not connected, remote search is currently not available', [
'identifier_type' => $identifierType,
'identifier' => $identifierValue,
]);
return null;
}
/** @var 'email'|'phone' $identifierType */
$apiResult = match($identifierType) {
ProspectCache::PROSPECT_TYPE_EMAIL => $this->crmService->matchExactlyByEmail(
email: $identifierValue,
userId: $userId
),
ProspectCache::PROSPECT_TYPE_PHONE => $this->crmService->matchByPhone(
phone: $identifierValue,
rawPhoneNumber: $identifierSecondaryValue,
userId: $userId
),
};
$cachedResult = $apiResult;
if (empty($apiResult)) {
// In case the result is null or an empty array,
// cache the missing prospect, so we don't keep calling the API
$this->logger->info(
'[Prospect match] API returned empty result, caching the miss with empty prospect data',
[
'identifier_type' => $identifierType,
'identifier' => $identifierValue,
]
);
$cachedResult = [null, null, null, null, null, null];
}
// Set the cache even if the result is empty,
// so we don't keep querying the database and the API
$this->prospectCache->set($configuration, $identifierValue, $cachedResult, $userId);
return $apiResult;
}
private function isConnected(): bool
{
if ($this->crmService instanceof ConnectionStateInterface) {
return $this->crmService->isConnected();
}
return $this->crmService !== null;
}
/**
* @throws ApplicationException
*/
private function getConfiguration(): Configuration
{
if ($this->configuration) {
return $this->configuration;
}
if ($this->crmService?->getConfiguration()) {
return $this->crmService->getConfiguration();
}
throw new ApplicationException('Missing team configuration. Cannot set team prospect cache');
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – CachedCrmServiceDecorator.php
|
NULL
|
|
Platform Sprint 3 Q2 - Platform Team - Scrum Board Platform Sprint 3 Q2 - Platform Team - Scrum Board - Jira
Platform Sprint 3 Q2 - Platform Team - Scrum Board - Jira
SevenShores\Hubspot\Exceptions\BadRequest: Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT
SevenShores\Hubspot\Exceptions\BadRequest: Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT
Close tab
Service-Desk - Queues - Platform team - Service space - Jira
Service-Desk - Queues - Platform team - Service space - Jira
Jy 20807 check various issues with stages by nikolaybiaivanov · Pull Request #12041 · jiminny/app
Jy 20807 check various issues with stages by nikolaybiaivanov · Pull Request #12041 · jiminny/app
Sentry
Sentry
Pull requests · jiminny/app
Pull requests · jiminny/app
Userpilot | Ask Jiminny Report Generated
Userpilot | Ask Jiminny Report Generated
JY-20773 fix user pilot tracking ofr automated report generated by LakyLak · Pull Request #12024 · jiminny/app
JY-20773 fix user pilot tracking ofr automated report generated by LakyLak · Pull Request #12024 · jiminny/app
Jiminny
Jiminny
Search the CRM - HubSpot docs
Search the CRM - HubSpot docs
New Tab
Customize sidebar
Open Google Gemini (⌃X)
Tabs from other devices
Open history (⇧⌘H)
Open bookmarks (⌘B)
Skip to main content
Skip to main content
Toggle organization menu
Issues
Issues
Explore
Explore
Dashboards
Dashboards
Monitors
Monitors
Settings
Settings
Try Business
What's New
Help
[EMAIL]
Issues
Expand
Feed
Feed
Errors & Outages
Errors & Outages
Breached Metrics
Breached Metrics
Warnings
Warnings
User Feedback
User Feedback
Autofix
Autofix
Recently Run
Recently Run
All Views
All Views
Configure
Alerts Moved
Alerts
Moved
Issues
Issues
View Project Details
APP-1EED
Ask Seer
Ask Seer
/
Give Feedback
SevenShores\Hubspot\Exceptions\BadRequest
View events
Events (total)
Users (90d)
Level: Error
Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT","correlationId":"019dffc4-4 (truncated...)
17K
0
Ongoing
/app/Services/Crm/Hubspot/Pagination/HubspotPaginationService.php in Jiminny\Services\Crm\Hubspot\Pagination\HubspotPaginationService::executeSearchRequest
Resolve
Resolve
More resolve options
Archive
Archive
Archive options
Subscribe
Share
More Actions
Priority
Modify issue priority
High
Assignee
Modify issue assignee
Lukas Kovalik
production, production-eu
production, production-eu
90D
90D
Add a search term
Add a search term
Close sidebar
Toggle graph series - Events
Events
17K
Toggle graph series - Users
Users
0
release 68% 874599
release
68%
874599
environment 92% production
environment
92%
production
os.name 100% Linux
os.name
100%
Linux
runtime 94% php 8.3.30
runtime
94%
php 8.3.30
View all tags
View all tags
Select issue content
Events
Previous Event
Next Event
First
First
First
Latest
Latest
Latest
Recommended
Recommended
View More Events
View More Events
Copy as
Copy as
ID: b2e90a6e
13 hours ago
JSON
JSON
Highlights
Highlights
Stack Trace
Stack Trace
Trace
Trace
Tags
Tags
Context
Context
php
8.3.30
Linux
6.1.164-196.303.amzn2023.aarch64
882306
882306
production
Collapse Highlights Section
Highlights
Edit
Edit
handled
yes
level
error
transaction
--
url
--
Trace: Trace ID
76712d464c1e4764be8cc81c504d471e
76712d464c1e4764be8cc81c504d471e
Collapse Stack Trace Section
Stack Trace
Display options
Display
Copy as
Copy as
There are 2 chained exceptions in this event.
SevenShores\Hubspot\Exceptions\BadRequest
SevenShores\Hubspot\Exceptions\BadRequest
SevenShores\Hubspot\Exceptions\BadRequest
Client error: `POST
https://api.hubapi.com/crm/v3/objects/contact/search
https://api.hubapi.com/crm/v3/objects/contact/search
` resulted in a `429 Too Many Requests` response:
{"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT","correlationId":"019dffc4-4 (truncated...)
mechanism
generic
handled
true
code
429
Crashed in non-app
:
/vendor/hubspot/hubspot-php/src/Exceptions/HubspotException.php
:24
in
SevenShores\Hubspot\Exceptions\HubspotException::create
Show 1 more frame
Show 1 more frame
/app/Services/Crm/Hubspot/Pagination/HubspotPaginationService.php
:163
in
Jiminny\Services\Crm\Hubspot\Pagination\HubspotPaginationService::executeSearchRequest
In App
/app/Services/Crm/Hubspot/Pagination/HubspotPaginationService.php
:51
in
Jiminny\Services\Crm\Hubspot\Pagination\HubspotPaginationService::getPaginatedDataGenerator
In App
/app/Services/Crm/Hubspot/Client.php
:94
in
Jiminny\Services\Crm\Hubspot\Client::getPaginatedData
In App
/app/Services/Crm/Hubspot/Service.php
:1212
in
Jiminny\Services\Crm\Hubspot\Service::Jiminny\Services\Crm\Hubspot\{closure}
In App
Called from
:
/vendor/laravel/framework/src/Illuminate/Cache/Repository.php
:564
in
Illuminate\Cache\Repository::remember
Show 2 more frames
Show 2 more frames
/app/Services/Crm/Hubspot/Service.php
:1206
in
Jiminny\Services\Crm\Hubspot\Service::matchByName
In App
/app/Services/Crm/CachedCrmServiceDecorator.php
:167
in
Jiminny\Services\Crm\CachedCrmServiceDecorator::matchByName
In App
/app/Services/Crm/CrmActivityService.php
:227
in
Jiminny\Services\Crm\CrmActivityService::findCrmRecords
In App
/app/Services/Crm/CrmActivityService.php
:139
in
Jiminny\Services\Crm\CrmActivityService::updateParticipantsCrmData
In App
/app/Services/Crm/CrmActivityService.php
:81
in
Jiminny\Services\Crm\CrmActivityService::updateCrmData
In App
/app/Jobs/Crm/MatchActivityCrmData.php
:107
in
Jiminny\Jobs\Crm\MatchActivityCrmData::Jiminny\Jobs\Crm\{closure}
In App
Called from
:
/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php
:35
in
Illuminate\Database\Connection::transaction
/app/Jobs/Crm/MatchActivityCrmData.php
:87
in
Jiminny\Jobs\Crm\MatchActivityCrmData::handle
Copy file path
Open this line in GitHub
In App
82
if
(
$activity
===
null
)
{
83
throw
new
InvalidArgumentException
(
'[MatchActivityCrmData] Cannot find activity.'
)
;
84
}
85
86
try
{
87
$connection
->
transaction
(
function
(
)
use
(
$activity
,
$crmActivityService
,
$activityRepository
)
{
88
Log
::
info
(
'[MatchActivityCrmData] Starting CRM data matching'
,
[
89
'activity'
=>
$this
->
activityId
,
90
'remote_search'
=>
$this
->
remoteSearch
,
91
'set_configuration'
=>
$this
->
fromConfiguration
?->
getId
(
)
,
92
'old_state'
=>
[
activityRepository
Object Jiminny\Repositories\ActivityRepository
connection
Object Illuminate\Database\MariaDbConnection
crmActivityService
Object Jiminny\Services\Crm\CrmActivityService
Called from
:
/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php
:36
in
Illuminate\Container\BoundMethod::Illuminate\Container\{closure}
Show 14 more frames
Show 14 more frames
/app/Queue/Worker/Worker.php
:71
in
Jiminny\Queue\Worker\Worker::process
In App
Called from
:
/vendor/laravel/framework/src/Illuminate/Queue/Worker.php
:435
in
Illuminate\Queue\Worker::runJob
Show 17 more frames
Show 17 more frames
GuzzleHttp\Exception\ClientException
GuzzleHttp\Exception\ClientException
GuzzleHttp\Exception\ClientException
Collapse Trace Preview Section
Trace Preview
View Full Trace
View Full Trace
0.00ms
0.00ms
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s
0s...
|
Firefox
|
SevenShores\Hubspot\Exceptions\BadRequest: Client SevenShores\Hubspot\Exceptions\BadRequest: Client error: `POST https://api.hubapi.com/crm/v3/objects/contact/search` resulted in a `429 Too Many Requests` response: {"status":"error","message":"You have reached your secondly limit.","errorType":"RATE_LIMIT — Work...
|
jiminny.sentry.io/issues/7007366572/?environment=p jiminny.sentry.io/issues/7007366572/?environment=production&environment=production-eu&project=82419&query=is%3Aunresolved&referrer=issue-stream&sort=freq...
|
|
PhostormINavigarecodeLaravelFV faVsco.js?9 masterP PhostormINavigarecodeLaravelFV faVsco.js?9 masterProiectRateLimitException.phpC) RateLimitAwareWrapper.pnp© Client.phpT SvncCrmFieldsTl• IntegrationApp/.../SyncCrmEntitiesTrait.phpobasicapl.ong© syncopportuntty.ong© SyncOpportunitiesJob.phpT OpportunitySyncTrait.phpT SvncCrmMetad:© WebhookSyncBatchProcessor.phpTImportBatchJobTrait.phpT SystemStateTra(c) Dataclient.one© Middleware/RateLimited.php© Hubspot/Service.php© Companies.php) MatchacuvitycrmData.pnp©) Crmacuivityservice.ong© DecorateActivity.phcachedcrmservicedecorator.onox( Hubspot/.../SyncCrmEntitiesTrait.phduservicelntenace.onooLocdlsearch.ong© LocalSearchInterfac(C) ProviderRateLimiter.php© RemoteSearch.phpclass CachedcrmServiceDecorator imolements MatchermentitiesWithCachelnterface) service.pnpv D Listeners© ConvertLeadActivit56 CT )public function matchExactlyByEmail(string Semail, ?int $userId = null): ?array{...}76 0*c) Purgelookupcache 145› D MeradaraMiarauion• PipedriveOpportunitvSvncSti 149• ProspectSearchStr 150C) ApiFields.oho© Client.phpC) FieldDerinitions.ont 155C) PioedriveAoiClient 154() PioedriveAoiExceot 153C) Service oho156 GtC) TokenStorade ohoSalestorce• M Sielde> OpportunityMatche 16€• D OpportunitySyncSti 161• M ProcnectSearchStra 169© Client.php© DecorateActivity.pr 165• DeleteObjectsTrait. 166© FieldDefinitions.phg 167© PayloadBuilder.php 168c) Profile.php© QueryBuilder.php© QuervHandler.phpC) @uerviterator.php© QuervResults.phpc) Service.ohr@ SvncBatchRedisSer 175M TraitsC Baseclient. ohoC BaseService.oho(C) CachedCrmServiceDe 1799) CrmActivitvProviderint 181(C) CrmActivitvService nhi 187@ CrmConfiaurationSetti 183 Gt›(C) CrmOhiectcRecolver n 192public function matchByDomain(string $email, ?int $userId = null): ?array{...}* areturn null/array(LeadnullACcoUnt nullUpporcunity null.contacc nutl.sragelnulustrinolnuLapublic function matchByName(string Sname, ?int Suserid = null): ?arrayif (u Sthis->isConnected@) &$this->logger->info('[Prospect match] Service is not connected, remote search is currently not available', ['identifier tvnel => 'name'.=> Sname.return null.return Sthis->crmService->matchByName(name• Snameucentd• Sucentdl* @return null/arraufLead nuLuAccount null.upportunitulnullcontact nult,Stage|null,strinalnulzoublic function matchßvPhone(strina Sphone. strina SrawPhoneNumber = nult, Jint Suserid = nulb: Darravs...arQube for IDE suggestions: Detect more security issues in your PHP files // Try SonarQube Cloud for free // Download SonarQube Server // Learn more // Don't ask again (today 10:25)40 h• # Lukas/Stefka 121 - in 1h 47m100% 12AskJiminnyReportActivityServiceTest viii accounts [jiminny@localhost] XA console [PROD)# console leu)& console [STAGING]Thu 7 May 15:43:57CSV vmA8.v= custom.log= laravel.log« SF [jiminny@localhost]A HS_local [jiminny@localhost]1rowvGOut-gtTx: AutovY- WHERE id = 5190E- ORDER BYdo idOuuid (UUID)51004e3f2289-a3d2-5235-b410-b94ebb547490o team_1do crm contiquration 1d :o crm_provider_id1212213464I user_id430#owner id579583316nameUmbrella Corpl phone[PHONE]extW industry1 domainUnbreLLacorp.col(• photo path/abae74b8-bfa8-4383-9a7f-89f4bf2bdb…country code<nUlluas internallШ deleted_at<nul1 created_at2026-03-30 06:44:25Iremotely_ created_at2019-02-01 15:39:53Iupdated_at2026-03-30 06:44:25W Windsurf Teams 167:39 UTF-8 P 4 spaces ®...
|
iTerm2
|
NULL
|
NULL
|
|
PostmanProiect vT SvncCrmFieldsTl• IntegrationApp/ PostmanProiect vT SvncCrmFieldsTl• IntegrationApp/.../SynoT SvncCrmMetad:T SystemStateTra(c) Dataclient.one© Middleware/RateLimited.php© DecorateActivity.ph© CachedCrmServiceDecorator.php x| (* Hubspot/.../SyncdoLocdlsearch.ong© LocalSearchInterfac(C) ProviderRateLimiter.php© RemoteSearch.phpclass CachedcrmServiceDecorator imoleme) service.pnp56 CT )public function matchExactlyByEmailv D Listeners© ConvertLeadActivit76 0*© PurgeLookupCache 145puburc Tuncczon macchbyvonarniscril› D MeradaraMiarauionv W PioedriveOpportunitvSvncSti 149• ProspectSearchStr 156C) ApiFields.oho© Client.phpC) FieldDerinitions.onr 15s© PipedriveApiClient 1 154() PioedriveAoiExceot 153C) Service oho156 GtC) TokenStorade oho• M Salesforce• M Sielde> MOnnortunitvMatche 166• D OpportunitySyncSti 161• M ProcnectSearchStra 169© Client.php© DecorateActivity.pr 165( DeleteObiectsTrait. 100© FieldDefinitions.phg 167© PayloadBuilder.php 168c) Profile.php© QueryBuilder.phr© QuervHandler.phpC) @uerviterator.phpC) @uervResults.phpc) Service.ohr@ SvncBatchRedisSer 175M TraitsC Baseclient. ohoC BaseService.oho(C) CachedCrmServiceDe 1799) CrmActivitvProviderint 181(C) CrmActivitvService nhi 187* areturn null/array(LeadnullAccount null.Upporcunity null.contacc nutl.sragelnulustrinolnuLaoublac function matchBvvame (strinaif (u Sthis->isConnected@) ‹Sthis->lodden->infol'Prosn"identifier tvne' => 'n=> Snamereturn null.neturnSthic-scnmSenvicp-smatchname• Snameucentd• Sucento* @return null/arraufLead nuLuAccount null.upportunitulnullcontact nult,Stage|null,strinalnulz(C) CrmConfiaurationSetti 183 Gl )oublic function matchßvPhone(strind(C) CrmOhiectcRecolver n 192• SearchYour team is now on the Free plan with 1 admin. You retain editing access and other members are read-only. View team permissions to see who can edit, or upgrade to restore collaborationV COLLECTIONSv obiect ld›associations/kto obiect lype,v GeT Read5e An error occurredea. successful oberation> bEL Archive> PATCH Uodate>GET LISt> POST Createpost Filter, sort, and search ekM Obiectsea. successful operationge. An error occurred• CRM Owners• CRM Pipelines> Dealsv Engagements> 7 OLD ENGAGEMENTSGET list meetingsPOST search modified companiesPosT search tasksDprcoarennailget list callspost meetinos scheculedGET aet meetinopost det link to task> POST Create Contact with Associationv Iteration run HSv GET Read Copyea. An error occurred.ge successful operation> Iteration run Search HS> Journal & webhoooks v4> ©Authl› Properties> RESSARCHI• CEADAUPOST search contact by phonePost search contaci.by emailCaMiDANMeNreSPECS>FLOWS§ Connect GitConcole 5.l TermGET Rea •GET Rea •GET readGET httos• IterationIterationlPOST seatteration run Search HS (#2)u Iteration run Search HS • 20 VUs • May 07, 2026 15:36:54 (1 min) • Fixed profileSummaryTotal requests sent ©Requests/second ©Avg. response time ©P90 ©P95 ©P99 ©Error %©Failure % ©7230121.40151 ms161 ms194 ms296 ms0,000,00% 10015•26•5815•27-0415-27-1015•27•1615-27-2215-27-2815:37:34POST search contact by email Copy0.000.00151" Lukas sterka 121 • In 1h 47mm lteration)IterationNo environmentSharePeak CPU % ©Peak Memory % ©996 %19.2 %Filter bv requestsvAva. responsev273 ms 140 req/s100% 52Inu / May 10.44:00UparadeVXAlAll variablesNo environment selected. Selec envionmeaGlobalstokenCKPur5PqMxIZQINQMI8kQE..baseUrlhttps://api.hubapi.comdev-tokenCLLm5NnQMxIRQINQMI8kQ.• Local VaultStore your APl secrets locally in vault. Set up vault10015-27•4015-27-46|15-27•50- Requests/second - Ava. response - Error % - Virtualusers *• CPU% *** Memory ⅞Min (ms)194Globals Vault Tools?000...
|
iTerm2
|
NULL
|
NULL
|
|
PostmanProiectWindowT SvncCrmFieldsTl• Integration PostmanProiectWindowT SvncCrmFieldsTl• IntegrationApp/.../SynoT SvncCrmMetad:T SystemStateTra(c) Dataclient.one© Middleware/RateLimited.php© DecorateActivity.ph© CachedCrmServiceDecorator.php x| (* Hubspot/.../SyncdoLocdlsearch.ong© LocalSearchInterfac(C) ProviderRateLimiter.php© RemoteSearch.phpclass CachedcrmServiceDecorator imoleme) service.pnp56 CT )public function matchExactlyByEmailv D Listeners© ConvertLeadActivit© PurgeLookupCache 145> 07 Metadata76 0*puburc Tuncczon macchbyvonarniscrilMiarauionv W PioedriveOpportunitySvncSti 149• ProspectSearchStr 156C) ApiFields.oho© Client.phpc) FieldDerinitions.onr 15s© PipedriveApiClient 1 154() PioedriveAoiExceot 153C) Service oho156 GtC) TokenStorade ohoSalestorce• M Sielde• M OnnortunitvMatche 160• D OpportunitySyncSti 161• M ProcnectSearchStra 169© Client.php© DecorateActivity.pr 165• DeleteObjectsTrait. 166© FieldDefinitions.phg 167© PayloadBuilder.php 168c) Profile.php© QueryBuilder.php© QuervHandler.phpC) @uerviterator.phpC) @uervResults.phpc) Service.ohr@ SvncBatchRedisSer 175M TraitsC Baseclient. ohoC BaseService.oho(C) CachedCrmServiceDe 1799) CrmActivitvProviderint 181(C) CrmActivitvService nhi 187* @return null/arrayfLeadnullACcoUnt nullUpporcunity null.contacc nutl.sragelnulustrinolnuLapublic function matchByName(stringif (u Sthis->isConnected@) ‹Sthis->lodden->infol'Prosnidentifier tvnel =>return null.neturnSthic-scnmSenvicp-smatchname• Snameucentd• Sucentdl* @return null/arraufLead nuLuAccount null.upportunitulnullcontact nult,Stage|null,strinalnulz@ CrmConfiaurationSetti 183 Gt›oublic function matchßvPhone(strind(C) CrmOhiectcRecolver n 192• SearchYour team is now on the Free plan with 1 admin. You retain editing access and other members are read-only. View team permissions to see who can edit, or upgrade to restore collaborationV COLLECTIONS> CRM Owners> CRM Pipelines› Dealsengagements> D OLD ENGAGEMENTSuer list meetingsGET read callGET ist callsPOST meetings scheduledGET det meetinoPOST get link to task>POST Create Contact with Association› Hubspotvteration run HSGet Read Copyeg. An error occurred.se. successful operationsmteration run Search HS• lournal 8 wohhasdkc wal› ©Auth•Properties> RESEARCHSFAPCHPOST search contact by phonePOST search contact by emailPOST search meetinasPOST search notes> POST Search calls v3POST Search related meetings v3POST search deals• Tickotsv UsefulGET Rea •GET Rea •GET readGET httos© IterationIterationlPOST seatteration run Search HS (#2)u Iteration run Search HS • 20 VUs • May 07, 2026 15:36:54 (1 min) • Fixed profileSummaryTotal requests sent ©Requests/second ©Avg. response time ©P90 ©P95 ©P99 ©Error %©Failure % ©7230121.40151 ms161 ms194 ms296 ms0,00I0,00% 100-****> POST filter per company / only open deal stagesGET engagements old associated by dealGEt engagements old associated by company> GeT aet history of propertv - deal stageGET get usersCaMiDANMeNreSPECS>FLOWS§ Connect GitConcole 5.l Term15•26•5815•27-0415-27-1015•27•1615-27-2215-27-2815:37:34POST search contact by email Copy0.000.00151"Lukas sterka 121 • In Th 40m100% 2Inu / May 10.44:00Uparadem lteration)IterationNo environmentVAIIShareAll variablesNo environment selected. Selec envionmeaPeak CPU % ©Peak Memory % ©Globals996 %19.2 %tokenCKPur5PqMxIZQINQMI8kQE..Filter bv requestsvAva. responsevbaseUrlhttps://api.hubapi.com273 ms 140 req/sdev-tokenCLLm5NnQMxIRQINQMI8kQ.• Local VaultStore your APl secrets locally in vault. Set up vault10015-27•4015-27-46|15-27•50- Requests/second - Ava. response - Error % - Virtualusers *• CPU% *** Memory ⅞Min (ms)194Globals Vault Tools?000...
|
iTerm2
|
NULL
|
NULL
|
|
iTerm2ShellEditViewSessionScriptsProfilesWindowHel iTerm2ShellEditViewSessionScriptsProfilesWindowHelp$0(wbl# Lukas/Stefka 121 • in 1h 46 m100% [8DEV (docker)DOCKERDEV (docker)H82APP (-zsh)artisan-schedule:artisan-schedule_00:stoppedworker-es-update:worker-es-update_00: stoppedartisan-schedule:artisan-schedule_00: startedjiminny-worker-processing-1:jiminny-worker-processing-1_00: startedjiminny-worker-processing-2: jiminny-worker-processing-2_00: startedjiminny-worker-processing-3:jiminny-worker-processing-3_00: startedjiminny-worker-processing-4:jiminny-worker-processing-4_00: startedjiminny-worker-processing-5:jiminny-worker-processing-5_00: startedjiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00:startedworker:worker_00: startedworker-analytics:worker-analytics_00:startedworker-audio:worker-audio_00: startedworker-calendar:worker-calendar_00:startedworker-conferences:worker-conferences_00: startedworker-crm-sync:worker-crm-sync_00:startedworker-crm-update:worker-crm-update_00: startedworker-download:worker-download_00: startedworker-emails:worker-emails_00:startedworker-es-update:worker-es-update_00: startedworker-nudges:worker-nudges_00: startedroot@docker_Lamp_1:/home/jiminny# php artisan jiminny: debugMatching contact 0root@docker_lamp_1:/home/jiminny# php artisan jiminny: debugMatching contact 0Matching contact 1Matchingcontact 2Matchingcontact 3Matching contact 4Matching contact 5Matching contact6Matching contact 7Matching contact 8Matching contact 9root@docker_lamp_1:/home/jiminny# php artisan jiminny:debugMatching contact 0Matching contact 1Matching contact 2Matching contact 3Matchingcontact 4Matchingcontact 5Matching contact 6Matching contact 7Matching contact 8Matching contact 9root@docker_lamp_1:/home/jiminny# ]-zsh• $4screenpipe*•$5-zshThu 7 May 15:44:06181₴6DEV...
|
iTerm2
|
NULL
|
NULL
|
|
PostmanProledeyWindowT SvncCrmFieldsTl• Integratio PostmanProledeyWindowT SvncCrmFieldsTl• IntegrationApp/.../SynoT SvncCrmMetad:T SystemStateTra(c) Dataclient.one© Middleware/RateLimited.php© DecorateActivity.ph© CachedCrmServiceDecorator.php x| (* Hubspot/.../SyncdoLocdlsearch.ong© LocalSearchInterfac(C) ProviderRateLimiter.php© RemoteSearch.phpclass CachedcrmServiceDecorator imoleme) service.pnp56 CT )public function matchExactlyByEmailv D Listeners© ConvertLeadActivit© PurgeLookupCache 145> 07 Metadata76 0*puburc Tuncczon macchbyvonarniscrilMiarauionv W PioedriveOpportunitvSvncSti 149• ProspectSearchStr 156C) ApiFields.oho© Client.phpc) FieldDerinitions.onr 15s© PipedriveApiClient 1 154() PioedriveAoiExceot 153C) Service oho156 GtC) TokenStorade ohoSalestorce• M Sielde> MOnnortunitvMatche 166• D OpportunitySyncSti 161• M ProcnectSearchStra 169© Client.php© DecorateActivity.pr 165• DeleteObjectsTrait. 166© FieldDefinitions.phg 167© PayloadBuilder.php 168c) Profile.php© QueryBuilder.php© QuervHandler.phpC) @uerviterator.phpC) @uervResults.phpc) Service.ohr@ SvncBatchRedisSer 175M TraitsC Baseclient. ohoC BaseService.oho(C) CachedCrmServiceDe 1799) CrmActivitvProviderint 181(C) CrmActivitvService nhi 187* @return null/arrayfLeadnullAccount null.Upporcunity null.contacc nutl.sragelnulustrinolnuLapublic function matchByName(stringif (u Sthis->isConnected@) ‹Sthis->lodden->infol'Prosn"identifier tvne' => 'nreturn null.neturnSthic-scnmSenvicp-smatchname• Snameucentd• Sucentdl* @return null/arraufLead nuLuAccount null.upportunitulnullcontact nult,Stage|null,strinalnulz@ CrmConfiaurationSetti 183 Gt›oublic function matchßvPhone(strind(C) CrmOhiectcRecolver n 192"Lukas sterka 121 • In 1h 40m100% 2Thu 7 May 15:44:07• SearchUparadeYour team is now on the Free plan with 1 admin. You retain editing access and other members are read-only. View team permissions to see who can edit, or upgrade to restore collaborationV COLLECTIONS> CRM Owners> CRM Pipelines› Dealsengagements> D OLD ENGAGEMENTSuer list meetingsGET read call> post soarch calleGET ist callsPOST meetings scheduledGET det meetinoPOST get link to task> POST Create Contact with Association› Hubspotvteration run HSv GET Read Copyeg. An error occurred.se. successful operationv lteration run Search HSrost search congaet oy emall copy> Journal & webhoooks v4• ©Authi› Properties> RESCAPCHSEARCHIPost search contact by phonePOST search contact by emailPOST search meetings> post Search calle v2POST Search related meetinas v3Post coarch deals> Ticketsv UicofullGET engagements old associated by dealGET engagements old associated by comoanv> GET get history of property - deal stageCaMiDANMeNreSPECS>FLOWS§ Connect GitConcole 5.l TerminsGET Rea •GET Rea •GET readGET httos• IterationIterationlPOST seatm lteration)IterationNo environmentVAIIteration run Search HS (#2)ShareAll variablesu Iteration run Search HS • 20 VUs • May 07, 2026 15:36:54 (1 min) • Fixed profileSummaryNo environment selected. Selec envionmeaTotal requests sent ©Requests/second ©Avg. response time ©P90 ©P95 ©P99 ©Error %©Failure % ©Peak CPU % ©7230121.40151 ms161ms194 ms296 ms0,000,00996 %Peak Memory % ©19.2 %GlobalstokenCKPur5PqMxIZQINQMI8kQE..Filter bv reauests.vAva. responsevbaseUrlhttps://api.hubapi.com% 100273 ms 140 req/sdev-tokenCLLm5NnQMxIRQINQMI8kQ.• Local VaultStore your APl secrets locally in vault. Set up vault10015•26•5815•27-0415-27-1015•27•1615-27-2215-27-2815:37:3415-27•4015-27-46|15-27•50- Requests/second - Ava. response - Error % - Virtualusers *• CPU% *** Memory ⅞Min (ms)POST search contact by email Copy0.000.00151194Globals Vault Tools?00O...
|
iTerm2
|
NULL
|
NULL
|
|
iTerm2ShellEditViewSessionScriptsProfilesWindowHel iTerm2ShellEditViewSessionScriptsProfilesWindowHelp$0(wbl# Lukas/Stefka 121 • in 1h 46 m100% [8DEV (docker)DOCKERDEV (docker)H82APP (-zsh)artisan-schedule:artisan-schedule_00:stoppedworker-es-update:worker-es-update_00: stoppedartisan-schedule:artisan-schedule_00: startedjiminny-worker-processing-1:jiminny-worker-processing-1_00: startedjiminny-worker-processing-2: jiminny-worker-processing-2_00: startedjiminny-worker-processing-3:jiminny-worker-processing-3_00: startedjiminny-worker-processing-4:jiminny-worker-processing-4_00: startedjiminny-worker-processing-5:jiminny-worker-processing-5_00: startedjiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00:startedworker:worker_00: startedworker-analytics:worker-analytics_00:startedworker-audio:worker-audio_00: startedworker-calendar:worker-calendar_00:startedworker-conferences:worker-conferences_00: startedworker-crm-sync:worker-crm-sync_00:startedworker-crm-update:worker-crm-update_00: startedworker-download:worker-download_00: startedworker-emails:worker-emails_00:startedworker-es-update:worker-es-update_00: startedworker-nudges:worker-nudges_00: startedroot@docker_Lamp_1:/home/jiminny# php artisan jiminny: debugMatching contact 0root@docker_lamp_1:/home/jiminny# php artisan jiminny: debugMatching contact 0Matching contact 1Matchingcontact 2Matchingcontact 3Matching contact 4Matching contact 5Matching contact6Matching contact 7Matching contact 8Matching contact 9root@docker_lamp_1:/home/jiminny# php artisan jiminny:debugMatching contact 0Matching contact 1Matching contact 2Matching contact 3Matchingcontact 4Matchingcontact 5Matching contact 6Matching contact 7Matching contact 8Matching contact 9root@docker_lamp_1:/home/jiminny# ]-zsh• $4screenpipe*•$5-zshThu 7 May 15:44:09181₴6DEV...
|
iTerm2
|
NULL
|
NULL
|
|
PostmanProledeyWindowT SvncCrmFieldsTl• Integratio PostmanProledeyWindowT SvncCrmFieldsTl• IntegrationApp/.../SynoT SvncCrmMetad:T SystemStateTra(c) Dataclient.one© Middleware/RateLimited.php© DecorateActivity.ph© CachedCrmServiceDecorator.php x| (* Hubspot/.../SyncdoLocdlsearch.ong© LocalSearchInterfac(C) ProviderRateLimiter.php© RemoteSearch.phpclass CachedcrmServiceDecorator imoleme) service.pnp56 at)public function matchExactlyByEmailv D Listeners© ConvertLeadActivit© PurgeLookupCache 145> 07 Metadata76 0*puburc Tuncczon macchbyvonarniscrelMiarauionv W PioedriveOpportunitvSvncSti 149• ProspectSearchStr 156C) ApiFields.oho© Client.phpC) FieldDerinitions.onr 15s© PipedriveApiClient 1 154() PioedriveAoiExceot 153C) Service oho156 GtC) TokenStorade ohoSalestorce• M Sielde> MOnnortunitvMatche 166• D OpportunitySyncSti 161• M ProcnectSearchStra 169© Client.php© DecorateActivity.pr 165• DeleteObjectsTrait. 166© FieldDefinitions.phg 167© PayloadBuilder.php 168c) Profile.php© QueryBuilder.php© QuervHandler.phpC) @uerviterator.phpC) @uervResults.phpc) Service.ohr@ SvncBatchRedisSer 175M TraitsC Baseclient. ohoC BaseService.oho(C) CachedCrmServiceDe 1799) CrmActivitvProviderint 181(C) CrmActivitvService nhi 187* @return null/arrayfLeadnullAccount null.Upporcunity null.contacc nutl.sragelnulustrinolnuLapublic function matchByName(stringif (u Sthis->isConnected@) ‹Sthis->lodden->infol'Prosn"identifier tvne' => 'nreturn null.neturnSthic-scnmSenvicp-smatchname• Snameucentd• Sucentdl* @return null/arraufLead nuLuAccount null.upportunitulnullcontact nult,Stage|null,strinalnulz@ CrmConfiaurationSetti 183 Gt›oublic function matchßvPhone(strind(C) CrmOhiectcRecolver n 192• SearchYour team is now on the Free plan with 1 admin. You retain editing access and other members are read-only. View team permissions to see who can edit, or upgrade to restore collaborationGET next •POST Rea. • POST Rea.GET Rea•GET readGET Get EeGET httos • IterationD IterationPOST seatIteration run Search HS › search contact by email CopyposTntps://api.nubapi.com/crm/vs/objects/contacts/searcn= Docs Params Authorization • Headers 11 Body • Scripts Settingso none torm-data x-www-form-urlencoded raw binary Grapnel JSON v1 { "limit": 1 }Iteratio#Lukas/Stefka 121 - in 1h 46 mThu 7 May 15:44:10No environmentg Save100% C4* AIVariables in requesG tokenCookies› All variables9 Schema BeautifyUparadeCKPur5PoMxIZOINOMI8kOEw.V COLLECTIONS> CRM Owners> CRM Pipelines› Dealsengagements› OLD ENGAGEMENTSuer list meetingsGET read callPost coarch calleGET ist callsPOST meetings scheduledGET det meetinoPOST get link to task>POST Create Contact with Association› Hubspotvteration run HSv GET Read Copyeg. An error occurred.se. successful operationv lteration run Search HSPOST search contact by email Copy> Journal & webhoooks v4• ©Authi› Properties> RESCAPCHSEARCHIPOST search contact by phonePOST search contact by emailPOST search meetings> Post Search callc vaPOST Search related meetinas v3Post coarch deals> Ticketsv UicofullGET engagements old associated by dealGET engagements old associated by comoany> GET get history of property - deal stageCaMiDANMeNreSPECS>FLOWS§ Connect GitConcole 5.l TerminsBody Cookies 1 Headers 16 Test ResultsSJSON vPreview~ Visualize200 OK • 217 ms • 1.15 KB • Ga e.g. Save Response ••: "2018-03-14T14:36:26.401Z",cenubspot.coyLastmod1tzeddate": "2025-10-14110:14:51.5172",createdAt": "2018-03-14T14:36:26.4017"."archived". falce."https://app.hubspot.com/contacts/4392066/record/0-1/1'I,nina" sfter", "1"Globals Vault Tools?000...
|
iTerm2
|
NULL
|
NULL
|
|
iTerm2ShellEditViewSessionScriptsProfilesWindowHel iTerm2ShellEditViewSessionScriptsProfilesWindowHelp$0(wbl# Lukas/Stefka 121 • in 1h 46 m100% [8DEV (docker)DOCKERDEV (docker)H82APP (-zsh)artisan-schedule:artisan-schedule_00:stoppedworker-es-update:worker-es-update_00: stoppedartisan-schedule:artisan-schedule_00: startedjiminny-worker-processing-1:jiminny-worker-processing-1_00: startedjiminny-worker-processing-2: jiminny-worker-processing-2_00: startedjiminny-worker-processing-3:jiminny-worker-processing-3_00: startedjiminny-worker-processing-4:jiminny-worker-processing-4_00: startedjiminny-worker-processing-5:jiminny-worker-processing-5_00: startedjiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00:startedworker:worker_00: startedworker-analytics:worker-analytics_00:startedworker-audio:worker-audio_00: startedworker-calendar:worker-calendar_00:startedworker-conferences:worker-conferences_00: startedworker-crm-sync:worker-crm-sync_00:startedworker-crm-update:worker-crm-update_00: startedworker-download:worker-download_00: startedworker-emails:worker-emails_00:startedworker-es-update:worker-es-update_00: startedworker-nudges:worker-nudges_00: startedroot@docker_Lamp_1:/home/jiminny# php artisan jiminny: debugMatching contact 0root@docker_lamp_1:/home/jiminny# php artisan jiminny: debugMatching contact 0Matching contact 1Matchingcontact 2Matchingcontact 3Matching contact 4Matching contact 5Matching contact6Matching contact 7Matching contact 8Matching contact 9root@docker_lamp_1:/home/jiminny# php artisan jiminny:debugMatching contact 0Matching contact 1Matching contact 2Matching contact 3Matchingcontact 4Matchingcontact 5Matching contact 6Matching contact 7Matching contact 8Matching contact 9root@docker_lamp_1:/home/jiminny# ]-zsh• $4screenpipe*•$5-zshThu 7 May 15:44:10T81₴6DEV...
|
iTerm2
|
NULL
|
NULL
|
|
PostmanProledeyWindowT SvncCrmFieldsTl• Integratio PostmanProledeyWindowT SvncCrmFieldsTl• IntegrationApp/.../SynoT SvncCrmMetad:T SystemStateTra(c) Dataclient.one© Middleware/RateLimited.php© DecorateActivity.ph© CachedCrmServiceDecorator.php x| (* Hubspot/.../SyncdoLocdlsearch.ong© LocalSearchInterfac(C) ProviderRateLimiter.php© RemoteSearch.phpclass CachedcrmServiceDecorator imoleme) service.pnp56 CT )public function matchExactlyByEmailv D Listeners© ConvertLeadActivit© PurgeLookupCache 145> 07 Metadata76 0*puburc Tuncczon macchbyvonarniscrelMiarauionv W PioedriveOpportunitvSvncSti 149• ProspectSearchStr 156C) ApiFields.oho© Client.phpc) FieldDerinitions.onr 15s© PinedriveApiClient 1 154() PioedriveAoiExceot 153C) Service oho156 GtC) TokenStorade ohoSalestorce• M Sielde> MOnnortunitvMatche 166• D OpportunitySyncSti 161• M ProcnectSearchStra 169© Client.php© DecorateActivity.pr 165• DeleteObjectsTrait. 166© FieldDefinitions.phg 167© PayloadBuilder.php 168c) Profile.php© QueryBuilder.php© QuervHandler.phpC) @uerviterator.phpC) @uervResults.phpc) Service.ohr@ SvncBatchRedisSer 175M TraitsC Baseclient. ohoC BaseService.oho(C) CachedCrmServiceDe 1799) CrmActivitvProviderint 181(C) CrmActivitvService nhi 187* @return null/arrayfLeadnullAccount null.Upporcunity null.contacc nutl.sragelnulustrinolnuLapublic function matchByName(stringif (u Sthis->isConnected@) ‹Sthis->lodden->infol'Prosn"identifier tvne' => 'nreturn null.neturnSthic-scnmSenvicp-smatchname• Snameucentd• Sucentdl* @return null/arraufLead nuLuAccount null.upportunitulnullcontact nult,Stage|null,strinalnulz@ CrmConfiaurationSetti 183 Gt›oublic function matchßvPhone(strind(C) CrmOhiectcRecolver n 192• SearchYour team is now on the Free plan with 1 admin. You retain editing access and other members are read-only. View team permissions to see who can edit, or upgrade to restore collaborationGET next •POST seatPOST Rea. • POST Rea.GET Rea•GET readGET Get EeGET httosO IterationD IterationPOST seatIteration run Search HS › search contact by email CopyposTntps://api.nubapi.com/crm/vs/objects/contacts/searcn= Docs Params Authorization • Headers 11 Body • Scripts Settingso none torm-data x-www-form-urlencoded raw binary Grapnel JSON v1 { "limit": 1 }Iteratio#Lukas/Stefka 121 - in 1h 46 mNo environmentg Save100% C4*AIVariables in requesG tokenCookies› All variables9 Schema BeautifyThu 7 May 15:44:11UparadeCKPur5PoMxIZOINOMI8kOEw.V COLLECTIONS> CRM Owners> CRM Pipelines› Dealsengagements› OLD ENGAGEMENTSuer list meetingsGET read callPost coarch calleGET ist callsPOST meetings scheduledGET det meetinoPOST get link to task>POST Create Contact with Association› Hubspotvteration run HSv GET Read Copyeg. An error occurred.se. successful operationv lteration run Search HSPOST search contact by email Copy> Journal & webhoooks v4• ©Authi› Properties> RESCAPCHSEARCHIPOST search contact by phonePOST search contact by emailPOST search meetings> Post Search callc vaPOST Search related meetinas v3Post coarch deals> Ticketsv UicofullGET engagements old associated by dealGET engagements old associated by comoany> GET get history of property - deal stageCaMiDANMeNreSPECS>FLOWS§ Connect GitConcole 5.l TerminsBodyCookioc 1 Headers 16 Toct PoculteSJSONvPreview~ Visualize200 OK • 217 ms • 1.15 KB • Ga e.g. Save Response ••: "2018-03-14T14:36:26.401Z",[EMAIL],Lastmod1tzeddate": "2025-10-14110:14:51.5172",createdAt": "2018-03-14T14:36:26.4017"."archived". falce."https://app.hubspot.com/contacts/4392066/record/0-1/1'I,nina" safter", "y"Globals Vault Tools?000...
|
iTerm2
|
NULL
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV
Export Data…
Copy to Database…
Compare Data
View as
Show Options Menu
Code changed:
Hide
Sync Changes...
|
PhpStorm
|
faVsco.js – CachedCrmServiceDecorator.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV
Export Data…
Copy to Database…
Compare Data
View as
Show Options Menu
Code changed:
Hide
Sync Changes
Hide This Notification
8
Previous Highlighted Error
Next Highlighted Error
<?php
declare(strict_types=1);
namespace Jiminny\Services\Crm;
use Jiminny\Contracts\Services\Crm\ConnectionStateInterface;
use Jiminny\Contracts\Services\Crm\MatchCrmEntitiesWithCacheInterface;
use Jiminny\Contracts\Services\Crm\ServiceInterface;
use Jiminny\Exceptions\ApplicationException;
use Jiminny\Models\Account;
use Jiminny\Models\Contact;
use Jiminny\Models\Crm\Configuration;
use Jiminny\Models\Lead;
use Jiminny\Models\Opportunity;
use Jiminny\Models\Stage;
use Psr\Log\LoggerInterface;
class CachedCrmServiceDecorator implements MatchCrmEntitiesWithCacheInterface
{
private ?ServiceInterface $crmService = null;
private ProspectCache $prospectCache;
private LoggerInterface $logger;
private ?Configuration $configuration;
public function __construct(
ProspectCache $prospectCache,
LoggerInterface $logger
) {
$this->prospectCache = $prospectCache;
$this->logger = $logger;
$this->configuration = null;
}
public function setCrmService(?ServiceInterface $crmService = null): void
{
$this->crmService = $crmService;
}
public function setConfiguration(Configuration $configuration): void
{
$this->configuration = $configuration;
}
/**
* @return null|array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
*}
*/
public function matchExactlyByEmail(string $email, ?int $userId = null): ?array
{
if (! filter_var($email, FILTER_VALIDATE_EMAIL)) {
$this->logger->warning('[Prospect match] Invalid email address', [
'identifier_type' => ProspectCache::PROSPECT_TYPE_EMAIL,
'identifier' => $email,
]);
// The email address of the prospect is invalid.
// Return null, so we can try to match by phone or name.
return null;
}
return $this->matchByProspectIdentifier(
identifierType: ProspectCache::PROSPECT_TYPE_EMAIL,
identifierValue: $email,
userId: $userId
);
}
public function matchByDomain(string $email, ?int $userId = null): ?array
{
if (! $this->crmService instanceof MatchDomainByEmailInterface) {
$this->logger->info('[Prospect match] Service does not support matching by domain', [
'identifier_type' => ProspectCache::PROSPECT_TYPE_DOMAIN,
'crm' => $this->crmService?->getDisplayName() ?? 'Not set',
'email' => $email,
]);
return null;
}
$domain = $this->crmService->getDomain($email);
if (empty($domain)) {
$this->logger->info('[Prospect match] Empty domain name', [
'identifier_type' => ProspectCache::PROSPECT_TYPE_DOMAIN,
'email' => $email,
]);
return null;
}
$this->logger->info('[Prospect match] Resolved company domain from email', [
'email' => $email,
'domain' => $domain,
]);
$configuration = $this->getConfiguration();
// try the cache
$cachedValue = $this->prospectCache->findDomainMatch(
configuration: $configuration,
identifier: $domain,
userId: $userId
);
if ($cachedValue !== null) {
return $cachedValue;
}
$this->logger->info('[Prospect match] Cache miss, calling the API', [
'identifier_type' => ProspectCache::PROSPECT_TYPE_DOMAIN,
'identifier' => $domain,
]);
$apiResult = $this->crmService->matchByDomain(domain: $domain, userId: $userId);
if (empty($apiResult)) {
$this->logger->info(
'[Prospect match] API returned empty result, caching the miss with empty prospect data',
[
'identifier_type' => ProspectCache::PROSPECT_TYPE_DOMAIN,
'identifier' => $domain,
]
);
// cache the miss with empty prospect data
$apiResult = [null, null, null, null, null, null];
}
$this->prospectCache->set(
configuration: $configuration,
identifier: $domain,
prospectData: $apiResult,
userId: $userId
);
return $apiResult;
}
/**
* @return null|array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
* }
*/
public function matchByName(string $name, ?int $userId = null): ?array
{
if (! $this->isConnected()) {
$this->logger->info('[Prospect match] Service is not connected, remote search is currently not available', [
'identifier_type' => 'name',
'identifier' => $name,
]);
return null;
}
return $this->crmService->matchByName(
name: $name,
userId: $userId
);
}
/**
* @return null|array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
*}
*/
public function matchByPhone(string $phone, ?string $rawPhoneNumber = null, ?int $userId = null): ?array
{
return $this->matchByProspectIdentifier(
identifierType: ProspectCache::PROSPECT_TYPE_PHONE,
identifierValue: $phone,
identifierSecondaryValue: $rawPhoneNumber,
userId: $userId
);
}
/**
* @throws ApplicationException
*/
private function matchByProspectIdentifier(
string $identifierType,
string $identifierValue,
?string $identifierSecondaryValue = null,
?int $userId = null,
): ?array {
$configuration = $this->getConfiguration();
$profile = $this->crmService->profile ?? null;
// Normalize phone number BEFORE cache lookup
if ($identifierType === ProspectCache::PROSPECT_TYPE_PHONE) {
$identifierValue = $this->prospectCache->normalizePhoneNumber($identifierValue);
}
$prospectData = $this->prospectCache->findByProspectIdentifier(
configuration: $configuration,
profile: $profile,
identifierType: $identifierType,
identifierValue: $identifierValue,
userId: $userId,
crmService: $this->crmService
);
if ($prospectData !== null) {
$this->logger->info('[Prospect match] Cache / local search hit', [
'identifier_type' => $identifierType,
'identifier' => $identifierValue,
]);
if (empty(array_filter($prospectData))) {
$this->logger->info('[Prospect match] cached empty result - no API calls, try next matching method', [
'identifier_type' => $identifierType,
'identifier' => $identifierValue,
]);
/**
* @IMPORTANT This is a cached empty result, i.e. there's no prospect with this email.
* We cache the empty result, so we don't keep querying the database and the API
* for non-existing prospects.
* However, we need to return null from this method
* in order to trigger the next matching method (e.g. matchByPhone or matchByName).
* This is because an array with null values is not considered empty.
*/
return null;
}
return $prospectData;
}
$this->logger->info('[Prospect match] Cache miss, calling the API', [
'identifier_type' => $identifierType,
'identifier' => $identifierValue,
]);
if (! $this->isConnected()) {
$this->logger->info('[Prospect match] Service is not connected, remote search is currently not available', [
'identifier_type' => $identifierType,
'identifier' => $identifierValue,
]);
return null;
}
/** @var 'email'|'phone' $identifierType */
$apiResult = match($identifierType) {
ProspectCache::PROSPECT_TYPE_EMAIL => $this->crmService->matchExactlyByEmail(
email: $identifierValue,
userId: $userId
),
ProspectCache::PROSPECT_TYPE_PHONE => $this->crmService->matchByPhone(
phone: $identifierValue,
rawPhoneNumber: $identifierSecondaryValue,
userId: $userId
),
};
$cachedResult = $apiResult;
if (empty($apiResult)) {
// In case the result is null or an empty array,
// cache the missing prospect, so we don't keep calling the API
$this->logger->info(
'[Prospect match] API returned empty result, caching the miss with empty prospect data',
[
'identifier_type' => $identifierType,
'identifier' => $identifierValue,
]
);
$cachedResult = [null, null, null, null, null, null];
}
// Set the cache even if the result is empty,
// so we don't keep querying the database and the API
$this->prospectCache->set($configuration, $identifierValue, $cachedResult, $userId);
return $apiResult;
}
private function isConnected(): bool
{
if ($this->crmService instanceof ConnectionStateInterface) {
return $this->crmService->isConnected();
}
return $this->crmService !== null;
}
/**
* @throws ApplicationException
*/
private function getConfiguration(): Configuration
{
if ($this->configuration) {
return $this->configuration;
}
if ($this->crmService?->getConfiguration()) {
return $this->crmService->getConfiguration();
}
throw new ApplicationException('Missing team configuration. Cannot set team prospect cache');
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All...
|
PhpStorm
|
faVsco.js – CachedCrmServiceDecorator.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp...
|
PhpStorm
|
faVsco.js – CachedCrmServiceDecorator.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
PhostormINavigarecodeLaravelFV faVsco.js?9 masterProiectRateLimitException.phpC) RateLimitAwareWrapper.pnp© Client.phpT SvncCrmFieldsTl• IntegrationApp/.../SyncCrmEntitiesTrait.phpobasicapl.ong© syncopportuntty.ong© SyncOpportunitiesJob.phpT OpportunitySyncTrait.phpT SvncCrmMetad:TImportBatchJobTrait.phpT SystemStateTra(c) Dataclient.one© Middleware/RateLimited.php© Hubspot/Service.php© Companies.php) MatchacuvitycrmData.pnp©) Crmacuivityservice.ong© DecorateActivity.phcachedcrmserviceDecorator.ono x( Hubspot/.../SyncCrmEntitiesTrait.phduservicelntenace.onooLocdlsearch.ong© LocalSearchInterfac(C) ProviderRateLimiter.php© RemoteSearch.phpclass CachedcrmServiceDecorator imolements MatchermentitiesWithCachelnterface) service.pnpv D Listeners© ConvertLeadActivit56 CT )public function matchExactlyByEmail(string Semail, ?int $userId = null): ?array{...}76 0*public function matchByDomain(string $email, ?int $userId = null): ?array{...}c) Purgelookupcache 145› D MeradaraMiarauion* areturn null/array(• PipedriveLeadnullOpportunitySvncSti 149ACcoUnt null• ProspectSearchStr 150Upporcunity null.C) ApiFields.ohocontacc nutl.© Client.phpsragelnuluC) FieldDerinitions.onr 15sstrinolnuLaC) PioedriveAoiClient1 154() PioedriveAoiExceot 153C) Service oho156 Gtnubuac function matchBvName (strina Sname. ?int Suserid = nulu: ?arravC) TokenStorade ohoSalestorce• M Sieldeif (u Sthis->isConnected@) &Sthis->loager->info('[Prospect matchl Service is not connected. remote search is currentlv not available'. [l• → OpportunityMatche 16€• D OpportunitySyncSti 161'identifier tvnel => "name'.• M ProcnectSearchStra 169© Client.phpreturn null.© DecorateActivity.pr 165• DeleteObjectsTrait. 166© FieldDefinitions.phg 167© PayloadBuilder.php 168neturn Sthic-scnmSenvicp-smatchRvNamename: Sname,c) Profile.phpuserId: SuserId© QueryBuilder.php© QuervHandler.php171C) @uerviterator.phpC) @uervResults.phpc) Service.ohr* @return null/arrauf@ SvncBatchRedisSer 175Lead nuLuM TraitsAccount null.C Baseclient. ohoupportunitulnullC BaseService.ohocontact nult,(C) CachedCrmServiceDe 179Stage|null,strinalnulz9) CrmActivitvProviderint 181(C) CrmActivitvService nhi 187@ CrmConfiaurationSetti 183 Gt›oublic function matchßvPhone(strina Sphone. strina SrawPhoneNumber = nult, Jint Suserid = nulb: Darravs...(C) CrmOhiectcRecolver n 192arQube for IDE suggestions: Detect more security issues in your PHP files // Try SonarQube Cloud for free // Download SonarQube Server // Learn more // Don't ask again (today 10:25)hal7 & Lukas/Stefka 121 - in 1h 46 ml100% 12Thu 7 May 15:44:19AskJiminnyReportActivityServiceTest viii accounts [jiminny@localhost] X console [PROD)# console leu)& console [STAGING]CSV vmA8.v= custom.log= laravel.log« SF [jiminny@localhost]A HS_local [jiminny@localhost]1rowvGOut-gtTx: AutovY- WHERE id = 5190E- ORDER BYdo idOuuid (UUID)51004e3f2289-a3d2-5235-b410-b94ebb547490o team_1do crm contiquration 1d :o crm_provider_id1212213464I user_id430#owner id579583316nameUmbrella Corpphone[PHONE]extW industry1 domainUnbreLLacorp.col(• photo path/abae74b8-bfa8-4383-9a7f-89f4bf2bdb….country code<nUlluas internallШ deleted_at<nul1 created_at2026-03-30 06:44:25Iremotely_ created_at2019-02-01 15:39:53Iupdated_at2026-03-30 06:44:25W Windsurf Teams 171:6 UTF-8 P 4 spaces ®...
|
PhpStorm
|
faVsco.js – CachedCrmServiceDecorator.php
|
NULL
|
|
Search
matchByName (Service .../app/Services/Crm/C Search
matchByName (Service .../app/Services/Crm/Close), public method
matchByName (Service .../app/Services/Crm/Hubspot), public method
matchByName (MatchCrmEntitiesInterface .../app/Contracts/Services/Crm), public abstract method
matchByName (MatchProspectsTrait .../app/Services/Crm/IntegrationApp/ServiceTraits), public method
matchByName (Service .../app/Services/Crm/Salesforce), public method
matchByName (ServiceInterface .../app/Contracts/Services/Crm), public abstract method
matchByName (Service .../app/Services/Crm/Dummy), public method
matchByName (Service .../app/Services/Crm/Pipedrive), public method
matchByName (BullhornService .../app/Services/Crm/Bullhorn), public method
matchByName (Service .../app/Services/Crm/Copper), public method
Choose Declaration...
|
PhpStorm
|
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190...
|
PhpStorm
|
faVsco.js – Hubspot/Service.php
|
NULL
|
|
iTerm2ShellEditViewSessionScriptsProfilesWindowHel iTerm2ShellEditViewSessionScriptsProfilesWindowHelp$0(wbl# Lukas/Stefka 121 • in 1h 46 m100% [8DEV (docker)DOCKERDEV (docker)H82APP (-zsh)artisan-schedule:artisan-schedule_00:stoppedworker-es-update:worker-es-update_00: stoppedartisan-schedule:artisan-schedule_00: startedjiminny-worker-processing-1:jiminny-worker-processing-1_00: startedjiminny-worker-processing-2: jiminny-worker-processing-2_00: startedjiminny-worker-processing-3:jiminny-worker-processing-3_00: startedjiminny-worker-processing-4:jiminny-worker-processing-4_00: startedjiminny-worker-processing-5:jiminny-worker-processing-5_00: startedjiminny-worker-processing-delayed:jiminny-worker-processing-delayed_00:startedworker:worker_00: startedworker-analytics:worker-analytics_00:startedworker-audio:worker-audio_00: startedworker-calendar:worker-calendar_00:startedworker-conferences:worker-conferences_00: startedworker-crm-sync:worker-crm-sync_00:startedworker-crm-update:worker-crm-update_00: startedworker-download:worker-download_00: startedworker-emails:worker-emails_00:startedworker-es-update:worker-es-update_00: startedworker-nudges:worker-nudges_00: startedroot@docker_Lamp_1:/home/jiminny# php artisan jiminny: debugMatching contact 0root@docker_lamp_1:/home/jiminny# php artisan jiminny: debugMatching contact 0Matching contact 1Matchingcontact 2Matchingcontact 3Matching contact 4Matching contact 5Matching contact6Matching contact 7Matching contact 8Matching contact 9root@docker_lamp_1:/home/jiminny# php artisan jiminny:debugMatching contact 0Matching contact 1Matching contact 2Matching contact 3Matchingcontact 4Matchingcontact 5Matching contact 6Matching contact 7Matching contact 8Matching contact 9root@docker_lamp_1:/home/jiminny# ]-zsh• $4screenpipe*•$5-zshThu 7 May 15:44:23181₴6DEV...
|
PhpStorm
|
faVsco.js – Hubspot/Service.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV
Export Data…
Copy to Database…
Compare Data
View as
Show Options Menu
Sync Changes
Hide This Notification
Code changed:
Hide
8
51
1
33
1
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\Crm\Hubspot;
use Carbon\Carbon;
use Exception;
use Generator;
use GuzzleHttp\Exception\RequestException;
use Illuminate\Support\Facades\Cache;
use InvalidArgumentException;
use Jiminny\Contracts\Repositories\TeamRepository;
use Jiminny\Contracts\Services\Crm\ClientInterface;
use Jiminny\Contracts\Services\Crm\FetchRelatedActivityInterface;
use Jiminny\Contracts\Services\Crm\LayoutManagementInterface;
use Jiminny\Contracts\Services\Crm\MatchCrmEntitiesInterface;
use Jiminny\Contracts\Services\Crm\Provider\HubspotInterface;
use Jiminny\Contracts\Services\Crm\RemoteEntityLookupInterface;
use Jiminny\Contracts\Services\Crm\RemoteEntityManipulationInterface;
use Jiminny\Contracts\Services\Crm\SavePlaybackLinkToCrmInterface;
use Jiminny\Contracts\Services\Crm\SendSummaryToCrmInterface;
use Jiminny\Contracts\Services\Crm\SettingsInterface;
use Jiminny\Contracts\Services\Crm\SyncCrmEntitiesInterface;
use Jiminny\Contracts\Services\Crm\SyncCrmMetadataInterface;
use Jiminny\Contracts\Services\Crm\VerifyTaskExistsInterface;
use Jiminny\Exceptions\CrmException;
use Jiminny\Exceptions\HttpNotFoundException;
use Jiminny\Jobs\Crm\NoteObject;
use Jiminny\Models\Account;
use Jiminny\Models\Activity;
use Jiminny\Models\Contact;
use Jiminny\Models\Contracts\ActivityContract;
use Jiminny\Models\Crm\BusinessProcess;
use Jiminny\Models\Crm\Field;
use Jiminny\Models\Crm\FieldData;
use Jiminny\Models\Crm\Layout;
use Jiminny\Models\Crm\Profile;
use Jiminny\Models\Lead;
use Jiminny\Models\Opportunity;
use Jiminny\Models\Participant;
use Jiminny\Models\Playbook;
use Jiminny\Models\SocialAccount;
use Jiminny\Models\Stage;
use Jiminny\Models\User;
use Jiminny\Repositories\Crm\CrmEntityRepository;
use Jiminny\Repositories\Crm\FieldRepository;
use Jiminny\Repositories\Crm\ProfileRepository;
use Jiminny\Repositories\ParticipantRepository;
use Jiminny\Services\Avatar\ProspectPhotoPathService;
use Jiminny\Services\Crm\BaseService;
use Jiminny\Services\Crm\Hubspot\Actions\SyncArchivedProfilesAction;
use Jiminny\Services\Crm\Hubspot\Fields\ValueNormalizer;
use Jiminny\Services\Crm\Hubspot\ServiceTraits\OpportunitySyncTrait;
use Jiminny\Services\Crm\Hubspot\ServiceTraits\SyncCrmEntitiesTrait;
use Jiminny\Services\Crm\Hubspot\ServiceTraits\SyncFieldsTrait;
use Jiminny\Services\Crm\Hubspot\ServiceTraits\WriteCrmTrait;
use Jiminny\Services\Crm\MatchDomainByEmailInterface;
use Jiminny\Services\Crm\OpportunitySyncStrategyResolver;
use Jiminny\Services\Crm\ResolveCompanyNameByEmailTrait;
use Jiminny\Utils\PlaybackUrlBuilder;
use Sentry;
use SevenShores\Hubspot\Exceptions\BadRequest;
use Throwable;
use UnexpectedValueException;
/**
* @phpstan-type CrmFieldDefinition array{
* name: string,
* label: string,
* description: string,
* type: string,
* fieldType: string,
* hidden: bool,
* showCurrencySymbol: bool,
* options: array<array{
* id: string,
* label: string,
* value?: string,
* }
*/
class Service extends BaseService implements
HubspotInterface,
SyncCrmEntitiesInterface,
SyncCrmMetadataInterface,
SendSummaryToCrmInterface,
MatchDomainByEmailInterface,
SavePlaybackLinkToCrmInterface,
RemoteEntityManipulationInterface,
FetchRelatedActivityInterface,
LayoutManagementInterface,
SettingsInterface,
MatchCrmEntitiesInterface,
RemoteEntityLookupInterface,
VerifyTaskExistsInterface
{
use ResolveCompanyNameByEmailTrait;
use SyncCrmEntitiesTrait;
use WriteCrmTrait;
use SyncFieldsTrait;
use OpportunitySyncTrait;
private const int ENGAGEMENT_BODY_MAX_LENGTH = 65536;
private const string LOG_DATE_FORMAT = 'Y-m-d H:i:s';
private const int BATCH_UPDATE_LIMIT = 100;
private const string TEN_SECONDLY_ROLLING_POLICY = 'TEN_SECONDLY_ROLLING';
private const int TEN_SECONDLY_ROLLING_LIMIT = 10;
private const string CALLS_SEARCH_ENDPOINT = '[URL_WITH_CREDENTIALS] ClientInterface|Client
*/
protected $client;
protected OpportunitySyncStrategyResolver $opportunitySyncStrategyResolver;
protected CrmEntityRepository $crmEntityRepository;
protected ProspectPhotoPathService $prospectPhotoPathService;
private SyncFieldAction $syncFieldAction;
private PayloadBuilder $payloadBuilder;
private SyncRelatedActivityManager $syncRelatedActivityManager;
private SyncArchivedProfilesAction $syncArchivedProfilesAction;
private WebhookSyncBatchProcessor $batchProcessor;
public function __construct(
Client $client,
SyncFieldAction $syncFieldAction,
PayloadBuilder $payloadBuilder,
ProspectPhotoPathService $prospectPhotoPathService,
SyncArchivedProfilesAction $syncArchivedProfilesAction,
WebhookSyncBatchProcessor $batchProcessor,
) {
parent::__construct();
$this->client = $client;
$this->syncFieldAction = $syncFieldAction;
$this->prospectPhotoPathService = $prospectPhotoPathService;
$this->payloadBuilder = $payloadBuilder;
$this->syncArchivedProfilesAction = $syncArchivedProfilesAction;
$this->batchProcessor = $batchProcessor;
$this->opportunitySyncStrategyResolver = app(OpportunitySyncStrategyResolver::class, [
'client' => $this->client,
]);
$this->syncRelatedActivityManager = app(SyncRelatedActivityManager::class, [
'client' => $this->client,
'payloadBuilder' => $this->payloadBuilder,
'logger' => $this->logger,
]);
$this->crmEntityRepository = app(CrmEntityRepository::class);
$this->dealFieldsService = app(DealFieldsService::class);
}
public function getDisplayName(): string
{
return 'HubSpot';
}
protected function getOAuthAccount(User $user): ?SocialAccount
{
// In this case, the Account Owner is always the connection for any API operations.
$owner = $user->team->owner;
return $owner->getSocialAccount(SocialAccount::PROVIDER_HUBSPOT);
}
public function getClient(): Client
{
/** @var Client */
return $this->client;
}
/**
* Convert raw field data into a format compatible with CRM APIs.
*
* @param bool $internal Direction of the conversion.
* True is pulling from CRM, false normalize before sending to CRM.
*/
public function normalizeValue(string $fieldType, string $fieldValue, bool $internal = false): string
{
return ValueNormalizer::normalize(
fieldType: $fieldType,
fieldValue: $fieldValue,
isInbound: $internal,
);
}
/**
* @inheritdoc
*/
public function getDefaultFields(string $activityType): array
{
$fields = [];
if ($activityType === Playbook::ACTIVITY_TYPE_TASK) {
$defaultFields = FieldDefinitions::defaultTaskFields();
// This lazy creates these fields if not already setup.
foreach ($defaultFields as $defaultField) {
$fields[] = $this->config->fields()->firstOrCreate($defaultField);
}
}
return $fields;
}
/**
* @inheritdoc
*/
public function getDefaultActivityField(string $activityType): Field
{
/** @var Field $activityField */
$activityField = $this->config->fields()->where([
'crm_provider_id' => 'activityType',
'object_type' => $activityType,
])->first();
return $activityField;
}
/**
* @inheritdoc
*/
public function getSupportedPlaybookTypes(): array
{
return [Playbook::ACTIVITY_TYPE_TASK];
}
/**
* @inheritdoc
*/
public function getDefaultActivityLayoutFields(string $activityType, string $layoutType): array
{
$fields = [];
if ($activityType === Playbook::ACTIVITY_TYPE_TASK) {
// Outcome should always be provided calls/meetings.
$fieldData = [
[
'crm_provider_id' => $layoutType === Layout::TYPE_SOFTPHONE_SUMMARY ? 'disposition' : 'meetingOutcome',
'object_type' => Field::OBJECT_TASK,
],
];
foreach ($fieldData as $data) {
$field = $this->config->fields()->where($data)->first();
// Only add the field if it is created, which it should be.
if ($field) {
$fields[] = $field;
}
}
}
return $fields;
}
public function getDealInsightsFields(): array
{
return FieldDefinitions::dealInsightsFields();
}
protected function getDefaultFollowupLayoutFields(string $activityType): array
{
$fields = [];
$fieldRepo = app(FieldRepository::class);
$fieldData = FieldDefinitions::followupFieldsFilter();
foreach ($fieldData as $data) {
$field = $fieldRepo->findOneConfigurationFieldByProperties($this->config, $data);
// Only add the field if it is created, which it should be.
if ($field) {
$fields[] = $field;
}
}
return $fields;
}
/**
* @inheritdoc
*/
public function syncField(Field $field): void
{
switch ($field->object_type) {
case Field::OBJECT_ACCOUNT:
$crmField = $this->client->getInstance()->companyProperties()->get($field->crm_provider_id);
break;
case Field::OBJECT_CONTACT:
$crmField = $this->client->getInstance()->contactProperties()->get($field->crm_provider_id);
break;
case Field::OBJECT_OPPORTUNITY:
$crmField = $this->client->getInstance()->dealProperties()->get($field->crm_provider_id);
break;
case Field::OBJECT_TASK:
$this->syncSingleTaskField($field);
return;
default:
return;
}
$this->syncFieldAction->execute($field, $crmField->toArray());
}
/**
* @param array<array{
* id:string,
* label:string,
* value?:string
* }> $options
*
* @throws CrmException
*
* @return FieldData[]
*
*/
public function importPicklistValues(
Field $field,
array $options = [['id' => '', 'label' => '', 'value' => '']],
): array {
if (! empty($options[0]['id']) || ! empty($options[0]['value'])) {
// We already have the options, no need to fetch them again
return $this->importOptions($field, $options);
}
$options = [];
switch ($field->getObjectType()) {
case Field::OBJECT_ACCOUNT:
$options = $this->getClient()->fetchPropertyOptions('company', $field->getCrmProviderId());
break;
case Field::OBJECT_CONTACT:
$options = $this->getClient()->fetchPropertyOptions('contact', $field->getCrmProviderId());
break;
case Field::OBJECT_OPPORTUNITY:
// Hubspot has different endpoint for stages
$options = $this->getClient()->fetchOpportunityFieldOptions($field);
break;
case Field::OBJECT_TASK:
if ($field->getCrmProviderId() === 'disposition') {
$options = $this->getClient()->fetchDispositionFieldOptions();
} elseif (in_array($field->getCrmProviderId(), ['meetingOutcome', 'activityType'])) {
$options = $this->getClient()->fetchMeetingOutcomeFieldOptions($field);
}
break;
default:
$this->logger->warning('Invalid object type', [
'object_type' => $field->getObjectType(),
'field_id' => $field->getId(),
]);
throw new CrmException('Invalid object type');
}
return $this->importOptions($field, $options);
}
/**
* @inheritdoc
*/
public function importStages(?array $types = null, ?string $missingStageName = null): ?Stage
{
$missingStage = null;
try {
// Use the HubSpot API client instead of the SDK crmPipelines() method
$endpoint = self::getDealsPipelinesEndpoint();
$pipelinesResponse = $this->client->getInstance()->getClient()->request('GET', $endpoint);
$pipelines = $pipelinesResponse->data->results;
} catch (RequestException|BadRequest $exception) {
throw $exception;
}
foreach ($pipelines as $pipeline) {
$stages = [];
// We create a business process to contain the pipeline, and store all stages against it.
$p = ResponseNormalize::normalizePipeline($pipeline);
// Create/update business process for this pipeline
$businessProcess = $this->config->businessProcesses()->updateOrCreate([
'crm_provider_id' => $p['id'],
], [
'team_id' => $this->team->id,
'name' => mb_strimwidth($p['label'], 0, 150),
'type' => BusinessProcess::TYPE_OPPORTUNITY,
'is_selectable' => $p['active'],
]);
// A record type is really a clone of the business process, used to store which record uses which pipeline.
// Create/update record type clone
$this->config->recordTypes()->updateOrCreate([
'crm_provider_id' => $p['id'],
], [
'team_id' => $this->team->id,
'name' => mb_strimwidth($p['label'], 0, 150),
'is_selectable' => $p['active'],
'business_process_id' => $businessProcess->id ?? null,
]);
// Stages - fetch all existing stages upfront to avoid N+1 queries
$existingStages = $this->config->stages()
->withTrashed()
->where('type', Stage::TYPE_OPPORTUNITY)
->get()
->keyBy('crm_provider_id');
foreach ($p['stages'] as $dealStage) {
$s = ResponseNormalize::normalizeDealStage($dealStage);
/** @var ?Stage $existingStage */
$existingStage = $existingStages->get($s['id']);
// Restore soft-deleted stages that are now active in HubSpot
if ($existingStage?->trashed() && $s['active']) {
$existingStage->restore();
}
// Upsert stage (updates soft-deleted records without restoring them)
$stage = $this->config->stages()->withTrashed()->updateOrCreate([
'crm_provider_id' => $s['id'],
], [
'team_id' => $this->team->id,
'name' => mb_strimwidth($s['label'], 0, 50),
'label' => mb_strimwidth($s['label'], 0, 191),
'type' => Stage::TYPE_OPPORTUNITY,
'sequence' => $s['displayOrder'],
'is_selectable' => $s['active'],
'probability' => $s['probability'] * 100,
]);
if ($missingStageName === $s['id']) {
$missingStage = $stage;
}
$stages[] = $stage->id;
}
$businessProcess->stages()->sync($stages);
}
return $missingStage;
}
/**
* @inheritdoc
*/
public function syncOrganization(): void
{
try {
$endpoint = '[URL_WITH_CREDENTIALS]
*/
public function find(string $name, array $scopes): array
{
$count = $this->limit ?? 20;
$offset = $this->offset ?? 0;
/** @var array<int, array<string, mixed>> */
return Cache::remember(
key: $this->team->getId() . $name . $count . $offset,
ttl: 300,
callback: function () use ($name, $offset, $count): array {
$data = [];
// Use the new V3 API to find contacts based on additional fields.
foreach (['companies', 'contacts'] as $objectType) {
$endpoint = '[URL_WITH_CREDENTIALS]
*/
public function findOpportunities(?string $crmAccountId, ?string $crmContactId, ?int $userId = null): array
{
$data = [];
$ownerData = [];
$ownerId = null;
if ($crmAccountId === null) {
return $data;
}
if ($userId) {
$profileRepository = app(ProfileRepository::class);
$profile = $profileRepository->findProfileByUserId($this->config, $userId);
$ownerId = $profile instanceof Profile ? $profile->getCrmProviderId() : null;
}
$closedStages = $this->getClosedDealStages();
$payload = $this->payloadBuilder->generateOpportunitiesSearchPayload(
$this->config,
$crmAccountId,
$closedStages,
);
$results = $this->client->getPaginatedData($payload, 'deals');
foreach ($results['results'] as $object) {
$properties = $object['properties'];
$amount = null;
if (empty($properties['amount']) === false) {
$currency = $properties['deal_currency_code'] ?? $this->config->default_currency;
// Values can contain commas and any junk so strip them.
$value = (float) preg_replace('/[^\d.]/', '', $properties['amount']);
$amount = formatCurrency($value, $currency);
}
$businessProcess = $this->config
->businessProcesses()
->where('crm_provider_id', $properties['pipeline'])
->first();
if ($businessProcess === null) {
// Import it.
$stage = $this->importStages([Stage::TYPE_OPPORTUNITY], $properties['dealstage']);
$businessProcess = $this->config
->businessProcesses()
->where('crm_provider_id', $properties['pipeline'])
->first();
} else {
$stage = $businessProcess
->stages()
->where('crm_provider_id', $properties['dealstage'])
->where('type', Stage::TYPE_OPPORTUNITY)
->first();
if ($stage === null) {
// Import it.
$stage = $this->importStages(null, $properties['dealstage']);
}
}
$recordType = null;
if ($businessProcess) {
$recordType = $businessProcess->recordTypes()->first();
}
$isWon = in_array($properties['dealstage'], $closedStages['won']);
$isLost = in_array($properties['dealstage'], $closedStages['lost']);
$record = [
'crmId' => $object['id'],
'name' => $properties['dealname'] ?? 'Unknown Deal',
'value' => $amount,
'won' => $isWon,
'closed' => $isWon || $isLost,
'stage' => [
'id' => $stage?->getUuid() ?? '',
'name' => $stage?->getName() ?? '',
],
];
if ($recordType) {
$record += [
'recordType' => [
'id' => $recordType->id_string,
'name' => $recordType->name,
],
];
}
if ($ownerId && isset($properties['hubspot_owner_id']) && $properties['hubspot_owner_id'] === $ownerId) {
$ownerData[] = $record;
}
$data[] = $record;
}
if (! empty($ownerData)) {
return $ownerData;
}
return $data;
}
/**
* @inheritdoc
*/
public function getTasks(?string $objectType, string $objectId, ?string $opportunityId): array
{
$data = [];
switch ($objectType) {
case 'contact':
$hsObject = 'contact';
break;
case 'account':
$hsObject = 'company';
break;
default:
// This is a hack to prioritise and override a contact/company with a deal.
if ($opportunityId) {
$hsObject = 'deal';
$objectId = $opportunityId;
} else {
throw new InvalidArgumentException('Object type not supported.');
}
}
$engagementTypes = ['meetings', 'tasks'];
foreach ($engagementTypes as $engagementType) {
$payload = $this->payloadBuilder->getLinkToTaskPayload($hsObject, $objectId, $engagementType);
$this->logger->info('[HubSpot] CRM Search requested', [
'request' => $payload,
]);
$engagements = $this->client->getPaginatedData($payload, $engagementType);
foreach ($engagements['results'] as $engagement) {
if ($engagementType == 'meetings') {
$title = $engagement['properties']['hs_meeting_title'] ?? 'Scheduled meeting';
} elseif ($engagementType == 'tasks') {
$title = $engagement['properties']['hs_task_subject'];
} else {
$title = 'Scheduled meeting';
}
$data[] = [
'crmId' => $engagement['id'],
'subject' => $title,
'due' => $engagement['properties']['hs_timestamp'],
'type' => $engagement['properties']['hs_activity_type'] ?? null,
];
}
}
usort($data, function ($item1, $item2) {
return $item2['due'] <=> $item1['due'];
});
return $data;
}
/**
* Try to find CRM Objects using email address
*
* @return null|array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
* }
*/
public function matchExactlyByEmail(string $email, ?int $userId = null): ?array
{
$contactProperties = [
'email',
// 'firstname',
// 'lastname',
// 'country',
// 'phone',
// 'mobilephone',
// 'jobtitle',
// 'hubspot_owner_id',
// 'associatedcompanyid',
// 'photo',
];
$contact = null;
$account = null;
try {
$hsContact = $this->getClient()->getContactByEmail($email, $contactProperties);
return null;
if ($hsContact) {
$contact = $this->importContact($hsContact);
$account = $contact->account;
}
$data = $this->convertCrmData($contact, $account, $userId);
return ! empty(array_filter($data)) ? $data : null;
} catch (BadRequest $e) {
$this->logger->warning('[HubSpot] Search failed', [
'team_id' => $this->team->getId(),
'search_identifier' => $email,
'reason' => $e->getMessage(),
]);
}
return null;
}
public function getDomain(string $email): ?string
{
return $this->getDomainFromEmail($email);
}
/**
* Try to find CRM objects using domain name of the email address
*
* @return null|array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
* }
*/
public function matchByDomain(string $domain, ?int $userId = null): ?array
{
$companyName = $domain;
// Try to find a company matching their email domain.
$companyProperties = [
'country',
'phone',
'name',
'hs_avatar_filemanager_key',
'industry',
'hubspot_owner_id',
'domain',
];
try {
$hsAccounts = $this->client
->getInstance()
->companies()
->searchByDomain($companyName, $companyProperties);
} catch (Throwable $e) {
$this->logger->info('[HubSpot] Search failed', [
'error' => $e->getMessage(),
'domain' => $domain,
]);
return null;
}
$account = null;
// If there are multiple accounts, don't guess, we'll ask later.
if (\count($hsAccounts->data->results) === 1) {
// Persist this remote object.
$account = $this->syncAccount($hsAccounts->data->results[0]->companyId);
}
$data = $this->convertCrmData(null, $account, $userId);
return ! empty(array_filter($data)) ? $data : null;
}
/**
* @return array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
* }
*/
protected function convertCrmData(?Contact $contact, ?Account $account, ?int $userId = null): array
{
$countryCode = null;
if ($contact && $contact->country_code) {
$countryCode = $contact->country_code;
} elseif ($account && $account->country_code) {
$countryCode = $account->country_code;
}
try {
$hsOpportunities = $this->findOpportunities(
$account ? $account->crm_provider_id : null,
$contact ? $contact->crm_provider_id : null,
$userId
);
} catch (Exception $e) {
$hsOpportunities = [];
}
// If there are multiple opportunities, don't guess, we'll ask later.
$opportunity = null;
$stage = null;
if (! empty($hsOpportunities)) {
// Persist this remote object.
$opportunity = $this->syncOpportunity($hsOpportunities[0]['crmId']);
$stage = $opportunity?->getStage();
}
return [
null,
$account,
$opportunity,
$contact,
$stage,
$countryCode,
];
}
protected function getCacheKey(string $object, ?int $userId = null): ?string
{
$key = $this->team->getId() . $object;
$keySuffix = $this->getOwnerKeySuffix($userId);
return $key . $keySuffix;
}
private function getOwnerKeySuffix(?int $userId = null): string
{
return $userId === null ? '' : (string) $userId;
}
/**
* @return null|array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
*}
*/
public function matchByPhone(string $phone, ?string $rawPhoneNumber = null, ?int $userId = null): ?array
{
if (str_contains($phone, '**')) {
return null;
}
// trim all whitespaces if present so the lookup doesn't fail
$phone = str_replace(' ', '', $phone);
// Check if the user is internal.
if ($this->isPhoneNumberOfTeamMember($phone)) {
return null;
}
$response = $this->searchForPhoneNumber($phone);
if (empty($response)) {
return null;
}
// This would ideally importContact instead but the response type differs.
$contact = $this->findAndSyncContact($response['results'][0]['id']);
if (! $contact instanceof Contact) {
return null;
}
$account = $contact->account;
$countryCode = $contact->country_code ?? $account->country_code ?? null;
try {
$hsOpportunities = $this->findOpportunities(
$account?->crm_provider_id,
$contact->crm_provider_id,
$userId
);
} catch (Exception $e) {
$hsOpportunities = [];
}
$opportunity = null;
$stage = null;
try {
if (! empty($hsOpportunities)) {
// Persist this remote object.
$opportunity = $this->syncOpportunity($hsOpportunities[0]['crmId']);
$stage = $opportunity?->getStage();
}
} catch (Exception $e) {
$this->logger->debug('[HubSpot] Opportunity failed to sync.', [
'reason' => $e->getMessage(),
]);
}
return [
null,
$account,
$opportunity,
$contact,
$stage,
$countryCode,
];
}
private function isPhoneNumberOfTeamMember(string $phone): bool
{
$teamRepository = app(TeamRepository::class);
$user = $teamRepository->findTeamMemberByPhone($this->team, $phone);
if ($user instanceof User) {
return true;
}
return false;
}
private function findAndSyncContact(string $crmId): ?Contact
{
try {
return $this->syncContact($crmId);
} catch (Exception $exception) {
$this->logger->info('[HubSpot] Phone match failed', [
'reason' => $exception->getMessage(),
]);
return null;
}
}
private function hasResults(array $response): bool
{
return isset($response['total']) && is_numeric($response['total']) && $response['total'] > 0;
}
private function searchForPhoneNumber(string $phone): array
{
// Normalizes the provided phone number for the API search.
$normalizedPhone = $this->normalizePhoneNumber($phone);
$payload = $this->payloadBuilder->generatePhoneSearchPayload($normalizedPhone);
$this->logger->info('[HubSpot] Phone match search triggered', [
'phone' => $phone,
'normalizedPhone' => $normalizedPhone,
'payload' => $payload,
]);
$response = $this->handlePhoneSearchRequest($normalizedPhone, $payload);
if (! $this->hasResults($response)) {
$nationalPhone = preg_replace('/\D/', '', phone_national(null, $phone));
$payload = $this->payloadBuilder->generatePhoneSearchPayload($nationalPhone);
$this->logger->info('[HubSpot] Phone match national number search triggered', [
'phone' => $phone,
'nationalPhone' => $nationalPhone,
'payload' => $payload,
]);
$response = $this->handlePhoneSearchRequest($phone, $payload);
}
if (! $this->hasResults($response)) {
$payload = $this->payloadBuilder->generatePhoneSearchPayload($normalizedPhone, true);
$this->logger->info('[HubSpot] Phone match alternative search triggered', [
'phone' => $phone,
'normalizedPhone' => $normalizedPhone,
'payload' => $payload,
]);
$response = $this->handlePhoneSearchRequest($phone, $payload);
}
return $this->hasResults($response) ? $response : [];
}
private function handlePhoneSearchRequest(string $phone, array $payload): array
{
$endpoint = '[URL_WITH_CREDENTIALS] null|array{
* Lead|null,
* Account|null,
* Opportunity|null,
* Contact|null,
* Stage|null,
* string|null
* }
*/
public function matchByName(string $name, ?int $userId = null): ?array
{
// Don't waste time searching for single character strings.
if (\strlen($name) <= 1) {
return null;
}
$cacheKey = $this->getCacheKey($name, $userId);
$result = Cache::remember($cacheKey, 60, function () use ($name, $userId) {
$payload = $this->payloadBuilder->generateSearchContactsByNamePayload(
$name,
$this->getContactFields()
);
$hsContacts = $this->client->getPaginatedData($payload, 'contact');
if (empty($hsContacts['results'])) {
return false;
}
$contact = $this->importContact($hsContacts['results'][0]);
if ($contact === null) {
return false;
}
$account = $contact->account;
$countryCode = $contact->country_code ?? $account->country_code ?? null;
try {
$hsOpportunities = $this->findOpportunities(
$account ? $account->crm_provider_id : null,
$contact->crm_provider_id,
$userId
);
} catch (Exception $e) {
$hsOpportunities = [];
}
$opportunity = null;
$stage = null;
if (! empty($hsOpportunities)) {
// Persist this remote object.
$opportunity = $this->syncOpportunity($hsOpportunities[0]['crmId']);
$stage = $opportunity?->getStage();
}
return [
null,
$account,
$opportunity,
$contact,
$stage,
$countryCode,
];
});
return is_array($result) ? $result : null;
}
private function convertActivityAssociations(Activity $activity): array
{
return [
'contactIds' => $this->getParticipantsIds($activity),
'companyIds' => $activity->hasAccount() ? [$activity->account->crm_provider_id] : [],
'dealIds' => $activity->hasOpportunity() ? [$activity->opportunity->crm_provider_id] : [],
'ownerIds' => [],
];
}
private function getParticipantsIds(Activity $activity): array
{
$attendees = [];
$participantRepository = app(ParticipantRepository::class);
$participants = $participantRepository->getParticipantsWhoEnteredMeeting($activity);
foreach ($participants as $participant) {
if ($participant->user_id || $participant->isCoach()) {
continue;
}
$contact = $participant->contact()->first();
if ($contact && $contact->crm_provider_id) {
$attendees[] = $contact->crm_provider_id;
} else {
if (! empty($participant->name)) {
$attendeeData = $this->fetchMissingAttendeeInfo($participant);
}
if (! empty($attendeeData['id'])) {
$attendees[] = $attendeeData['id'];
}
}
}
if ($activity->hasContact()) {
$attendees[] = $activity->contact->crm_provider_id;
}
return array_unique($attendees);
}
private function fetchMissingAttendeeInfo(Participant $participant): array
{
// Check if we need to look inside an account context.
$activity = $participant->getActivity();
$companyId = $activity->hasAccount() ? $activity->getAccount()->crm_provider_id : null;
// First check the local data.
/** @var Contact[] $contacts */
$contacts = $this->team->contacts()
->with('account')
->where('name', $participant->name)
->whereNotNull('email')
->get();
foreach ($contacts as $contact) {
// If we have a company in scope, check the contact is associated to it.
if (
$companyId !== null
&& ($contact->account_id === null || $companyId !== $contact->account->crm_provider_id)
) {
continue;
}
return [
'id' => $contact->crm_provider_id,
'email' => $contact->email,
];
}
$payload = $this->generateNameSearchPayload($participant->name, 0, 20);
try {
$response = $this->client->getNewInstance()->crm()->contacts()->searchApi()->doSearch($payload);
// TODO add some logic to choose the most suitable contact if multiple
foreach ($response['results'] as $object) {
$properties = $object['properties'];
if (empty($object['properties']) === false) {
// Check the company matches the contact.
// Todo: Move this check inside the API search.
if ($companyId !== null && $companyId !== $properties['associatedcompanyid']) {
continue;
}
return [
'id' => $object['id'],
'email' => $properties['email'],
];
}
}
} catch (Exception $e) {
$this->logger->warning('[' . $this->getDisplayName() . '] Search failed', [
'teamId' => $this->team->id_string,
'request' => $payload,
'reason' => $e->getMessage(),
]);
}
return [];
}
/**
* Store transcripts as note engagement.
*
* @throws Exception
*/
public function createTranscriptNotes(Activity $activity): void
{
// For HS no need to check if Crm profile - Log Notes field is enabled
// We only check if store_transcript toggle is enabled on crm profile.
$engagement = [
'active' => true,
'ownerId' => $this->profile->crm_provider_id,
'timestamp' => $activity->created_at->tz($activity->user->timezone)->getTimestamp() * 1000,
'type' => 'NOTE',
];
// Generate activity transcription.
$transcriptionData = $this->generateTranscription($activity);
// Truncate Notes with max notes length because transcription text could be very long.
$transcripts = mb_strimwidth($transcriptionData, 0, static::ENGAGEMENT_BODY_MAX_LENGTH);
$metadata = [
'body' => $transcripts,
];
$associations = $this->convertActivityAssociations($activity);
try {
$hsEngagement = $this->client
->getInstance()
->engagements()
->create($engagement, $associations, $metadata);
$this->logCrmEngagementManipulation(self::ACTION_CREATE, $engagement, $metadata, $associations);
$noteId = $hsEngagement->data->engagement->id;
// Store crm logged id in transcription.
$transcription = $activity->getTranscription();
$transcription->crm_activity_id = $noteId;
$transcription->save();
} catch (Exception $e) {
Sentry::captureException($e);
}
}
/*
* @inheritdoc
*/
public function updateRecord(string $objectType, string $objectId, array $data, array $headers = []): void
{
$payload = [
'properties' => $data,
];
try {
switch ($objectType) {
case FieldData::OBJECT_OPPORTUNITY:
$this->client->getNewInstance()->crm()->deals()->basicApi()->update($objectId, $payload);
break;
case FieldData::OBJECT_CONTACT:
$this->client->getNewInstance()->crm()->contacts()->basicApi()->update($objectId, $payload);
break;
case FieldData::OBJECT_ACCOUNT:
$this->client->getNewInstance()->crm()->companies()->basicApi()->update($objectId, $payload);
break;
case FieldData::OBJECT_TASK:
// Endpoint for Engagements not ready
$engagements = [
'type' => 'TASK',
];
$metadata = $data;
$this->client->getInstance()->en...
|
PhpStorm
|
faVsco.js – Hubspot/Service.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
2019-02-01 15:39:53
2019-02-01 15:39:53
Umbrella Corp
2026-03-30 06:44:25
2026-03-30 06:44:25
Umbrella Corp
id = 5190
Editor
1 row
Reload Page
Table Result Auto Refresh
Cancel Running Statements
Add Row
Delete Row
Revert Selected
Preview Pending Changes
Submit
Tx: Auto
DDL
Find on Current Page
Table Result Local Filter
Record View
Table Coloring Options
Show Geo Viewer
Show Chart
CSV
Export Data…
Copy to Database…
Compare Data
View as
Show Options Menu
Sync Changes...
|
PhpStorm
|
faVsco.js – Hubspot/Service.php
|
NULL
|
|
Project: faVsco.js, menu
master, menu
Start Listen Project: faVsco.js, menu
master, menu
Start Listening for PHP Debug Connections
AskJiminnyReportActivityServiceTest
Run 'AskJiminnyReportActivityServiceTest'
Debug 'AskJiminnyReportActivityServiceTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
A
1
Select All
5190
5190
0
4e3f2289-a3d2-5235-b410-b94ebb547490
4e3f2289-a3d2-5235-b410-b94ebb547490
Umbrella Corp
2
2
0
2
2
0
1212213464
1212213464
Umbrella Corp
430
430
0
579583316
579583316
Umbrella Corp
Umbrella Corp
Umbrella Corp
Umbrella Corp
[PHONE]
[PHONE]
Umbrella Corp
<null>
<null>
Umbrella Corp
<null>
<null>
Umbrella Corp
umbrellacorp.com
umbrellacorp.com
Umbrella Corp
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
/abae74b8-bfa8-4383-9a7f-89f4bf2bdbb4/avatars/1212213464.png
Umbrella Corp
<null>
<null>
Umbrella Corp
0
0
0
<null>
<null>
Umbrella Corp...
|
PhpStorm
|
faVsco.js – Hubspot/Service.php
|
NULL
|