Commit 997ec821 authored by Mark Harding's avatar Mark Harding
Browse files

(feat): support recording multiple entity types

parent eaaf74d0
Loading
Loading
Loading
Loading
+17 −14
Original line number Original line Diff line number Diff line
@@ -67,15 +67,17 @@ class views implements Interfaces\Api
                ]);
                ]);
                break;
                break;
            case 'activity':
            case 'activity':
                $activity = new Entities\Activity($pages[1]);
            case 'entity':
                $entity = Entities\Factory::build($pages[1]);


                if (!$activity->guid) {
                if (!$entity) {
                    return Factory::response([
                    return Factory::response([
                        'status' => 'error',
                        'status' => 'error',
                        'message' => 'Could not find activity post'
                        'message' => 'Could not the entity'
                    ]);
                    ]);
                }
                }


                if ($entity->type === 'activity') {
                    try {
                    try {
                        Core\Analytics\App::_()
                        Core\Analytics\App::_()
                        ->setMetric('impression')
                        ->setMetric('impression')
@@ -101,12 +103,13 @@ class views implements Interfaces\Api
                    } catch (\Exception $e) {
                    } catch (\Exception $e) {
                        error_log($e->getMessage());
                        error_log($e->getMessage());
                    }
                    }
                }


                try {
                try {
                    $viewsManager->record(
                    $viewsManager->record(
                        (new Core\Analytics\Views\View())
                        (new Core\Analytics\Views\View())
                            ->setEntityUrn($activity->getUrn())
                            ->setEntityUrn($entity->getUrn())
                            ->setOwnerGuid((string) $activity->getOwnerGuid())
                            ->setOwnerGuid((string) $entity->getOwnerGuid())
                            ->setClientMeta($_POST['client_meta'] ?? [])
                            ->setClientMeta($_POST['client_meta'] ?? [])
                    );
                    );
                } catch (\Exception $e) {
                } catch (\Exception $e) {