Skip to content

Commit ce553c5

Browse files
adriendupuisdabrt
andauthored
Raptor integration: Rework PHP (#3131)
* tracking_php_api.md: Detail EventMapper, EventType, EventContext * tracking_php_api.md: caution about buy event --------- Co-authored-by: Tomasz Dąbrowski <64841871+dabrt@users.noreply.github.com>
1 parent 9fb1061 commit ce553c5

6 files changed

Lines changed: 2011 additions & 9 deletions

code_samples/recommendations/EventMapper.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Tracking;
44

5+
use Ibexa\Contracts\ConnectorRaptor\Tracking\EventContext;
56
use Ibexa\Contracts\ConnectorRaptor\Tracking\EventMapperInterface;
67
use Ibexa\Contracts\ConnectorRaptor\Tracking\EventType;
78
use Ibexa\Contracts\ConnectorRaptor\Tracking\ServerSideTrackingDispatcherInterface;
@@ -15,10 +16,12 @@ public function __construct(
1516
) {
1617
}
1718

18-
public function trackProductView(ProductInterface $product, string $url): void
19+
public function trackProductView(ProductInterface $product): void
1920
{
20-
// Map product to VisitEventData automatically
21-
$eventData = $this->eventMapper->map(EventType::VISIT, $product);
21+
// Map product to VisitEventData automatically, override its category
22+
$eventData = $this->eventMapper->map(EventType::VISIT, $product, [
23+
EventContext::CATEGORY_IDENTIFIER => 'electronics',
24+
]);
2225

2326
// Send tracking event
2427
$this->trackingDispatcher->dispatch($eventData);

0 commit comments

Comments
 (0)