|
Project: faVsco.js, menu
JY-20738-debug-AJ-trackin Project: faVsco.js, menu
JY-20738-debug-AJ-tracking-UP, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$automatedReport->shouldReceive('getUuid')->andReturn('automated-report-uuid');
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$automatedReport->shouldReceive('getUuid')->andReturn('automated-report-uuid');
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77586
|
|
Project: faVsco.js, menu
JY-20738-debug-AJ-trackin Project: faVsco.js, menu
JY-20738-debug-AJ-tracking-UP, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$automatedReport->shouldReceive('getUuid')->andReturn('automated-report-uuid');
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$automatedReport->shouldReceive('getUuid')->andReturn('automated-report-uuid');
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77587
|
|
Project: faVsco.js, menu
JY-20738-debug-AJ-trackin Project: faVsco.js, menu
JY-20738-debug-AJ-tracking-UP, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$automatedReport->shouldReceive('getUuid')->andReturn('automated-report-uuid');
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$automatedReport->shouldReceive('getUuid')->andReturn('automated-report-uuid');
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77588
|
|
Project: faVsco.js, menu
JY-20738-debug-AJ-trackin Project: faVsco.js, menu
JY-20738-debug-AJ-tracking-UP, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$automatedReport->shouldReceive('getUuid')->andReturn('automated-report-uuid');
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$automatedReport->shouldReceive('getUuid')->andReturn('automated-report-uuid');
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77589
|
|
Project: faVsco.js, menu
JY-20738-debug-AJ-trackin Project: faVsco.js, menu
JY-20738-debug-AJ-tracking-UP, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$automatedReport->shouldReceive('getUuid')->andReturn('automated-report-uuid');
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$automatedReport->shouldReceive('getUuid')->andReturn('automated-report-uuid');
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77590
|
|
Last login: Thu Apr 23 14:01:28 on ttys007
Poetry Last login: Thu Apr 23 14:01:28 on ttys007
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20157-AJ-report-not-send-notification
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git pull
remote: Enumerating objects: 1015, done.
remote: Counting objects: 100% (262/262), done.
remote: Compressing objects: 100% (143/143), done.
remote: Total 1015 (delta 167), reused 129 (delta 119), pack-reused 753 (from 3)
Receiving objects: 100% (1015/1015), 851.14 KiB | 2.09 MiB/s, done.
Resolving deltas: 100% (613/613), completed with 65 local objects.
From github.com:jiminny/app
c3c8d86b22..68bb20c72a JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
3ac71c265a..595c95b7e0 JY-19995-delete-leftover-tracks-command -> origin/JY-19995-delete-leftover-tracks-command
* [new branch] JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null -> origin/JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null
* [new branch] JY-20478-stop-sync-calendar-emails -> origin/JY-20478-stop-sync-calendar-emails
d4d05c775b..b11048beed JY-20541-cleanup-stale-tasks-and-events -> origin/JY-20541-cleanup-stale-tasks-and-events
10d290c778..a250abe939 JY-20663-partner-rockeed -> origin/JY-20663-partner-rockeed
* [new branch] JY-20713-activity-sync-job-restart -> origin/JY-20713-activity-sync-job-restart
242cf1b554..96a22e59f2 JY-9712-change-forever-nudges-to-1-year-expiration -> origin/JY-9712-change-forever-nudges-to-1-year-expiration
* [new branch] fix-close-missing-logger-error -> origin/fix-close-missing-logger-error
0dd5b23990..60fa1787c1 master -> origin/master
f044edca5b..e7e0e50b27 secfix/npm-20260416 -> origin/secfix/npm-20260416
* [new branch] secfix/npm-20260423 -> origin/secfix/npm-20260423
Updating c3c8d86b22..68bb20c72a
Fast-forward
Makefile | 5 +
app/Component/Activity/Services/UpdateActivityService.php | 5 +
app/Component/ActivitySearch/FilterDefinition/ActivityUpdatedDate.php | 7 +-
app/Component/ActivitySearch/Service/ActivitySearch.php | 15 ++
app/Component/AiCallScoring/Services/GenerateAiCallScoringService.php | 6 +
app/Component/AiCallScoring/Services/GetAiCallScoringService.php | 5 +-
app/Component/AiCallScoring/Transformers/AiCallScoringTransformer.php | 2 +-
app/Component/ProphetAi/ProphetClient.php | 5 +
app/Console/Commands/Crm/SyncHubspotObjects.php | 84 +++++++++++
app/Console/Commands/Crm/SyncObjects.php | 82 ++++++-----
app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php | 81 +++++++++++
app/Console/Commands/Reports/AutomatedReportsCommand.php | 91 +++++++++++-
app/Console/Commands/Reports/AutomatedReportsSendCommand.php | 40 +++++-
app/Console/Kernel.php | 4 +
app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php | 15 ++
app/Contracts/Services/Crm/Provider/SalesforceInterface.php | 12 +-
app/Contracts/Services/Crm/ServiceInterface.php | 29 ----
app/Contracts/Services/Crm/SyncCrmMetadataInterface.php | 6 +-
app/Events/AutomatedReports/AutomatedReportGenerated.php | 15 ++
app/Http/Controllers/API/CrmController.php | 19 ++-
app/Http/Controllers/API/UserAutomatedReports/UserAutomatedReportsController.php | 33 ++++-
app/Http/Controllers/Internal/WebhookReceiver/HubspotController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/EventsController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTrait.php | 64 ++++++---
app/Http/Controllers/Webhook/ReportController.php | 5 +
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRuleRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/TestAiCallScoringPromptRequest.php | 2 +-
app/Jobs/Activity/SyncActivity.php | 3 +-
app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php | 210 ++++++++++++++++++++++++++++
app/Jobs/AutomatedReports/SendReportJob.php | 2 +
app/Jobs/AutomatedReports/SendReportMailJob.php | 6 +-
app/Jobs/Crm/SyncActivity.php | 10 ++
app/Jobs/Crm/SyncHubspotObjects.php | 120 ++++++++++++++++
app/Jobs/Crm/SyncObjects.php | 26 ++--
app/Jobs/Crm/SyncTeamMetadata.php | 14 +-
app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php | 82 +++++++++++
app/Listeners/Crm/ResolveOwner.php | 21 +--
app/Mail/Reports/ReportWithAttachment.php | 7 +-
app/Models/Ai/AiScorecardRuleRun.php | 4 +-
app/Models/Ai/AiScorecardRun.php | 4 +-
app/Models/Contracts/UserContract.php | 6 +
app/Providers/EventServiceProvider.php | 4 +
app/Repositories/AutomatedReportsRepository.php | 76 +++++++++-
app/Repositories/Crm/CrmEntityRepository.php | 40 ++++++
app/Services/Crm/BaseService.php | 13 --
app/Services/Crm/Bullhorn/BullhornService.php | 21 ---
app/Services/Crm/Close/Service.php | 38 -----
app/Services/Crm/Copper/Service.php | 37 -----
app/Services/Crm/Dummy/Service.php | 25 ----
app/Services/Crm/Hubspot/Service.php | 37 -----
app/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTrait.php | 174 +++++++++++++++++------
app/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTrait.php | 27 ++--
app/Services/Crm/IntegrationApp/Service.php | 2 +
app/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTrait.php | 12 +-
app/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTrait.php | 5 -
app/Services/Crm/Pipedrive/Service.php | 43 +-----
app/Services/Crm/Salesforce/Service.php | 13 +-
app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php | 143 +++++++++++++++++++
app/Services/Kiosk/AutomatedReports/AutomatedReportsService.php | 222 +++++++++++++++++++++++++----
front-end/package.json | 2 +-
front-end/src/__mocks__/kit/endpoints/team-insights.js | 1 +
front-end/src/components/AiReports/AiReports.vue | 9 +-
front-end/src/components/AiReports/GridCells/ActionsCell.vue | 107 +++++++++++---
front-end/src/components/AiReports/GridCells/NameCell.vue | 13 +-
front-end/src/components/AiReports/GridCells/TypeIndicator.vue | 26 ++--
front-end/src/components/AiReports/Manage/CreateDefinition/CreateDefinitionDrawer.vue | 4 +-
front-end/src/components/AiReports/Manage/ExpiringCell.vue | 86 ++++++++++++
front-end/src/components/AiReports/Manage/ManageAiReports.less | 6 +
front-end/src/components/AiReports/Manage/ManageAiReports.vue | 6 +-
front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js | 116 +++++++++++++++
front-end/src/components/AiReports/Manage/__tests__/ManageAiReports.spec.js | 32 +++--
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/create-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/edit-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/manage-ai-reports.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/gridConfig.js | 12 +-
front-end/src/components/AiReports/__tests__/AiReports.spec.js | 45 +++++-
front-end/src/components/AiReports/__tests__/__mocks__/data.js | 49 +++++++
front-end/src/components/AiReports/__tests__/__mocks__/requestHandlers.js | 3 +
front-end/src/components/AiReports/__tests__/__snapshots__/ai-reports.output.html | 319 +++++++++++++++++++++++++++++++++++++++++-
front-end/src/components/AiReports/constants.js | 1 +
front-end/src/components/AiReports/gridConfig.js | 2 +-
front-end/src/components/AiReports/useAiReportsGrid.js | 27 ++++
front-end/src/components/Settings/Kiosk/AutomatedReports/RecipientsCell.vue | 36 ++++-
front-end/src/components/Settings/Kiosk/AutomatedReports/UsersCell.vue | 9 +-
front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js | 171 ++++++++++++++++++++++
front-end/src/components/Settings/OrgSettings/AiAutomation/CallScoring/ScorecardRuleForm.vue | 2 +-
front-end/src/components/TeamInsights/CoachingFrameworks/AICallScoring/aiCallScoringOverTime.ts | 18 ++-
front-end/src/components/shared/GridView/useOrder.js | 6 +-
front-end/src/components/shared/GridView/usePaginationList.js | 7 +-
front-end/yarn.lock | 8 +-
resources/views/emails/reports/ask-jiminny-report-generated.blade.php | 25 ++++
routes/api.php | 1 +
tests/Unit/Component/Activity/Services/UpdateActivityServiceTest.php | 62 ++++++++
tests/Unit/Component/AiCallScoring/Services/GenerateAiCallScoringServiceTest.php | 13 +-
tests/Unit/Console/Commands/Reports/AutomatedReportsCommandTest.php | 468 ++++++++++++++++++++++++++++++++++++++++++-------------------
tests/Unit/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTraitTest.php | 5 +-
tests/Unit/Http/Controllers/Webhook/ReportControllerTest.php | 9 +-
tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php | 407 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncActivityTest.php | 74 +++++++---
tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php | 455 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncTeamMetadataTest.php | 8 +-
tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php | 199 ++++++++++++++++++++++++++
tests/Unit/Listeners/Crm/ResolveOwnerTest.php | 64 ++++-----
tests/Unit/Repositories/AutomatedReportsRepositoryTest.php | 55 ++++++++
tests/Unit/Services/Crm/Copper/ServiceTest.php | 19 ---
tests/Unit/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTest.php | 74 ++++++----
tests/Unit/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTraitTest.php | 8 +-
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTraitTest.php | 76 ++--------
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTraitTest.php | 5 -
tests/Unit/Services/Crm/Pipedrive/ServiceTest.php | 11 --
tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php | 430 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Services/Kiosk/AutomatedReports/AutomatedReportsServiceTest.php | 521 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
113 files changed, 5468 insertions(+), 980 deletions(-)
create mode 100644 app/Console/Commands/Crm/SyncHubspotObjects.php
create mode 100644 app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php
create mode 100644 app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php
create mode 100644 app/Events/AutomatedReports/AutomatedReportGenerated.php
create mode 100644 app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php
create mode 100644 app/Jobs/Crm/SyncHubspotObjects.php
create mode 100644 app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php
create mode 100644 app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php
create mode 100644 front-end/src/components/AiReports/Manage/ExpiringCell.vue
create mode 100644 front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js
create mode 100644 front-end/src/components/AiReports/constants.js
create mode 100644 front-end/src/components/AiReports/useAiReportsGrid.js
create mode 100644 front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js
create mode 100644 resources/views/emails/reports/ask-jiminny-report-generated.blade.php
create mode 100644 tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php
create mode 100644 tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php
create mode 100644 tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php
create mode 100644 tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Http/Transformers/UserTransformer.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Repositories/AutomatedReportsRepository.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
modified: tests/Unit/Repositories/AutomatedReportsRepositoryTest.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5613/5613 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Console/Commands/JiminnyDebugCommand.php (braces_position, statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
+++ /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
@@ -37,15 +37,14 @@
JobDispatcherInterface $jobDispatcher,
AutomatedReportsService $automatedReportsService,
AutomatedReportsRepository $automatedReportsRepository,
- ): void
- {
-// $user = User::find(143);
-// $count = $automatedReportsRepository->countUserReports($user);
-// $this->info("Count: {$count}");
-// $count = $automatedReportsRepository->countAllUserReports($user);
-// $this->info("All count: {$count}");
-//
-// exit(1);
+ ): void {
+ // $user = User::find(143);
+ // $count = $automatedReportsRepository->countUserReports($user);
+ // $this->info("Count: {$count}");
+ // $count = $automatedReportsRepository->countAllUserReports($user);
+ // $this->info("All count: {$count}");
+ //
+ // exit(1);
$now = Carbon::now()->subDay(1);
$this->info("Now: {$now->toDateTimeString()}");
@@ -52,18 +51,18 @@
$weekStart = Carbon::getWeekStartsAt();
$this->info("Now: {$weekStart}");
-// $from = $now->copy()->previousWeekday()->startOfDay();
-// $to = $now->copy()->previousWeekday()->endOfDay();
+ // $from = $now->copy()->previousWeekday()->startOfDay();
+ // $to = $now->copy()->previousWeekday()->endOfDay();
-// $fromOld = $now->copy()->subWeeks(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subWeek()->startOfWeek();
-// $toNew = $now->copy()->subWeek()->endOfWeek();
+ // $fromOld = $now->copy()->subWeeks(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subWeek()->startOfWeek();
+ // $toNew = $now->copy()->subWeek()->endOfWeek();
-// $fromOld = $now->copy()->subMonths(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
-// $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
+ // $fromOld = $now->copy()->subMonths(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
+ // $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
$fromOld = $now->copy()->subMonths(3)->startOfDay();
$toOld = $now->copy()->subDay()->endOfDay();
----------- end diff -----------
Fixed 1 of 5613 files in 66.818 seconds, 67.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 65.183 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 40.863 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 53, done.
remote: Counting objects: 100% (53/53), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 53 (delta 33), reused 49 (delta 30), pack-reused 0 (from 0)
Unpacking objects: 100% (53/53), 46.00 KiB | 523.00 KiB/s, done.
From github.com:jiminny/app
b1d5c77ad1..dfc8da14d2 JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
+ 47037d2c29...5138acf14e secfix/npm-20260423 -> origin/secfix/npm-20260423 (forced update)
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20738-debug-AJ-tracking-UP
Switched to a new branch 'JY-20738-debug-AJ-tracking-UP'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5621/5621 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5621 files in 22.942 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at https://docs.docker.com/go/debug-cli/
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ gbr
* JY-20738-debug-AJ-tracking-UP
JY-20157-AJ-report-not-send-notification
master
JY-20372-ai-reports-promotion-pages
JY-18909-automated-reports-ask-jiminny
JY-20692-fix-integration-app-[API_KEY]
JY-20553-debug-crm-sync-delays
JY-20698-fix-SF-activity-types-on-new-playbook
JY-20543-AJ-report-tracking
JY-20384-handle-auto-sync-with-no-access-to-event-type
JY-20458-ask-jiminny-user-definitions
JY-19666-fix-import-contacts-account-association
JY-19666-HS-import-contacts-and-accounts-batch-job
JY-20458-Ask-Jiminny-Reports
JY-20200-batch-update-CRM-objects-Salesforce
JY-19666-HS-webhooks-add-contact-and-company
JY-20348-trigger-setup-DI-layout-on-team-creation
JY-20326-refactor-info-message-in-command
JY-20317-fix-auto-log-delay-issue-on-all-channels-disabled
JY-20312-remove-on-update-change-last-synced-at-crm-configurations
JY-20306-SF-skip-auto-sync-for-task-based-playbook
JY-20192-remove-deleted-team-from-saved-search-filters
JY-20197-import-opportunity-batch-job
JY-20293-enable-status-field-for-pipedrive-deals
JY-20191-remove-commands-interactive-prompts
JY-20118-change-default-sync-strategy
JY-20183-add-cache-on-auto-log-delay
JY-20197-add-import-opportunity-batch-job
20118-hs-opportunity-make-webhook-strategy-default
JY-20118-make-default-hs-opportunity-sync-strategy-webhook-based
JY-20196-handle-opportunity-without-note
JY-20118-improve-opportunity-import
JY-20189-handle-activity-search-on-deleted-groups
JY-20160
JY-20145-filter-out-converted-leads-when-matching
JY-20150-skip-push-summary-on-summary-ready-if-autolog
JY-20132-fix-note-encoding
JY-19792-clean-logs
JY-20117-fix-sync-profile-fields-on-empty-fields
JY-20027-extend-email-import-to-all-crm-objects
JY-20017-fix-hubspot-webhooks-processing
JY-20026-convert-lead-activities
JY-19501-hs-crm-sync-optimized
JY-19220-assign-activities-on-new-opportunity
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ co JY-20157-AJ-report-not-send...
|
iTerm2
|
APP (-zsh)
|
NULL
|
77591
|
|
Last login: Thu Apr 23 14:01:28 on ttys007
Poetry Last login: Thu Apr 23 14:01:28 on ttys007
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20157-AJ-report-not-send-notification
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git pull
remote: Enumerating objects: 1015, done.
remote: Counting objects: 100% (262/262), done.
remote: Compressing objects: 100% (143/143), done.
remote: Total 1015 (delta 167), reused 129 (delta 119), pack-reused 753 (from 3)
Receiving objects: 100% (1015/1015), 851.14 KiB | 2.09 MiB/s, done.
Resolving deltas: 100% (613/613), completed with 65 local objects.
From github.com:jiminny/app
c3c8d86b22..68bb20c72a JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
3ac71c265a..595c95b7e0 JY-19995-delete-leftover-tracks-command -> origin/JY-19995-delete-leftover-tracks-command
* [new branch] JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null -> origin/JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null
* [new branch] JY-20478-stop-sync-calendar-emails -> origin/JY-20478-stop-sync-calendar-emails
d4d05c775b..b11048beed JY-20541-cleanup-stale-tasks-and-events -> origin/JY-20541-cleanup-stale-tasks-and-events
10d290c778..a250abe939 JY-20663-partner-rockeed -> origin/JY-20663-partner-rockeed
* [new branch] JY-20713-activity-sync-job-restart -> origin/JY-20713-activity-sync-job-restart
242cf1b554..96a22e59f2 JY-9712-change-forever-nudges-to-1-year-expiration -> origin/JY-9712-change-forever-nudges-to-1-year-expiration
* [new branch] fix-close-missing-logger-error -> origin/fix-close-missing-logger-error
0dd5b23990..60fa1787c1 master -> origin/master
f044edca5b..e7e0e50b27 secfix/npm-20260416 -> origin/secfix/npm-20260416
* [new branch] secfix/npm-20260423 -> origin/secfix/npm-20260423
Updating c3c8d86b22..68bb20c72a
Fast-forward
Makefile | 5 +
app/Component/Activity/Services/UpdateActivityService.php | 5 +
app/Component/ActivitySearch/FilterDefinition/ActivityUpdatedDate.php | 7 +-
app/Component/ActivitySearch/Service/ActivitySearch.php | 15 ++
app/Component/AiCallScoring/Services/GenerateAiCallScoringService.php | 6 +
app/Component/AiCallScoring/Services/GetAiCallScoringService.php | 5 +-
app/Component/AiCallScoring/Transformers/AiCallScoringTransformer.php | 2 +-
app/Component/ProphetAi/ProphetClient.php | 5 +
app/Console/Commands/Crm/SyncHubspotObjects.php | 84 +++++++++++
app/Console/Commands/Crm/SyncObjects.php | 82 ++++++-----
app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php | 81 +++++++++++
app/Console/Commands/Reports/AutomatedReportsCommand.php | 91 +++++++++++-
app/Console/Commands/Reports/AutomatedReportsSendCommand.php | 40 +++++-
app/Console/Kernel.php | 4 +
app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php | 15 ++
app/Contracts/Services/Crm/Provider/SalesforceInterface.php | 12 +-
app/Contracts/Services/Crm/ServiceInterface.php | 29 ----
app/Contracts/Services/Crm/SyncCrmMetadataInterface.php | 6 +-
app/Events/AutomatedReports/AutomatedReportGenerated.php | 15 ++
app/Http/Controllers/API/CrmController.php | 19 ++-
app/Http/Controllers/API/UserAutomatedReports/UserAutomatedReportsController.php | 33 ++++-
app/Http/Controllers/Internal/WebhookReceiver/HubspotController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/EventsController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTrait.php | 64 ++++++---
app/Http/Controllers/Webhook/ReportController.php | 5 +
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRuleRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/TestAiCallScoringPromptRequest.php | 2 +-
app/Jobs/Activity/SyncActivity.php | 3 +-
app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php | 210 ++++++++++++++++++++++++++++
app/Jobs/AutomatedReports/SendReportJob.php | 2 +
app/Jobs/AutomatedReports/SendReportMailJob.php | 6 +-
app/Jobs/Crm/SyncActivity.php | 10 ++
app/Jobs/Crm/SyncHubspotObjects.php | 120 ++++++++++++++++
app/Jobs/Crm/SyncObjects.php | 26 ++--
app/Jobs/Crm/SyncTeamMetadata.php | 14 +-
app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php | 82 +++++++++++
app/Listeners/Crm/ResolveOwner.php | 21 +--
app/Mail/Reports/ReportWithAttachment.php | 7 +-
app/Models/Ai/AiScorecardRuleRun.php | 4 +-
app/Models/Ai/AiScorecardRun.php | 4 +-
app/Models/Contracts/UserContract.php | 6 +
app/Providers/EventServiceProvider.php | 4 +
app/Repositories/AutomatedReportsRepository.php | 76 +++++++++-
app/Repositories/Crm/CrmEntityRepository.php | 40 ++++++
app/Services/Crm/BaseService.php | 13 --
app/Services/Crm/Bullhorn/BullhornService.php | 21 ---
app/Services/Crm/Close/Service.php | 38 -----
app/Services/Crm/Copper/Service.php | 37 -----
app/Services/Crm/Dummy/Service.php | 25 ----
app/Services/Crm/Hubspot/Service.php | 37 -----
app/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTrait.php | 174 +++++++++++++++++------
app/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTrait.php | 27 ++--
app/Services/Crm/IntegrationApp/Service.php | 2 +
app/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTrait.php | 12 +-
app/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTrait.php | 5 -
app/Services/Crm/Pipedrive/Service.php | 43 +-----
app/Services/Crm/Salesforce/Service.php | 13 +-
app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php | 143 +++++++++++++++++++
app/Services/Kiosk/AutomatedReports/AutomatedReportsService.php | 222 +++++++++++++++++++++++++----
front-end/package.json | 2 +-
front-end/src/__mocks__/kit/endpoints/team-insights.js | 1 +
front-end/src/components/AiReports/AiReports.vue | 9 +-
front-end/src/components/AiReports/GridCells/ActionsCell.vue | 107 +++++++++++---
front-end/src/components/AiReports/GridCells/NameCell.vue | 13 +-
front-end/src/components/AiReports/GridCells/TypeIndicator.vue | 26 ++--
front-end/src/components/AiReports/Manage/CreateDefinition/CreateDefinitionDrawer.vue | 4 +-
front-end/src/components/AiReports/Manage/ExpiringCell.vue | 86 ++++++++++++
front-end/src/components/AiReports/Manage/ManageAiReports.less | 6 +
front-end/src/components/AiReports/Manage/ManageAiReports.vue | 6 +-
front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js | 116 +++++++++++++++
front-end/src/components/AiReports/Manage/__tests__/ManageAiReports.spec.js | 32 +++--
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/create-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/edit-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/manage-ai-reports.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/gridConfig.js | 12 +-
front-end/src/components/AiReports/__tests__/AiReports.spec.js | 45 +++++-
front-end/src/components/AiReports/__tests__/__mocks__/data.js | 49 +++++++
front-end/src/components/AiReports/__tests__/__mocks__/requestHandlers.js | 3 +
front-end/src/components/AiReports/__tests__/__snapshots__/ai-reports.output.html | 319 +++++++++++++++++++++++++++++++++++++++++-
front-end/src/components/AiReports/constants.js | 1 +
front-end/src/components/AiReports/gridConfig.js | 2 +-
front-end/src/components/AiReports/useAiReportsGrid.js | 27 ++++
front-end/src/components/Settings/Kiosk/AutomatedReports/RecipientsCell.vue | 36 ++++-
front-end/src/components/Settings/Kiosk/AutomatedReports/UsersCell.vue | 9 +-
front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js | 171 ++++++++++++++++++++++
front-end/src/components/Settings/OrgSettings/AiAutomation/CallScoring/ScorecardRuleForm.vue | 2 +-
front-end/src/components/TeamInsights/CoachingFrameworks/AICallScoring/aiCallScoringOverTime.ts | 18 ++-
front-end/src/components/shared/GridView/useOrder.js | 6 +-
front-end/src/components/shared/GridView/usePaginationList.js | 7 +-
front-end/yarn.lock | 8 +-
resources/views/emails/reports/ask-jiminny-report-generated.blade.php | 25 ++++
routes/api.php | 1 +
tests/Unit/Component/Activity/Services/UpdateActivityServiceTest.php | 62 ++++++++
tests/Unit/Component/AiCallScoring/Services/GenerateAiCallScoringServiceTest.php | 13 +-
tests/Unit/Console/Commands/Reports/AutomatedReportsCommandTest.php | 468 ++++++++++++++++++++++++++++++++++++++++++-------------------
tests/Unit/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTraitTest.php | 5 +-
tests/Unit/Http/Controllers/Webhook/ReportControllerTest.php | 9 +-
tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php | 407 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncActivityTest.php | 74 +++++++---
tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php | 455 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncTeamMetadataTest.php | 8 +-
tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php | 199 ++++++++++++++++++++++++++
tests/Unit/Listeners/Crm/ResolveOwnerTest.php | 64 ++++-----
tests/Unit/Repositories/AutomatedReportsRepositoryTest.php | 55 ++++++++
tests/Unit/Services/Crm/Copper/ServiceTest.php | 19 ---
tests/Unit/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTest.php | 74 ++++++----
tests/Unit/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTraitTest.php | 8 +-
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTraitTest.php | 76 ++--------
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTraitTest.php | 5 -
tests/Unit/Services/Crm/Pipedrive/ServiceTest.php | 11 --
tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php | 430 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Services/Kiosk/AutomatedReports/AutomatedReportsServiceTest.php | 521 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
113 files changed, 5468 insertions(+), 980 deletions(-)
create mode 100644 app/Console/Commands/Crm/SyncHubspotObjects.php
create mode 100644 app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php
create mode 100644 app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php
create mode 100644 app/Events/AutomatedReports/AutomatedReportGenerated.php
create mode 100644 app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php
create mode 100644 app/Jobs/Crm/SyncHubspotObjects.php
create mode 100644 app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php
create mode 100644 app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php
create mode 100644 front-end/src/components/AiReports/Manage/ExpiringCell.vue
create mode 100644 front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js
create mode 100644 front-end/src/components/AiReports/constants.js
create mode 100644 front-end/src/components/AiReports/useAiReportsGrid.js
create mode 100644 front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js
create mode 100644 resources/views/emails/reports/ask-jiminny-report-generated.blade.php
create mode 100644 tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php
create mode 100644 tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php
create mode 100644 tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php
create mode 100644 tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Http/Transformers/UserTransformer.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Repositories/AutomatedReportsRepository.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
modified: tests/Unit/Repositories/AutomatedReportsRepositoryTest.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5613/5613 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Console/Commands/JiminnyDebugCommand.php (braces_position, statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
+++ /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
@@ -37,15 +37,14 @@
JobDispatcherInterface $jobDispatcher,
AutomatedReportsService $automatedReportsService,
AutomatedReportsRepository $automatedReportsRepository,
- ): void
- {
-// $user = User::find(143);
-// $count = $automatedReportsRepository->countUserReports($user);
-// $this->info("Count: {$count}");
-// $count = $automatedReportsRepository->countAllUserReports($user);
-// $this->info("All count: {$count}");
-//
-// exit(1);
+ ): void {
+ // $user = User::find(143);
+ // $count = $automatedReportsRepository->countUserReports($user);
+ // $this->info("Count: {$count}");
+ // $count = $automatedReportsRepository->countAllUserReports($user);
+ // $this->info("All count: {$count}");
+ //
+ // exit(1);
$now = Carbon::now()->subDay(1);
$this->info("Now: {$now->toDateTimeString()}");
@@ -52,18 +51,18 @@
$weekStart = Carbon::getWeekStartsAt();
$this->info("Now: {$weekStart}");
-// $from = $now->copy()->previousWeekday()->startOfDay();
-// $to = $now->copy()->previousWeekday()->endOfDay();
+ // $from = $now->copy()->previousWeekday()->startOfDay();
+ // $to = $now->copy()->previousWeekday()->endOfDay();
-// $fromOld = $now->copy()->subWeeks(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subWeek()->startOfWeek();
-// $toNew = $now->copy()->subWeek()->endOfWeek();
+ // $fromOld = $now->copy()->subWeeks(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subWeek()->startOfWeek();
+ // $toNew = $now->copy()->subWeek()->endOfWeek();
-// $fromOld = $now->copy()->subMonths(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
-// $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
+ // $fromOld = $now->copy()->subMonths(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
+ // $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
$fromOld = $now->copy()->subMonths(3)->startOfDay();
$toOld = $now->copy()->subDay()->endOfDay();
----------- end diff -----------
Fixed 1 of 5613 files in 66.818 seconds, 67.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 65.183 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 40.863 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 53, done.
remote: Counting objects: 100% (53/53), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 53 (delta 33), reused 49 (delta 30), pack-reused 0 (from 0)
Unpacking objects: 100% (53/53), 46.00 KiB | 523.00 KiB/s, done.
From github.com:jiminny/app
b1d5c77ad1..dfc8da14d2 JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
+ 47037d2c29...5138acf14e secfix/npm-20260423 -> origin/secfix/npm-20260423 (forced update)
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20738-debug-AJ-tracking-UP
Switched to a new branch 'JY-20738-debug-AJ-tracking-UP'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5621/5621 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5621 files in 22.942 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at https://docs.docker.com/go/debug-cli/
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ gbr
* JY-20738-debug-AJ-tracking-UP
JY-20157-AJ-report-not-send-notification
master
JY-20372-ai-reports-promotion-pages
JY-18909-automated-reports-ask-jiminny
JY-20692-fix-integration-app-[API_KEY]
JY-20553-debug-crm-sync-delays
JY-20698-fix-SF-activity-types-on-new-playbook
JY-20543-AJ-report-tracking
JY-20384-handle-auto-sync-with-no-access-to-event-type
JY-20458-ask-jiminny-user-definitions
JY-19666-fix-import-contacts-account-association
JY-19666-HS-import-contacts-and-accounts-batch-job
JY-20458-Ask-Jiminny-Reports
JY-20200-batch-update-CRM-objects-Salesforce
JY-19666-HS-webhooks-add-contact-and-company
JY-20348-trigger-setup-DI-layout-on-team-creation
JY-20326-refactor-info-message-in-command
JY-20317-fix-auto-log-delay-issue-on-all-channels-disabled
JY-20312-remove-on-update-change-last-synced-at-crm-configurations
JY-20306-SF-skip-auto-sync-for-task-based-playbook
JY-20192-remove-deleted-team-from-saved-search-filters
JY-20197-import-opportunity-batch-job
JY-20293-enable-status-field-for-pipedrive-deals
JY-20191-remove-commands-interactive-prompts
JY-20118-change-default-sync-strategy
JY-20183-add-cache-on-auto-log-delay
JY-20197-add-import-opportunity-batch-job
20118-hs-opportunity-make-webhook-strategy-default
JY-20118-make-default-hs-opportunity-sync-strategy-webhook-based
JY-20196-handle-opportunity-without-note
JY-20118-improve-opportunity-import
JY-20189-handle-activity-search-on-deleted-groups
JY-20160
JY-20145-filter-out-converted-leads-when-matching
JY-20150-skip-push-summary-on-summary-ready-if-autolog
JY-20132-fix-note-encoding
JY-19792-clean-logs
JY-20117-fix-sync-profile-fields-on-empty-fields
JY-20027-extend-email-import-to-all-crm-objects
JY-20017-fix-hubspot-webhooks-processing
JY-20026-convert-lead-activities
JY-19501-hs-crm-sync-optimized
JY-19220-assign-activities-on-new-opportunity
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ co JY-20157-AJ-report-not-send...
|
iTerm2
|
APP (-zsh)
|
NULL
|
77592
|
|
Last login: Thu Apr 23 14:01:28 on ttys007
Poetry Last login: Thu Apr 23 14:01:28 on ttys007
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20157-AJ-report-not-send-notification
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git pull
remote: Enumerating objects: 1015, done.
remote: Counting objects: 100% (262/262), done.
remote: Compressing objects: 100% (143/143), done.
remote: Total 1015 (delta 167), reused 129 (delta 119), pack-reused 753 (from 3)
Receiving objects: 100% (1015/1015), 851.14 KiB | 2.09 MiB/s, done.
Resolving deltas: 100% (613/613), completed with 65 local objects.
From github.com:jiminny/app
c3c8d86b22..68bb20c72a JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
3ac71c265a..595c95b7e0 JY-19995-delete-leftover-tracks-command -> origin/JY-19995-delete-leftover-tracks-command
* [new branch] JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null -> origin/JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null
* [new branch] JY-20478-stop-sync-calendar-emails -> origin/JY-20478-stop-sync-calendar-emails
d4d05c775b..b11048beed JY-20541-cleanup-stale-tasks-and-events -> origin/JY-20541-cleanup-stale-tasks-and-events
10d290c778..a250abe939 JY-20663-partner-rockeed -> origin/JY-20663-partner-rockeed
* [new branch] JY-20713-activity-sync-job-restart -> origin/JY-20713-activity-sync-job-restart
242cf1b554..96a22e59f2 JY-9712-change-forever-nudges-to-1-year-expiration -> origin/JY-9712-change-forever-nudges-to-1-year-expiration
* [new branch] fix-close-missing-logger-error -> origin/fix-close-missing-logger-error
0dd5b23990..60fa1787c1 master -> origin/master
f044edca5b..e7e0e50b27 secfix/npm-20260416 -> origin/secfix/npm-20260416
* [new branch] secfix/npm-20260423 -> origin/secfix/npm-20260423
Updating c3c8d86b22..68bb20c72a
Fast-forward
Makefile | 5 +
app/Component/Activity/Services/UpdateActivityService.php | 5 +
app/Component/ActivitySearch/FilterDefinition/ActivityUpdatedDate.php | 7 +-
app/Component/ActivitySearch/Service/ActivitySearch.php | 15 ++
app/Component/AiCallScoring/Services/GenerateAiCallScoringService.php | 6 +
app/Component/AiCallScoring/Services/GetAiCallScoringService.php | 5 +-
app/Component/AiCallScoring/Transformers/AiCallScoringTransformer.php | 2 +-
app/Component/ProphetAi/ProphetClient.php | 5 +
app/Console/Commands/Crm/SyncHubspotObjects.php | 84 +++++++++++
app/Console/Commands/Crm/SyncObjects.php | 82 ++++++-----
app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php | 81 +++++++++++
app/Console/Commands/Reports/AutomatedReportsCommand.php | 91 +++++++++++-
app/Console/Commands/Reports/AutomatedReportsSendCommand.php | 40 +++++-
app/Console/Kernel.php | 4 +
app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php | 15 ++
app/Contracts/Services/Crm/Provider/SalesforceInterface.php | 12 +-
app/Contracts/Services/Crm/ServiceInterface.php | 29 ----
app/Contracts/Services/Crm/SyncCrmMetadataInterface.php | 6 +-
app/Events/AutomatedReports/AutomatedReportGenerated.php | 15 ++
app/Http/Controllers/API/CrmController.php | 19 ++-
app/Http/Controllers/API/UserAutomatedReports/UserAutomatedReportsController.php | 33 ++++-
app/Http/Controllers/Internal/WebhookReceiver/HubspotController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/EventsController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTrait.php | 64 ++++++---
app/Http/Controllers/Webhook/ReportController.php | 5 +
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRuleRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/TestAiCallScoringPromptRequest.php | 2 +-
app/Jobs/Activity/SyncActivity.php | 3 +-
app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php | 210 ++++++++++++++++++++++++++++
app/Jobs/AutomatedReports/SendReportJob.php | 2 +
app/Jobs/AutomatedReports/SendReportMailJob.php | 6 +-
app/Jobs/Crm/SyncActivity.php | 10 ++
app/Jobs/Crm/SyncHubspotObjects.php | 120 ++++++++++++++++
app/Jobs/Crm/SyncObjects.php | 26 ++--
app/Jobs/Crm/SyncTeamMetadata.php | 14 +-
app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php | 82 +++++++++++
app/Listeners/Crm/ResolveOwner.php | 21 +--
app/Mail/Reports/ReportWithAttachment.php | 7 +-
app/Models/Ai/AiScorecardRuleRun.php | 4 +-
app/Models/Ai/AiScorecardRun.php | 4 +-
app/Models/Contracts/UserContract.php | 6 +
app/Providers/EventServiceProvider.php | 4 +
app/Repositories/AutomatedReportsRepository.php | 76 +++++++++-
app/Repositories/Crm/CrmEntityRepository.php | 40 ++++++
app/Services/Crm/BaseService.php | 13 --
app/Services/Crm/Bullhorn/BullhornService.php | 21 ---
app/Services/Crm/Close/Service.php | 38 -----
app/Services/Crm/Copper/Service.php | 37 -----
app/Services/Crm/Dummy/Service.php | 25 ----
app/Services/Crm/Hubspot/Service.php | 37 -----
app/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTrait.php | 174 +++++++++++++++++------
app/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTrait.php | 27 ++--
app/Services/Crm/IntegrationApp/Service.php | 2 +
app/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTrait.php | 12 +-
app/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTrait.php | 5 -
app/Services/Crm/Pipedrive/Service.php | 43 +-----
app/Services/Crm/Salesforce/Service.php | 13 +-
app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php | 143 +++++++++++++++++++
app/Services/Kiosk/AutomatedReports/AutomatedReportsService.php | 222 +++++++++++++++++++++++++----
front-end/package.json | 2 +-
front-end/src/__mocks__/kit/endpoints/team-insights.js | 1 +
front-end/src/components/AiReports/AiReports.vue | 9 +-
front-end/src/components/AiReports/GridCells/ActionsCell.vue | 107 +++++++++++---
front-end/src/components/AiReports/GridCells/NameCell.vue | 13 +-
front-end/src/components/AiReports/GridCells/TypeIndicator.vue | 26 ++--
front-end/src/components/AiReports/Manage/CreateDefinition/CreateDefinitionDrawer.vue | 4 +-
front-end/src/components/AiReports/Manage/ExpiringCell.vue | 86 ++++++++++++
front-end/src/components/AiReports/Manage/ManageAiReports.less | 6 +
front-end/src/components/AiReports/Manage/ManageAiReports.vue | 6 +-
front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js | 116 +++++++++++++++
front-end/src/components/AiReports/Manage/__tests__/ManageAiReports.spec.js | 32 +++--
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/create-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/edit-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/manage-ai-reports.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/gridConfig.js | 12 +-
front-end/src/components/AiReports/__tests__/AiReports.spec.js | 45 +++++-
front-end/src/components/AiReports/__tests__/__mocks__/data.js | 49 +++++++
front-end/src/components/AiReports/__tests__/__mocks__/requestHandlers.js | 3 +
front-end/src/components/AiReports/__tests__/__snapshots__/ai-reports.output.html | 319 +++++++++++++++++++++++++++++++++++++++++-
front-end/src/components/AiReports/constants.js | 1 +
front-end/src/components/AiReports/gridConfig.js | 2 +-
front-end/src/components/AiReports/useAiReportsGrid.js | 27 ++++
front-end/src/components/Settings/Kiosk/AutomatedReports/RecipientsCell.vue | 36 ++++-
front-end/src/components/Settings/Kiosk/AutomatedReports/UsersCell.vue | 9 +-
front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js | 171 ++++++++++++++++++++++
front-end/src/components/Settings/OrgSettings/AiAutomation/CallScoring/ScorecardRuleForm.vue | 2 +-
front-end/src/components/TeamInsights/CoachingFrameworks/AICallScoring/aiCallScoringOverTime.ts | 18 ++-
front-end/src/components/shared/GridView/useOrder.js | 6 +-
front-end/src/components/shared/GridView/usePaginationList.js | 7 +-
front-end/yarn.lock | 8 +-
resources/views/emails/reports/ask-jiminny-report-generated.blade.php | 25 ++++
routes/api.php | 1 +
tests/Unit/Component/Activity/Services/UpdateActivityServiceTest.php | 62 ++++++++
tests/Unit/Component/AiCallScoring/Services/GenerateAiCallScoringServiceTest.php | 13 +-
tests/Unit/Console/Commands/Reports/AutomatedReportsCommandTest.php | 468 ++++++++++++++++++++++++++++++++++++++++++-------------------
tests/Unit/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTraitTest.php | 5 +-
tests/Unit/Http/Controllers/Webhook/ReportControllerTest.php | 9 +-
tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php | 407 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncActivityTest.php | 74 +++++++---
tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php | 455 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncTeamMetadataTest.php | 8 +-
tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php | 199 ++++++++++++++++++++++++++
tests/Unit/Listeners/Crm/ResolveOwnerTest.php | 64 ++++-----
tests/Unit/Repositories/AutomatedReportsRepositoryTest.php | 55 ++++++++
tests/Unit/Services/Crm/Copper/ServiceTest.php | 19 ---
tests/Unit/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTest.php | 74 ++++++----
tests/Unit/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTraitTest.php | 8 +-
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTraitTest.php | 76 ++--------
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTraitTest.php | 5 -
tests/Unit/Services/Crm/Pipedrive/ServiceTest.php | 11 --
tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php | 430 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Services/Kiosk/AutomatedReports/AutomatedReportsServiceTest.php | 521 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
113 files changed, 5468 insertions(+), 980 deletions(-)
create mode 100644 app/Console/Commands/Crm/SyncHubspotObjects.php
create mode 100644 app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php
create mode 100644 app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php
create mode 100644 app/Events/AutomatedReports/AutomatedReportGenerated.php
create mode 100644 app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php
create mode 100644 app/Jobs/Crm/SyncHubspotObjects.php
create mode 100644 app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php
create mode 100644 app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php
create mode 100644 front-end/src/components/AiReports/Manage/ExpiringCell.vue
create mode 100644 front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js
create mode 100644 front-end/src/components/AiReports/constants.js
create mode 100644 front-end/src/components/AiReports/useAiReportsGrid.js
create mode 100644 front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js
create mode 100644 resources/views/emails/reports/ask-jiminny-report-generated.blade.php
create mode 100644 tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php
create mode 100644 tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php
create mode 100644 tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php
create mode 100644 tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Http/Transformers/UserTransformer.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Repositories/AutomatedReportsRepository.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
modified: tests/Unit/Repositories/AutomatedReportsRepositoryTest.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5613/5613 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Console/Commands/JiminnyDebugCommand.php (braces_position, statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
+++ /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
@@ -37,15 +37,14 @@
JobDispatcherInterface $jobDispatcher,
AutomatedReportsService $automatedReportsService,
AutomatedReportsRepository $automatedReportsRepository,
- ): void
- {
-// $user = User::find(143);
-// $count = $automatedReportsRepository->countUserReports($user);
-// $this->info("Count: {$count}");
-// $count = $automatedReportsRepository->countAllUserReports($user);
-// $this->info("All count: {$count}");
-//
-// exit(1);
+ ): void {
+ // $user = User::find(143);
+ // $count = $automatedReportsRepository->countUserReports($user);
+ // $this->info("Count: {$count}");
+ // $count = $automatedReportsRepository->countAllUserReports($user);
+ // $this->info("All count: {$count}");
+ //
+ // exit(1);
$now = Carbon::now()->subDay(1);
$this->info("Now: {$now->toDateTimeString()}");
@@ -52,18 +51,18 @@
$weekStart = Carbon::getWeekStartsAt();
$this->info("Now: {$weekStart}");
-// $from = $now->copy()->previousWeekday()->startOfDay();
-// $to = $now->copy()->previousWeekday()->endOfDay();
+ // $from = $now->copy()->previousWeekday()->startOfDay();
+ // $to = $now->copy()->previousWeekday()->endOfDay();
-// $fromOld = $now->copy()->subWeeks(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subWeek()->startOfWeek();
-// $toNew = $now->copy()->subWeek()->endOfWeek();
+ // $fromOld = $now->copy()->subWeeks(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subWeek()->startOfWeek();
+ // $toNew = $now->copy()->subWeek()->endOfWeek();
-// $fromOld = $now->copy()->subMonths(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
-// $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
+ // $fromOld = $now->copy()->subMonths(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
+ // $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
$fromOld = $now->copy()->subMonths(3)->startOfDay();
$toOld = $now->copy()->subDay()->endOfDay();
----------- end diff -----------
Fixed 1 of 5613 files in 66.818 seconds, 67.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 65.183 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 40.863 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 53, done.
remote: Counting objects: 100% (53/53), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 53 (delta 33), reused 49 (delta 30), pack-reused 0 (from 0)
Unpacking objects: 100% (53/53), 46.00 KiB | 523.00 KiB/s, done.
From github.com:jiminny/app
b1d5c77ad1..dfc8da14d2 JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
+ 47037d2c29...5138acf14e secfix/npm-20260423 -> origin/secfix/npm-20260423 (forced update)
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20738-debug-AJ-tracking-UP
Switched to a new branch 'JY-20738-debug-AJ-tracking-UP'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5621/5621 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5621 files in 22.942 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at https://docs.docker.com/go/debug-cli/
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ gbr
* JY-20738-debug-AJ-tracking-UP
JY-20157-AJ-report-not-send-notification
master
JY-20372-ai-reports-promotion-pages
JY-18909-automated-reports-ask-jiminny
JY-20692-fix-integration-app-[API_KEY]
JY-20553-debug-crm-sync-delays
JY-20698-fix-SF-activity-types-on-new-playbook
JY-20543-AJ-report-tracking
JY-20384-handle-auto-sync-with-no-access-to-event-type
JY-20458-ask-jiminny-user-definitions
JY-19666-fix-import-contacts-account-association
JY-19666-HS-import-contacts-and-accounts-batch-job
JY-20458-Ask-Jiminny-Reports
JY-20200-batch-update-CRM-objects-Salesforce
JY-19666-HS-webhooks-add-contact-and-company
JY-20348-trigger-setup-DI-layout-on-team-creation
JY-20326-refactor-info-message-in-command
JY-20317-fix-auto-log-delay-issue-on-all-channels-disabled
JY-20312-remove-on-update-change-last-synced-at-crm-configurations
JY-20306-SF-skip-auto-sync-for-task-based-playbook
JY-20192-remove-deleted-team-from-saved-search-filters
JY-20197-import-opportunity-batch-job
JY-20293-enable-status-field-for-pipedrive-deals
JY-20191-remove-commands-interactive-prompts
JY-20118-change-default-sync-strategy
JY-20183-add-cache-on-auto-log-delay
JY-20197-add-import-opportunity-batch-job
20118-hs-opportunity-make-webhook-strategy-default
JY-20118-make-default-hs-opportunity-sync-strategy-webhook-based
JY-20196-handle-opportunity-without-note
JY-20118-improve-opportunity-import
JY-20189-handle-activity-search-on-deleted-groups
JY-20160
JY-20145-filter-out-converted-leads-when-matching
JY-20150-skip-push-summary-on-summary-ready-if-autolog
JY-20132-fix-note-encoding
JY-19792-clean-logs
JY-20117-fix-sync-profile-fields-on-empty-fields
JY-20027-extend-email-import-to-all-crm-objects
JY-20017-fix-hubspot-webhooks-processing
JY-20026-convert-lead-activities
JY-19501-hs-crm-sync-optimized
JY-19220-assign-activities-on-new-opportunity
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ co JY-20157-AJ-report-not-send...
|
iTerm2
|
APP (-zsh)
|
NULL
|
77593
|
|
Last login: Thu Apr 23 14:01:28 on ttys007
Poetry Last login: Thu Apr 23 14:01:28 on ttys007
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20157-AJ-report-not-send-notification
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git pull
remote: Enumerating objects: 1015, done.
remote: Counting objects: 100% (262/262), done.
remote: Compressing objects: 100% (143/143), done.
remote: Total 1015 (delta 167), reused 129 (delta 119), pack-reused 753 (from 3)
Receiving objects: 100% (1015/1015), 851.14 KiB | 2.09 MiB/s, done.
Resolving deltas: 100% (613/613), completed with 65 local objects.
From github.com:jiminny/app
c3c8d86b22..68bb20c72a JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
3ac71c265a..595c95b7e0 JY-19995-delete-leftover-tracks-command -> origin/JY-19995-delete-leftover-tracks-command
* [new branch] JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null -> origin/JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null
* [new branch] JY-20478-stop-sync-calendar-emails -> origin/JY-20478-stop-sync-calendar-emails
d4d05c775b..b11048beed JY-20541-cleanup-stale-tasks-and-events -> origin/JY-20541-cleanup-stale-tasks-and-events
10d290c778..a250abe939 JY-20663-partner-rockeed -> origin/JY-20663-partner-rockeed
* [new branch] JY-20713-activity-sync-job-restart -> origin/JY-20713-activity-sync-job-restart
242cf1b554..96a22e59f2 JY-9712-change-forever-nudges-to-1-year-expiration -> origin/JY-9712-change-forever-nudges-to-1-year-expiration
* [new branch] fix-close-missing-logger-error -> origin/fix-close-missing-logger-error
0dd5b23990..60fa1787c1 master -> origin/master
f044edca5b..e7e0e50b27 secfix/npm-20260416 -> origin/secfix/npm-20260416
* [new branch] secfix/npm-20260423 -> origin/secfix/npm-20260423
Updating c3c8d86b22..68bb20c72a
Fast-forward
Makefile | 5 +
app/Component/Activity/Services/UpdateActivityService.php | 5 +
app/Component/ActivitySearch/FilterDefinition/ActivityUpdatedDate.php | 7 +-
app/Component/ActivitySearch/Service/ActivitySearch.php | 15 ++
app/Component/AiCallScoring/Services/GenerateAiCallScoringService.php | 6 +
app/Component/AiCallScoring/Services/GetAiCallScoringService.php | 5 +-
app/Component/AiCallScoring/Transformers/AiCallScoringTransformer.php | 2 +-
app/Component/ProphetAi/ProphetClient.php | 5 +
app/Console/Commands/Crm/SyncHubspotObjects.php | 84 +++++++++++
app/Console/Commands/Crm/SyncObjects.php | 82 ++++++-----
app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php | 81 +++++++++++
app/Console/Commands/Reports/AutomatedReportsCommand.php | 91 +++++++++++-
app/Console/Commands/Reports/AutomatedReportsSendCommand.php | 40 +++++-
app/Console/Kernel.php | 4 +
app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php | 15 ++
app/Contracts/Services/Crm/Provider/SalesforceInterface.php | 12 +-
app/Contracts/Services/Crm/ServiceInterface.php | 29 ----
app/Contracts/Services/Crm/SyncCrmMetadataInterface.php | 6 +-
app/Events/AutomatedReports/AutomatedReportGenerated.php | 15 ++
app/Http/Controllers/API/CrmController.php | 19 ++-
app/Http/Controllers/API/UserAutomatedReports/UserAutomatedReportsController.php | 33 ++++-
app/Http/Controllers/Internal/WebhookReceiver/HubspotController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/EventsController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTrait.php | 64 ++++++---
app/Http/Controllers/Webhook/ReportController.php | 5 +
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRuleRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/TestAiCallScoringPromptRequest.php | 2 +-
app/Jobs/Activity/SyncActivity.php | 3 +-
app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php | 210 ++++++++++++++++++++++++++++
app/Jobs/AutomatedReports/SendReportJob.php | 2 +
app/Jobs/AutomatedReports/SendReportMailJob.php | 6 +-
app/Jobs/Crm/SyncActivity.php | 10 ++
app/Jobs/Crm/SyncHubspotObjects.php | 120 ++++++++++++++++
app/Jobs/Crm/SyncObjects.php | 26 ++--
app/Jobs/Crm/SyncTeamMetadata.php | 14 +-
app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php | 82 +++++++++++
app/Listeners/Crm/ResolveOwner.php | 21 +--
app/Mail/Reports/ReportWithAttachment.php | 7 +-
app/Models/Ai/AiScorecardRuleRun.php | 4 +-
app/Models/Ai/AiScorecardRun.php | 4 +-
app/Models/Contracts/UserContract.php | 6 +
app/Providers/EventServiceProvider.php | 4 +
app/Repositories/AutomatedReportsRepository.php | 76 +++++++++-
app/Repositories/Crm/CrmEntityRepository.php | 40 ++++++
app/Services/Crm/BaseService.php | 13 --
app/Services/Crm/Bullhorn/BullhornService.php | 21 ---
app/Services/Crm/Close/Service.php | 38 -----
app/Services/Crm/Copper/Service.php | 37 -----
app/Services/Crm/Dummy/Service.php | 25 ----
app/Services/Crm/Hubspot/Service.php | 37 -----
app/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTrait.php | 174 +++++++++++++++++------
app/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTrait.php | 27 ++--
app/Services/Crm/IntegrationApp/Service.php | 2 +
app/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTrait.php | 12 +-
app/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTrait.php | 5 -
app/Services/Crm/Pipedrive/Service.php | 43 +-----
app/Services/Crm/Salesforce/Service.php | 13 +-
app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php | 143 +++++++++++++++++++
app/Services/Kiosk/AutomatedReports/AutomatedReportsService.php | 222 +++++++++++++++++++++++++----
front-end/package.json | 2 +-
front-end/src/__mocks__/kit/endpoints/team-insights.js | 1 +
front-end/src/components/AiReports/AiReports.vue | 9 +-
front-end/src/components/AiReports/GridCells/ActionsCell.vue | 107 +++++++++++---
front-end/src/components/AiReports/GridCells/NameCell.vue | 13 +-
front-end/src/components/AiReports/GridCells/TypeIndicator.vue | 26 ++--
front-end/src/components/AiReports/Manage/CreateDefinition/CreateDefinitionDrawer.vue | 4 +-
front-end/src/components/AiReports/Manage/ExpiringCell.vue | 86 ++++++++++++
front-end/src/components/AiReports/Manage/ManageAiReports.less | 6 +
front-end/src/components/AiReports/Manage/ManageAiReports.vue | 6 +-
front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js | 116 +++++++++++++++
front-end/src/components/AiReports/Manage/__tests__/ManageAiReports.spec.js | 32 +++--
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/create-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/edit-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/manage-ai-reports.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/gridConfig.js | 12 +-
front-end/src/components/AiReports/__tests__/AiReports.spec.js | 45 +++++-
front-end/src/components/AiReports/__tests__/__mocks__/data.js | 49 +++++++
front-end/src/components/AiReports/__tests__/__mocks__/requestHandlers.js | 3 +
front-end/src/components/AiReports/__tests__/__snapshots__/ai-reports.output.html | 319 +++++++++++++++++++++++++++++++++++++++++-
front-end/src/components/AiReports/constants.js | 1 +
front-end/src/components/AiReports/gridConfig.js | 2 +-
front-end/src/components/AiReports/useAiReportsGrid.js | 27 ++++
front-end/src/components/Settings/Kiosk/AutomatedReports/RecipientsCell.vue | 36 ++++-
front-end/src/components/Settings/Kiosk/AutomatedReports/UsersCell.vue | 9 +-
front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js | 171 ++++++++++++++++++++++
front-end/src/components/Settings/OrgSettings/AiAutomation/CallScoring/ScorecardRuleForm.vue | 2 +-
front-end/src/components/TeamInsights/CoachingFrameworks/AICallScoring/aiCallScoringOverTime.ts | 18 ++-
front-end/src/components/shared/GridView/useOrder.js | 6 +-
front-end/src/components/shared/GridView/usePaginationList.js | 7 +-
front-end/yarn.lock | 8 +-
resources/views/emails/reports/ask-jiminny-report-generated.blade.php | 25 ++++
routes/api.php | 1 +
tests/Unit/Component/Activity/Services/UpdateActivityServiceTest.php | 62 ++++++++
tests/Unit/Component/AiCallScoring/Services/GenerateAiCallScoringServiceTest.php | 13 +-
tests/Unit/Console/Commands/Reports/AutomatedReportsCommandTest.php | 468 ++++++++++++++++++++++++++++++++++++++++++-------------------
tests/Unit/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTraitTest.php | 5 +-
tests/Unit/Http/Controllers/Webhook/ReportControllerTest.php | 9 +-
tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php | 407 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncActivityTest.php | 74 +++++++---
tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php | 455 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncTeamMetadataTest.php | 8 +-
tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php | 199 ++++++++++++++++++++++++++
tests/Unit/Listeners/Crm/ResolveOwnerTest.php | 64 ++++-----
tests/Unit/Repositories/AutomatedReportsRepositoryTest.php | 55 ++++++++
tests/Unit/Services/Crm/Copper/ServiceTest.php | 19 ---
tests/Unit/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTest.php | 74 ++++++----
tests/Unit/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTraitTest.php | 8 +-
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTraitTest.php | 76 ++--------
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTraitTest.php | 5 -
tests/Unit/Services/Crm/Pipedrive/ServiceTest.php | 11 --
tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php | 430 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Services/Kiosk/AutomatedReports/AutomatedReportsServiceTest.php | 521 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
113 files changed, 5468 insertions(+), 980 deletions(-)
create mode 100644 app/Console/Commands/Crm/SyncHubspotObjects.php
create mode 100644 app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php
create mode 100644 app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php
create mode 100644 app/Events/AutomatedReports/AutomatedReportGenerated.php
create mode 100644 app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php
create mode 100644 app/Jobs/Crm/SyncHubspotObjects.php
create mode 100644 app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php
create mode 100644 app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php
create mode 100644 front-end/src/components/AiReports/Manage/ExpiringCell.vue
create mode 100644 front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js
create mode 100644 front-end/src/components/AiReports/constants.js
create mode 100644 front-end/src/components/AiReports/useAiReportsGrid.js
create mode 100644 front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js
create mode 100644 resources/views/emails/reports/ask-jiminny-report-generated.blade.php
create mode 100644 tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php
create mode 100644 tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php
create mode 100644 tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php
create mode 100644 tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Http/Transformers/UserTransformer.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Repositories/AutomatedReportsRepository.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
modified: tests/Unit/Repositories/AutomatedReportsRepositoryTest.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5613/5613 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Console/Commands/JiminnyDebugCommand.php (braces_position, statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
+++ /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
@@ -37,15 +37,14 @@
JobDispatcherInterface $jobDispatcher,
AutomatedReportsService $automatedReportsService,
AutomatedReportsRepository $automatedReportsRepository,
- ): void
- {
-// $user = User::find(143);
-// $count = $automatedReportsRepository->countUserReports($user);
-// $this->info("Count: {$count}");
-// $count = $automatedReportsRepository->countAllUserReports($user);
-// $this->info("All count: {$count}");
-//
-// exit(1);
+ ): void {
+ // $user = User::find(143);
+ // $count = $automatedReportsRepository->countUserReports($user);
+ // $this->info("Count: {$count}");
+ // $count = $automatedReportsRepository->countAllUserReports($user);
+ // $this->info("All count: {$count}");
+ //
+ // exit(1);
$now = Carbon::now()->subDay(1);
$this->info("Now: {$now->toDateTimeString()}");
@@ -52,18 +51,18 @@
$weekStart = Carbon::getWeekStartsAt();
$this->info("Now: {$weekStart}");
-// $from = $now->copy()->previousWeekday()->startOfDay();
-// $to = $now->copy()->previousWeekday()->endOfDay();
+ // $from = $now->copy()->previousWeekday()->startOfDay();
+ // $to = $now->copy()->previousWeekday()->endOfDay();
-// $fromOld = $now->copy()->subWeeks(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subWeek()->startOfWeek();
-// $toNew = $now->copy()->subWeek()->endOfWeek();
+ // $fromOld = $now->copy()->subWeeks(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subWeek()->startOfWeek();
+ // $toNew = $now->copy()->subWeek()->endOfWeek();
-// $fromOld = $now->copy()->subMonths(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
-// $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
+ // $fromOld = $now->copy()->subMonths(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
+ // $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
$fromOld = $now->copy()->subMonths(3)->startOfDay();
$toOld = $now->copy()->subDay()->endOfDay();
----------- end diff -----------
Fixed 1 of 5613 files in 66.818 seconds, 67.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 65.183 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 40.863 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 53, done.
remote: Counting objects: 100% (53/53), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 53 (delta 33), reused 49 (delta 30), pack-reused 0 (from 0)
Unpacking objects: 100% (53/53), 46.00 KiB | 523.00 KiB/s, done.
From github.com:jiminny/app
b1d5c77ad1..dfc8da14d2 JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
+ 47037d2c29...5138acf14e secfix/npm-20260423 -> origin/secfix/npm-20260423 (forced update)
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20738-debug-AJ-tracking-UP
Switched to a new branch 'JY-20738-debug-AJ-tracking-UP'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5621/5621 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5621 files in 22.942 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at https://docs.docker.com/go/debug-cli/
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ gbr
* JY-20738-debug-AJ-tracking-UP
JY-20157-AJ-report-not-send-notification
master
JY-20372-ai-reports-promotion-pages
JY-18909-automated-reports-ask-jiminny
JY-20692-fix-integration-app-[API_KEY]
JY-20553-debug-crm-sync-delays
JY-20698-fix-SF-activity-types-on-new-playbook
JY-20543-AJ-report-tracking
JY-20384-handle-auto-sync-with-no-access-to-event-type
JY-20458-ask-jiminny-user-definitions
JY-19666-fix-import-contacts-account-association
JY-19666-HS-import-contacts-and-accounts-batch-job
JY-20458-Ask-Jiminny-Reports
JY-20200-batch-update-CRM-objects-Salesforce
JY-19666-HS-webhooks-add-contact-and-company
JY-20348-trigger-setup-DI-layout-on-team-creation
JY-20326-refactor-info-message-in-command
JY-20317-fix-auto-log-delay-issue-on-all-channels-disabled
JY-20312-remove-on-update-change-last-synced-at-crm-configurations
JY-20306-SF-skip-auto-sync-for-task-based-playbook
JY-20192-remove-deleted-team-from-saved-search-filters
JY-20197-import-opportunity-batch-job
JY-20293-enable-status-field-for-pipedrive-deals
JY-20191-remove-commands-interactive-prompts
JY-20118-change-default-sync-strategy
JY-20183-add-cache-on-auto-log-delay
JY-20197-add-import-opportunity-batch-job
20118-hs-opportunity-make-webhook-strategy-default
JY-20118-make-default-hs-opportunity-sync-strategy-webhook-based
JY-20196-handle-opportunity-without-note
JY-20118-improve-opportunity-import
JY-20189-handle-activity-search-on-deleted-groups
JY-20160
JY-20145-filter-out-converted-leads-when-matching
JY-20150-skip-push-summary-on-summary-ready-if-autolog
JY-20132-fix-note-encoding
JY-19792-clean-logs
JY-20117-fix-sync-profile-fields-on-empty-fields
JY-20027-extend-email-import-to-all-crm-objects
JY-20017-fix-hubspot-webhooks-processing
JY-20026-convert-lead-activities
JY-19501-hs-crm-sync-optimized
JY-19220-assign-activities-on-new-opportunity
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ co JY-20157-AJ-report-not-send...
|
iTerm2
|
APP (-zsh)
|
NULL
|
77594
|
|
Last login: Thu Apr 23 14:01:28 on ttys007
Poetry Last login: Thu Apr 23 14:01:28 on ttys007
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20157-AJ-report-not-send-notification
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git pull
remote: Enumerating objects: 1015, done.
remote: Counting objects: 100% (262/262), done.
remote: Compressing objects: 100% (143/143), done.
remote: Total 1015 (delta 167), reused 129 (delta 119), pack-reused 753 (from 3)
Receiving objects: 100% (1015/1015), 851.14 KiB | 2.09 MiB/s, done.
Resolving deltas: 100% (613/613), completed with 65 local objects.
From github.com:jiminny/app
c3c8d86b22..68bb20c72a JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
3ac71c265a..595c95b7e0 JY-19995-delete-leftover-tracks-command -> origin/JY-19995-delete-leftover-tracks-command
* [new branch] JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null -> origin/JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null
* [new branch] JY-20478-stop-sync-calendar-emails -> origin/JY-20478-stop-sync-calendar-emails
d4d05c775b..b11048beed JY-20541-cleanup-stale-tasks-and-events -> origin/JY-20541-cleanup-stale-tasks-and-events
10d290c778..a250abe939 JY-20663-partner-rockeed -> origin/JY-20663-partner-rockeed
* [new branch] JY-20713-activity-sync-job-restart -> origin/JY-20713-activity-sync-job-restart
242cf1b554..96a22e59f2 JY-9712-change-forever-nudges-to-1-year-expiration -> origin/JY-9712-change-forever-nudges-to-1-year-expiration
* [new branch] fix-close-missing-logger-error -> origin/fix-close-missing-logger-error
0dd5b23990..60fa1787c1 master -> origin/master
f044edca5b..e7e0e50b27 secfix/npm-20260416 -> origin/secfix/npm-20260416
* [new branch] secfix/npm-20260423 -> origin/secfix/npm-20260423
Updating c3c8d86b22..68bb20c72a
Fast-forward
Makefile | 5 +
app/Component/Activity/Services/UpdateActivityService.php | 5 +
app/Component/ActivitySearch/FilterDefinition/ActivityUpdatedDate.php | 7 +-
app/Component/ActivitySearch/Service/ActivitySearch.php | 15 ++
app/Component/AiCallScoring/Services/GenerateAiCallScoringService.php | 6 +
app/Component/AiCallScoring/Services/GetAiCallScoringService.php | 5 +-
app/Component/AiCallScoring/Transformers/AiCallScoringTransformer.php | 2 +-
app/Component/ProphetAi/ProphetClient.php | 5 +
app/Console/Commands/Crm/SyncHubspotObjects.php | 84 +++++++++++
app/Console/Commands/Crm/SyncObjects.php | 82 ++++++-----
app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php | 81 +++++++++++
app/Console/Commands/Reports/AutomatedReportsCommand.php | 91 +++++++++++-
app/Console/Commands/Reports/AutomatedReportsSendCommand.php | 40 +++++-
app/Console/Kernel.php | 4 +
app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php | 15 ++
app/Contracts/Services/Crm/Provider/SalesforceInterface.php | 12 +-
app/Contracts/Services/Crm/ServiceInterface.php | 29 ----
app/Contracts/Services/Crm/SyncCrmMetadataInterface.php | 6 +-
app/Events/AutomatedReports/AutomatedReportGenerated.php | 15 ++
app/Http/Controllers/API/CrmController.php | 19 ++-
app/Http/Controllers/API/UserAutomatedReports/UserAutomatedReportsController.php | 33 ++++-
app/Http/Controllers/Internal/WebhookReceiver/HubspotController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/EventsController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTrait.php | 64 ++++++---
app/Http/Controllers/Webhook/ReportController.php | 5 +
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRuleRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/TestAiCallScoringPromptRequest.php | 2 +-
app/Jobs/Activity/SyncActivity.php | 3 +-
app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php | 210 ++++++++++++++++++++++++++++
app/Jobs/AutomatedReports/SendReportJob.php | 2 +
app/Jobs/AutomatedReports/SendReportMailJob.php | 6 +-
app/Jobs/Crm/SyncActivity.php | 10 ++
app/Jobs/Crm/SyncHubspotObjects.php | 120 ++++++++++++++++
app/Jobs/Crm/SyncObjects.php | 26 ++--
app/Jobs/Crm/SyncTeamMetadata.php | 14 +-
app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php | 82 +++++++++++
app/Listeners/Crm/ResolveOwner.php | 21 +--
app/Mail/Reports/ReportWithAttachment.php | 7 +-
app/Models/Ai/AiScorecardRuleRun.php | 4 +-
app/Models/Ai/AiScorecardRun.php | 4 +-
app/Models/Contracts/UserContract.php | 6 +
app/Providers/EventServiceProvider.php | 4 +
app/Repositories/AutomatedReportsRepository.php | 76 +++++++++-
app/Repositories/Crm/CrmEntityRepository.php | 40 ++++++
app/Services/Crm/BaseService.php | 13 --
app/Services/Crm/Bullhorn/BullhornService.php | 21 ---
app/Services/Crm/Close/Service.php | 38 -----
app/Services/Crm/Copper/Service.php | 37 -----
app/Services/Crm/Dummy/Service.php | 25 ----
app/Services/Crm/Hubspot/Service.php | 37 -----
app/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTrait.php | 174 +++++++++++++++++------
app/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTrait.php | 27 ++--
app/Services/Crm/IntegrationApp/Service.php | 2 +
app/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTrait.php | 12 +-
app/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTrait.php | 5 -
app/Services/Crm/Pipedrive/Service.php | 43 +-----
app/Services/Crm/Salesforce/Service.php | 13 +-
app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php | 143 +++++++++++++++++++
app/Services/Kiosk/AutomatedReports/AutomatedReportsService.php | 222 +++++++++++++++++++++++++----
front-end/package.json | 2 +-
front-end/src/__mocks__/kit/endpoints/team-insights.js | 1 +
front-end/src/components/AiReports/AiReports.vue | 9 +-
front-end/src/components/AiReports/GridCells/ActionsCell.vue | 107 +++++++++++---
front-end/src/components/AiReports/GridCells/NameCell.vue | 13 +-
front-end/src/components/AiReports/GridCells/TypeIndicator.vue | 26 ++--
front-end/src/components/AiReports/Manage/CreateDefinition/CreateDefinitionDrawer.vue | 4 +-
front-end/src/components/AiReports/Manage/ExpiringCell.vue | 86 ++++++++++++
front-end/src/components/AiReports/Manage/ManageAiReports.less | 6 +
front-end/src/components/AiReports/Manage/ManageAiReports.vue | 6 +-
front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js | 116 +++++++++++++++
front-end/src/components/AiReports/Manage/__tests__/ManageAiReports.spec.js | 32 +++--
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/create-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/edit-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/manage-ai-reports.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/gridConfig.js | 12 +-
front-end/src/components/AiReports/__tests__/AiReports.spec.js | 45 +++++-
front-end/src/components/AiReports/__tests__/__mocks__/data.js | 49 +++++++
front-end/src/components/AiReports/__tests__/__mocks__/requestHandlers.js | 3 +
front-end/src/components/AiReports/__tests__/__snapshots__/ai-reports.output.html | 319 +++++++++++++++++++++++++++++++++++++++++-
front-end/src/components/AiReports/constants.js | 1 +
front-end/src/components/AiReports/gridConfig.js | 2 +-
front-end/src/components/AiReports/useAiReportsGrid.js | 27 ++++
front-end/src/components/Settings/Kiosk/AutomatedReports/RecipientsCell.vue | 36 ++++-
front-end/src/components/Settings/Kiosk/AutomatedReports/UsersCell.vue | 9 +-
front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js | 171 ++++++++++++++++++++++
front-end/src/components/Settings/OrgSettings/AiAutomation/CallScoring/ScorecardRuleForm.vue | 2 +-
front-end/src/components/TeamInsights/CoachingFrameworks/AICallScoring/aiCallScoringOverTime.ts | 18 ++-
front-end/src/components/shared/GridView/useOrder.js | 6 +-
front-end/src/components/shared/GridView/usePaginationList.js | 7 +-
front-end/yarn.lock | 8 +-
resources/views/emails/reports/ask-jiminny-report-generated.blade.php | 25 ++++
routes/api.php | 1 +
tests/Unit/Component/Activity/Services/UpdateActivityServiceTest.php | 62 ++++++++
tests/Unit/Component/AiCallScoring/Services/GenerateAiCallScoringServiceTest.php | 13 +-
tests/Unit/Console/Commands/Reports/AutomatedReportsCommandTest.php | 468 ++++++++++++++++++++++++++++++++++++++++++-------------------
tests/Unit/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTraitTest.php | 5 +-
tests/Unit/Http/Controllers/Webhook/ReportControllerTest.php | 9 +-
tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php | 407 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncActivityTest.php | 74 +++++++---
tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php | 455 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncTeamMetadataTest.php | 8 +-
tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php | 199 ++++++++++++++++++++++++++
tests/Unit/Listeners/Crm/ResolveOwnerTest.php | 64 ++++-----
tests/Unit/Repositories/AutomatedReportsRepositoryTest.php | 55 ++++++++
tests/Unit/Services/Crm/Copper/ServiceTest.php | 19 ---
tests/Unit/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTest.php | 74 ++++++----
tests/Unit/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTraitTest.php | 8 +-
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTraitTest.php | 76 ++--------
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTraitTest.php | 5 -
tests/Unit/Services/Crm/Pipedrive/ServiceTest.php | 11 --
tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php | 430 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Services/Kiosk/AutomatedReports/AutomatedReportsServiceTest.php | 521 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
113 files changed, 5468 insertions(+), 980 deletions(-)
create mode 100644 app/Console/Commands/Crm/SyncHubspotObjects.php
create mode 100644 app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php
create mode 100644 app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php
create mode 100644 app/Events/AutomatedReports/AutomatedReportGenerated.php
create mode 100644 app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php
create mode 100644 app/Jobs/Crm/SyncHubspotObjects.php
create mode 100644 app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php
create mode 100644 app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php
create mode 100644 front-end/src/components/AiReports/Manage/ExpiringCell.vue
create mode 100644 front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js
create mode 100644 front-end/src/components/AiReports/constants.js
create mode 100644 front-end/src/components/AiReports/useAiReportsGrid.js
create mode 100644 front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js
create mode 100644 resources/views/emails/reports/ask-jiminny-report-generated.blade.php
create mode 100644 tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php
create mode 100644 tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php
create mode 100644 tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php
create mode 100644 tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Http/Transformers/UserTransformer.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Repositories/AutomatedReportsRepository.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
modified: tests/Unit/Repositories/AutomatedReportsRepositoryTest.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5613/5613 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Console/Commands/JiminnyDebugCommand.php (braces_position, statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
+++ /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
@@ -37,15 +37,14 @@
JobDispatcherInterface $jobDispatcher,
AutomatedReportsService $automatedReportsService,
AutomatedReportsRepository $automatedReportsRepository,
- ): void
- {
-// $user = User::find(143);
-// $count = $automatedReportsRepository->countUserReports($user);
-// $this->info("Count: {$count}");
-// $count = $automatedReportsRepository->countAllUserReports($user);
-// $this->info("All count: {$count}");
-//
-// exit(1);
+ ): void {
+ // $user = User::find(143);
+ // $count = $automatedReportsRepository->countUserReports($user);
+ // $this->info("Count: {$count}");
+ // $count = $automatedReportsRepository->countAllUserReports($user);
+ // $this->info("All count: {$count}");
+ //
+ // exit(1);
$now = Carbon::now()->subDay(1);
$this->info("Now: {$now->toDateTimeString()}");
@@ -52,18 +51,18 @@
$weekStart = Carbon::getWeekStartsAt();
$this->info("Now: {$weekStart}");
-// $from = $now->copy()->previousWeekday()->startOfDay();
-// $to = $now->copy()->previousWeekday()->endOfDay();
+ // $from = $now->copy()->previousWeekday()->startOfDay();
+ // $to = $now->copy()->previousWeekday()->endOfDay();
-// $fromOld = $now->copy()->subWeeks(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subWeek()->startOfWeek();
-// $toNew = $now->copy()->subWeek()->endOfWeek();
+ // $fromOld = $now->copy()->subWeeks(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subWeek()->startOfWeek();
+ // $toNew = $now->copy()->subWeek()->endOfWeek();
-// $fromOld = $now->copy()->subMonths(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
-// $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
+ // $fromOld = $now->copy()->subMonths(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
+ // $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
$fromOld = $now->copy()->subMonths(3)->startOfDay();
$toOld = $now->copy()->subDay()->endOfDay();
----------- end diff -----------
Fixed 1 of 5613 files in 66.818 seconds, 67.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 65.183 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 40.863 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 53, done.
remote: Counting objects: 100% (53/53), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 53 (delta 33), reused 49 (delta 30), pack-reused 0 (from 0)
Unpacking objects: 100% (53/53), 46.00 KiB | 523.00 KiB/s, done.
From github.com:jiminny/app
b1d5c77ad1..dfc8da14d2 JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
+ 47037d2c29...5138acf14e secfix/npm-20260423 -> origin/secfix/npm-20260423 (forced update)
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20738-debug-AJ-tracking-UP
Switched to a new branch 'JY-20738-debug-AJ-tracking-UP'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5621/5621 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5621 files in 22.942 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at https://docs.docker.com/go/debug-cli/
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ gbr
* JY-20738-debug-AJ-tracking-UP
JY-20157-AJ-report-not-send-notification
master
JY-20372-ai-reports-promotion-pages
JY-18909-automated-reports-ask-jiminny
JY-20692-fix-integration-app-[API_KEY]
JY-20553-debug-crm-sync-delays
JY-20698-fix-SF-activity-types-on-new-playbook
JY-20543-AJ-report-tracking
JY-20384-handle-auto-sync-with-no-access-to-event-type
JY-20458-ask-jiminny-user-definitions
JY-19666-fix-import-contacts-account-association
JY-19666-HS-import-contacts-and-accounts-batch-job
JY-20458-Ask-Jiminny-Reports
JY-20200-batch-update-CRM-objects-Salesforce
JY-19666-HS-webhooks-add-contact-and-company
JY-20348-trigger-setup-DI-layout-on-team-creation
JY-20326-refactor-info-message-in-command
JY-20317-fix-auto-log-delay-issue-on-all-channels-disabled
JY-20312-remove-on-update-change-last-synced-at-crm-configurations
JY-20306-SF-skip-auto-sync-for-task-based-playbook
JY-20192-remove-deleted-team-from-saved-search-filters
JY-20197-import-opportunity-batch-job
JY-20293-enable-status-field-for-pipedrive-deals
JY-20191-remove-commands-interactive-prompts
JY-20118-change-default-sync-strategy
JY-20183-add-cache-on-auto-log-delay
JY-20197-add-import-opportunity-batch-job
20118-hs-opportunity-make-webhook-strategy-default
JY-20118-make-default-hs-opportunity-sync-strategy-webhook-based
JY-20196-handle-opportunity-without-note
JY-20118-improve-opportunity-import
JY-20189-handle-activity-search-on-deleted-groups
JY-20160
JY-20145-filter-out-converted-leads-when-matching
JY-20150-skip-push-summary-on-summary-ready-if-autolog
JY-20132-fix-note-encoding
JY-19792-clean-logs
JY-20117-fix-sync-profile-fields-on-empty-fields
JY-20027-extend-email-import-to-all-crm-objects
JY-20017-fix-hubspot-webhooks-processing
JY-20026-convert-lead-activities
JY-19501-hs-crm-sync-optimized
JY-19220-assign-activities-on-new-opportunity
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ co JY-20157-AJ-report-not-send...
|
iTerm2
|
APP (-zsh)
|
NULL
|
77595
|
|
Last login: Thu Apr 23 14:01:28 on ttys007
Poetry Last login: Thu Apr 23 14:01:28 on ttys007
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20157-AJ-report-not-send-notification
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git pull
remote: Enumerating objects: 1015, done.
remote: Counting objects: 100% (262/262), done.
remote: Compressing objects: 100% (143/143), done.
remote: Total 1015 (delta 167), reused 129 (delta 119), pack-reused 753 (from 3)
Receiving objects: 100% (1015/1015), 851.14 KiB | 2.09 MiB/s, done.
Resolving deltas: 100% (613/613), completed with 65 local objects.
From github.com:jiminny/app
c3c8d86b22..68bb20c72a JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
3ac71c265a..595c95b7e0 JY-19995-delete-leftover-tracks-command -> origin/JY-19995-delete-leftover-tracks-command
* [new branch] JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null -> origin/JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null
* [new branch] JY-20478-stop-sync-calendar-emails -> origin/JY-20478-stop-sync-calendar-emails
d4d05c775b..b11048beed JY-20541-cleanup-stale-tasks-and-events -> origin/JY-20541-cleanup-stale-tasks-and-events
10d290c778..a250abe939 JY-20663-partner-rockeed -> origin/JY-20663-partner-rockeed
* [new branch] JY-20713-activity-sync-job-restart -> origin/JY-20713-activity-sync-job-restart
242cf1b554..96a22e59f2 JY-9712-change-forever-nudges-to-1-year-expiration -> origin/JY-9712-change-forever-nudges-to-1-year-expiration
* [new branch] fix-close-missing-logger-error -> origin/fix-close-missing-logger-error
0dd5b23990..60fa1787c1 master -> origin/master
f044edca5b..e7e0e50b27 secfix/npm-20260416 -> origin/secfix/npm-20260416
* [new branch] secfix/npm-20260423 -> origin/secfix/npm-20260423
Updating c3c8d86b22..68bb20c72a
Fast-forward
Makefile | 5 +
app/Component/Activity/Services/UpdateActivityService.php | 5 +
app/Component/ActivitySearch/FilterDefinition/ActivityUpdatedDate.php | 7 +-
app/Component/ActivitySearch/Service/ActivitySearch.php | 15 ++
app/Component/AiCallScoring/Services/GenerateAiCallScoringService.php | 6 +
app/Component/AiCallScoring/Services/GetAiCallScoringService.php | 5 +-
app/Component/AiCallScoring/Transformers/AiCallScoringTransformer.php | 2 +-
app/Component/ProphetAi/ProphetClient.php | 5 +
app/Console/Commands/Crm/SyncHubspotObjects.php | 84 +++++++++++
app/Console/Commands/Crm/SyncObjects.php | 82 ++++++-----
app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php | 81 +++++++++++
app/Console/Commands/Reports/AutomatedReportsCommand.php | 91 +++++++++++-
app/Console/Commands/Reports/AutomatedReportsSendCommand.php | 40 +++++-
app/Console/Kernel.php | 4 +
app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php | 15 ++
app/Contracts/Services/Crm/Provider/SalesforceInterface.php | 12 +-
app/Contracts/Services/Crm/ServiceInterface.php | 29 ----
app/Contracts/Services/Crm/SyncCrmMetadataInterface.php | 6 +-
app/Events/AutomatedReports/AutomatedReportGenerated.php | 15 ++
app/Http/Controllers/API/CrmController.php | 19 ++-
app/Http/Controllers/API/UserAutomatedReports/UserAutomatedReportsController.php | 33 ++++-
app/Http/Controllers/Internal/WebhookReceiver/HubspotController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/EventsController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTrait.php | 64 ++++++---
app/Http/Controllers/Webhook/ReportController.php | 5 +
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRuleRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/TestAiCallScoringPromptRequest.php | 2 +-
app/Jobs/Activity/SyncActivity.php | 3 +-
app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php | 210 ++++++++++++++++++++++++++++
app/Jobs/AutomatedReports/SendReportJob.php | 2 +
app/Jobs/AutomatedReports/SendReportMailJob.php | 6 +-
app/Jobs/Crm/SyncActivity.php | 10 ++
app/Jobs/Crm/SyncHubspotObjects.php | 120 ++++++++++++++++
app/Jobs/Crm/SyncObjects.php | 26 ++--
app/Jobs/Crm/SyncTeamMetadata.php | 14 +-
app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php | 82 +++++++++++
app/Listeners/Crm/ResolveOwner.php | 21 +--
app/Mail/Reports/ReportWithAttachment.php | 7 +-
app/Models/Ai/AiScorecardRuleRun.php | 4 +-
app/Models/Ai/AiScorecardRun.php | 4 +-
app/Models/Contracts/UserContract.php | 6 +
app/Providers/EventServiceProvider.php | 4 +
app/Repositories/AutomatedReportsRepository.php | 76 +++++++++-
app/Repositories/Crm/CrmEntityRepository.php | 40 ++++++
app/Services/Crm/BaseService.php | 13 --
app/Services/Crm/Bullhorn/BullhornService.php | 21 ---
app/Services/Crm/Close/Service.php | 38 -----
app/Services/Crm/Copper/Service.php | 37 -----
app/Services/Crm/Dummy/Service.php | 25 ----
app/Services/Crm/Hubspot/Service.php | 37 -----
app/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTrait.php | 174 +++++++++++++++++------
app/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTrait.php | 27 ++--
app/Services/Crm/IntegrationApp/Service.php | 2 +
app/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTrait.php | 12 +-
app/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTrait.php | 5 -
app/Services/Crm/Pipedrive/Service.php | 43 +-----
app/Services/Crm/Salesforce/Service.php | 13 +-
app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php | 143 +++++++++++++++++++
app/Services/Kiosk/AutomatedReports/AutomatedReportsService.php | 222 +++++++++++++++++++++++++----
front-end/package.json | 2 +-
front-end/src/__mocks__/kit/endpoints/team-insights.js | 1 +
front-end/src/components/AiReports/AiReports.vue | 9 +-
front-end/src/components/AiReports/GridCells/ActionsCell.vue | 107 +++++++++++---
front-end/src/components/AiReports/GridCells/NameCell.vue | 13 +-
front-end/src/components/AiReports/GridCells/TypeIndicator.vue | 26 ++--
front-end/src/components/AiReports/Manage/CreateDefinition/CreateDefinitionDrawer.vue | 4 +-
front-end/src/components/AiReports/Manage/ExpiringCell.vue | 86 ++++++++++++
front-end/src/components/AiReports/Manage/ManageAiReports.less | 6 +
front-end/src/components/AiReports/Manage/ManageAiReports.vue | 6 +-
front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js | 116 +++++++++++++++
front-end/src/components/AiReports/Manage/__tests__/ManageAiReports.spec.js | 32 +++--
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/create-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/edit-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/manage-ai-reports.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/gridConfig.js | 12 +-
front-end/src/components/AiReports/__tests__/AiReports.spec.js | 45 +++++-
front-end/src/components/AiReports/__tests__/__mocks__/data.js | 49 +++++++
front-end/src/components/AiReports/__tests__/__mocks__/requestHandlers.js | 3 +
front-end/src/components/AiReports/__tests__/__snapshots__/ai-reports.output.html | 319 +++++++++++++++++++++++++++++++++++++++++-
front-end/src/components/AiReports/constants.js | 1 +
front-end/src/components/AiReports/gridConfig.js | 2 +-
front-end/src/components/AiReports/useAiReportsGrid.js | 27 ++++
front-end/src/components/Settings/Kiosk/AutomatedReports/RecipientsCell.vue | 36 ++++-
front-end/src/components/Settings/Kiosk/AutomatedReports/UsersCell.vue | 9 +-
front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js | 171 ++++++++++++++++++++++
front-end/src/components/Settings/OrgSettings/AiAutomation/CallScoring/ScorecardRuleForm.vue | 2 +-
front-end/src/components/TeamInsights/CoachingFrameworks/AICallScoring/aiCallScoringOverTime.ts | 18 ++-
front-end/src/components/shared/GridView/useOrder.js | 6 +-
front-end/src/components/shared/GridView/usePaginationList.js | 7 +-
front-end/yarn.lock | 8 +-
resources/views/emails/reports/ask-jiminny-report-generated.blade.php | 25 ++++
routes/api.php | 1 +
tests/Unit/Component/Activity/Services/UpdateActivityServiceTest.php | 62 ++++++++
tests/Unit/Component/AiCallScoring/Services/GenerateAiCallScoringServiceTest.php | 13 +-
tests/Unit/Console/Commands/Reports/AutomatedReportsCommandTest.php | 468 ++++++++++++++++++++++++++++++++++++++++++-------------------
tests/Unit/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTraitTest.php | 5 +-
tests/Unit/Http/Controllers/Webhook/ReportControllerTest.php | 9 +-
tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php | 407 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncActivityTest.php | 74 +++++++---
tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php | 455 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncTeamMetadataTest.php | 8 +-
tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php | 199 ++++++++++++++++++++++++++
tests/Unit/Listeners/Crm/ResolveOwnerTest.php | 64 ++++-----
tests/Unit/Repositories/AutomatedReportsRepositoryTest.php | 55 ++++++++
tests/Unit/Services/Crm/Copper/ServiceTest.php | 19 ---
tests/Unit/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTest.php | 74 ++++++----
tests/Unit/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTraitTest.php | 8 +-
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTraitTest.php | 76 ++--------
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTraitTest.php | 5 -
tests/Unit/Services/Crm/Pipedrive/ServiceTest.php | 11 --
tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php | 430 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Services/Kiosk/AutomatedReports/AutomatedReportsServiceTest.php | 521 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
113 files changed, 5468 insertions(+), 980 deletions(-)
create mode 100644 app/Console/Commands/Crm/SyncHubspotObjects.php
create mode 100644 app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php
create mode 100644 app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php
create mode 100644 app/Events/AutomatedReports/AutomatedReportGenerated.php
create mode 100644 app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php
create mode 100644 app/Jobs/Crm/SyncHubspotObjects.php
create mode 100644 app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php
create mode 100644 app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php
create mode 100644 front-end/src/components/AiReports/Manage/ExpiringCell.vue
create mode 100644 front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js
create mode 100644 front-end/src/components/AiReports/constants.js
create mode 100644 front-end/src/components/AiReports/useAiReportsGrid.js
create mode 100644 front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js
create mode 100644 resources/views/emails/reports/ask-jiminny-report-generated.blade.php
create mode 100644 tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php
create mode 100644 tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php
create mode 100644 tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php
create mode 100644 tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Http/Transformers/UserTransformer.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Repositories/AutomatedReportsRepository.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
modified: tests/Unit/Repositories/AutomatedReportsRepositoryTest.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5613/5613 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Console/Commands/JiminnyDebugCommand.php (braces_position, statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
+++ /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
@@ -37,15 +37,14 @@
JobDispatcherInterface $jobDispatcher,
AutomatedReportsService $automatedReportsService,
AutomatedReportsRepository $automatedReportsRepository,
- ): void
- {
-// $user = User::find(143);
-// $count = $automatedReportsRepository->countUserReports($user);
-// $this->info("Count: {$count}");
-// $count = $automatedReportsRepository->countAllUserReports($user);
-// $this->info("All count: {$count}");
-//
-// exit(1);
+ ): void {
+ // $user = User::find(143);
+ // $count = $automatedReportsRepository->countUserReports($user);
+ // $this->info("Count: {$count}");
+ // $count = $automatedReportsRepository->countAllUserReports($user);
+ // $this->info("All count: {$count}");
+ //
+ // exit(1);
$now = Carbon::now()->subDay(1);
$this->info("Now: {$now->toDateTimeString()}");
@@ -52,18 +51,18 @@
$weekStart = Carbon::getWeekStartsAt();
$this->info("Now: {$weekStart}");
-// $from = $now->copy()->previousWeekday()->startOfDay();
-// $to = $now->copy()->previousWeekday()->endOfDay();
+ // $from = $now->copy()->previousWeekday()->startOfDay();
+ // $to = $now->copy()->previousWeekday()->endOfDay();
-// $fromOld = $now->copy()->subWeeks(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subWeek()->startOfWeek();
-// $toNew = $now->copy()->subWeek()->endOfWeek();
+ // $fromOld = $now->copy()->subWeeks(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subWeek()->startOfWeek();
+ // $toNew = $now->copy()->subWeek()->endOfWeek();
-// $fromOld = $now->copy()->subMonths(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
-// $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
+ // $fromOld = $now->copy()->subMonths(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
+ // $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
$fromOld = $now->copy()->subMonths(3)->startOfDay();
$toOld = $now->copy()->subDay()->endOfDay();
----------- end diff -----------
Fixed 1 of 5613 files in 66.818 seconds, 67.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 65.183 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 40.863 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 53, done.
remote: Counting objects: 100% (53/53), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 53 (delta 33), reused 49 (delta 30), pack-reused 0 (from 0)
Unpacking objects: 100% (53/53), 46.00 KiB | 523.00 KiB/s, done.
From github.com:jiminny/app
b1d5c77ad1..dfc8da14d2 JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
+ 47037d2c29...5138acf14e secfix/npm-20260423 -> origin/secfix/npm-20260423 (forced update)
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20738-debug-AJ-tracking-UP
Switched to a new branch 'JY-20738-debug-AJ-tracking-UP'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5621/5621 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5621 files in 22.942 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at https://docs.docker.com/go/debug-cli/
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ gbr
* JY-20738-debug-AJ-tracking-UP
JY-20157-AJ-report-not-send-notification
master
JY-20372-ai-reports-promotion-pages
JY-18909-automated-reports-ask-jiminny
JY-20692-fix-integration-app-[API_KEY]
JY-20553-debug-crm-sync-delays
JY-20698-fix-SF-activity-types-on-new-playbook
JY-20543-AJ-report-tracking
JY-20384-handle-auto-sync-with-no-access-to-event-type
JY-20458-ask-jiminny-user-definitions
JY-19666-fix-import-contacts-account-association
JY-19666-HS-import-contacts-and-accounts-batch-job
JY-20458-Ask-Jiminny-Reports
JY-20200-batch-update-CRM-objects-Salesforce
JY-19666-HS-webhooks-add-contact-and-company
JY-20348-trigger-setup-DI-layout-on-team-creation
JY-20326-refactor-info-message-in-command
JY-20317-fix-auto-log-delay-issue-on-all-channels-disabled
JY-20312-remove-on-update-change-last-synced-at-crm-configurations
JY-20306-SF-skip-auto-sync-for-task-based-playbook
JY-20192-remove-deleted-team-from-saved-search-filters
JY-20197-import-opportunity-batch-job
JY-20293-enable-status-field-for-pipedrive-deals
JY-20191-remove-commands-interactive-prompts
JY-20118-change-default-sync-strategy
JY-20183-add-cache-on-auto-log-delay
JY-20197-add-import-opportunity-batch-job
20118-hs-opportunity-make-webhook-strategy-default
JY-20118-make-default-hs-opportunity-sync-strategy-webhook-based
JY-20196-handle-opportunity-without-note
JY-20118-improve-opportunity-import
JY-20189-handle-activity-search-on-deleted-groups
JY-20160
JY-20145-filter-out-converted-leads-when-matching
JY-20150-skip-push-summary-on-summary-ready-if-autolog
JY-20132-fix-note-encoding
JY-19792-clean-logs
JY-20117-fix-sync-profile-fields-on-empty-fields
JY-20027-extend-email-import-to-all-crm-objects
JY-20017-fix-hubspot-webhooks-processing
JY-20026-convert-lead-activities
JY-19501-hs-crm-sync-optimized
JY-19220-assign-activities-on-new-opportunity
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ co JY-20157-AJ-report-not-send...
|
iTerm2
|
APP (-zsh)
|
NULL
|
77596
|
|
Last login: Thu Apr 23 14:01:28 on ttys007
Poetry Last login: Thu Apr 23 14:01:28 on ttys007
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20157-AJ-report-not-send-notification
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git pull
remote: Enumerating objects: 1015, done.
remote: Counting objects: 100% (262/262), done.
remote: Compressing objects: 100% (143/143), done.
remote: Total 1015 (delta 167), reused 129 (delta 119), pack-reused 753 (from 3)
Receiving objects: 100% (1015/1015), 851.14 KiB | 2.09 MiB/s, done.
Resolving deltas: 100% (613/613), completed with 65 local objects.
From github.com:jiminny/app
c3c8d86b22..68bb20c72a JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
3ac71c265a..595c95b7e0 JY-19995-delete-leftover-tracks-command -> origin/JY-19995-delete-leftover-tracks-command
* [new branch] JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null -> origin/JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null
* [new branch] JY-20478-stop-sync-calendar-emails -> origin/JY-20478-stop-sync-calendar-emails
d4d05c775b..b11048beed JY-20541-cleanup-stale-tasks-and-events -> origin/JY-20541-cleanup-stale-tasks-and-events
10d290c778..a250abe939 JY-20663-partner-rockeed -> origin/JY-20663-partner-rockeed
* [new branch] JY-20713-activity-sync-job-restart -> origin/JY-20713-activity-sync-job-restart
242cf1b554..96a22e59f2 JY-9712-change-forever-nudges-to-1-year-expiration -> origin/JY-9712-change-forever-nudges-to-1-year-expiration
* [new branch] fix-close-missing-logger-error -> origin/fix-close-missing-logger-error
0dd5b23990..60fa1787c1 master -> origin/master
f044edca5b..e7e0e50b27 secfix/npm-20260416 -> origin/secfix/npm-20260416
* [new branch] secfix/npm-20260423 -> origin/secfix/npm-20260423
Updating c3c8d86b22..68bb20c72a
Fast-forward
Makefile | 5 +
app/Component/Activity/Services/UpdateActivityService.php | 5 +
app/Component/ActivitySearch/FilterDefinition/ActivityUpdatedDate.php | 7 +-
app/Component/ActivitySearch/Service/ActivitySearch.php | 15 ++
app/Component/AiCallScoring/Services/GenerateAiCallScoringService.php | 6 +
app/Component/AiCallScoring/Services/GetAiCallScoringService.php | 5 +-
app/Component/AiCallScoring/Transformers/AiCallScoringTransformer.php | 2 +-
app/Component/ProphetAi/ProphetClient.php | 5 +
app/Console/Commands/Crm/SyncHubspotObjects.php | 84 +++++++++++
app/Console/Commands/Crm/SyncObjects.php | 82 ++++++-----
app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php | 81 +++++++++++
app/Console/Commands/Reports/AutomatedReportsCommand.php | 91 +++++++++++-
app/Console/Commands/Reports/AutomatedReportsSendCommand.php | 40 +++++-
app/Console/Kernel.php | 4 +
app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php | 15 ++
app/Contracts/Services/Crm/Provider/SalesforceInterface.php | 12 +-
app/Contracts/Services/Crm/ServiceInterface.php | 29 ----
app/Contracts/Services/Crm/SyncCrmMetadataInterface.php | 6 +-
app/Events/AutomatedReports/AutomatedReportGenerated.php | 15 ++
app/Http/Controllers/API/CrmController.php | 19 ++-
app/Http/Controllers/API/UserAutomatedReports/UserAutomatedReportsController.php | 33 ++++-
app/Http/Controllers/Internal/WebhookReceiver/HubspotController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/EventsController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTrait.php | 64 ++++++---
app/Http/Controllers/Webhook/ReportController.php | 5 +
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRuleRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/TestAiCallScoringPromptRequest.php | 2 +-
app/Jobs/Activity/SyncActivity.php | 3 +-
app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php | 210 ++++++++++++++++++++++++++++
app/Jobs/AutomatedReports/SendReportJob.php | 2 +
app/Jobs/AutomatedReports/SendReportMailJob.php | 6 +-
app/Jobs/Crm/SyncActivity.php | 10 ++
app/Jobs/Crm/SyncHubspotObjects.php | 120 ++++++++++++++++
app/Jobs/Crm/SyncObjects.php | 26 ++--
app/Jobs/Crm/SyncTeamMetadata.php | 14 +-
app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php | 82 +++++++++++
app/Listeners/Crm/ResolveOwner.php | 21 +--
app/Mail/Reports/ReportWithAttachment.php | 7 +-
app/Models/Ai/AiScorecardRuleRun.php | 4 +-
app/Models/Ai/AiScorecardRun.php | 4 +-
app/Models/Contracts/UserContract.php | 6 +
app/Providers/EventServiceProvider.php | 4 +
app/Repositories/AutomatedReportsRepository.php | 76 +++++++++-
app/Repositories/Crm/CrmEntityRepository.php | 40 ++++++
app/Services/Crm/BaseService.php | 13 --
app/Services/Crm/Bullhorn/BullhornService.php | 21 ---
app/Services/Crm/Close/Service.php | 38 -----
app/Services/Crm/Copper/Service.php | 37 -----
app/Services/Crm/Dummy/Service.php | 25 ----
app/Services/Crm/Hubspot/Service.php | 37 -----
app/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTrait.php | 174 +++++++++++++++++------
app/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTrait.php | 27 ++--
app/Services/Crm/IntegrationApp/Service.php | 2 +
app/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTrait.php | 12 +-
app/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTrait.php | 5 -
app/Services/Crm/Pipedrive/Service.php | 43 +-----
app/Services/Crm/Salesforce/Service.php | 13 +-
app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php | 143 +++++++++++++++++++
app/Services/Kiosk/AutomatedReports/AutomatedReportsService.php | 222 +++++++++++++++++++++++++----
front-end/package.json | 2 +-
front-end/src/__mocks__/kit/endpoints/team-insights.js | 1 +
front-end/src/components/AiReports/AiReports.vue | 9 +-
front-end/src/components/AiReports/GridCells/ActionsCell.vue | 107 +++++++++++---
front-end/src/components/AiReports/GridCells/NameCell.vue | 13 +-
front-end/src/components/AiReports/GridCells/TypeIndicator.vue | 26 ++--
front-end/src/components/AiReports/Manage/CreateDefinition/CreateDefinitionDrawer.vue | 4 +-
front-end/src/components/AiReports/Manage/ExpiringCell.vue | 86 ++++++++++++
front-end/src/components/AiReports/Manage/ManageAiReports.less | 6 +
front-end/src/components/AiReports/Manage/ManageAiReports.vue | 6 +-
front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js | 116 +++++++++++++++
front-end/src/components/AiReports/Manage/__tests__/ManageAiReports.spec.js | 32 +++--
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/create-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/edit-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/manage-ai-reports.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/gridConfig.js | 12 +-
front-end/src/components/AiReports/__tests__/AiReports.spec.js | 45 +++++-
front-end/src/components/AiReports/__tests__/__mocks__/data.js | 49 +++++++
front-end/src/components/AiReports/__tests__/__mocks__/requestHandlers.js | 3 +
front-end/src/components/AiReports/__tests__/__snapshots__/ai-reports.output.html | 319 +++++++++++++++++++++++++++++++++++++++++-
front-end/src/components/AiReports/constants.js | 1 +
front-end/src/components/AiReports/gridConfig.js | 2 +-
front-end/src/components/AiReports/useAiReportsGrid.js | 27 ++++
front-end/src/components/Settings/Kiosk/AutomatedReports/RecipientsCell.vue | 36 ++++-
front-end/src/components/Settings/Kiosk/AutomatedReports/UsersCell.vue | 9 +-
front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js | 171 ++++++++++++++++++++++
front-end/src/components/Settings/OrgSettings/AiAutomation/CallScoring/ScorecardRuleForm.vue | 2 +-
front-end/src/components/TeamInsights/CoachingFrameworks/AICallScoring/aiCallScoringOverTime.ts | 18 ++-
front-end/src/components/shared/GridView/useOrder.js | 6 +-
front-end/src/components/shared/GridView/usePaginationList.js | 7 +-
front-end/yarn.lock | 8 +-
resources/views/emails/reports/ask-jiminny-report-generated.blade.php | 25 ++++
routes/api.php | 1 +
tests/Unit/Component/Activity/Services/UpdateActivityServiceTest.php | 62 ++++++++
tests/Unit/Component/AiCallScoring/Services/GenerateAiCallScoringServiceTest.php | 13 +-
tests/Unit/Console/Commands/Reports/AutomatedReportsCommandTest.php | 468 ++++++++++++++++++++++++++++++++++++++++++-------------------
tests/Unit/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTraitTest.php | 5 +-
tests/Unit/Http/Controllers/Webhook/ReportControllerTest.php | 9 +-
tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php | 407 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncActivityTest.php | 74 +++++++---
tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php | 455 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncTeamMetadataTest.php | 8 +-
tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php | 199 ++++++++++++++++++++++++++
tests/Unit/Listeners/Crm/ResolveOwnerTest.php | 64 ++++-----
tests/Unit/Repositories/AutomatedReportsRepositoryTest.php | 55 ++++++++
tests/Unit/Services/Crm/Copper/ServiceTest.php | 19 ---
tests/Unit/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTest.php | 74 ++++++----
tests/Unit/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTraitTest.php | 8 +-
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTraitTest.php | 76 ++--------
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTraitTest.php | 5 -
tests/Unit/Services/Crm/Pipedrive/ServiceTest.php | 11 --
tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php | 430 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Services/Kiosk/AutomatedReports/AutomatedReportsServiceTest.php | 521 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
113 files changed, 5468 insertions(+), 980 deletions(-)
create mode 100644 app/Console/Commands/Crm/SyncHubspotObjects.php
create mode 100644 app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php
create mode 100644 app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php
create mode 100644 app/Events/AutomatedReports/AutomatedReportGenerated.php
create mode 100644 app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php
create mode 100644 app/Jobs/Crm/SyncHubspotObjects.php
create mode 100644 app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php
create mode 100644 app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php
create mode 100644 front-end/src/components/AiReports/Manage/ExpiringCell.vue
create mode 100644 front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js
create mode 100644 front-end/src/components/AiReports/constants.js
create mode 100644 front-end/src/components/AiReports/useAiReportsGrid.js
create mode 100644 front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js
create mode 100644 resources/views/emails/reports/ask-jiminny-report-generated.blade.php
create mode 100644 tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php
create mode 100644 tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php
create mode 100644 tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php
create mode 100644 tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Http/Transformers/UserTransformer.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Repositories/AutomatedReportsRepository.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
modified: tests/Unit/Repositories/AutomatedReportsRepositoryTest.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5613/5613 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Console/Commands/JiminnyDebugCommand.php (braces_position, statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
+++ /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
@@ -37,15 +37,14 @@
JobDispatcherInterface $jobDispatcher,
AutomatedReportsService $automatedReportsService,
AutomatedReportsRepository $automatedReportsRepository,
- ): void
- {
-// $user = User::find(143);
-// $count = $automatedReportsRepository->countUserReports($user);
-// $this->info("Count: {$count}");
-// $count = $automatedReportsRepository->countAllUserReports($user);
-// $this->info("All count: {$count}");
-//
-// exit(1);
+ ): void {
+ // $user = User::find(143);
+ // $count = $automatedReportsRepository->countUserReports($user);
+ // $this->info("Count: {$count}");
+ // $count = $automatedReportsRepository->countAllUserReports($user);
+ // $this->info("All count: {$count}");
+ //
+ // exit(1);
$now = Carbon::now()->subDay(1);
$this->info("Now: {$now->toDateTimeString()}");
@@ -52,18 +51,18 @@
$weekStart = Carbon::getWeekStartsAt();
$this->info("Now: {$weekStart}");
-// $from = $now->copy()->previousWeekday()->startOfDay();
-// $to = $now->copy()->previousWeekday()->endOfDay();
+ // $from = $now->copy()->previousWeekday()->startOfDay();
+ // $to = $now->copy()->previousWeekday()->endOfDay();
-// $fromOld = $now->copy()->subWeeks(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subWeek()->startOfWeek();
-// $toNew = $now->copy()->subWeek()->endOfWeek();
+ // $fromOld = $now->copy()->subWeeks(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subWeek()->startOfWeek();
+ // $toNew = $now->copy()->subWeek()->endOfWeek();
-// $fromOld = $now->copy()->subMonths(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
-// $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
+ // $fromOld = $now->copy()->subMonths(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
+ // $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
$fromOld = $now->copy()->subMonths(3)->startOfDay();
$toOld = $now->copy()->subDay()->endOfDay();
----------- end diff -----------
Fixed 1 of 5613 files in 66.818 seconds, 67.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 65.183 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 40.863 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 53, done.
remote: Counting objects: 100% (53/53), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 53 (delta 33), reused 49 (delta 30), pack-reused 0 (from 0)
Unpacking objects: 100% (53/53), 46.00 KiB | 523.00 KiB/s, done.
From github.com:jiminny/app
b1d5c77ad1..dfc8da14d2 JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
+ 47037d2c29...5138acf14e secfix/npm-20260423 -> origin/secfix/npm-20260423 (forced update)
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20738-debug-AJ-tracking-UP
Switched to a new branch 'JY-20738-debug-AJ-tracking-UP'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5621/5621 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5621 files in 22.942 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at https://docs.docker.com/go/debug-cli/
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ gbr
* JY-20738-debug-AJ-tracking-UP
JY-20157-AJ-report-not-send-notification
master
JY-20372-ai-reports-promotion-pages
JY-18909-automated-reports-ask-jiminny
JY-20692-fix-integration-app-[API_KEY]
JY-20553-debug-crm-sync-delays
JY-20698-fix-SF-activity-types-on-new-playbook
JY-20543-AJ-report-tracking
JY-20384-handle-auto-sync-with-no-access-to-event-type
JY-20458-ask-jiminny-user-definitions
JY-19666-fix-import-contacts-account-association
JY-19666-HS-import-contacts-and-accounts-batch-job
JY-20458-Ask-Jiminny-Reports
JY-20200-batch-update-CRM-objects-Salesforce
JY-19666-HS-webhooks-add-contact-and-company
JY-20348-trigger-setup-DI-layout-on-team-creation
JY-20326-refactor-info-message-in-command
JY-20317-fix-auto-log-delay-issue-on-all-channels-disabled
JY-20312-remove-on-update-change-last-synced-at-crm-configurations
JY-20306-SF-skip-auto-sync-for-task-based-playbook
JY-20192-remove-deleted-team-from-saved-search-filters
JY-20197-import-opportunity-batch-job
JY-20293-enable-status-field-for-pipedrive-deals
JY-20191-remove-commands-interactive-prompts
JY-20118-change-default-sync-strategy
JY-20183-add-cache-on-auto-log-delay
JY-20197-add-import-opportunity-batch-job
20118-hs-opportunity-make-webhook-strategy-default
JY-20118-make-default-hs-opportunity-sync-strategy-webhook-based
JY-20196-handle-opportunity-without-note
JY-20118-improve-opportunity-import
JY-20189-handle-activity-search-on-deleted-groups
JY-20160
JY-20145-filter-out-converted-leads-when-matching
JY-20150-skip-push-summary-on-summary-ready-if-autolog
JY-20132-fix-note-encoding
JY-19792-clean-logs
JY-20117-fix-sync-profile-fields-on-empty-fields
JY-20027-extend-email-import-to-all-crm-objects
JY-20017-fix-hubspot-webhooks-processing
JY-20026-convert-lead-activities
JY-19501-hs-crm-sync-optimized
JY-19220-assign-activities-on-new-opportunity
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ co JY-20157-AJ-report-not-send...
|
iTerm2
|
APP (-zsh)
|
NULL
|
77597
|
|
Last login: Thu Apr 23 14:01:28 on ttys007
Poetry Last login: Thu Apr 23 14:01:28 on ttys007
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20157-AJ-report-not-send-notification
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git pull
remote: Enumerating objects: 1015, done.
remote: Counting objects: 100% (262/262), done.
remote: Compressing objects: 100% (143/143), done.
remote: Total 1015 (delta 167), reused 129 (delta 119), pack-reused 753 (from 3)
Receiving objects: 100% (1015/1015), 851.14 KiB | 2.09 MiB/s, done.
Resolving deltas: 100% (613/613), completed with 65 local objects.
From github.com:jiminny/app
c3c8d86b22..68bb20c72a JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
3ac71c265a..595c95b7e0 JY-19995-delete-leftover-tracks-command -> origin/JY-19995-delete-leftover-tracks-command
* [new branch] JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null -> origin/JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null
* [new branch] JY-20478-stop-sync-calendar-emails -> origin/JY-20478-stop-sync-calendar-emails
d4d05c775b..b11048beed JY-20541-cleanup-stale-tasks-and-events -> origin/JY-20541-cleanup-stale-tasks-and-events
10d290c778..a250abe939 JY-20663-partner-rockeed -> origin/JY-20663-partner-rockeed
* [new branch] JY-20713-activity-sync-job-restart -> origin/JY-20713-activity-sync-job-restart
242cf1b554..96a22e59f2 JY-9712-change-forever-nudges-to-1-year-expiration -> origin/JY-9712-change-forever-nudges-to-1-year-expiration
* [new branch] fix-close-missing-logger-error -> origin/fix-close-missing-logger-error
0dd5b23990..60fa1787c1 master -> origin/master
f044edca5b..e7e0e50b27 secfix/npm-20260416 -> origin/secfix/npm-20260416
* [new branch] secfix/npm-20260423 -> origin/secfix/npm-20260423
Updating c3c8d86b22..68bb20c72a
Fast-forward
Makefile | 5 +
app/Component/Activity/Services/UpdateActivityService.php | 5 +
app/Component/ActivitySearch/FilterDefinition/ActivityUpdatedDate.php | 7 +-
app/Component/ActivitySearch/Service/ActivitySearch.php | 15 ++
app/Component/AiCallScoring/Services/GenerateAiCallScoringService.php | 6 +
app/Component/AiCallScoring/Services/GetAiCallScoringService.php | 5 +-
app/Component/AiCallScoring/Transformers/AiCallScoringTransformer.php | 2 +-
app/Component/ProphetAi/ProphetClient.php | 5 +
app/Console/Commands/Crm/SyncHubspotObjects.php | 84 +++++++++++
app/Console/Commands/Crm/SyncObjects.php | 82 ++++++-----
app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php | 81 +++++++++++
app/Console/Commands/Reports/AutomatedReportsCommand.php | 91 +++++++++++-
app/Console/Commands/Reports/AutomatedReportsSendCommand.php | 40 +++++-
app/Console/Kernel.php | 4 +
app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php | 15 ++
app/Contracts/Services/Crm/Provider/SalesforceInterface.php | 12 +-
app/Contracts/Services/Crm/ServiceInterface.php | 29 ----
app/Contracts/Services/Crm/SyncCrmMetadataInterface.php | 6 +-
app/Events/AutomatedReports/AutomatedReportGenerated.php | 15 ++
app/Http/Controllers/API/CrmController.php | 19 ++-
app/Http/Controllers/API/UserAutomatedReports/UserAutomatedReportsController.php | 33 ++++-
app/Http/Controllers/Internal/WebhookReceiver/HubspotController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/EventsController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTrait.php | 64 ++++++---
app/Http/Controllers/Webhook/ReportController.php | 5 +
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRuleRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/TestAiCallScoringPromptRequest.php | 2 +-
app/Jobs/Activity/SyncActivity.php | 3 +-
app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php | 210 ++++++++++++++++++++++++++++
app/Jobs/AutomatedReports/SendReportJob.php | 2 +
app/Jobs/AutomatedReports/SendReportMailJob.php | 6 +-
app/Jobs/Crm/SyncActivity.php | 10 ++
app/Jobs/Crm/SyncHubspotObjects.php | 120 ++++++++++++++++
app/Jobs/Crm/SyncObjects.php | 26 ++--
app/Jobs/Crm/SyncTeamMetadata.php | 14 +-
app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php | 82 +++++++++++
app/Listeners/Crm/ResolveOwner.php | 21 +--
app/Mail/Reports/ReportWithAttachment.php | 7 +-
app/Models/Ai/AiScorecardRuleRun.php | 4 +-
app/Models/Ai/AiScorecardRun.php | 4 +-
app/Models/Contracts/UserContract.php | 6 +
app/Providers/EventServiceProvider.php | 4 +
app/Repositories/AutomatedReportsRepository.php | 76 +++++++++-
app/Repositories/Crm/CrmEntityRepository.php | 40 ++++++
app/Services/Crm/BaseService.php | 13 --
app/Services/Crm/Bullhorn/BullhornService.php | 21 ---
app/Services/Crm/Close/Service.php | 38 -----
app/Services/Crm/Copper/Service.php | 37 -----
app/Services/Crm/Dummy/Service.php | 25 ----
app/Services/Crm/Hubspot/Service.php | 37 -----
app/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTrait.php | 174 +++++++++++++++++------
app/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTrait.php | 27 ++--
app/Services/Crm/IntegrationApp/Service.php | 2 +
app/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTrait.php | 12 +-
app/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTrait.php | 5 -
app/Services/Crm/Pipedrive/Service.php | 43 +-----
app/Services/Crm/Salesforce/Service.php | 13 +-
app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php | 143 +++++++++++++++++++
app/Services/Kiosk/AutomatedReports/AutomatedReportsService.php | 222 +++++++++++++++++++++++++----
front-end/package.json | 2 +-
front-end/src/__mocks__/kit/endpoints/team-insights.js | 1 +
front-end/src/components/AiReports/AiReports.vue | 9 +-
front-end/src/components/AiReports/GridCells/ActionsCell.vue | 107 +++++++++++---
front-end/src/components/AiReports/GridCells/NameCell.vue | 13 +-
front-end/src/components/AiReports/GridCells/TypeIndicator.vue | 26 ++--
front-end/src/components/AiReports/Manage/CreateDefinition/CreateDefinitionDrawer.vue | 4 +-
front-end/src/components/AiReports/Manage/ExpiringCell.vue | 86 ++++++++++++
front-end/src/components/AiReports/Manage/ManageAiReports.less | 6 +
front-end/src/components/AiReports/Manage/ManageAiReports.vue | 6 +-
front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js | 116 +++++++++++++++
front-end/src/components/AiReports/Manage/__tests__/ManageAiReports.spec.js | 32 +++--
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/create-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/edit-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/manage-ai-reports.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/gridConfig.js | 12 +-
front-end/src/components/AiReports/__tests__/AiReports.spec.js | 45 +++++-
front-end/src/components/AiReports/__tests__/__mocks__/data.js | 49 +++++++
front-end/src/components/AiReports/__tests__/__mocks__/requestHandlers.js | 3 +
front-end/src/components/AiReports/__tests__/__snapshots__/ai-reports.output.html | 319 +++++++++++++++++++++++++++++++++++++++++-
front-end/src/components/AiReports/constants.js | 1 +
front-end/src/components/AiReports/gridConfig.js | 2 +-
front-end/src/components/AiReports/useAiReportsGrid.js | 27 ++++
front-end/src/components/Settings/Kiosk/AutomatedReports/RecipientsCell.vue | 36 ++++-
front-end/src/components/Settings/Kiosk/AutomatedReports/UsersCell.vue | 9 +-
front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js | 171 ++++++++++++++++++++++
front-end/src/components/Settings/OrgSettings/AiAutomation/CallScoring/ScorecardRuleForm.vue | 2 +-
front-end/src/components/TeamInsights/CoachingFrameworks/AICallScoring/aiCallScoringOverTime.ts | 18 ++-
front-end/src/components/shared/GridView/useOrder.js | 6 +-
front-end/src/components/shared/GridView/usePaginationList.js | 7 +-
front-end/yarn.lock | 8 +-
resources/views/emails/reports/ask-jiminny-report-generated.blade.php | 25 ++++
routes/api.php | 1 +
tests/Unit/Component/Activity/Services/UpdateActivityServiceTest.php | 62 ++++++++
tests/Unit/Component/AiCallScoring/Services/GenerateAiCallScoringServiceTest.php | 13 +-
tests/Unit/Console/Commands/Reports/AutomatedReportsCommandTest.php | 468 ++++++++++++++++++++++++++++++++++++++++++-------------------
tests/Unit/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTraitTest.php | 5 +-
tests/Unit/Http/Controllers/Webhook/ReportControllerTest.php | 9 +-
tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php | 407 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncActivityTest.php | 74 +++++++---
tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php | 455 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncTeamMetadataTest.php | 8 +-
tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php | 199 ++++++++++++++++++++++++++
tests/Unit/Listeners/Crm/ResolveOwnerTest.php | 64 ++++-----
tests/Unit/Repositories/AutomatedReportsRepositoryTest.php | 55 ++++++++
tests/Unit/Services/Crm/Copper/ServiceTest.php | 19 ---
tests/Unit/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTest.php | 74 ++++++----
tests/Unit/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTraitTest.php | 8 +-
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTraitTest.php | 76 ++--------
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTraitTest.php | 5 -
tests/Unit/Services/Crm/Pipedrive/ServiceTest.php | 11 --
tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php | 430 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Services/Kiosk/AutomatedReports/AutomatedReportsServiceTest.php | 521 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
113 files changed, 5468 insertions(+), 980 deletions(-)
create mode 100644 app/Console/Commands/Crm/SyncHubspotObjects.php
create mode 100644 app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php
create mode 100644 app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php
create mode 100644 app/Events/AutomatedReports/AutomatedReportGenerated.php
create mode 100644 app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php
create mode 100644 app/Jobs/Crm/SyncHubspotObjects.php
create mode 100644 app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php
create mode 100644 app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php
create mode 100644 front-end/src/components/AiReports/Manage/ExpiringCell.vue
create mode 100644 front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js
create mode 100644 front-end/src/components/AiReports/constants.js
create mode 100644 front-end/src/components/AiReports/useAiReportsGrid.js
create mode 100644 front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js
create mode 100644 resources/views/emails/reports/ask-jiminny-report-generated.blade.php
create mode 100644 tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php
create mode 100644 tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php
create mode 100644 tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php
create mode 100644 tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Http/Transformers/UserTransformer.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Repositories/AutomatedReportsRepository.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
modified: tests/Unit/Repositories/AutomatedReportsRepositoryTest.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5613/5613 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Console/Commands/JiminnyDebugCommand.php (braces_position, statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
+++ /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
@@ -37,15 +37,14 @@
JobDispatcherInterface $jobDispatcher,
AutomatedReportsService $automatedReportsService,
AutomatedReportsRepository $automatedReportsRepository,
- ): void
- {
-// $user = User::find(143);
-// $count = $automatedReportsRepository->countUserReports($user);
-// $this->info("Count: {$count}");
-// $count = $automatedReportsRepository->countAllUserReports($user);
-// $this->info("All count: {$count}");
-//
-// exit(1);
+ ): void {
+ // $user = User::find(143);
+ // $count = $automatedReportsRepository->countUserReports($user);
+ // $this->info("Count: {$count}");
+ // $count = $automatedReportsRepository->countAllUserReports($user);
+ // $this->info("All count: {$count}");
+ //
+ // exit(1);
$now = Carbon::now()->subDay(1);
$this->info("Now: {$now->toDateTimeString()}");
@@ -52,18 +51,18 @@
$weekStart = Carbon::getWeekStartsAt();
$this->info("Now: {$weekStart}");
-// $from = $now->copy()->previousWeekday()->startOfDay();
-// $to = $now->copy()->previousWeekday()->endOfDay();
+ // $from = $now->copy()->previousWeekday()->startOfDay();
+ // $to = $now->copy()->previousWeekday()->endOfDay();
-// $fromOld = $now->copy()->subWeeks(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subWeek()->startOfWeek();
-// $toNew = $now->copy()->subWeek()->endOfWeek();
+ // $fromOld = $now->copy()->subWeeks(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subWeek()->startOfWeek();
+ // $toNew = $now->copy()->subWeek()->endOfWeek();
-// $fromOld = $now->copy()->subMonths(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
-// $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
+ // $fromOld = $now->copy()->subMonths(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
+ // $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
$fromOld = $now->copy()->subMonths(3)->startOfDay();
$toOld = $now->copy()->subDay()->endOfDay();
----------- end diff -----------
Fixed 1 of 5613 files in 66.818 seconds, 67.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 65.183 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 40.863 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 53, done.
remote: Counting objects: 100% (53/53), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 53 (delta 33), reused 49 (delta 30), pack-reused 0 (from 0)
Unpacking objects: 100% (53/53), 46.00 KiB | 523.00 KiB/s, done.
From github.com:jiminny/app
b1d5c77ad1..dfc8da14d2 JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
+ 47037d2c29...5138acf14e secfix/npm-20260423 -> origin/secfix/npm-20260423 (forced update)
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20738-debug-AJ-tracking-UP
Switched to a new branch 'JY-20738-debug-AJ-tracking-UP'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5621/5621 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5621 files in 22.942 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at https://docs.docker.com/go/debug-cli/
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ gbr
* JY-20738-debug-AJ-tracking-UP
JY-20157-AJ-report-not-send-notification
master
JY-20372-ai-reports-promotion-pages
JY-18909-automated-reports-ask-jiminny
JY-20692-fix-integration-app-[API_KEY]
JY-20553-debug-crm-sync-delays
JY-20698-fix-SF-activity-types-on-new-playbook
JY-20543-AJ-report-tracking
JY-20384-handle-auto-sync-with-no-access-to-event-type
JY-20458-ask-jiminny-user-definitions
JY-19666-fix-import-contacts-account-association
JY-19666-HS-import-contacts-and-accounts-batch-job
JY-20458-Ask-Jiminny-Reports
JY-20200-batch-update-CRM-objects-Salesforce
JY-19666-HS-webhooks-add-contact-and-company
JY-20348-trigger-setup-DI-layout-on-team-creation
JY-20326-refactor-info-message-in-command
JY-20317-fix-auto-log-delay-issue-on-all-channels-disabled
JY-20312-remove-on-update-change-last-synced-at-crm-configurations
JY-20306-SF-skip-auto-sync-for-task-based-playbook
JY-20192-remove-deleted-team-from-saved-search-filters
JY-20197-import-opportunity-batch-job
JY-20293-enable-status-field-for-pipedrive-deals
JY-20191-remove-commands-interactive-prompts
JY-20118-change-default-sync-strategy
JY-20183-add-cache-on-auto-log-delay
JY-20197-add-import-opportunity-batch-job
20118-hs-opportunity-make-webhook-strategy-default
JY-20118-make-default-hs-opportunity-sync-strategy-webhook-based
JY-20196-handle-opportunity-without-note
JY-20118-improve-opportunity-import
JY-20189-handle-activity-search-on-deleted-groups
JY-20160
JY-20145-filter-out-converted-leads-when-matching
JY-20150-skip-push-summary-on-summary-ready-if-autolog
JY-20132-fix-note-encoding
JY-19792-clean-logs
JY-20117-fix-sync-profile-fields-on-empty-fields
JY-20027-extend-email-import-to-all-crm-objects
JY-20017-fix-hubspot-webhooks-processing
JY-20026-convert-lead-activities
JY-19501-hs-crm-sync-optimized
JY-19220-assign-activities-on-new-opportunity
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ co JY-20157-AJ-report-not-send...
|
iTerm2
|
APP (-zsh)
|
NULL
|
77598
|
|
Last login: Thu Apr 23 14:01:28 on ttys007
Poetry Last login: Thu Apr 23 14:01:28 on ttys007
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20157-AJ-report-not-send-notification
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git pull
remote: Enumerating objects: 1015, done.
remote: Counting objects: 100% (262/262), done.
remote: Compressing objects: 100% (143/143), done.
remote: Total 1015 (delta 167), reused 129 (delta 119), pack-reused 753 (from 3)
Receiving objects: 100% (1015/1015), 851.14 KiB | 2.09 MiB/s, done.
Resolving deltas: 100% (613/613), completed with 65 local objects.
From github.com:jiminny/app
c3c8d86b22..68bb20c72a JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
3ac71c265a..595c95b7e0 JY-19995-delete-leftover-tracks-command -> origin/JY-19995-delete-leftover-tracks-command
* [new branch] JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null -> origin/JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null
* [new branch] JY-20478-stop-sync-calendar-emails -> origin/JY-20478-stop-sync-calendar-emails
d4d05c775b..b11048beed JY-20541-cleanup-stale-tasks-and-events -> origin/JY-20541-cleanup-stale-tasks-and-events
10d290c778..a250abe939 JY-20663-partner-rockeed -> origin/JY-20663-partner-rockeed
* [new branch] JY-20713-activity-sync-job-restart -> origin/JY-20713-activity-sync-job-restart
242cf1b554..96a22e59f2 JY-9712-change-forever-nudges-to-1-year-expiration -> origin/JY-9712-change-forever-nudges-to-1-year-expiration
* [new branch] fix-close-missing-logger-error -> origin/fix-close-missing-logger-error
0dd5b23990..60fa1787c1 master -> origin/master
f044edca5b..e7e0e50b27 secfix/npm-20260416 -> origin/secfix/npm-20260416
* [new branch] secfix/npm-20260423 -> origin/secfix/npm-20260423
Updating c3c8d86b22..68bb20c72a
Fast-forward
Makefile | 5 +
app/Component/Activity/Services/UpdateActivityService.php | 5 +
app/Component/ActivitySearch/FilterDefinition/ActivityUpdatedDate.php | 7 +-
app/Component/ActivitySearch/Service/ActivitySearch.php | 15 ++
app/Component/AiCallScoring/Services/GenerateAiCallScoringService.php | 6 +
app/Component/AiCallScoring/Services/GetAiCallScoringService.php | 5 +-
app/Component/AiCallScoring/Transformers/AiCallScoringTransformer.php | 2 +-
app/Component/ProphetAi/ProphetClient.php | 5 +
app/Console/Commands/Crm/SyncHubspotObjects.php | 84 +++++++++++
app/Console/Commands/Crm/SyncObjects.php | 82 ++++++-----
app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php | 81 +++++++++++
app/Console/Commands/Reports/AutomatedReportsCommand.php | 91 +++++++++++-
app/Console/Commands/Reports/AutomatedReportsSendCommand.php | 40 +++++-
app/Console/Kernel.php | 4 +
app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php | 15 ++
app/Contracts/Services/Crm/Provider/SalesforceInterface.php | 12 +-
app/Contracts/Services/Crm/ServiceInterface.php | 29 ----
app/Contracts/Services/Crm/SyncCrmMetadataInterface.php | 6 +-
app/Events/AutomatedReports/AutomatedReportGenerated.php | 15 ++
app/Http/Controllers/API/CrmController.php | 19 ++-
app/Http/Controllers/API/UserAutomatedReports/UserAutomatedReportsController.php | 33 ++++-
app/Http/Controllers/Internal/WebhookReceiver/HubspotController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/EventsController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTrait.php | 64 ++++++---
app/Http/Controllers/Webhook/ReportController.php | 5 +
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRuleRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/TestAiCallScoringPromptRequest.php | 2 +-
app/Jobs/Activity/SyncActivity.php | 3 +-
app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php | 210 ++++++++++++++++++++++++++++
app/Jobs/AutomatedReports/SendReportJob.php | 2 +
app/Jobs/AutomatedReports/SendReportMailJob.php | 6 +-
app/Jobs/Crm/SyncActivity.php | 10 ++
app/Jobs/Crm/SyncHubspotObjects.php | 120 ++++++++++++++++
app/Jobs/Crm/SyncObjects.php | 26 ++--
app/Jobs/Crm/SyncTeamMetadata.php | 14 +-
app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php | 82 +++++++++++
app/Listeners/Crm/ResolveOwner.php | 21 +--
app/Mail/Reports/ReportWithAttachment.php | 7 +-
app/Models/Ai/AiScorecardRuleRun.php | 4 +-
app/Models/Ai/AiScorecardRun.php | 4 +-
app/Models/Contracts/UserContract.php | 6 +
app/Providers/EventServiceProvider.php | 4 +
app/Repositories/AutomatedReportsRepository.php | 76 +++++++++-
app/Repositories/Crm/CrmEntityRepository.php | 40 ++++++
app/Services/Crm/BaseService.php | 13 --
app/Services/Crm/Bullhorn/BullhornService.php | 21 ---
app/Services/Crm/Close/Service.php | 38 -----
app/Services/Crm/Copper/Service.php | 37 -----
app/Services/Crm/Dummy/Service.php | 25 ----
app/Services/Crm/Hubspot/Service.php | 37 -----
app/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTrait.php | 174 +++++++++++++++++------
app/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTrait.php | 27 ++--
app/Services/Crm/IntegrationApp/Service.php | 2 +
app/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTrait.php | 12 +-
app/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTrait.php | 5 -
app/Services/Crm/Pipedrive/Service.php | 43 +-----
app/Services/Crm/Salesforce/Service.php | 13 +-
app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php | 143 +++++++++++++++++++
app/Services/Kiosk/AutomatedReports/AutomatedReportsService.php | 222 +++++++++++++++++++++++++----
front-end/package.json | 2 +-
front-end/src/__mocks__/kit/endpoints/team-insights.js | 1 +
front-end/src/components/AiReports/AiReports.vue | 9 +-
front-end/src/components/AiReports/GridCells/ActionsCell.vue | 107 +++++++++++---
front-end/src/components/AiReports/GridCells/NameCell.vue | 13 +-
front-end/src/components/AiReports/GridCells/TypeIndicator.vue | 26 ++--
front-end/src/components/AiReports/Manage/CreateDefinition/CreateDefinitionDrawer.vue | 4 +-
front-end/src/components/AiReports/Manage/ExpiringCell.vue | 86 ++++++++++++
front-end/src/components/AiReports/Manage/ManageAiReports.less | 6 +
front-end/src/components/AiReports/Manage/ManageAiReports.vue | 6 +-
front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js | 116 +++++++++++++++
front-end/src/components/AiReports/Manage/__tests__/ManageAiReports.spec.js | 32 +++--
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/create-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/edit-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/manage-ai-reports.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/gridConfig.js | 12 +-
front-end/src/components/AiReports/__tests__/AiReports.spec.js | 45 +++++-
front-end/src/components/AiReports/__tests__/__mocks__/data.js | 49 +++++++
front-end/src/components/AiReports/__tests__/__mocks__/requestHandlers.js | 3 +
front-end/src/components/AiReports/__tests__/__snapshots__/ai-reports.output.html | 319 +++++++++++++++++++++++++++++++++++++++++-
front-end/src/components/AiReports/constants.js | 1 +
front-end/src/components/AiReports/gridConfig.js | 2 +-
front-end/src/components/AiReports/useAiReportsGrid.js | 27 ++++
front-end/src/components/Settings/Kiosk/AutomatedReports/RecipientsCell.vue | 36 ++++-
front-end/src/components/Settings/Kiosk/AutomatedReports/UsersCell.vue | 9 +-
front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js | 171 ++++++++++++++++++++++
front-end/src/components/Settings/OrgSettings/AiAutomation/CallScoring/ScorecardRuleForm.vue | 2 +-
front-end/src/components/TeamInsights/CoachingFrameworks/AICallScoring/aiCallScoringOverTime.ts | 18 ++-
front-end/src/components/shared/GridView/useOrder.js | 6 +-
front-end/src/components/shared/GridView/usePaginationList.js | 7 +-
front-end/yarn.lock | 8 +-
resources/views/emails/reports/ask-jiminny-report-generated.blade.php | 25 ++++
routes/api.php | 1 +
tests/Unit/Component/Activity/Services/UpdateActivityServiceTest.php | 62 ++++++++
tests/Unit/Component/AiCallScoring/Services/GenerateAiCallScoringServiceTest.php | 13 +-
tests/Unit/Console/Commands/Reports/AutomatedReportsCommandTest.php | 468 ++++++++++++++++++++++++++++++++++++++++++-------------------
tests/Unit/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTraitTest.php | 5 +-
tests/Unit/Http/Controllers/Webhook/ReportControllerTest.php | 9 +-
tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php | 407 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncActivityTest.php | 74 +++++++---
tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php | 455 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncTeamMetadataTest.php | 8 +-
tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php | 199 ++++++++++++++++++++++++++
tests/Unit/Listeners/Crm/ResolveOwnerTest.php | 64 ++++-----
tests/Unit/Repositories/AutomatedReportsRepositoryTest.php | 55 ++++++++
tests/Unit/Services/Crm/Copper/ServiceTest.php | 19 ---
tests/Unit/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTest.php | 74 ++++++----
tests/Unit/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTraitTest.php | 8 +-
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTraitTest.php | 76 ++--------
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTraitTest.php | 5 -
tests/Unit/Services/Crm/Pipedrive/ServiceTest.php | 11 --
tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php | 430 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Services/Kiosk/AutomatedReports/AutomatedReportsServiceTest.php | 521 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
113 files changed, 5468 insertions(+), 980 deletions(-)
create mode 100644 app/Console/Commands/Crm/SyncHubspotObjects.php
create mode 100644 app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php
create mode 100644 app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php
create mode 100644 app/Events/AutomatedReports/AutomatedReportGenerated.php
create mode 100644 app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php
create mode 100644 app/Jobs/Crm/SyncHubspotObjects.php
create mode 100644 app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php
create mode 100644 app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php
create mode 100644 front-end/src/components/AiReports/Manage/ExpiringCell.vue
create mode 100644 front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js
create mode 100644 front-end/src/components/AiReports/constants.js
create mode 100644 front-end/src/components/AiReports/useAiReportsGrid.js
create mode 100644 front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js
create mode 100644 resources/views/emails/reports/ask-jiminny-report-generated.blade.php
create mode 100644 tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php
create mode 100644 tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php
create mode 100644 tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php
create mode 100644 tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Http/Transformers/UserTransformer.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Repositories/AutomatedReportsRepository.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
modified: tests/Unit/Repositories/AutomatedReportsRepositoryTest.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5613/5613 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Console/Commands/JiminnyDebugCommand.php (braces_position, statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
+++ /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
@@ -37,15 +37,14 @@
JobDispatcherInterface $jobDispatcher,
AutomatedReportsService $automatedReportsService,
AutomatedReportsRepository $automatedReportsRepository,
- ): void
- {
-// $user = User::find(143);
-// $count = $automatedReportsRepository->countUserReports($user);
-// $this->info("Count: {$count}");
-// $count = $automatedReportsRepository->countAllUserReports($user);
-// $this->info("All count: {$count}");
-//
-// exit(1);
+ ): void {
+ // $user = User::find(143);
+ // $count = $automatedReportsRepository->countUserReports($user);
+ // $this->info("Count: {$count}");
+ // $count = $automatedReportsRepository->countAllUserReports($user);
+ // $this->info("All count: {$count}");
+ //
+ // exit(1);
$now = Carbon::now()->subDay(1);
$this->info("Now: {$now->toDateTimeString()}");
@@ -52,18 +51,18 @@
$weekStart = Carbon::getWeekStartsAt();
$this->info("Now: {$weekStart}");
-// $from = $now->copy()->previousWeekday()->startOfDay();
-// $to = $now->copy()->previousWeekday()->endOfDay();
+ // $from = $now->copy()->previousWeekday()->startOfDay();
+ // $to = $now->copy()->previousWeekday()->endOfDay();
-// $fromOld = $now->copy()->subWeeks(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subWeek()->startOfWeek();
-// $toNew = $now->copy()->subWeek()->endOfWeek();
+ // $fromOld = $now->copy()->subWeeks(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subWeek()->startOfWeek();
+ // $toNew = $now->copy()->subWeek()->endOfWeek();
-// $fromOld = $now->copy()->subMonths(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
-// $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
+ // $fromOld = $now->copy()->subMonths(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
+ // $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
$fromOld = $now->copy()->subMonths(3)->startOfDay();
$toOld = $now->copy()->subDay()->endOfDay();
----------- end diff -----------
Fixed 1 of 5613 files in 66.818 seconds, 67.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 65.183 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 40.863 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 53, done.
remote: Counting objects: 100% (53/53), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 53 (delta 33), reused 49 (delta 30), pack-reused 0 (from 0)
Unpacking objects: 100% (53/53), 46.00 KiB | 523.00 KiB/s, done.
From github.com:jiminny/app
b1d5c77ad1..dfc8da14d2 JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
+ 47037d2c29...5138acf14e secfix/npm-20260423 -> origin/secfix/npm-20260423 (forced update)
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20738-debug-AJ-tracking-UP
Switched to a new branch 'JY-20738-debug-AJ-tracking-UP'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5621/5621 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5621 files in 22.942 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at https://docs.docker.com/go/debug-cli/
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ gbr
* JY-20738-debug-AJ-tracking-UP
JY-20157-AJ-report-not-send-notification
master
JY-20372-ai-reports-promotion-pages
JY-18909-automated-reports-ask-jiminny
JY-20692-fix-integration-app-[API_KEY]
JY-20553-debug-crm-sync-delays
JY-20698-fix-SF-activity-types-on-new-playbook
JY-20543-AJ-report-tracking
JY-20384-handle-auto-sync-with-no-access-to-event-type
JY-20458-ask-jiminny-user-definitions
JY-19666-fix-import-contacts-account-association
JY-19666-HS-import-contacts-and-accounts-batch-job
JY-20458-Ask-Jiminny-Reports
JY-20200-batch-update-CRM-objects-Salesforce
JY-19666-HS-webhooks-add-contact-and-company
JY-20348-trigger-setup-DI-layout-on-team-creation
JY-20326-refactor-info-message-in-command
JY-20317-fix-auto-log-delay-issue-on-all-channels-disabled
JY-20312-remove-on-update-change-last-synced-at-crm-configurations
JY-20306-SF-skip-auto-sync-for-task-based-playbook
JY-20192-remove-deleted-team-from-saved-search-filters
JY-20197-import-opportunity-batch-job
JY-20293-enable-status-field-for-pipedrive-deals
JY-20191-remove-commands-interactive-prompts
JY-20118-change-default-sync-strategy
JY-20183-add-cache-on-auto-log-delay
JY-20197-add-import-opportunity-batch-job
20118-hs-opportunity-make-webhook-strategy-default
JY-20118-make-default-hs-opportunity-sync-strategy-webhook-based
JY-20196-handle-opportunity-without-note
JY-20118-improve-opportunity-import
JY-20189-handle-activity-search-on-deleted-groups
JY-20160
JY-20145-filter-out-converted-leads-when-matching
JY-20150-skip-push-summary-on-summary-ready-if-autolog
JY-20132-fix-note-encoding
JY-19792-clean-logs
JY-20117-fix-sync-profile-fields-on-empty-fields
JY-20027-extend-email-import-to-all-crm-objects
JY-20017-fix-hubspot-webhooks-processing
JY-20026-convert-lead-activities
JY-19501-hs-crm-sync-optimized
JY-19220-assign-activities-on-new-opportunity
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ co JY-20157-AJ-report-not-send...
|
iTerm2
|
APP (-zsh)
|
NULL
|
77599
|
|
Last login: Thu Apr 23 14:01:28 on ttys007
Poetry Last login: Thu Apr 23 14:01:28 on ttys007
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
Poetry could not find a pyproject.toml file in /Users/lukas/jiminny/app or its parents
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20157-AJ-report-not-send-notification
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git pull
remote: Enumerating objects: 1015, done.
remote: Counting objects: 100% (262/262), done.
remote: Compressing objects: 100% (143/143), done.
remote: Total 1015 (delta 167), reused 129 (delta 119), pack-reused 753 (from 3)
Receiving objects: 100% (1015/1015), 851.14 KiB | 2.09 MiB/s, done.
Resolving deltas: 100% (613/613), completed with 65 local objects.
From github.com:jiminny/app
c3c8d86b22..68bb20c72a JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
3ac71c265a..595c95b7e0 JY-19995-delete-leftover-tracks-command -> origin/JY-19995-delete-leftover-tracks-command
* [new branch] JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null -> origin/JY-20352-sync-opportunities-without-a-local-owner-user-id-is-null
* [new branch] JY-20478-stop-sync-calendar-emails -> origin/JY-20478-stop-sync-calendar-emails
d4d05c775b..b11048beed JY-20541-cleanup-stale-tasks-and-events -> origin/JY-20541-cleanup-stale-tasks-and-events
10d290c778..a250abe939 JY-20663-partner-rockeed -> origin/JY-20663-partner-rockeed
* [new branch] JY-20713-activity-sync-job-restart -> origin/JY-20713-activity-sync-job-restart
242cf1b554..96a22e59f2 JY-9712-change-forever-nudges-to-1-year-expiration -> origin/JY-9712-change-forever-nudges-to-1-year-expiration
* [new branch] fix-close-missing-logger-error -> origin/fix-close-missing-logger-error
0dd5b23990..60fa1787c1 master -> origin/master
f044edca5b..e7e0e50b27 secfix/npm-20260416 -> origin/secfix/npm-20260416
* [new branch] secfix/npm-20260423 -> origin/secfix/npm-20260423
Updating c3c8d86b22..68bb20c72a
Fast-forward
Makefile | 5 +
app/Component/Activity/Services/UpdateActivityService.php | 5 +
app/Component/ActivitySearch/FilterDefinition/ActivityUpdatedDate.php | 7 +-
app/Component/ActivitySearch/Service/ActivitySearch.php | 15 ++
app/Component/AiCallScoring/Services/GenerateAiCallScoringService.php | 6 +
app/Component/AiCallScoring/Services/GetAiCallScoringService.php | 5 +-
app/Component/AiCallScoring/Transformers/AiCallScoringTransformer.php | 2 +-
app/Component/ProphetAi/ProphetClient.php | 5 +
app/Console/Commands/Crm/SyncHubspotObjects.php | 84 +++++++++++
app/Console/Commands/Crm/SyncObjects.php | 82 ++++++-----
app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php | 81 +++++++++++
app/Console/Commands/Reports/AutomatedReportsCommand.php | 91 +++++++++++-
app/Console/Commands/Reports/AutomatedReportsSendCommand.php | 40 +++++-
app/Console/Kernel.php | 4 +
app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php | 15 ++
app/Contracts/Services/Crm/Provider/SalesforceInterface.php | 12 +-
app/Contracts/Services/Crm/ServiceInterface.php | 29 ----
app/Contracts/Services/Crm/SyncCrmMetadataInterface.php | 6 +-
app/Events/AutomatedReports/AutomatedReportGenerated.php | 15 ++
app/Http/Controllers/API/CrmController.php | 19 ++-
app/Http/Controllers/API/UserAutomatedReports/UserAutomatedReportsController.php | 33 ++++-
app/Http/Controllers/Internal/WebhookReceiver/HubspotController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/EventsController.php | 2 +-
app/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTrait.php | 64 ++++++---
app/Http/Controllers/Webhook/ReportController.php | 5 +
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/CreateOrUpdateAiScorecardRuleRequest.php | 2 +-
app/Http/Requests/Settings/AiCallScoring/TestAiCallScoringPromptRequest.php | 2 +-
app/Jobs/Activity/SyncActivity.php | 3 +-
app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php | 210 ++++++++++++++++++++++++++++
app/Jobs/AutomatedReports/SendReportJob.php | 2 +
app/Jobs/AutomatedReports/SendReportMailJob.php | 6 +-
app/Jobs/Crm/SyncActivity.php | 10 ++
app/Jobs/Crm/SyncHubspotObjects.php | 120 ++++++++++++++++
app/Jobs/Crm/SyncObjects.php | 26 ++--
app/Jobs/Crm/SyncTeamMetadata.php | 14 +-
app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php | 82 +++++++++++
app/Listeners/Crm/ResolveOwner.php | 21 +--
app/Mail/Reports/ReportWithAttachment.php | 7 +-
app/Models/Ai/AiScorecardRuleRun.php | 4 +-
app/Models/Ai/AiScorecardRun.php | 4 +-
app/Models/Contracts/UserContract.php | 6 +
app/Providers/EventServiceProvider.php | 4 +
app/Repositories/AutomatedReportsRepository.php | 76 +++++++++-
app/Repositories/Crm/CrmEntityRepository.php | 40 ++++++
app/Services/Crm/BaseService.php | 13 --
app/Services/Crm/Bullhorn/BullhornService.php | 21 ---
app/Services/Crm/Close/Service.php | 38 -----
app/Services/Crm/Copper/Service.php | 37 -----
app/Services/Crm/Dummy/Service.php | 25 ----
app/Services/Crm/Hubspot/Service.php | 37 -----
app/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTrait.php | 174 +++++++++++++++++------
app/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTrait.php | 27 ++--
app/Services/Crm/IntegrationApp/Service.php | 2 +
app/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTrait.php | 12 +-
app/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTrait.php | 5 -
app/Services/Crm/Pipedrive/Service.php | 43 +-----
app/Services/Crm/Salesforce/Service.php | 13 +-
app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php | 143 +++++++++++++++++++
app/Services/Kiosk/AutomatedReports/AutomatedReportsService.php | 222 +++++++++++++++++++++++++----
front-end/package.json | 2 +-
front-end/src/__mocks__/kit/endpoints/team-insights.js | 1 +
front-end/src/components/AiReports/AiReports.vue | 9 +-
front-end/src/components/AiReports/GridCells/ActionsCell.vue | 107 +++++++++++---
front-end/src/components/AiReports/GridCells/NameCell.vue | 13 +-
front-end/src/components/AiReports/GridCells/TypeIndicator.vue | 26 ++--
front-end/src/components/AiReports/Manage/CreateDefinition/CreateDefinitionDrawer.vue | 4 +-
front-end/src/components/AiReports/Manage/ExpiringCell.vue | 86 ++++++++++++
front-end/src/components/AiReports/Manage/ManageAiReports.less | 6 +
front-end/src/components/AiReports/Manage/ManageAiReports.vue | 6 +-
front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js | 116 +++++++++++++++
front-end/src/components/AiReports/Manage/__tests__/ManageAiReports.spec.js | 32 +++--
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/create-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/edit-definition-drawer.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/__tests__/__snapshots__/manage-ai-reports.output.html | 83 ++++++++---
front-end/src/components/AiReports/Manage/gridConfig.js | 12 +-
front-end/src/components/AiReports/__tests__/AiReports.spec.js | 45 +++++-
front-end/src/components/AiReports/__tests__/__mocks__/data.js | 49 +++++++
front-end/src/components/AiReports/__tests__/__mocks__/requestHandlers.js | 3 +
front-end/src/components/AiReports/__tests__/__snapshots__/ai-reports.output.html | 319 +++++++++++++++++++++++++++++++++++++++++-
front-end/src/components/AiReports/constants.js | 1 +
front-end/src/components/AiReports/gridConfig.js | 2 +-
front-end/src/components/AiReports/useAiReportsGrid.js | 27 ++++
front-end/src/components/Settings/Kiosk/AutomatedReports/RecipientsCell.vue | 36 ++++-
front-end/src/components/Settings/Kiosk/AutomatedReports/UsersCell.vue | 9 +-
front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js | 171 ++++++++++++++++++++++
front-end/src/components/Settings/OrgSettings/AiAutomation/CallScoring/ScorecardRuleForm.vue | 2 +-
front-end/src/components/TeamInsights/CoachingFrameworks/AICallScoring/aiCallScoringOverTime.ts | 18 ++-
front-end/src/components/shared/GridView/useOrder.js | 6 +-
front-end/src/components/shared/GridView/usePaginationList.js | 7 +-
front-end/yarn.lock | 8 +-
resources/views/emails/reports/ask-jiminny-report-generated.blade.php | 25 ++++
routes/api.php | 1 +
tests/Unit/Component/Activity/Services/UpdateActivityServiceTest.php | 62 ++++++++
tests/Unit/Component/AiCallScoring/Services/GenerateAiCallScoringServiceTest.php | 13 +-
tests/Unit/Console/Commands/Reports/AutomatedReportsCommandTest.php | 468 ++++++++++++++++++++++++++++++++++++++++++-------------------
tests/Unit/Http/Controllers/Webhook/Hubspot/ProcessesWebhooksTraitTest.php | 5 +-
tests/Unit/Http/Controllers/Webhook/ReportControllerTest.php | 9 +-
tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php | 407 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncActivityTest.php | 74 +++++++---
tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php | 455 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Jobs/Crm/SyncTeamMetadataTest.php | 8 +-
tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php | 199 ++++++++++++++++++++++++++
tests/Unit/Listeners/Crm/ResolveOwnerTest.php | 64 ++++-----
tests/Unit/Repositories/AutomatedReportsRepositoryTest.php | 55 ++++++++
tests/Unit/Services/Crm/Copper/ServiceTest.php | 19 ---
tests/Unit/Services/Crm/Hubspot/ServiceTraits/OpportunitySyncTest.php | 74 ++++++----
tests/Unit/Services/Crm/Hubspot/ServiceTraits/SyncCrmEntitiesTraitTest.php | 8 +-
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/NotSupportedTraitTest.php | 76 ++--------
tests/Unit/Services/Crm/IntegrationApp/ServiceTraits/SyncCrmMetadataTraitTest.php | 5 -
tests/Unit/Services/Crm/Pipedrive/ServiceTest.php | 11 --
tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php | 430 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Unit/Services/Kiosk/AutomatedReports/AutomatedReportsServiceTest.php | 521 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
113 files changed, 5468 insertions(+), 980 deletions(-)
create mode 100644 app/Console/Commands/Crm/SyncHubspotObjects.php
create mode 100644 app/Console/Commands/Crm/Traits/SyncObjectsCommandTrait.php
create mode 100644 app/Contracts/Services/Crm/ImportsBusinessProcessesInterface.php
create mode 100644 app/Events/AutomatedReports/AutomatedReportGenerated.php
create mode 100644 app/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJob.php
create mode 100644 app/Jobs/Crm/SyncHubspotObjects.php
create mode 100644 app/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEvent.php
create mode 100644 app/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityService.php
create mode 100644 front-end/src/components/AiReports/Manage/ExpiringCell.vue
create mode 100644 front-end/src/components/AiReports/Manage/__tests__/ExpiringCell.spec.js
create mode 100644 front-end/src/components/AiReports/constants.js
create mode 100644 front-end/src/components/AiReports/useAiReportsGrid.js
create mode 100644 front-end/src/components/Settings/Kiosk/AutomatedReports/__tests__/RecipientsCell.spec.js
create mode 100644 resources/views/emails/reports/ask-jiminny-report-generated.blade.php
create mode 100644 tests/Unit/Jobs/AutomatedReports/RequestGenerateAskJiminnyReportJobTest.php
create mode 100644 tests/Unit/Jobs/Crm/SyncHubspotObjectsTest.php
create mode 100644 tests/Unit/Listeners/AutomatedReports/UserPilot/TrackAutomatedReportGeneratedEventTest.php
create mode 100644 tests/Unit/Services/Kiosk/AutomatedReports/AskJiminnyReportActivityServiceTest.php
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ git status
On branch JY-20372-ai-reports-promotion-pages
Your branch is up to date with 'origin/JY-20372-ai-reports-promotion-pages'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .env.local
modified: app/Console/Commands/JiminnyDebugCommand.php
modified: app/Http/Controllers/API/ActivityController.php
modified: app/Http/Transformers/UserTransformer.php
modified: app/Jobs/Team/SyncToIntercom.php
modified: app/Repositories/AutomatedReportsRepository.php
modified: app/Services/PlaybackService.php
modified: config/logging.php
modified: tests/Unit/Repositories/AutomatedReportsRepositoryTest.php
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env.nikilocal
.env.other
WEBHOOK_FILTERING_IMPLEMENTATION.md
app/Console/Commands/Crm/Hubspot/SimulateWebhooksCommand.php
app/Console/Commands/Reports/CreateMockAskJiminnyReportResultCommand.php
ids.txt
raw_sql_query.sql
tests/Unit/Policies/CanAccessAiReportsTest.php
no changes added to commit (use "git add" and/or "git commit -a")
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20372-ai-reports-promotion-pages) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5613/5613 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
1) app/Console/Commands/JiminnyDebugCommand.php (braces_position, statement_indentation)
---------- begin diff ----------
--- /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
+++ /home/jiminny/app/Console/Commands/JiminnyDebugCommand.php
@@ -37,15 +37,14 @@
JobDispatcherInterface $jobDispatcher,
AutomatedReportsService $automatedReportsService,
AutomatedReportsRepository $automatedReportsRepository,
- ): void
- {
-// $user = User::find(143);
-// $count = $automatedReportsRepository->countUserReports($user);
-// $this->info("Count: {$count}");
-// $count = $automatedReportsRepository->countAllUserReports($user);
-// $this->info("All count: {$count}");
-//
-// exit(1);
+ ): void {
+ // $user = User::find(143);
+ // $count = $automatedReportsRepository->countUserReports($user);
+ // $this->info("Count: {$count}");
+ // $count = $automatedReportsRepository->countAllUserReports($user);
+ // $this->info("All count: {$count}");
+ //
+ // exit(1);
$now = Carbon::now()->subDay(1);
$this->info("Now: {$now->toDateTimeString()}");
@@ -52,18 +51,18 @@
$weekStart = Carbon::getWeekStartsAt();
$this->info("Now: {$weekStart}");
-// $from = $now->copy()->previousWeekday()->startOfDay();
-// $to = $now->copy()->previousWeekday()->endOfDay();
+ // $from = $now->copy()->previousWeekday()->startOfDay();
+ // $to = $now->copy()->previousWeekday()->endOfDay();
-// $fromOld = $now->copy()->subWeeks(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subWeek()->startOfWeek();
-// $toNew = $now->copy()->subWeek()->endOfWeek();
+ // $fromOld = $now->copy()->subWeeks(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subWeek()->startOfWeek();
+ // $toNew = $now->copy()->subWeek()->endOfWeek();
-// $fromOld = $now->copy()->subMonths(1)->startOfDay();
-// $toOld = $now->copy()->subDay()->endOfDay();
-// $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
-// $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
+ // $fromOld = $now->copy()->subMonths(1)->startOfDay();
+ // $toOld = $now->copy()->subDay()->endOfDay();
+ // $fromNew = $now->copy()->subMonthNoOverflow()->startOfMonth();
+ // $toNew = $now->copy()->subMonthNoOverflow()->endOfMonth();
$fromOld = $now->copy()->subMonths(3)->startOfDay();
$toOld = $now->copy()->subDay()->endOfDay();
----------- end diff -----------
Fixed 1 of 5613 files in 66.818 seconds, 67.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 65.183 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ ;xd
docker exec -it docker_lamp_1 bash -c "mv /usr/local/etc/php/conf.d/xdebug.ini ~/xdebug.ini"
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (JY-20157-AJ-report-not-send-notification) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5616/5616 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5616 files in 40.863 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at [URL_WITH_CREDENTIALS] ~/jiminny/app (master) $ git pull
remote: Enumerating objects: 53, done.
remote: Counting objects: 100% (53/53), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 53 (delta 33), reused 49 (delta 30), pack-reused 0 (from 0)
Unpacking objects: 100% (53/53), 46.00 KiB | 523.00 KiB/s, done.
From github.com:jiminny/app
b1d5c77ad1..dfc8da14d2 JY-20372-ai-reports-promotion-pages -> origin/JY-20372-ai-reports-promotion-pages
+ 47037d2c29...5138acf14e secfix/npm-20260423 -> origin/secfix/npm-20260423 (forced update)
Already up to date.
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (master) $ co -b JY-20738-debug-AJ-tracking-UP
Switched to a new branch 'JY-20738-debug-AJ-tracking-UP'
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ csfix
docker exec -it docker_lamp_1 ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php -v --using-cache=no --diff
PHP CS Fixer 3.87.1 Alexander by Fabien Potencier, Dariusz Ruminski and contributors.
PHP runtime: 8.3.30
Running analysis on 7 cores with 10 files per process.
Parallel runner is an experimental feature and may be unstable, use it at your own risk. Feedback highly appreciated!
Loaded config default from ".php-cs-fixer.dist.php".
5621/5621 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Fixed 0 of 5621 files in 22.942 seconds, 60.00 MB memory used
What's next:
Try Docker Debug for seamless, persistent debugging tools in any container or image → docker debug docker_lamp_1
Learn more at https://docs.docker.com/go/debug-cli/
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ gbr
* JY-20738-debug-AJ-tracking-UP
JY-20157-AJ-report-not-send-notification
master
JY-20372-ai-reports-promotion-pages
JY-18909-automated-reports-ask-jiminny
JY-20692-fix-integration-app-[API_KEY]
JY-20553-debug-crm-sync-delays
JY-20698-fix-SF-activity-types-on-new-playbook
JY-20543-AJ-report-tracking
JY-20384-handle-auto-sync-with-no-access-to-event-type
JY-20458-ask-jiminny-user-definitions
JY-19666-fix-import-contacts-account-association
JY-19666-HS-import-contacts-and-accounts-batch-job
JY-20458-Ask-Jiminny-Reports
JY-20200-batch-update-CRM-objects-Salesforce
JY-19666-HS-webhooks-add-contact-and-company
JY-20348-trigger-setup-DI-layout-on-team-creation
JY-20326-refactor-info-message-in-command
JY-20317-fix-auto-log-delay-issue-on-all-channels-disabled
JY-20312-remove-on-update-change-last-synced-at-crm-configurations
JY-20306-SF-skip-auto-sync-for-task-based-playbook
JY-20192-remove-deleted-team-from-saved-search-filters
JY-20197-import-opportunity-batch-job
JY-20293-enable-status-field-for-pipedrive-deals
JY-20191-remove-commands-interactive-prompts
JY-20118-change-default-sync-strategy
JY-20183-add-cache-on-auto-log-delay
JY-20197-add-import-opportunity-batch-job
20118-hs-opportunity-make-webhook-strategy-default
JY-20118-make-default-hs-opportunity-sync-strategy-webhook-based
JY-20196-handle-opportunity-without-note
JY-20118-improve-opportunity-import
JY-20189-handle-activity-search-on-deleted-groups
JY-20160
JY-20145-filter-out-converted-leads-when-matching
JY-20150-skip-push-summary-on-summary-ready-if-autolog
JY-20132-fix-note-encoding
JY-19792-clean-logs
JY-20117-fix-sync-profile-fields-on-empty-fields
JY-20027-extend-email-import-to-all-crm-objects
JY-20017-fix-hubspot-webhooks-processing
JY-20026-convert-lead-activities
JY-19501-hs-crm-sync-optimized
JY-19220-assign-activities-on-new-opportunity
lukas@Lukas-Kovaliks-MacBook-Pro-Jiminny ~/jiminny/app (JY-20738-debug-AJ-tracking-UP) $ co JY-20157-AJ-report-not-send...
|
iTerm2
|
APP (-zsh)
|
NULL
|
77600
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once(); // This seems to be the logic in the controller
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77601
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once(); // This seems to be the logic in the controller
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77602
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once(); // This seems to be the logic in the controller
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77603
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once(); // This seems to be the logic in the controller
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77604
|
|
DMSActivityMorerireroxToolsHelpcalMistorbookmarksJ DMSActivityMorerireroxToolsHelpcalMistorbookmarksJiminny …..vXStarredi• jiminny-x-integrati..8 platform-inner-teamE) Channels# ai-chapter# ai-team# alerts# backend# c-learning-peoplei confusion-clinic# curiosity_labadeal-insichts-dev# engineering# frontend# general# infra-changes# jiminny-bg8 people-with-copilo...8 people-with-zoom-# platform-team# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the Deople of iimi...ProtllesWindow& platform-inner-...& 10MessagesChannel OverviewMoreYesterdayjinnylaop Aor 22nd Added by GitHubNikolay Ivanov 3:24 PMнякой нещо да е настроивал по githubactions. Почна да прави къмити вместо менбез да съм му разрешевал?https:/github.com/lminnv/app/pull/1200//changes/a68f42f210859f838a4fdced451f750627besoioИли нещо аз не разбирам?0AA0e 20 replies Last reply 18...Nikolay Yankov 3:50PMreplied to a uhread: някои нешо ла е насто..лол. ами предлагам маи ла му заораним лапускам към всички ла вилятNikolav Yankov 9.38 AMЩе се забавя за дейлито. Започнете без Мен.Aneliva Angelova 9:43 AMIДобро утро, няма да успея да вляза влейлито. Пествам ньлжовете.Message & platform-inner-team+ Aa I..•) New TabAl reports promotion pages by nik• JY-9712 | Nuges to expire after on8 Jiminnyu Userpilot Logged-activityJY-20157 add not enough activ XPipelines - jiminny/app+ New Tab©github.com/jimjiminny / app 8<> Code87 Pull requests 31( Agents |© Actions•• Wiki © Security and quality 32 ~ Insights 3 Settings@ On April 24 we'll start using GitHub Copilot interaction data for Al model training unless you opt out. Review this update and manage your preferences in your GitHub account settings.JY-20157 add not enough activities notification #12011 •$1 Open LakyLak wants to merge 2 commits into master from JY-20157-AJ-report-not-send-notification@) Conversation o• Commits 2|- Checks 21E Files changed 13A © All commits +Q Filter files...apo/Console/Commands/Reports/AutomatedReportsCommand.ohp@ -61,21 +61,29 @ public function handle(): intv = Console/Commands/Renorts|Snow = Carbon: : now();E AutomatedReportsCommand...v Jobs/AutomatedReportsE RequestGenerateAskJiminnyR...SendReportNotGeneratedMail...v @ Listeners/AutomatedReports/U….E TrackAutomatedReportGener...v # Mail/ReportsS1sMondav = Snow->1SMonday)S1sr1rstDayUtMonth = Snow->day === 1;ScurrentMonth = Snow->month.// Check if the current month is a quarterly month (January, April, July, October)$isQuarterlyMonth = in_array($currentMonth, [1, 4, 7, 10], true);$this->logger->info(self::LOG_PREFIX . ' Checking conditions', [+ ReportNotGenerated.ohp |"1SMonday' => S1SMonday,~ E Services/Kiosk/AutomatedRepo…..AskJiminnyReportActivityServ…'isFirstDay0fMonth' => SisFirstDay0fMonth,'currentMonth' => ScurrentMonth.E AutomatedReportsService.php'isQuarterlyMonth' => SisQuarterlyMonth,~E resources/views/emails/reportsreport-not-generated.blade.php/I Process dailv revortsl• F tests/UnitSthis->processReports(AutomatedReportsService::FREQUENCYDAILY):~ Jobs/AutomatedReportsE ReguestGenerateAsk JiminnvR....v = listeners/AutomatedRenorts/U.₴ TrackAutomatedReportGener..v E Services/Kiosk/AutomatedRepo…..E AskJiminnyReportActivityServ....AutomatedReportsServiceActi…./ Process weekly renorts on Mondavcif (SisMondav) {64 +67 +74 +86 +@40@ Daily - Platform - nowQ Type to search100% C4 8• Fri 24 Apr 9:46:13• Checks pending Code • (Preview) -+384 -52 9000C 0 I 13 viewedSubmit review+10 -2 mane [ Viewed0 ...Snow = Carhon:.nowdSisMondav = Snow->1SMonday)"Sisweekend = $now->isWeekend():SisFirstDay0fMonth = Snow->day === 1;ScurrentMonth = Snow->month.SisManualTrigger = $this->option('report-id') !== null;// Check if the current month is a quarterly month (January, April, July, October)$isQuarterlyMonth = in_array($currentMonth, [1, 4, 7, 10], true);Sthis->loager->info(self::L0G PREFIX . ' Checkina conditions'. [I"isMonday' => SisMonday,'isweekend' => $isWeekend,'isFirstDay0fMonth' => $isFirstDay0fMonth,'currentMonth' => ScurrentMonth.l'isQuarterlyMonth' => SisQuarterlyMonth,/ Process dailv renorts on weekdavs onlv (skio Saturdav/Sundav)...// Manual triggers via --report-id bypass the weekend skip.if (I Sisweekend || SisManualTriager) {Sthis->processReports(AutomatedReportsService::FREQUENCY_DAILY):} else {ISthis->logger->info(self::L0G PREFIX . ' Skipping daily reports on weekend'):/ Process weekly renorts on Mondavslif (SisMonday) {...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77605
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once(); // This seems to be the logic in the controller
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77622
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once(); // This seems to be the logic in the controller
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77623
|
|
Undo
Redo
Cut
Copy
Paste
Paste and Match Style
Sel Undo
Redo
Cut
Copy
Paste
Paste and Match Style
Select All
Open DevTools
Firefox• 0FileEditViewHistory→BookmarksProfilesToolsWindowHelpmeet.google.com/agt-teir-cwt?authuser=lukas.kovalik%40jiminny.com•Daily - Platform - now100% K78 • Fri 24 Apr 9:46:13|=Pop out this videoNikolay NikolovStefka StoyanovaGalya DimitrovaLukas Kovalik9:46 AM | Daily - Platform• 0:27...
|
PhpStorm
|
|
NULL
|
77624
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once(); // This seems to be the logic in the controller
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77625
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once(); // This seems to be the logic in the controller
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77626
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once(); // This seems to be the logic in the controller
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77627
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once(); // This seems to be the logic in the controller
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77628
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once(); // This seems to be the logic in the controller
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77629
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once(); // This seems to be the logic in the controller
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77630
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once(); // This seems to be the logic in the controller
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77631
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once(); // This seems to be the logic in the controller
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77632
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once(); // This seems to be the logic in the controller
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77633
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once(); // This seems to be the logic in the controller
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77634
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once(); // This seems to be the logic in the controller
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77635
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Tests\Unit\Http\Controllers\Webhook;
use Illuminate\Contracts\Bus\Dispatcher;
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Http\Request;
use Jiminny\Events\AutomatedReports\AutomatedReportGenerated;
use Jiminny\Http\Controllers\Webhook\ReportController;
use Jiminny\Jobs\AutomatedReports\SendReportJob;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsCallbackService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Mockery;
use Mockery\MockInterface;
use Psr\Log\LoggerInterface;
use Tests\TestCase;
class ReportControllerTest extends TestCase
{
private AutomatedReportsService|MockInterface $reportService;
private Dispatcher|MockInterface $dispatcher;
private LoggerInterface|MockInterface $logger;
private AutomatedReportsCallbackService|MockInterface $callbackService;
private EventDispatcher|MockInterface $eventDispatcher;
private ReportController $controller;
protected function setUp(): void
{
parent::setUp();
$this->reportService = Mockery::mock(AutomatedReportsService::class);
$this->dispatcher = Mockery::mock(Dispatcher::class);
$this->logger = Mockery::mock(LoggerInterface::class);
$this->callbackService = Mockery::mock(AutomatedReportsCallbackService::class);
$this->eventDispatcher = Mockery::mock(EventDispatcher::class);
$this->logger->shouldReceive('info'); // Allow info logs
$this->controller = new ReportController(
$this->reportService,
$this->dispatcher,
$this->logger,
$this->callbackService,
$this->eventDispatcher,
);
}
protected function tearDown(): void
{
Mockery::close();
parent::tearDown();
}
public function testReadyMethodSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn(null);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(SendReportJob::class));
$this->callbackService->shouldReceive('pushToDatadog')->once();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastSuccess(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$automatedReport = Mockery::mock(AutomatedReport::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_GENERATED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(true);
$reportResult->shouldReceive('getReport')->andReturn($automatedReport);
$automatedReport->shouldReceive('getFrequency')->andReturn(AutomatedReportsService::FREQUENCY_ONE_OFF);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once(); // This seems to be the logic in the controller
$this->dispatcher->shouldReceive('dispatch')->twice();
$this->callbackService->shouldReceive('pushToDatadog')->twice();
$this->eventDispatcher->shouldReceive('dispatch')->once()->with(Mockery::type(AutomatedReportGenerated::class));
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
public function testReadyMethodWithPodcastFailure(): void
{
$reportUuid = 'test-uuid';
$payload = ['request_id' => $reportUuid];
$request = Mockery::mock(Request::class);
$request->shouldReceive('all')->andReturn($payload);
$reportResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult = Mockery::mock(AutomatedReportResult::class);
$podcastResult->shouldReceive('getUuid')->andReturn('podcast-uuid');
$podcastResult->shouldReceive('getStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getResultUuid')->with($payload)->andReturn($reportUuid);
$this->reportService->shouldReceive('getReportResult')->with($reportUuid)->andReturn($reportResult);
$this->callbackService->shouldReceive('isProcessed')->with($reportResult)->andReturn(false);
$this->reportService->shouldReceive('findChildResult')->andReturn($podcastResult);
$this->callbackService->shouldReceive('getPrimaryStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('getPodcastStatus')->andReturn(AutomatedReportResult::STATUS_FAILED);
$this->callbackService->shouldReceive('isSuccess')->andReturn(false);
$reportResult->shouldReceive('update')->once();
$podcastResult->shouldReceive('update')->once();
$this->dispatcher->shouldReceive('dispatch')->never();
$this->callbackService->shouldReceive('pushToDatadog')->never();
$this->logger->shouldReceive('warning')->once();
$response = $this->controller->ready($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals(['status' => 'ok'], json_decode($response->getContent(), true));
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – ReportControllerTest.php
|
NULL
|
77636
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Firefox• 0FileEditViewHistory→BookmarksProfilesToolsWindowHelpmeet.google.com/agt-teir-cwt?authuser=lukas.kovalik%40jiminny.com•Daily - Platform - now100% K78 • Fri 24 Apr 9:46:13|=Pop out this videoNikolay NikolovStefka StoyanovaGalya DimitrovaLukas Kovalik9:46 AM | Daily - Platform• 0:27...
|
PhpStorm
|
faVsco.js – RequestGenerateAskJiminnyReportJob.php
|
NULL
|
77645
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
DMSActivityMorerireroxToolsHelpcalMistorbookmarksJiminny …..vXStarredi• jiminny-x-integrati..8 platform-inner-teamE) Channels# ai-chapter# ai-team# alerts# backend# c-learning-peoplei confusion-clinic# curiosity_labadeal-insichts-dev# engineering# frontend# general# infra-changes# jiminny-bg8 people-with-copilo...8 people-with-zoom-# platform-team# platform-tickets# product_launches# random# releases# sofia-office# support# thank-yous# the Deople of iimi...ProtllesWindow& platform-inner-...& 10MessagesChannel OverviewMoreYesterdayjinnylaop Aor 22nd Added by GitHubNikolay Ivanov 3:24 PMнякой нещо да е настроивал по githubactions. Почна да прави къмити вместо менбез да съм му разрешевал?https:/github.com/lminnv/app/pull/1200//changes/a68f42f210859f838a4fdced451f750627besoioИли нещо аз не разбирам?0AA0e 20 replies Last reply 18...Nikolay Yankov 3:50PMreplied to a uhread: някои нешо ла е насто..лол. ами предлагам маи ла му заораним лапускам към всички ла вилятNikolav Yankov 9.38 AMЩе се забавя за дейлито. Започнете без Мен.Aneliva Angelova 9:43 AMIДобро утро, няма да успея да вляза влейлито. Пествам ньлжовете.Message & platform-inner-team+ Aa I..•) New TabAl reports promotion pages by nik• JY-9712 | Nuges to expire after on8 Jiminnyu Userpilot Logged-activityJY-20157 add not enough activ XPipelines - jiminny/app+ New Tab©github.com/jimjiminny / app 8<> Code87 Pull requests 31( Agents |© Actions•• Wiki © Security and quality 32 ~ Insights 3 Settings@ On April 24 we'll start using GitHub Copilot interaction data for Al model training unless you opt out. Review this update and manage your preferences in your GitHub account settings.JY-20157 add not enough activities notification #12011 •$1 Open LakyLak wants to merge 2 commits into master from JY-20157-AJ-report-not-send-notification@) Conversation o• Commits 2|- Checks 21E Files changed 13A © All commits +Q Filter files...apo/Console/Commands/Reports/AutomatedReportsCommand.ohp@ -61,21 +61,29 @ public function handle(): intv = Console/Commands/Renorts|Snow = Carbon: : now();E AutomatedReportsCommand...v Jobs/AutomatedReportsE RequestGenerateAskJiminnyR...SendReportNotGeneratedMail...v @ Listeners/AutomatedReports/U….E TrackAutomatedReportGener...v # Mail/ReportsS1sMondav = Snow->1SMonday)S1sr1rstDayUtMonth = Snow->day === 1;ScurrentMonth = Snow->month.// Check if the current month is a quarterly month (January, April, July, October)$isQuarterlyMonth = in_array($currentMonth, [1, 4, 7, 10], true);$this->logger->info(self::LOG_PREFIX . ' Checking conditions', [+ ReportNotGenerated.ohp |"1SMonday' => S1SMonday,~ E Services/Kiosk/AutomatedRepo…..AskJiminnyReportActivityServ…'isFirstDay0fMonth' => SisFirstDay0fMonth,'currentMonth' => ScurrentMonth.E AutomatedReportsService.php'isQuarterlyMonth' => SisQuarterlyMonth,~E resources/views/emails/reportsreport-not-generated.blade.php/I Process dailv revortsl• F tests/UnitSthis->processReports(AutomatedReportsService::FREQUENCYDAILY):~ Jobs/AutomatedReportsE ReguestGenerateAsk JiminnvR....v = listeners/AutomatedRenorts/U.₴ TrackAutomatedReportGener..v E Services/Kiosk/AutomatedRepo…..E AskJiminnyReportActivityServ....AutomatedReportsServiceActi…./ Process weekly renorts on Mondavcif (SisMondav) {64 +67 +74 +86 +@40@ Daily - Platform - nowQ Type to search100% C4 8• Fri 24 Apr 9:46:13• Checks pending Code • (Preview) -+384 -52 9000C 0 I 13 viewedSubmit review+10 -2 mane [ Viewed0 ...Snow = Carhon:.nowdSisMondav = Snow->1SMonday)"Sisweekend = $now->isWeekend():SisFirstDay0fMonth = Snow->day === 1;ScurrentMonth = Snow->month.SisManualTrigger = $this->option('report-id') !== null;// Check if the current month is a quarterly month (January, April, July, October)$isQuarterlyMonth = in_array($currentMonth, [1, 4, 7, 10], true);Sthis->loager->info(self::L0G PREFIX . ' Checkina conditions'. [I"isMonday' => SisMonday,'isweekend' => $isWeekend,'isFirstDay0fMonth' => $isFirstDay0fMonth,'currentMonth' => ScurrentMonth.l'isQuarterlyMonth' => SisQuarterlyMonth,/ Process dailv renorts on weekdavs onlv (skio Saturdav/Sundav)...// Manual triggers via --report-id bypass the weekend skip.if (I Sisweekend || SisManualTriager) {Sthis->processReports(AutomatedReportsService::FREQUENCY_DAILY):} else {ISthis->logger->info(self::L0G PREFIX . ' Skipping daily reports on weekend'):/ Process weekly renorts on Mondavslif (SisMonday) {...
|
PhpStorm
|
faVsco.js – RequestGenerateAskJiminnyReportJob.php
|
NULL
|
77646
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Jiminny\Jobs\AutomatedReports;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Queue\InteractsWithQueue;
use Jiminny\Component\ProphetAi\Exceptions\ProphetException;
use Jiminny\Component\ProphetAi\ProphetClient;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\JobDispatcherInterface;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Models\Team;
use Jiminny\Services\Kiosk\AutomatedReports\AskJiminnyReportActivityService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Throwable;
class RequestGenerateAskJiminnyReportJob implements ShouldQueue, ShouldBeUnique
{
use InteractsWithQueue;
use Queueable;
private const string LOG_PREFIX = '[AskJiminnyReport:Generate]';
private const int MIN_ACTIVITIES_COUNT = 1;
public int $tries = 2;
private ?AutomatedReportResult $reportResult = null;
public function __construct(private readonly string $reportUuid)
{
$this->onQueue(Constants::QUEUE_ANALYTICS);
}
public function uniqueId(): string
{
return $this->reportUuid;
}
public function handle(
AutomatedReportsService $reportService,
AskJiminnyReportActivityService $activityService,
ProphetClient $prophetClient,
LoggerInterface $logger,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
): void {
$logger->info(self::LOG_PREFIX . ' Started', [
'automatedReportUuid' => $this->reportUuid,
]);
try {
$automatedReport = $reportService->getReport($this->reportUuid);
if (! $this->validateReport($automatedReport, $logger)) {
return;
}
$creator = $automatedReport->getCreator();
if ($creator === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, report creator not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$savedSearch = $automatedReport->getSavedSearch();
if ($savedSearch === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, saved search not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$prompt = $automatedReport->getAskAnythingPrompt();
if ($prompt === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, ask anything prompt not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$this->reportResult = $reportService->getOrCreateReportResult(
automatedReport: $automatedReport,
data: [
'status' => AutomatedReportResult::STATUS_DEFAULT,
'media_type' => AutomatedReportsService::MEDIA_TYPE_PDF,
]
);
$activityIds = $activityService->getActivityIdsForSavedSearch(
savedSearch: $savedSearch,
user: $creator,
frequency: $automatedReport->getFrequency(),
);
$activityCount = count($activityIds);
$logger->info(self::LOG_PREFIX . ' Fetched activity IDs', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
if ($activityCount < self::MIN_ACTIVITIES_COUNT) {
$this->failReport(AutomatedReportResult::REASON_NOT_ENOUGH_ACTIVITIES);
$logger->info(self::LOG_PREFIX . ' Not enough activities, skipped', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
$this->dispatchNotGeneratedNotifications(
$automatedReport,
$reportService,
$urlGenerator,
$jobDispatcher,
$logger,
);
return;
}
$payload = $reportService->getAskJiminnyGenerateReportPayload(
automatedReport: $automatedReport,
reportResult: $this->reportResult,
activityIds: $activityIds,
);
$this->reportResult->update([
'name' => $reportService->getReportFileName($this->reportResult),
'payload' => $payload,
'status' => AutomatedReportResult::STATUS_REQUESTED,
'requested_at' => Carbon::now()->toDateTimeString(),
]);
$logger->info(self::LOG_PREFIX . ' Request sent', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult->getUuid(),
'payload' => $payload,
]);
$response = $prophetClient->sendRequest(
endpoint: ProphetClient::ASK_JIMINNY_REPORT,
requestArray: $payload,
);
$logger->info(self::LOG_PREFIX . ' Response received', [
'response' => $response->getContent(),
]);
} catch (Throwable $exception) {
$reason = $exception instanceof ProphetException
? AutomatedReportResult::REASON_PROPHET_API_ERROR
: AutomatedReportResult::REASON_DEFAULT;
$this->failReport($reason);
$logger->error(self::LOG_PREFIX . ' Error', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult?->getUuid(),
'code' => $exception->getCode(),
'message' => $exception->getMessage(),
]);
if ($this->attempts() < $this->tries) {
$logger->info(self::LOG_PREFIX . ' Retry scheduled', [
'attempts' => $this->attempts(),
]);
$this->release(30);
} else {
$this->fail($exception);
}
}
}
private function validateReport(AutomatedReport $automatedReport, LoggerInterface $logger): bool
{
if ($automatedReport->getType() !== AutomatedReportsService::TYPE_ASK_JIMINNY) {
$logger->warning(self::LOG_PREFIX . ' Skipped, not an ask_jiminny report', [
'automatedReportUuid' => $this->reportUuid,
'type' => $automatedReport->getType(),
]);
return false;
}
if (! $automatedReport->getStatus()) {
$logger->info(self::LOG_PREFIX . ' Skipped, report is not active', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
if ($automatedReport->getTeam()->getStatus() !== Team::STATUS_ACTIVE) {
$logger->info(self::LOG_PREFIX . ' Skipped, team is inactive', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
return true;
}
private function failReport(int $reason): void
{
$this->reportResult?->update([
'status' => AutomatedReportResult::STATUS_FAILED,
'reason' => $reason,
]);
}
private function dispatchNotGeneratedNotifications(
AutomatedReport $automatedReport,
AutomatedReportsService $reportService,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
LoggerInterface $logger,
): void {
if ($this->reportResult === null) {
return;
}
$recipients = $reportService->getValidRecipientUsers($automatedReport);
if (empty($recipients)) {
$logger->info(self::LOG_PREFIX . ' No recipients to notify about missing report', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$reportName = $automatedReport->getCustomName()
?: $reportService->getReportTypeName($this->reportResult);
$periodName = $reportService->getReportPeriodName($this->reportResult);
$reportsPageUrl = $urlGenerator->route('ai.reports.show');
foreach ($recipients as $recipient) {
$jobDispatcher->dispatch(new SendReportNotGeneratedMailJob(
reportUuid: $this->reportResult->getUuid(),
recipientEmail: $recipient['email'],
recipientName: $recipient['name'] ?? null,
reportName: $reportName,
periodName: $periodName,
reportsPageUrl: $reportsPageUrl,
));
}
$logger->info(self::LOG_PREFIX . ' Dispatched not-generated notifications', [
'automatedReportUuid' => $this->reportUuid,
'recipientsCount' => count($recipients),
]);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide
app ~/jiminny/app, folder
.circleci, folder
.cursor, folder
.github
.sonarlint, folder
.vscode, folder
.windsurf, folder
app, sources root
Actions, folder
Component, folder
Acl, folder
ActionItems, folder
Activity, folder
ActivityAnalytics, folder
ActivitySearch, folder
AiActivityType, folder
AiAutomation, folder
AiCallScoring, folder
AskAnything, folder
Dtos, folder
Events, folder
AskAnythingPromptService.php, class
HistoryService.php, class
AskJiminnyAi, folder
AWS, folder
BillingManagement, folder
Cache, folder
CoachingFeedback, folder
Country, folder
CustomerApi, folder
Database, folder
Datadog, folder
DateTime, folder
DealInsights, folder
DealRisks
ElasticSearch
Eloquent
Encoding
Encryption
ES
Faker
FeatureFlags
FFMpeg
FileSystem
Gecko
Gong
GuzzleHttp
KeyPoints
Kiosk
LanguageDetection, folder
LiveFeed, folder
Locks, folder
Math, folder
MediaPipeline, folder
MeetingBot
MobileSettings
Model
Notification
Nudge, folder
ParagraphBreaker, folder
ParticipantSpeech, folder
PartitionedCookie, folder
PlaybackPage, folder
Playlist, folder
Prophet, folder
ProphetAi, folder
ProsperWorks, folder
Queue, folder
Router, folder
Saml2, folder
SCIM, folder
Seeder, folder...
|
PhpStorm
|
faVsco.js – RequestGenerateAskJiminnyReportJob.php
|
NULL
|
77647
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Jiminny\Jobs\AutomatedReports;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Queue\InteractsWithQueue;
use Jiminny\Component\ProphetAi\Exceptions\ProphetException;
use Jiminny\Component\ProphetAi\ProphetClient;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\JobDispatcherInterface;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Models\Team;
use Jiminny\Services\Kiosk\AutomatedReports\AskJiminnyReportActivityService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Throwable;
class RequestGenerateAskJiminnyReportJob implements ShouldQueue, ShouldBeUnique
{
use InteractsWithQueue;
use Queueable;
private const string LOG_PREFIX = '[AskJiminnyReport:Generate]';
private const int MIN_ACTIVITIES_COUNT = 1;
public int $tries = 2;
private ?AutomatedReportResult $reportResult = null;
public function __construct(private readonly string $reportUuid)
{
$this->onQueue(Constants::QUEUE_ANALYTICS);
}
public function uniqueId(): string
{
return $this->reportUuid;
}
public function handle(
AutomatedReportsService $reportService,
AskJiminnyReportActivityService $activityService,
ProphetClient $prophetClient,
LoggerInterface $logger,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
): void {
$logger->info(self::LOG_PREFIX . ' Started', [
'automatedReportUuid' => $this->reportUuid,
]);
try {
$automatedReport = $reportService->getReport($this->reportUuid);
if (! $this->validateReport($automatedReport, $logger)) {
return;
}
$creator = $automatedReport->getCreator();
if ($creator === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, report creator not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$savedSearch = $automatedReport->getSavedSearch();
if ($savedSearch === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, saved search not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$prompt = $automatedReport->getAskAnythingPrompt();
if ($prompt === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, ask anything prompt not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$this->reportResult = $reportService->getOrCreateReportResult(
automatedReport: $automatedReport,
data: [
'status' => AutomatedReportResult::STATUS_DEFAULT,
'media_type' => AutomatedReportsService::MEDIA_TYPE_PDF,
]
);
$activityIds = $activityService->getActivityIdsForSavedSearch(
savedSearch: $savedSearch,
user: $creator,
frequency: $automatedReport->getFrequency(),
);
$activityCount = count($activityIds);
$logger->info(self::LOG_PREFIX . ' Fetched activity IDs', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
if ($activityCount < self::MIN_ACTIVITIES_COUNT) {
$this->failReport(AutomatedReportResult::REASON_NOT_ENOUGH_ACTIVITIES);
$logger->info(self::LOG_PREFIX . ' Not enough activities, skipped', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
$this->dispatchNotGeneratedNotifications(
$automatedReport,
$reportService,
$urlGenerator,
$jobDispatcher,
$logger,
);
return;
}
$payload = $reportService->getAskJiminnyGenerateReportPayload(
automatedReport: $automatedReport,
reportResult: $this->reportResult,
activityIds: $activityIds,
);
$this->reportResult->update([
'name' => $reportService->getReportFileName($this->reportResult),
'payload' => $payload,
'status' => AutomatedReportResult::STATUS_REQUESTED,
'requested_at' => Carbon::now()->toDateTimeString(),
]);
$logger->info(self::LOG_PREFIX . ' Request sent', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult->getUuid(),
'payload' => $payload,
]);
$response = $prophetClient->sendRequest(
endpoint: ProphetClient::ASK_JIMINNY_REPORT,
requestArray: $payload,
);
$logger->info(self::LOG_PREFIX . ' Response received', [
'response' => $response->getContent(),
]);
} catch (Throwable $exception) {
$reason = $exception instanceof ProphetException
? AutomatedReportResult::REASON_PROPHET_API_ERROR
: AutomatedReportResult::REASON_DEFAULT;
$this->failReport($reason);
$logger->error(self::LOG_PREFIX . ' Error', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult?->getUuid(),
'code' => $exception->getCode(),
'message' => $exception->getMessage(),
]);
if ($this->attempts() < $this->tries) {
$logger->info(self::LOG_PREFIX . ' Retry scheduled', [
'attempts' => $this->attempts(),
]);
$this->release(30);
} else {
$this->fail($exception);
}
}
}
private function validateReport(AutomatedReport $automatedReport, LoggerInterface $logger): bool
{
if ($automatedReport->getType() !== AutomatedReportsService::TYPE_ASK_JIMINNY) {
$logger->warning(self::LOG_PREFIX . ' Skipped, not an ask_jiminny report', [
'automatedReportUuid' => $this->reportUuid,
'type' => $automatedReport->getType(),
]);
return false;
}
if (! $automatedReport->getStatus()) {
$logger->info(self::LOG_PREFIX . ' Skipped, report is not active', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
if ($automatedReport->getTeam()->getStatus() !== Team::STATUS_ACTIVE) {
$logger->info(self::LOG_PREFIX . ' Skipped, team is inactive', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
return true;
}
private function failReport(int $reason): void
{
$this->reportResult?->update([
'status' => AutomatedReportResult::STATUS_FAILED,
'reason' => $reason,
]);
}
private function dispatchNotGeneratedNotifications(
AutomatedReport $automatedReport,
AutomatedReportsService $reportService,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
LoggerInterface $logger,
): void {
if ($this->reportResult === null) {
return;
}
$recipients = $reportService->getValidRecipientUsers($automatedReport);
if (empty($recipients)) {
$logger->info(self::LOG_PREFIX . ' No recipients to notify about missing report', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$reportName = $automatedReport->getCustomName()
?: $reportService->getReportTypeName($this->reportResult);
$periodName = $reportService->getReportPeriodName($this->reportResult);
$reportsPageUrl = $urlGenerator->route('ai.reports.show');
foreach ($recipients as $recipient) {
$jobDispatcher->dispatch(new SendReportNotGeneratedMailJob(
reportUuid: $this->reportResult->getUuid(),
recipientEmail: $recipient['email'],
recipientName: $recipient['name'] ?? null,
reportName: $reportName,
periodName: $periodName,
reportsPageUrl: $reportsPageUrl,
));
}
$logger->info(self::LOG_PREFIX . ' Dispatched not-generated notifications', [
'automatedReportUuid' => $this->reportUuid,
'recipientsCount' => count($recipients),
]);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide
app ~/jiminny/app, folder
.circleci, folder
.cursor, folder
.github
.sonarlint, folder
.vscode, folder...
|
PhpStorm
|
faVsco.js – RequestGenerateAskJiminnyReportJob.php
|
NULL
|
77648
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Jiminny\Jobs\AutomatedReports;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Queue\InteractsWithQueue;
use Jiminny\Component\ProphetAi\Exceptions\ProphetException;
use Jiminny\Component\ProphetAi\ProphetClient;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\JobDispatcherInterface;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Models\Team;
use Jiminny\Services\Kiosk\AutomatedReports\AskJiminnyReportActivityService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Throwable;
class RequestGenerateAskJiminnyReportJob implements ShouldQueue, ShouldBeUnique
{
use InteractsWithQueue;
use Queueable;
private const string LOG_PREFIX = '[AskJiminnyReport:Generate]';
private const int MIN_ACTIVITIES_COUNT = 1;
public int $tries = 2;
private ?AutomatedReportResult $reportResult = null;
public function __construct(private readonly string $reportUuid)
{
$this->onQueue(Constants::QUEUE_ANALYTICS);
}
public function uniqueId(): string
{
return $this->reportUuid;
}
public function handle(
AutomatedReportsService $reportService,
AskJiminnyReportActivityService $activityService,
ProphetClient $prophetClient,
LoggerInterface $logger,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
): void {
$logger->info(self::LOG_PREFIX . ' Started', [
'automatedReportUuid' => $this->reportUuid,
]);
try {
$automatedReport = $reportService->getReport($this->reportUuid);
if (! $this->validateReport($automatedReport, $logger)) {
return;
}
$creator = $automatedReport->getCreator();
if ($creator === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, report creator not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$savedSearch = $automatedReport->getSavedSearch();
if ($savedSearch === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, saved search not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$prompt = $automatedReport->getAskAnythingPrompt();
if ($prompt === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, ask anything prompt not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$this->reportResult = $reportService->getOrCreateReportResult(
automatedReport: $automatedReport,
data: [
'status' => AutomatedReportResult::STATUS_DEFAULT,
'media_type' => AutomatedReportsService::MEDIA_TYPE_PDF,
]
);
$activityIds = $activityService->getActivityIdsForSavedSearch(
savedSearch: $savedSearch,
user: $creator,
frequency: $automatedReport->getFrequency(),
);
$activityCount = count($activityIds);
$logger->info(self::LOG_PREFIX . ' Fetched activity IDs', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
if ($activityCount < self::MIN_ACTIVITIES_COUNT) {
$this->failReport(AutomatedReportResult::REASON_NOT_ENOUGH_ACTIVITIES);
$logger->info(self::LOG_PREFIX . ' Not enough activities, skipped', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
$this->dispatchNotGeneratedNotifications(
$automatedReport,
$reportService,
$urlGenerator,
$jobDispatcher,
$logger,
);
return;
}
$payload = $reportService->getAskJiminnyGenerateReportPayload(
automatedReport: $automatedReport,
reportResult: $this->reportResult,
activityIds: $activityIds,
);
$this->reportResult->update([
'name' => $reportService->getReportFileName($this->reportResult),
'payload' => $payload,
'status' => AutomatedReportResult::STATUS_REQUESTED,
'requested_at' => Carbon::now()->toDateTimeString(),
]);
$logger->info(self::LOG_PREFIX . ' Request sent', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult->getUuid(),
'payload' => $payload,
]);
$response = $prophetClient->sendRequest(
endpoint: ProphetClient::ASK_JIMINNY_REPORT,
requestArray: $payload,
);
$logger->info(self::LOG_PREFIX . ' Response received', [
'response' => $response->getContent(),
]);
} catch (Throwable $exception) {
$reason = $exception instanceof ProphetException
? AutomatedReportResult::REASON_PROPHET_API_ERROR
: AutomatedReportResult::REASON_DEFAULT;
$this->failReport($reason);
$logger->error(self::LOG_PREFIX . ' Error', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult?->getUuid(),
'code' => $exception->getCode(),
'message' => $exception->getMessage(),
]);
if ($this->attempts() < $this->tries) {
$logger->info(self::LOG_PREFIX . ' Retry scheduled', [
'attempts' => $this->attempts(),
]);
$this->release(30);
} else {
$this->fail($exception);
}
}
}
private function validateReport(AutomatedReport $automatedReport, LoggerInterface $logger): bool
{
if ($automatedReport->getType() !== AutomatedReportsService::TYPE_ASK_JIMINNY) {
$logger->warning(self::LOG_PREFIX . ' Skipped, not an ask_jiminny report', [
'automatedReportUuid' => $this->reportUuid,
'type' => $automatedReport->getType(),
]);
return false;
}
if (! $automatedReport->getStatus()) {
$logger->info(self::LOG_PREFIX . ' Skipped, report is not active', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
if ($automatedReport->getTeam()->getStatus() !== Team::STATUS_ACTIVE) {
$logger->info(self::LOG_PREFIX . ' Skipped, team is inactive', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
return true;
}
private function failReport(int $reason): void
{
$this->reportResult?->update([
'status' => AutomatedReportResult::STATUS_FAILED,
'reason' => $reason,
]);
}
private function dispatchNotGeneratedNotifications(
AutomatedReport $automatedReport,
AutomatedReportsService $reportService,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
LoggerInterface $logger,
): void {
if ($this->reportResult === null) {
return;
}
$recipients = $reportService->getValidRecipientUsers($automatedReport);
if (empty($recipients)) {
$logger->info(self::LOG_PREFIX . ' No recipients to notify about missing report', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$reportName = $automatedReport->getCustomName()
?: $reportService->getReportTypeName($this->reportResult);
$periodName = $reportService->getReportPeriodName($this->reportResult);
$reportsPageUrl = $urlGenerator->route('ai.reports.show');
foreach ($recipients as $recipient) {
$jobDispatcher->dispatch(new SendReportNotGeneratedMailJob(
reportUuid: $this->reportResult->getUuid(),
recipientEmail: $recipient['email'],
recipientName: $recipient['name'] ?? null,
reportName: $reportName,
periodName: $periodName,
reportsPageUrl: $reportsPageUrl,
));
}
$logger->info(self::LOG_PREFIX . ' Dispatched not-generated notifications', [
'automatedReportUuid' => $this->reportUuid,
'recipientsCount' => count($recipients),
]);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – RequestGenerateAskJiminnyReportJob.php
|
NULL
|
77649
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Jiminny\Jobs\AutomatedReports;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Queue\InteractsWithQueue;
use Jiminny\Component\ProphetAi\Exceptions\ProphetException;
use Jiminny\Component\ProphetAi\ProphetClient;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\JobDispatcherInterface;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Models\Team;
use Jiminny\Services\Kiosk\AutomatedReports\AskJiminnyReportActivityService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Throwable;
class RequestGenerateAskJiminnyReportJob implements ShouldQueue, ShouldBeUnique
{
use InteractsWithQueue;
use Queueable;
private const string LOG_PREFIX = '[AskJiminnyReport:Generate]';
private const int MIN_ACTIVITIES_COUNT = 1;
public int $tries = 2;
private ?AutomatedReportResult $reportResult = null;
public function __construct(private readonly string $reportUuid)
{
$this->onQueue(Constants::QUEUE_ANALYTICS);
}
public function uniqueId(): string
{
return $this->reportUuid;
}
public function handle(
AutomatedReportsService $reportService,
AskJiminnyReportActivityService $activityService,
ProphetClient $prophetClient,
LoggerInterface $logger,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
): void {
$logger->info(self::LOG_PREFIX . ' Started', [
'automatedReportUuid' => $this->reportUuid,
]);
try {
$automatedReport = $reportService->getReport($this->reportUuid);
if (! $this->validateReport($automatedReport, $logger)) {
return;
}
$creator = $automatedReport->getCreator();
if ($creator === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, report creator not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$savedSearch = $automatedReport->getSavedSearch();
if ($savedSearch === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, saved search not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$prompt = $automatedReport->getAskAnythingPrompt();
if ($prompt === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, ask anything prompt not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$this->reportResult = $reportService->getOrCreateReportResult(
automatedReport: $automatedReport,
data: [
'status' => AutomatedReportResult::STATUS_DEFAULT,
'media_type' => AutomatedReportsService::MEDIA_TYPE_PDF,
]
);
$activityIds = $activityService->getActivityIdsForSavedSearch(
savedSearch: $savedSearch,
user: $creator,
frequency: $automatedReport->getFrequency(),
);
$activityCount = count($activityIds);
$logger->info(self::LOG_PREFIX . ' Fetched activity IDs', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
if ($activityCount < self::MIN_ACTIVITIES_COUNT) {
$this->failReport(AutomatedReportResult::REASON_NOT_ENOUGH_ACTIVITIES);
$logger->info(self::LOG_PREFIX . ' Not enough activities, skipped', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
$this->dispatchNotGeneratedNotifications(
$automatedReport,
$reportService,
$urlGenerator,
$jobDispatcher,
$logger,
);
return;
}
$payload = $reportService->getAskJiminnyGenerateReportPayload(
automatedReport: $automatedReport,
reportResult: $this->reportResult,
activityIds: $activityIds,
);
$this->reportResult->update([
'name' => $reportService->getReportFileName($this->reportResult),
'payload' => $payload,
'status' => AutomatedReportResult::STATUS_REQUESTED,
'requested_at' => Carbon::now()->toDateTimeString(),
]);
$logger->info(self::LOG_PREFIX . ' Request sent', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult->getUuid(),
'payload' => $payload,
]);
$response = $prophetClient->sendRequest(
endpoint: ProphetClient::ASK_JIMINNY_REPORT,
requestArray: $payload,
);
$logger->info(self::LOG_PREFIX . ' Response received', [
'response' => $response->getContent(),
]);
} catch (Throwable $exception) {
$reason = $exception instanceof ProphetException
? AutomatedReportResult::REASON_PROPHET_API_ERROR
: AutomatedReportResult::REASON_DEFAULT;
$this->failReport($reason);
$logger->error(self::LOG_PREFIX . ' Error', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult?->getUuid(),
'code' => $exception->getCode(),
'message' => $exception->getMessage(),
]);
if ($this->attempts() < $this->tries) {
$logger->info(self::LOG_PREFIX . ' Retry scheduled', [
'attempts' => $this->attempts(),
]);
$this->release(30);
} else {
$this->fail($exception);
}
}
}
private function validateReport(AutomatedReport $automatedReport, LoggerInterface $logger): bool
{
if ($automatedReport->getType() !== AutomatedReportsService::TYPE_ASK_JIMINNY) {
$logger->warning(self::LOG_PREFIX . ' Skipped, not an ask_jiminny report', [
'automatedReportUuid' => $this->reportUuid,
'type' => $automatedReport->getType(),
]);
return false;
}
if (! $automatedReport->getStatus()) {
$logger->info(self::LOG_PREFIX . ' Skipped, report is not active', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
if ($automatedReport->getTeam()->getStatus() !== Team::STATUS_ACTIVE) {
$logger->info(self::LOG_PREFIX . ' Skipped, team is inactive', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
return true;
}
private function failReport(int $reason): void
{
$this->reportResult?->update([
'status' => AutomatedReportResult::STATUS_FAILED,
'reason' => $reason,
]);
}
private function dispatchNotGeneratedNotifications(
AutomatedReport $automatedReport,
AutomatedReportsService $reportService,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
LoggerInterface $logger,
): void {
if ($this->reportResult === null) {
return;
}
$recipients = $reportService->getValidRecipientUsers($automatedReport);
if (empty($recipients)) {
$logger->info(self::LOG_PREFIX . ' No recipients to notify about missing report', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$reportName = $automatedReport->getCustomName()
?: $reportService->getReportTypeName($this->reportResult);
$periodName = $reportService->getReportPeriodName($this->reportResult);
$reportsPageUrl = $urlGenerator->route('ai.reports.show');
foreach ($recipients as $recipient) {
$jobDispatcher->dispatch(new SendReportNotGeneratedMailJob(
reportUuid: $this->reportResult->getUuid(),
recipientEmail: $recipient['email'],
recipientName: $recipient['name'] ?? null,
reportName: $reportName,
periodName: $periodName,
reportsPageUrl: $reportsPageUrl,
));
}
$logger->info(self::LOG_PREFIX . ' Dispatched not-generated notifications', [
'automatedReportUuid' => $this->reportUuid,
'recipientsCount' => count($recipients),
]);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – RequestGenerateAskJiminnyReportJob.php
|
NULL
|
77650
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Jiminny\Jobs\AutomatedReports;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Queue\InteractsWithQueue;
use Jiminny\Component\ProphetAi\Exceptions\ProphetException;
use Jiminny\Component\ProphetAi\ProphetClient;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\JobDispatcherInterface;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Models\Team;
use Jiminny\Services\Kiosk\AutomatedReports\AskJiminnyReportActivityService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Throwable;
class RequestGenerateAskJiminnyReportJob implements ShouldQueue, ShouldBeUnique
{
use InteractsWithQueue;
use Queueable;
private const string LOG_PREFIX = '[AskJiminnyReport:Generate]';
private const int MIN_ACTIVITIES_COUNT = 1;
public int $tries = 2;
private ?AutomatedReportResult $reportResult = null;
public function __construct(private readonly string $reportUuid)
{
$this->onQueue(Constants::QUEUE_ANALYTICS);
}
public function uniqueId(): string
{
return $this->reportUuid;
}
public function handle(
AutomatedReportsService $reportService,
AskJiminnyReportActivityService $activityService,
ProphetClient $prophetClient,
LoggerInterface $logger,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
): void {
$logger->info(self::LOG_PREFIX . ' Started', [
'automatedReportUuid' => $this->reportUuid,
]);
try {
$automatedReport = $reportService->getReport($this->reportUuid);
if (! $this->validateReport($automatedReport, $logger)) {
return;
}
$creator = $automatedReport->getCreator();
if ($creator === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, report creator not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$savedSearch = $automatedReport->getSavedSearch();
if ($savedSearch === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, saved search not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$prompt = $automatedReport->getAskAnythingPrompt();
if ($prompt === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, ask anything prompt not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$this->reportResult = $reportService->getOrCreateReportResult(
automatedReport: $automatedReport,
data: [
'status' => AutomatedReportResult::STATUS_DEFAULT,
'media_type' => AutomatedReportsService::MEDIA_TYPE_PDF,
]
);
$activityIds = $activityService->getActivityIdsForSavedSearch(
savedSearch: $savedSearch,
user: $creator,
frequency: $automatedReport->getFrequency(),
);
$activityCount = count($activityIds);
$logger->info(self::LOG_PREFIX . ' Fetched activity IDs', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
if ($activityCount < self::MIN_ACTIVITIES_COUNT) {
$this->failReport(AutomatedReportResult::REASON_NOT_ENOUGH_ACTIVITIES);
$logger->info(self::LOG_PREFIX . ' Not enough activities, skipped', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
$this->dispatchNotGeneratedNotifications(
$automatedReport,
$reportService,
$urlGenerator,
$jobDispatcher,
$logger,
);
return;
}
$payload = $reportService->getAskJiminnyGenerateReportPayload(
automatedReport: $automatedReport,
reportResult: $this->reportResult,
activityIds: $activityIds,
);
$this->reportResult->update([
'name' => $reportService->getReportFileName($this->reportResult),
'payload' => $payload,
'status' => AutomatedReportResult::STATUS_REQUESTED,
'requested_at' => Carbon::now()->toDateTimeString(),
]);
$logger->info(self::LOG_PREFIX . ' Request sent', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult->getUuid(),
'payload' => $payload,
]);
$response = $prophetClient->sendRequest(
endpoint: ProphetClient::ASK_JIMINNY_REPORT,
requestArray: $payload,
);
$logger->info(self::LOG_PREFIX . ' Response received', [
'response' => $response->getContent(),
]);
} catch (Throwable $exception) {
$reason = $exception instanceof ProphetException
? AutomatedReportResult::REASON_PROPHET_API_ERROR
: AutomatedReportResult::REASON_DEFAULT;
$this->failReport($reason);
$logger->error(self::LOG_PREFIX . ' Error', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult?->getUuid(),
'code' => $exception->getCode(),
'message' => $exception->getMessage(),
]);
if ($this->attempts() < $this->tries) {
$logger->info(self::LOG_PREFIX . ' Retry scheduled', [
'attempts' => $this->attempts(),
]);
$this->release(30);
} else {
$this->fail($exception);
}
}
}
private function validateReport(AutomatedReport $automatedReport, LoggerInterface $logger): bool
{
if ($automatedReport->getType() !== AutomatedReportsService::TYPE_ASK_JIMINNY) {
$logger->warning(self::LOG_PREFIX . ' Skipped, not an ask_jiminny report', [
'automatedReportUuid' => $this->reportUuid,
'type' => $automatedReport->getType(),
]);
return false;
}
if (! $automatedReport->getStatus()) {
$logger->info(self::LOG_PREFIX . ' Skipped, report is not active', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
if ($automatedReport->getTeam()->getStatus() !== Team::STATUS_ACTIVE) {
$logger->info(self::LOG_PREFIX . ' Skipped, team is inactive', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
return true;
}
private function failReport(int $reason): void
{
$this->reportResult?->update([
'status' => AutomatedReportResult::STATUS_FAILED,
'reason' => $reason,
]);
}
private function dispatchNotGeneratedNotifications(
AutomatedReport $automatedReport,
AutomatedReportsService $reportService,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
LoggerInterface $logger,
): void {
if ($this->reportResult === null) {
return;
}
$recipients = $reportService->getValidRecipientUsers($automatedReport);
if (empty($recipients)) {
$logger->info(self::LOG_PREFIX . ' No recipients to notify about missing report', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$reportName = $automatedReport->getCustomName()
?: $reportService->getReportTypeName($this->reportResult);
$periodName = $reportService->getReportPeriodName($this->reportResult);
$reportsPageUrl = $urlGenerator->route('ai.reports.show');
foreach ($recipients as $recipient) {
$jobDispatcher->dispatch(new SendReportNotGeneratedMailJob(
reportUuid: $this->reportResult->getUuid(),
recipientEmail: $recipient['email'],
recipientName: $recipient['name'] ?? null,
reportName: $reportName,
periodName: $periodName,
reportsPageUrl: $reportsPageUrl,
));
}
$logger->info(self::LOG_PREFIX . ' Dispatched not-generated notifications', [
'automatedReportUuid' => $this->reportUuid,
'recipientsCount' => count($recipients),
]);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – RequestGenerateAskJiminnyReportJob.php
|
NULL
|
77651
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Jiminny\Jobs\AutomatedReports;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Queue\InteractsWithQueue;
use Jiminny\Component\ProphetAi\Exceptions\ProphetException;
use Jiminny\Component\ProphetAi\ProphetClient;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\JobDispatcherInterface;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Models\Team;
use Jiminny\Services\Kiosk\AutomatedReports\AskJiminnyReportActivityService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Throwable;
class RequestGenerateAskJiminnyReportJob implements ShouldQueue, ShouldBeUnique
{
use InteractsWithQueue;
use Queueable;
private const string LOG_PREFIX = '[AskJiminnyReport:Generate]';
private const int MIN_ACTIVITIES_COUNT = 1;
public int $tries = 2;
private ?AutomatedReportResult $reportResult = null;
public function __construct(private readonly string $reportUuid)
{
$this->onQueue(Constants::QUEUE_ANALYTICS);
}
public function uniqueId(): string
{
return $this->reportUuid;
}
public function handle(
AutomatedReportsService $reportService,
AskJiminnyReportActivityService $activityService,
ProphetClient $prophetClient,
LoggerInterface $logger,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
): void {
$logger->info(self::LOG_PREFIX . ' Started', [
'automatedReportUuid' => $this->reportUuid,
]);
try {
$automatedReport = $reportService->getReport($this->reportUuid);
if (! $this->validateReport($automatedReport, $logger)) {
return;
}
$creator = $automatedReport->getCreator();
if ($creator === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, report creator not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$savedSearch = $automatedReport->getSavedSearch();
if ($savedSearch === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, saved search not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$prompt = $automatedReport->getAskAnythingPrompt();
if ($prompt === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, ask anything prompt not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$this->reportResult = $reportService->getOrCreateReportResult(
automatedReport: $automatedReport,
data: [
'status' => AutomatedReportResult::STATUS_DEFAULT,
'media_type' => AutomatedReportsService::MEDIA_TYPE_PDF,
]
);
$activityIds = $activityService->getActivityIdsForSavedSearch(
savedSearch: $savedSearch,
user: $creator,
frequency: $automatedReport->getFrequency(),
);
$activityCount = count($activityIds);
$logger->info(self::LOG_PREFIX . ' Fetched activity IDs', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
if ($activityCount < self::MIN_ACTIVITIES_COUNT) {
$this->failReport(AutomatedReportResult::REASON_NOT_ENOUGH_ACTIVITIES);
$logger->info(self::LOG_PREFIX . ' Not enough activities, skipped', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
$this->dispatchNotGeneratedNotifications(
$automatedReport,
$reportService,
$urlGenerator,
$jobDispatcher,
$logger,
);
return;
}
$payload = $reportService->getAskJiminnyGenerateReportPayload(
automatedReport: $automatedReport,
reportResult: $this->reportResult,
activityIds: $activityIds,
);
$this->reportResult->update([
'name' => $reportService->getReportFileName($this->reportResult),
'payload' => $payload,
'status' => AutomatedReportResult::STATUS_REQUESTED,
'requested_at' => Carbon::now()->toDateTimeString(),
]);
$logger->info(self::LOG_PREFIX . ' Request sent', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult->getUuid(),
'payload' => $payload,
]);
$response = $prophetClient->sendRequest(
endpoint: ProphetClient::ASK_JIMINNY_REPORT,
requestArray: $payload,
);
$logger->info(self::LOG_PREFIX . ' Response received', [
'response' => $response->getContent(),
]);
} catch (Throwable $exception) {
$reason = $exception instanceof ProphetException
? AutomatedReportResult::REASON_PROPHET_API_ERROR
: AutomatedReportResult::REASON_DEFAULT;
$this->failReport($reason);
$logger->error(self::LOG_PREFIX . ' Error', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult?->getUuid(),
'code' => $exception->getCode(),
'message' => $exception->getMessage(),
]);
if ($this->attempts() < $this->tries) {
$logger->info(self::LOG_PREFIX . ' Retry scheduled', [
'attempts' => $this->attempts(),
]);
$this->release(30);
} else {
$this->fail($exception);
}
}
}
private function validateReport(AutomatedReport $automatedReport, LoggerInterface $logger): bool
{
if ($automatedReport->getType() !== AutomatedReportsService::TYPE_ASK_JIMINNY) {
$logger->warning(self::LOG_PREFIX . ' Skipped, not an ask_jiminny report', [
'automatedReportUuid' => $this->reportUuid,
'type' => $automatedReport->getType(),
]);
return false;
}
if (! $automatedReport->getStatus()) {
$logger->info(self::LOG_PREFIX . ' Skipped, report is not active', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
if ($automatedReport->getTeam()->getStatus() !== Team::STATUS_ACTIVE) {
$logger->info(self::LOG_PREFIX . ' Skipped, team is inactive', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
return true;
}
private function failReport(int $reason): void
{
$this->reportResult?->update([
'status' => AutomatedReportResult::STATUS_FAILED,
'reason' => $reason,
]);
}
private function dispatchNotGeneratedNotifications(
AutomatedReport $automatedReport,
AutomatedReportsService $reportService,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
LoggerInterface $logger,
): void {
if ($this->reportResult === null) {
return;
}
$recipients = $reportService->getValidRecipientUsers($automatedReport);
if (empty($recipients)) {
$logger->info(self::LOG_PREFIX . ' No recipients to notify about missing report', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$reportName = $automatedReport->getCustomName()
?: $reportService->getReportTypeName($this->reportResult);
$periodName = $reportService->getReportPeriodName($this->reportResult);
$reportsPageUrl = $urlGenerator->route('ai.reports.show');
foreach ($recipients as $recipient) {
$jobDispatcher->dispatch(new SendReportNotGeneratedMailJob(
reportUuid: $this->reportResult->getUuid(),
recipientEmail: $recipient['email'],
recipientName: $recipient['name'] ?? null,
reportName: $reportName,
periodName: $periodName,
reportsPageUrl: $reportsPageUrl,
));
}
$logger->info(self::LOG_PREFIX . ' Dispatched not-generated notifications', [
'automatedReportUuid' => $this->reportUuid,
'recipientsCount' => count($recipients),
]);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – RequestGenerateAskJiminnyReportJob.php
|
NULL
|
77652
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Jiminny\Jobs\AutomatedReports;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Queue\InteractsWithQueue;
use Jiminny\Component\ProphetAi\Exceptions\ProphetException;
use Jiminny\Component\ProphetAi\ProphetClient;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\JobDispatcherInterface;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Models\Team;
use Jiminny\Services\Kiosk\AutomatedReports\AskJiminnyReportActivityService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Throwable;
class RequestGenerateAskJiminnyReportJob implements ShouldQueue, ShouldBeUnique
{
use InteractsWithQueue;
use Queueable;
private const string LOG_PREFIX = '[AskJiminnyReport:Generate]';
private const int MIN_ACTIVITIES_COUNT = 1;
public int $tries = 2;
private ?AutomatedReportResult $reportResult = null;
public function __construct(private readonly string $reportUuid)
{
$this->onQueue(Constants::QUEUE_ANALYTICS);
}
public function uniqueId(): string
{
return $this->reportUuid;
}
public function handle(
AutomatedReportsService $reportService,
AskJiminnyReportActivityService $activityService,
ProphetClient $prophetClient,
LoggerInterface $logger,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
): void {
$logger->info(self::LOG_PREFIX . ' Started', [
'automatedReportUuid' => $this->reportUuid,
]);
try {
$automatedReport = $reportService->getReport($this->reportUuid);
if (! $this->validateReport($automatedReport, $logger)) {
return;
}
$creator = $automatedReport->getCreator();
if ($creator === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, report creator not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$savedSearch = $automatedReport->getSavedSearch();
if ($savedSearch === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, saved search not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$prompt = $automatedReport->getAskAnythingPrompt();
if ($prompt === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, ask anything prompt not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$this->reportResult = $reportService->getOrCreateReportResult(
automatedReport: $automatedReport,
data: [
'status' => AutomatedReportResult::STATUS_DEFAULT,
'media_type' => AutomatedReportsService::MEDIA_TYPE_PDF,
]
);
$activityIds = $activityService->getActivityIdsForSavedSearch(
savedSearch: $savedSearch,
user: $creator,
frequency: $automatedReport->getFrequency(),
);
$activityCount = count($activityIds);
$logger->info(self::LOG_PREFIX . ' Fetched activity IDs', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
if ($activityCount < self::MIN_ACTIVITIES_COUNT) {
$this->failReport(AutomatedReportResult::REASON_NOT_ENOUGH_ACTIVITIES);
$logger->info(self::LOG_PREFIX . ' Not enough activities, skipped', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
$this->dispatchNotGeneratedNotifications(
$automatedReport,
$reportService,
$urlGenerator,
$jobDispatcher,
$logger,
);
return;
}
$payload = $reportService->getAskJiminnyGenerateReportPayload(
automatedReport: $automatedReport,
reportResult: $this->reportResult,
activityIds: $activityIds,
);
$this->reportResult->update([
'name' => $reportService->getReportFileName($this->reportResult),
'payload' => $payload,
'status' => AutomatedReportResult::STATUS_REQUESTED,
'requested_at' => Carbon::now()->toDateTimeString(),
]);
$logger->info(self::LOG_PREFIX . ' Request sent', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult->getUuid(),
'payload' => $payload,
]);
$response = $prophetClient->sendRequest(
endpoint: ProphetClient::ASK_JIMINNY_REPORT,
requestArray: $payload,
);
$logger->info(self::LOG_PREFIX . ' Response received', [
'response' => $response->getContent(),
]);
} catch (Throwable $exception) {
$reason = $exception instanceof ProphetException
? AutomatedReportResult::REASON_PROPHET_API_ERROR
: AutomatedReportResult::REASON_DEFAULT;
$this->failReport($reason);
$logger->error(self::LOG_PREFIX . ' Error', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult?->getUuid(),
'code' => $exception->getCode(),
'message' => $exception->getMessage(),
]);
if ($this->attempts() < $this->tries) {
$logger->info(self::LOG_PREFIX . ' Retry scheduled', [
'attempts' => $this->attempts(),
]);
$this->release(30);
} else {
$this->fail($exception);
}
}
}
private function validateReport(AutomatedReport $automatedReport, LoggerInterface $logger): bool
{
if ($automatedReport->getType() !== AutomatedReportsService::TYPE_ASK_JIMINNY) {
$logger->warning(self::LOG_PREFIX . ' Skipped, not an ask_jiminny report', [
'automatedReportUuid' => $this->reportUuid,
'type' => $automatedReport->getType(),
]);
return false;
}
if (! $automatedReport->getStatus()) {
$logger->info(self::LOG_PREFIX . ' Skipped, report is not active', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
if ($automatedReport->getTeam()->getStatus() !== Team::STATUS_ACTIVE) {
$logger->info(self::LOG_PREFIX . ' Skipped, team is inactive', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
return true;
}
private function failReport(int $reason): void
{
$this->reportResult?->update([
'status' => AutomatedReportResult::STATUS_FAILED,
'reason' => $reason,
]);
}
private function dispatchNotGeneratedNotifications(
AutomatedReport $automatedReport,
AutomatedReportsService $reportService,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
LoggerInterface $logger,
): void {
if ($this->reportResult === null) {
return;
}
$recipients = $reportService->getValidRecipientUsers($automatedReport);
if (empty($recipients)) {
$logger->info(self::LOG_PREFIX . ' No recipients to notify about missing report', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$reportName = $automatedReport->getCustomName()
?: $reportService->getReportTypeName($this->reportResult);
$periodName = $reportService->getReportPeriodName($this->reportResult);
$reportsPageUrl = $urlGenerator->route('ai.reports.show');
foreach ($recipients as $recipient) {
$jobDispatcher->dispatch(new SendReportNotGeneratedMailJob(
reportUuid: $this->reportResult->getUuid(),
recipientEmail: $recipient['email'],
recipientName: $recipient['name'] ?? null,
reportName: $reportName,
periodName: $periodName,
reportsPageUrl: $reportsPageUrl,
));
}
$logger->info(self::LOG_PREFIX . ' Dispatched not-generated notifications', [
'automatedReportUuid' => $this->reportUuid,
'recipientsCount' => count($recipients),
]);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – RequestGenerateAskJiminnyReportJob.php
|
NULL
|
77653
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Jiminny\Jobs\AutomatedReports;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Queue\InteractsWithQueue;
use Jiminny\Component\ProphetAi\Exceptions\ProphetException;
use Jiminny\Component\ProphetAi\ProphetClient;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\JobDispatcherInterface;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Models\Team;
use Jiminny\Services\Kiosk\AutomatedReports\AskJiminnyReportActivityService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Throwable;
class RequestGenerateAskJiminnyReportJob implements ShouldQueue, ShouldBeUnique
{
use InteractsWithQueue;
use Queueable;
private const string LOG_PREFIX = '[AskJiminnyReport:Generate]';
private const int MIN_ACTIVITIES_COUNT = 1;
public int $tries = 2;
private ?AutomatedReportResult $reportResult = null;
public function __construct(private readonly string $reportUuid)
{
$this->onQueue(Constants::QUEUE_ANALYTICS);
}
public function uniqueId(): string
{
return $this->reportUuid;
}
public function handle(
AutomatedReportsService $reportService,
AskJiminnyReportActivityService $activityService,
ProphetClient $prophetClient,
LoggerInterface $logger,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
): void {
$logger->info(self::LOG_PREFIX . ' Started', [
'automatedReportUuid' => $this->reportUuid,
]);
try {
$automatedReport = $reportService->getReport($this->reportUuid);
if (! $this->validateReport($automatedReport, $logger)) {
return;
}
$creator = $automatedReport->getCreator();
if ($creator === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, report creator not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$savedSearch = $automatedReport->getSavedSearch();
if ($savedSearch === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, saved search not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$prompt = $automatedReport->getAskAnythingPrompt();
if ($prompt === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, ask anything prompt not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$this->reportResult = $reportService->getOrCreateReportResult(
automatedReport: $automatedReport,
data: [
'status' => AutomatedReportResult::STATUS_DEFAULT,
'media_type' => AutomatedReportsService::MEDIA_TYPE_PDF,
]
);
$activityIds = $activityService->getActivityIdsForSavedSearch(
savedSearch: $savedSearch,
user: $creator,
frequency: $automatedReport->getFrequency(),
);
$activityCount = count($activityIds);
$logger->info(self::LOG_PREFIX . ' Fetched activity IDs', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
if ($activityCount < self::MIN_ACTIVITIES_COUNT) {
$this->failReport(AutomatedReportResult::REASON_NOT_ENOUGH_ACTIVITIES);
$logger->info(self::LOG_PREFIX . ' Not enough activities, skipped', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
$this->dispatchNotGeneratedNotifications(
$automatedReport,
$reportService,
$urlGenerator,
$jobDispatcher,
$logger,
);
return;
}
$payload = $reportService->getAskJiminnyGenerateReportPayload(
automatedReport: $automatedReport,
reportResult: $this->reportResult,
activityIds: $activityIds,
);
$this->reportResult->update([
'name' => $reportService->getReportFileName($this->reportResult),
'payload' => $payload,
'status' => AutomatedReportResult::STATUS_REQUESTED,
'requested_at' => Carbon::now()->toDateTimeString(),
]);
$logger->info(self::LOG_PREFIX . ' Request sent', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult->getUuid(),
'payload' => $payload,
]);
$response = $prophetClient->sendRequest(
endpoint: ProphetClient::ASK_JIMINNY_REPORT,
requestArray: $payload,
);
$logger->info(self::LOG_PREFIX . ' Response received', [
'response' => $response->getContent(),
]);
} catch (Throwable $exception) {
$reason = $exception instanceof ProphetException
? AutomatedReportResult::REASON_PROPHET_API_ERROR
: AutomatedReportResult::REASON_DEFAULT;
$this->failReport($reason);
$logger->error(self::LOG_PREFIX . ' Error', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult?->getUuid(),
'code' => $exception->getCode(),
'message' => $exception->getMessage(),
]);
if ($this->attempts() < $this->tries) {
$logger->info(self::LOG_PREFIX . ' Retry scheduled', [
'attempts' => $this->attempts(),
]);
$this->release(30);
} else {
$this->fail($exception);
}
}
}
private function validateReport(AutomatedReport $automatedReport, LoggerInterface $logger): bool
{
if ($automatedReport->getType() !== AutomatedReportsService::TYPE_ASK_JIMINNY) {
$logger->warning(self::LOG_PREFIX . ' Skipped, not an ask_jiminny report', [
'automatedReportUuid' => $this->reportUuid,
'type' => $automatedReport->getType(),
]);
return false;
}
if (! $automatedReport->getStatus()) {
$logger->info(self::LOG_PREFIX . ' Skipped, report is not active', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
if ($automatedReport->getTeam()->getStatus() !== Team::STATUS_ACTIVE) {
$logger->info(self::LOG_PREFIX . ' Skipped, team is inactive', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
return true;
}
private function failReport(int $reason): void
{
$this->reportResult?->update([
'status' => AutomatedReportResult::STATUS_FAILED,
'reason' => $reason,
]);
}
private function dispatchNotGeneratedNotifications(
AutomatedReport $automatedReport,
AutomatedReportsService $reportService,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
LoggerInterface $logger,
): void {
if ($this->reportResult === null) {
return;
}
$recipients = $reportService->getValidRecipientUsers($automatedReport);
if (empty($recipients)) {
$logger->info(self::LOG_PREFIX . ' No recipients to notify about missing report', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$reportName = $automatedReport->getCustomName()
?: $reportService->getReportTypeName($this->reportResult);
$periodName = $reportService->getReportPeriodName($this->reportResult);
$reportsPageUrl = $urlGenerator->route('ai.reports.show');
foreach ($recipients as $recipient) {
$jobDispatcher->dispatch(new SendReportNotGeneratedMailJob(
reportUuid: $this->reportResult->getUuid(),
recipientEmail: $recipient['email'],
recipientName: $recipient['name'] ?? null,
reportName: $reportName,
periodName: $periodName,
reportsPageUrl: $reportsPageUrl,
));
}
$logger->info(self::LOG_PREFIX . ' Dispatched not-generated notifications', [
'automatedReportUuid' => $this->reportUuid,
'recipientsCount' => count($recipients),
]);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – RequestGenerateAskJiminnyReportJob.php
|
NULL
|
77654
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Jiminny\Jobs\AutomatedReports;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Queue\InteractsWithQueue;
use Jiminny\Component\ProphetAi\Exceptions\ProphetException;
use Jiminny\Component\ProphetAi\ProphetClient;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\JobDispatcherInterface;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Models\Team;
use Jiminny\Services\Kiosk\AutomatedReports\AskJiminnyReportActivityService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Throwable;
class RequestGenerateAskJiminnyReportJob implements ShouldQueue, ShouldBeUnique
{
use InteractsWithQueue;
use Queueable;
private const string LOG_PREFIX = '[AskJiminnyReport:Generate]';
private const int MIN_ACTIVITIES_COUNT = 1;
public int $tries = 2;
private ?AutomatedReportResult $reportResult = null;
public function __construct(private readonly string $reportUuid)
{
$this->onQueue(Constants::QUEUE_ANALYTICS);
}
public function uniqueId(): string
{
return $this->reportUuid;
}
public function handle(
AutomatedReportsService $reportService,
AskJiminnyReportActivityService $activityService,
ProphetClient $prophetClient,
LoggerInterface $logger,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
): void {
$logger->info(self::LOG_PREFIX . ' Started', [
'automatedReportUuid' => $this->reportUuid,
]);
try {
$automatedReport = $reportService->getReport($this->reportUuid);
if (! $this->validateReport($automatedReport, $logger)) {
return;
}
$creator = $automatedReport->getCreator();
if ($creator === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, report creator not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$savedSearch = $automatedReport->getSavedSearch();
if ($savedSearch === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, saved search not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$prompt = $automatedReport->getAskAnythingPrompt();
if ($prompt === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, ask anything prompt not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$this->reportResult = $reportService->getOrCreateReportResult(
automatedReport: $automatedReport,
data: [
'status' => AutomatedReportResult::STATUS_DEFAULT,
'media_type' => AutomatedReportsService::MEDIA_TYPE_PDF,
]
);
$activityIds = $activityService->getActivityIdsForSavedSearch(
savedSearch: $savedSearch,
user: $creator,
frequency: $automatedReport->getFrequency(),
);
$activityCount = count($activityIds);
$logger->info(self::LOG_PREFIX . ' Fetched activity IDs', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
if ($activityCount < self::MIN_ACTIVITIES_COUNT) {
$this->failReport(AutomatedReportResult::REASON_NOT_ENOUGH_ACTIVITIES);
$logger->info(self::LOG_PREFIX . ' Not enough activities, skipped', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
$this->dispatchNotGeneratedNotifications(
$automatedReport,
$reportService,
$urlGenerator,
$jobDispatcher,
$logger,
);
return;
}
$payload = $reportService->getAskJiminnyGenerateReportPayload(
automatedReport: $automatedReport,
reportResult: $this->reportResult,
activityIds: $activityIds,
);
$this->reportResult->update([
'name' => $reportService->getReportFileName($this->reportResult),
'payload' => $payload,
'status' => AutomatedReportResult::STATUS_REQUESTED,
'requested_at' => Carbon::now()->toDateTimeString(),
]);
$logger->info(self::LOG_PREFIX . ' Request sent', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult->getUuid(),
'payload' => $payload,
]);
$response = $prophetClient->sendRequest(
endpoint: ProphetClient::ASK_JIMINNY_REPORT,
requestArray: $payload,
);
$logger->info(self::LOG_PREFIX . ' Response received', [
'response' => $response->getContent(),
]);
} catch (Throwable $exception) {
$reason = $exception instanceof ProphetException
? AutomatedReportResult::REASON_PROPHET_API_ERROR
: AutomatedReportResult::REASON_DEFAULT;
$this->failReport($reason);
$logger->error(self::LOG_PREFIX . ' Error', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult?->getUuid(),
'code' => $exception->getCode(),
'message' => $exception->getMessage(),
]);
if ($this->attempts() < $this->tries) {
$logger->info(self::LOG_PREFIX . ' Retry scheduled', [
'attempts' => $this->attempts(),
]);
$this->release(30);
} else {
$this->fail($exception);
}
}
}
private function validateReport(AutomatedReport $automatedReport, LoggerInterface $logger): bool
{
if ($automatedReport->getType() !== AutomatedReportsService::TYPE_ASK_JIMINNY) {
$logger->warning(self::LOG_PREFIX . ' Skipped, not an ask_jiminny report', [
'automatedReportUuid' => $this->reportUuid,
'type' => $automatedReport->getType(),
]);
return false;
}
if (! $automatedReport->getStatus()) {
$logger->info(self::LOG_PREFIX . ' Skipped, report is not active', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
if ($automatedReport->getTeam()->getStatus() !== Team::STATUS_ACTIVE) {
$logger->info(self::LOG_PREFIX . ' Skipped, team is inactive', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
return true;
}
private function failReport(int $reason): void
{
$this->reportResult?->update([
'status' => AutomatedReportResult::STATUS_FAILED,
'reason' => $reason,
]);
}
private function dispatchNotGeneratedNotifications(
AutomatedReport $automatedReport,
AutomatedReportsService $reportService,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
LoggerInterface $logger,
): void {
if ($this->reportResult === null) {
return;
}
$recipients = $reportService->getValidRecipientUsers($automatedReport);
if (empty($recipients)) {
$logger->info(self::LOG_PREFIX . ' No recipients to notify about missing report', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$reportName = $automatedReport->getCustomName()
?: $reportService->getReportTypeName($this->reportResult);
$periodName = $reportService->getReportPeriodName($this->reportResult);
$reportsPageUrl = $urlGenerator->route('ai.reports.show');
foreach ($recipients as $recipient) {
$jobDispatcher->dispatch(new SendReportNotGeneratedMailJob(
reportUuid: $this->reportResult->getUuid(),
recipientEmail: $recipient['email'],
recipientName: $recipient['name'] ?? null,
reportName: $reportName,
periodName: $periodName,
reportsPageUrl: $reportsPageUrl,
));
}
$logger->info(self::LOG_PREFIX . ' Dispatched not-generated notifications', [
'automatedReportUuid' => $this->reportUuid,
'recipientsCount' => count($recipients),
]);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – RequestGenerateAskJiminnyReportJob.php
|
NULL
|
77655
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Jiminny\Jobs\AutomatedReports;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Queue\InteractsWithQueue;
use Jiminny\Component\ProphetAi\Exceptions\ProphetException;
use Jiminny\Component\ProphetAi\ProphetClient;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\JobDispatcherInterface;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Models\Team;
use Jiminny\Services\Kiosk\AutomatedReports\AskJiminnyReportActivityService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Throwable;
class RequestGenerateAskJiminnyReportJob implements ShouldQueue, ShouldBeUnique
{
use InteractsWithQueue;
use Queueable;
private const string LOG_PREFIX = '[AskJiminnyReport:Generate]';
private const int MIN_ACTIVITIES_COUNT = 1;
public int $tries = 2;
private ?AutomatedReportResult $reportResult = null;
public function __construct(private readonly string $reportUuid)
{
$this->onQueue(Constants::QUEUE_ANALYTICS);
}
public function uniqueId(): string
{
return $this->reportUuid;
}
public function handle(
AutomatedReportsService $reportService,
AskJiminnyReportActivityService $activityService,
ProphetClient $prophetClient,
LoggerInterface $logger,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
): void {
$logger->info(self::LOG_PREFIX . ' Started', [
'automatedReportUuid' => $this->reportUuid,
]);
try {
$automatedReport = $reportService->getReport($this->reportUuid);
if (! $this->validateReport($automatedReport, $logger)) {
return;
}
$creator = $automatedReport->getCreator();
if ($creator === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, report creator not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$savedSearch = $automatedReport->getSavedSearch();
if ($savedSearch === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, saved search not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$prompt = $automatedReport->getAskAnythingPrompt();
if ($prompt === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, ask anything prompt not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$this->reportResult = $reportService->getOrCreateReportResult(
automatedReport: $automatedReport,
data: [
'status' => AutomatedReportResult::STATUS_DEFAULT,
'media_type' => AutomatedReportsService::MEDIA_TYPE_PDF,
]
);
$activityIds = $activityService->getActivityIdsForSavedSearch(
savedSearch: $savedSearch,
user: $creator,
frequency: $automatedReport->getFrequency(),
);
$activityCount = count($activityIds);
$logger->info(self::LOG_PREFIX . ' Fetched activity IDs', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
if ($activityCount < self::MIN_ACTIVITIES_COUNT) {
$this->failReport(AutomatedReportResult::REASON_NOT_ENOUGH_ACTIVITIES);
$logger->info(self::LOG_PREFIX . ' Not enough activities, skipped', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
$this->dispatchNotGeneratedNotifications(
$automatedReport,
$reportService,
$urlGenerator,
$jobDispatcher,
$logger,
);
return;
}
$payload = $reportService->getAskJiminnyGenerateReportPayload(
automatedReport: $automatedReport,
reportResult: $this->reportResult,
activityIds: $activityIds,
);
$this->reportResult->update([
'name' => $reportService->getReportFileName($this->reportResult),
'payload' => $payload,
'status' => AutomatedReportResult::STATUS_REQUESTED,
'requested_at' => Carbon::now()->toDateTimeString(),
]);
$logger->info(self::LOG_PREFIX . ' Request sent', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult->getUuid(),
'payload' => $payload,
]);
$response = $prophetClient->sendRequest(
endpoint: ProphetClient::ASK_JIMINNY_REPORT,
requestArray: $payload,
);
$logger->info(self::LOG_PREFIX . ' Response received', [
'response' => $response->getContent(),
]);
} catch (Throwable $exception) {
$reason = $exception instanceof ProphetException
? AutomatedReportResult::REASON_PROPHET_API_ERROR
: AutomatedReportResult::REASON_DEFAULT;
$this->failReport($reason);
$logger->error(self::LOG_PREFIX . ' Error', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult?->getUuid(),
'code' => $exception->getCode(),
'message' => $exception->getMessage(),
]);
if ($this->attempts() < $this->tries) {
$logger->info(self::LOG_PREFIX . ' Retry scheduled', [
'attempts' => $this->attempts(),
]);
$this->release(30);
} else {
$this->fail($exception);
}
}
}
private function validateReport(AutomatedReport $automatedReport, LoggerInterface $logger): bool
{
if ($automatedReport->getType() !== AutomatedReportsService::TYPE_ASK_JIMINNY) {
$logger->warning(self::LOG_PREFIX . ' Skipped, not an ask_jiminny report', [
'automatedReportUuid' => $this->reportUuid,
'type' => $automatedReport->getType(),
]);
return false;
}
if (! $automatedReport->getStatus()) {
$logger->info(self::LOG_PREFIX . ' Skipped, report is not active', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
if ($automatedReport->getTeam()->getStatus() !== Team::STATUS_ACTIVE) {
$logger->info(self::LOG_PREFIX . ' Skipped, team is inactive', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
return true;
}
private function failReport(int $reason): void
{
$this->reportResult?->update([
'status' => AutomatedReportResult::STATUS_FAILED,
'reason' => $reason,
]);
}
private function dispatchNotGeneratedNotifications(
AutomatedReport $automatedReport,
AutomatedReportsService $reportService,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
LoggerInterface $logger,
): void {
if ($this->reportResult === null) {
return;
}
$recipients = $reportService->getValidRecipientUsers($automatedReport);
if (empty($recipients)) {
$logger->info(self::LOG_PREFIX . ' No recipients to notify about missing report', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$reportName = $automatedReport->getCustomName()
?: $reportService->getReportTypeName($this->reportResult);
$periodName = $reportService->getReportPeriodName($this->reportResult);
$reportsPageUrl = $urlGenerator->route('ai.reports.show');
foreach ($recipients as $recipient) {
$jobDispatcher->dispatch(new SendReportNotGeneratedMailJob(
reportUuid: $this->reportResult->getUuid(),
recipientEmail: $recipient['email'],
recipientName: $recipient['name'] ?? null,
reportName: $reportName,
periodName: $periodName,
reportsPageUrl: $reportsPageUrl,
));
}
$logger->info(self::LOG_PREFIX . ' Dispatched not-generated notifications', [
'automatedReportUuid' => $this->reportUuid,
'recipientsCount' => count($recipients),
]);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – RequestGenerateAskJiminnyReportJob.php
|
NULL
|
77656
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Jiminny\Jobs\AutomatedReports;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Queue\InteractsWithQueue;
use Jiminny\Component\ProphetAi\Exceptions\ProphetException;
use Jiminny\Component\ProphetAi\ProphetClient;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\JobDispatcherInterface;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Models\Team;
use Jiminny\Services\Kiosk\AutomatedReports\AskJiminnyReportActivityService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Throwable;
class RequestGenerateAskJiminnyReportJob implements ShouldQueue, ShouldBeUnique
{
use InteractsWithQueue;
use Queueable;
private const string LOG_PREFIX = '[AskJiminnyReport:Generate]';
private const int MIN_ACTIVITIES_COUNT = 1;
public int $tries = 2;
private ?AutomatedReportResult $reportResult = null;
public function __construct(private readonly string $reportUuid)
{
$this->onQueue(Constants::QUEUE_ANALYTICS);
}
public function uniqueId(): string
{
return $this->reportUuid;
}
public function handle(
AutomatedReportsService $reportService,
AskJiminnyReportActivityService $activityService,
ProphetClient $prophetClient,
LoggerInterface $logger,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
): void {
$logger->info(self::LOG_PREFIX . ' Started', [
'automatedReportUuid' => $this->reportUuid,
]);
try {
$automatedReport = $reportService->getReport($this->reportUuid);
if (! $this->validateReport($automatedReport, $logger)) {
return;
}
$creator = $automatedReport->getCreator();
if ($creator === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, report creator not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$savedSearch = $automatedReport->getSavedSearch();
if ($savedSearch === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, saved search not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$prompt = $automatedReport->getAskAnythingPrompt();
if ($prompt === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, ask anything prompt not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$this->reportResult = $reportService->getOrCreateReportResult(
automatedReport: $automatedReport,
data: [
'status' => AutomatedReportResult::STATUS_DEFAULT,
'media_type' => AutomatedReportsService::MEDIA_TYPE_PDF,
]
);
$activityIds = $activityService->getActivityIdsForSavedSearch(
savedSearch: $savedSearch,
user: $creator,
frequency: $automatedReport->getFrequency(),
);
$activityCount = count($activityIds);
$logger->info(self::LOG_PREFIX . ' Fetched activity IDs', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
if ($activityCount < self::MIN_ACTIVITIES_COUNT) {
$this->failReport(AutomatedReportResult::REASON_NOT_ENOUGH_ACTIVITIES);
$logger->info(self::LOG_PREFIX . ' Not enough activities, skipped', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
$this->dispatchNotGeneratedNotifications(
$automatedReport,
$reportService,
$urlGenerator,
$jobDispatcher,
$logger,
);
return;
}
$payload = $reportService->getAskJiminnyGenerateReportPayload(
automatedReport: $automatedReport,
reportResult: $this->reportResult,
activityIds: $activityIds,
);
$this->reportResult->update([
'name' => $reportService->getReportFileName($this->reportResult),
'payload' => $payload,
'status' => AutomatedReportResult::STATUS_REQUESTED,
'requested_at' => Carbon::now()->toDateTimeString(),
]);
$logger->info(self::LOG_PREFIX . ' Request sent', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult->getUuid(),
'payload' => $payload,
]);
$response = $prophetClient->sendRequest(
endpoint: ProphetClient::ASK_JIMINNY_REPORT,
requestArray: $payload,
);
$logger->info(self::LOG_PREFIX . ' Response received', [
'response' => $response->getContent(),
]);
} catch (Throwable $exception) {
$reason = $exception instanceof ProphetException
? AutomatedReportResult::REASON_PROPHET_API_ERROR
: AutomatedReportResult::REASON_DEFAULT;
$this->failReport($reason);
$logger->error(self::LOG_PREFIX . ' Error', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult?->getUuid(),
'code' => $exception->getCode(),
'message' => $exception->getMessage(),
]);
if ($this->attempts() < $this->tries) {
$logger->info(self::LOG_PREFIX . ' Retry scheduled', [
'attempts' => $this->attempts(),
]);
$this->release(30);
} else {
$this->fail($exception);
}
}
}
private function validateReport(AutomatedReport $automatedReport, LoggerInterface $logger): bool
{
if ($automatedReport->getType() !== AutomatedReportsService::TYPE_ASK_JIMINNY) {
$logger->warning(self::LOG_PREFIX . ' Skipped, not an ask_jiminny report', [
'automatedReportUuid' => $this->reportUuid,
'type' => $automatedReport->getType(),
]);
return false;
}
if (! $automatedReport->getStatus()) {
$logger->info(self::LOG_PREFIX . ' Skipped, report is not active', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
if ($automatedReport->getTeam()->getStatus() !== Team::STATUS_ACTIVE) {
$logger->info(self::LOG_PREFIX . ' Skipped, team is inactive', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
return true;
}
private function failReport(int $reason): void
{
$this->reportResult?->update([
'status' => AutomatedReportResult::STATUS_FAILED,
'reason' => $reason,
]);
}
private function dispatchNotGeneratedNotifications(
AutomatedReport $automatedReport,
AutomatedReportsService $reportService,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
LoggerInterface $logger,
): void {
if ($this->reportResult === null) {
return;
}
$recipients = $reportService->getValidRecipientUsers($automatedReport);
if (empty($recipients)) {
$logger->info(self::LOG_PREFIX . ' No recipients to notify about missing report', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$reportName = $automatedReport->getCustomName()
?: $reportService->getReportTypeName($this->reportResult);
$periodName = $reportService->getReportPeriodName($this->reportResult);
$reportsPageUrl = $urlGenerator->route('ai.reports.show');
foreach ($recipients as $recipient) {
$jobDispatcher->dispatch(new SendReportNotGeneratedMailJob(
reportUuid: $this->reportResult->getUuid(),
recipientEmail: $recipient['email'],
recipientName: $recipient['name'] ?? null,
reportName: $reportName,
periodName: $periodName,
reportsPageUrl: $reportsPageUrl,
));
}
$logger->info(self::LOG_PREFIX . ' Dispatched not-generated notifications', [
'automatedReportUuid' => $this->reportUuid,
'recipientsCount' => count($recipients),
]);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – RequestGenerateAskJiminnyReportJob.php
|
NULL
|
77657
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Jiminny\Jobs\AutomatedReports;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Queue\InteractsWithQueue;
use Jiminny\Component\ProphetAi\Exceptions\ProphetException;
use Jiminny\Component\ProphetAi\ProphetClient;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\JobDispatcherInterface;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Models\Team;
use Jiminny\Services\Kiosk\AutomatedReports\AskJiminnyReportActivityService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Throwable;
class RequestGenerateAskJiminnyReportJob implements ShouldQueue, ShouldBeUnique
{
use InteractsWithQueue;
use Queueable;
private const string LOG_PREFIX = '[AskJiminnyReport:Generate]';
private const int MIN_ACTIVITIES_COUNT = 1;
public int $tries = 2;
private ?AutomatedReportResult $reportResult = null;
public function __construct(private readonly string $reportUuid)
{
$this->onQueue(Constants::QUEUE_ANALYTICS);
}
public function uniqueId(): string
{
return $this->reportUuid;
}
public function handle(
AutomatedReportsService $reportService,
AskJiminnyReportActivityService $activityService,
ProphetClient $prophetClient,
LoggerInterface $logger,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
): void {
$logger->info(self::LOG_PREFIX . ' Started', [
'automatedReportUuid' => $this->reportUuid,
]);
try {
$automatedReport = $reportService->getReport($this->reportUuid);
if (! $this->validateReport($automatedReport, $logger)) {
return;
}
$creator = $automatedReport->getCreator();
if ($creator === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, report creator not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$savedSearch = $automatedReport->getSavedSearch();
if ($savedSearch === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, saved search not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$prompt = $automatedReport->getAskAnythingPrompt();
if ($prompt === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, ask anything prompt not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$this->reportResult = $reportService->getOrCreateReportResult(
automatedReport: $automatedReport,
data: [
'status' => AutomatedReportResult::STATUS_DEFAULT,
'media_type' => AutomatedReportsService::MEDIA_TYPE_PDF,
]
);
$activityIds = $activityService->getActivityIdsForSavedSearch(
savedSearch: $savedSearch,
user: $creator,
frequency: $automatedReport->getFrequency(),
);
$activityCount = count($activityIds);
$logger->info(self::LOG_PREFIX . ' Fetched activity IDs', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
if ($activityCount < self::MIN_ACTIVITIES_COUNT) {
$this->failReport(AutomatedReportResult::REASON_NOT_ENOUGH_ACTIVITIES);
$logger->info(self::LOG_PREFIX . ' Not enough activities, skipped', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
$this->dispatchNotGeneratedNotifications(
$automatedReport,
$reportService,
$urlGenerator,
$jobDispatcher,
$logger,
);
return;
}
$payload = $reportService->getAskJiminnyGenerateReportPayload(
automatedReport: $automatedReport,
reportResult: $this->reportResult,
activityIds: $activityIds,
);
$this->reportResult->update([
'name' => $reportService->getReportFileName($this->reportResult),
'payload' => $payload,
'status' => AutomatedReportResult::STATUS_REQUESTED,
'requested_at' => Carbon::now()->toDateTimeString(),
]);
$logger->info(self::LOG_PREFIX . ' Request sent', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult->getUuid(),
'payload' => $payload,
]);
$response = $prophetClient->sendRequest(
endpoint: ProphetClient::ASK_JIMINNY_REPORT,
requestArray: $payload,
);
$logger->info(self::LOG_PREFIX . ' Response received', [
'response' => $response->getContent(),
]);
} catch (Throwable $exception) {
$reason = $exception instanceof ProphetException
? AutomatedReportResult::REASON_PROPHET_API_ERROR
: AutomatedReportResult::REASON_DEFAULT;
$this->failReport($reason);
$logger->error(self::LOG_PREFIX . ' Error', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult?->getUuid(),
'code' => $exception->getCode(),
'message' => $exception->getMessage(),
]);
if ($this->attempts() < $this->tries) {
$logger->info(self::LOG_PREFIX . ' Retry scheduled', [
'attempts' => $this->attempts(),
]);
$this->release(30);
} else {
$this->fail($exception);
}
}
}
private function validateReport(AutomatedReport $automatedReport, LoggerInterface $logger): bool
{
if ($automatedReport->getType() !== AutomatedReportsService::TYPE_ASK_JIMINNY) {
$logger->warning(self::LOG_PREFIX . ' Skipped, not an ask_jiminny report', [
'automatedReportUuid' => $this->reportUuid,
'type' => $automatedReport->getType(),
]);
return false;
}
if (! $automatedReport->getStatus()) {
$logger->info(self::LOG_PREFIX . ' Skipped, report is not active', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
if ($automatedReport->getTeam()->getStatus() !== Team::STATUS_ACTIVE) {
$logger->info(self::LOG_PREFIX . ' Skipped, team is inactive', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
return true;
}
private function failReport(int $reason): void
{
$this->reportResult?->update([
'status' => AutomatedReportResult::STATUS_FAILED,
'reason' => $reason,
]);
}
private function dispatchNotGeneratedNotifications(
AutomatedReport $automatedReport,
AutomatedReportsService $reportService,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
LoggerInterface $logger,
): void {
if ($this->reportResult === null) {
return;
}
$recipients = $reportService->getValidRecipientUsers($automatedReport);
if (empty($recipients)) {
$logger->info(self::LOG_PREFIX . ' No recipients to notify about missing report', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$reportName = $automatedReport->getCustomName()
?: $reportService->getReportTypeName($this->reportResult);
$periodName = $reportService->getReportPeriodName($this->reportResult);
$reportsPageUrl = $urlGenerator->route('ai.reports.show');
foreach ($recipients as $recipient) {
$jobDispatcher->dispatch(new SendReportNotGeneratedMailJob(
reportUuid: $this->reportResult->getUuid(),
recipientEmail: $recipient['email'],
recipientName: $recipient['name'] ?? null,
reportName: $reportName,
periodName: $periodName,
reportsPageUrl: $reportsPageUrl,
));
}
$logger->info(self::LOG_PREFIX . ' Dispatched not-generated notifications', [
'automatedReportUuid' => $this->reportUuid,
'recipientsCount' => count($recipients),
]);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – RequestGenerateAskJiminnyReportJob.php
|
NULL
|
77658
|
|
Project: faVsco.js, menu
#12011 on JY-20157-AJ-rep Project: faVsco.js, menu
#12011 on JY-20157-AJ-report-not-send-notification, menu
Start Listening for PHP Debug Connections
ReportControllerTest
Run 'ReportControllerTest'
Debug 'ReportControllerTest'
More Actions
JetBrains AI
Search Everywhere
IDE and Project Settings
Code changed:
Hide
Sync Changes
Hide This Notification
<?php
declare(strict_types=1);
namespace Jiminny\Jobs\AutomatedReports;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Queue\InteractsWithQueue;
use Jiminny\Component\ProphetAi\Exceptions\ProphetException;
use Jiminny\Component\ProphetAi\ProphetClient;
use Jiminny\Component\Queue\Constants;
use Jiminny\Jobs\JobDispatcherInterface;
use Jiminny\Models\AutomatedReport;
use Jiminny\Models\AutomatedReportResult;
use Jiminny\Models\Team;
use Jiminny\Services\Kiosk\AutomatedReports\AskJiminnyReportActivityService;
use Jiminny\Services\Kiosk\AutomatedReports\AutomatedReportsService;
use Psr\Log\LoggerInterface;
use Throwable;
class RequestGenerateAskJiminnyReportJob implements ShouldQueue, ShouldBeUnique
{
use InteractsWithQueue;
use Queueable;
private const string LOG_PREFIX = '[AskJiminnyReport:Generate]';
private const int MIN_ACTIVITIES_COUNT = 1;
public int $tries = 2;
private ?AutomatedReportResult $reportResult = null;
public function __construct(private readonly string $reportUuid)
{
$this->onQueue(Constants::QUEUE_ANALYTICS);
}
public function uniqueId(): string
{
return $this->reportUuid;
}
public function handle(
AutomatedReportsService $reportService,
AskJiminnyReportActivityService $activityService,
ProphetClient $prophetClient,
LoggerInterface $logger,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
): void {
$logger->info(self::LOG_PREFIX . ' Started', [
'automatedReportUuid' => $this->reportUuid,
]);
try {
$automatedReport = $reportService->getReport($this->reportUuid);
if (! $this->validateReport($automatedReport, $logger)) {
return;
}
$creator = $automatedReport->getCreator();
if ($creator === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, report creator not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$savedSearch = $automatedReport->getSavedSearch();
if ($savedSearch === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, saved search not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$prompt = $automatedReport->getAskAnythingPrompt();
if ($prompt === null) {
$logger->warning(self::LOG_PREFIX . ' Skipped, ask anything prompt not found', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$this->reportResult = $reportService->getOrCreateReportResult(
automatedReport: $automatedReport,
data: [
'status' => AutomatedReportResult::STATUS_DEFAULT,
'media_type' => AutomatedReportsService::MEDIA_TYPE_PDF,
]
);
$activityIds = $activityService->getActivityIdsForSavedSearch(
savedSearch: $savedSearch,
user: $creator,
frequency: $automatedReport->getFrequency(),
);
$activityCount = count($activityIds);
$logger->info(self::LOG_PREFIX . ' Fetched activity IDs', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
if ($activityCount < self::MIN_ACTIVITIES_COUNT) {
$this->failReport(AutomatedReportResult::REASON_NOT_ENOUGH_ACTIVITIES);
$logger->info(self::LOG_PREFIX . ' Not enough activities, skipped', [
'automatedReportUuid' => $this->reportUuid,
'activityCount' => $activityCount,
]);
$this->dispatchNotGeneratedNotifications(
$automatedReport,
$reportService,
$urlGenerator,
$jobDispatcher,
$logger,
);
return;
}
$payload = $reportService->getAskJiminnyGenerateReportPayload(
automatedReport: $automatedReport,
reportResult: $this->reportResult,
activityIds: $activityIds,
);
$this->reportResult->update([
'name' => $reportService->getReportFileName($this->reportResult),
'payload' => $payload,
'status' => AutomatedReportResult::STATUS_REQUESTED,
'requested_at' => Carbon::now()->toDateTimeString(),
]);
$logger->info(self::LOG_PREFIX . ' Request sent', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult->getUuid(),
'payload' => $payload,
]);
$response = $prophetClient->sendRequest(
endpoint: ProphetClient::ASK_JIMINNY_REPORT,
requestArray: $payload,
);
$logger->info(self::LOG_PREFIX . ' Response received', [
'response' => $response->getContent(),
]);
} catch (Throwable $exception) {
$reason = $exception instanceof ProphetException
? AutomatedReportResult::REASON_PROPHET_API_ERROR
: AutomatedReportResult::REASON_DEFAULT;
$this->failReport($reason);
$logger->error(self::LOG_PREFIX . ' Error', [
'automatedReportUuid' => $this->reportUuid,
'reportUuid' => $this->reportResult?->getUuid(),
'code' => $exception->getCode(),
'message' => $exception->getMessage(),
]);
if ($this->attempts() < $this->tries) {
$logger->info(self::LOG_PREFIX . ' Retry scheduled', [
'attempts' => $this->attempts(),
]);
$this->release(30);
} else {
$this->fail($exception);
}
}
}
private function validateReport(AutomatedReport $automatedReport, LoggerInterface $logger): bool
{
if ($automatedReport->getType() !== AutomatedReportsService::TYPE_ASK_JIMINNY) {
$logger->warning(self::LOG_PREFIX . ' Skipped, not an ask_jiminny report', [
'automatedReportUuid' => $this->reportUuid,
'type' => $automatedReport->getType(),
]);
return false;
}
if (! $automatedReport->getStatus()) {
$logger->info(self::LOG_PREFIX . ' Skipped, report is not active', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
if ($automatedReport->getTeam()->getStatus() !== Team::STATUS_ACTIVE) {
$logger->info(self::LOG_PREFIX . ' Skipped, team is inactive', [
'automatedReportUuid' => $this->reportUuid,
]);
return false;
}
return true;
}
private function failReport(int $reason): void
{
$this->reportResult?->update([
'status' => AutomatedReportResult::STATUS_FAILED,
'reason' => $reason,
]);
}
private function dispatchNotGeneratedNotifications(
AutomatedReport $automatedReport,
AutomatedReportsService $reportService,
UrlGenerator $urlGenerator,
JobDispatcherInterface $jobDispatcher,
LoggerInterface $logger,
): void {
if ($this->reportResult === null) {
return;
}
$recipients = $reportService->getValidRecipientUsers($automatedReport);
if (empty($recipients)) {
$logger->info(self::LOG_PREFIX . ' No recipients to notify about missing report', [
'automatedReportUuid' => $this->reportUuid,
]);
return;
}
$reportName = $automatedReport->getCustomName()
?: $reportService->getReportTypeName($this->reportResult);
$periodName = $reportService->getReportPeriodName($this->reportResult);
$reportsPageUrl = $urlGenerator->route('ai.reports.show');
foreach ($recipients as $recipient) {
$jobDispatcher->dispatch(new SendReportNotGeneratedMailJob(
reportUuid: $this->reportResult->getUuid(),
recipientEmail: $recipient['email'],
recipientName: $recipient['name'] ?? null,
reportName: $reportName,
periodName: $periodName,
reportsPageUrl: $reportsPageUrl,
));
}
$logger->info(self::LOG_PREFIX . ' Dispatched not-generated notifications', [
'automatedReportUuid' => $this->reportUuid,
'recipientsCount' => count($recipients),
]);
}
}
Sync Changes
Hide This Notification
Code changed:
Hide
7
Previous Highlighted Error
Next Highlighted Error
<?php
namespace Jiminny\Services\UserPilot;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Jiminny\Models\Feature\FeatureEnum;
use Jiminny\Models\Partner;
use Jiminny\Models\Team;
use Jiminny\Models\User;
class UserPilotClient
{
private const API_ENDPOINT = 'https://api.userpilot.io/v1/';
private const ANALYTICS_ENDPOINT = 'https://analytex.userpilot.io/v1/';
private function createRequest(): PendingRequest
{
return Http::withHeaders([
'X-API-Version' => '2020-09-22',
'Authorization' => 'Token ' . config('services.userpilot.key'),
]);
}
public function track(User $user, string $event, array $payload = []): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'track', [
'event_name' => $event,
'user_id' => $user->getUuid(),
'metadata' => $payload,
]);
}
public function upsertUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$companyMetadata = $this->getCompanyMetadata($user->getTeam());
$companyMetadata['id'] = $user->getTeam()->getUuid();
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'identify', [
'user_id' => $user->getUuid(),
'metadata' => [
'name' => $user->name,
'first_name' => $user->getFirstName(),
'position' => $user->job ? $user->job->name : null,
'email' => $user->getEmailAddress(),
'created_at' => $user->getCreatedAt()->unix(),
'is_admin' => $user->hasRole(User::ROLE_ADMIN),
'is_manager' => $user->hasRole(User::ROLE_MANAGER),
'is_owner' => $user->isTeamOwner(),
'is_insights' => $user->hasRole(User::ROLE_ANALYST),
'is_recorder' => $user->hasRole(User::ROLE_RECORDER),
'is_jiminny_voice' => $user->hasRole(User::ROLE_RECORDER_AND_VOICE),
'is_listener' => $user->hasRole(User::ROLE_LISTENER),
'license' => null,
'team' => $user->group ? $user->group->name : null,
'language' => $user->getLanguage(),
'email_sync' => $user->isSyncEmailEnabled(),
],
'company' => $companyMetadata,
]);
}
public function upsertCompany(Team $team): void
{
$this->createRequest()->post(self::ANALYTICS_ENDPOINT . 'companies/identify', [
'company_id' => $team->getUuid(),
'metadata' => $this->getCompanyMetadata($team),
]);
}
private function getCompanyMetadata(Team $team): array
{
return [
'created_at' => $team->getCreatedAt()->unix(),
'name' => $team->getName(),
'region' => config('jiminny.deploy_region'),
'crm' => $team->getCrmConfiguration()->getProviderName(),
'crm_installed_app_version' => $team->getCrmConfiguration()->getInstalledAppVersion(),
'calendar' => $team->getCalendarProvider(),
'notification_provider' => $team->getNotificationProvider(),
'has_jiminny_voice' => $team->hasFeature(FeatureEnum::DIALER),
'tier' => $team->getTier()?->getTitle(),
];
}
public function deleteUser(User $user): void
{
if ($this->shouldRequest($user->getTeam()) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'users', [
'users' => [$user->getUuid()],
]);
}
public function deleteCompany(Team $team): void
{
if ($this->shouldRequest($team) === false) {
return;
}
$this->createRequest()->delete(self::API_ENDPOINT . 'companies', [
'companies' => [$team->getUuid()],
]);
}
public function shouldRequest(Team $team): bool
{
return config('services.userpilot.key') !== null && $team->getPartnerId() === Partner::PARTNER_DEFAULT;
}
}
Project
Project
New File or Directory…
Expand Selected
Collapse All
Options
Hide...
|
PhpStorm
|
faVsco.js – RequestGenerateAskJiminnyReportJob.php
|
NULL
|
77659
|