From 107740d04b35d6a6cf167e02e624179c5b64e815 Mon Sep 17 00:00:00 2001 From: Thorsten Reiter <34274688+reithor@users.noreply.github.com> Date: Tue, 24 Sep 2024 10:53:03 +0200 Subject: [PATCH] Perso REST: update namespace (#2346) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ezp → ibexa --------- Co-authored-by: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> (cherry picked from commit 6bbfb04836eefd7013c20ea8b1a3e253456ec36f) --- .../personalization/enable_personalization.md | 72 +++++++++---------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/docs/personalization/enable_personalization.md b/docs/personalization/enable_personalization.md index ce7ea79830..13a74fe53e 100644 --- a/docs/personalization/enable_personalization.md +++ b/docs/personalization/enable_personalization.md @@ -1,4 +1,3 @@ ---- description: Configure your project files to enable Personalization and set up items you want to track. --- @@ -161,33 +160,41 @@ Place the following code snippet in the `` section of your header template ### Check whether the bundle provides REST data You can verify the import controller of the bundle by calling the local API. -Use the `Accept` header; you may need to add an `Authorization` header if authentication is required. +As the API uses token based authorization you first need a valid bearer token. -To check whether the `content` endpoint is working as expected, perform the following request: +When you publish a content item a bearer token is created and saved to the `ibexa_token` db table. -``` -GET http:///api/ezp/v2/ibexa_personalization/v1/content/{contentId} -Accept application/vnd.ez.api.Content+json -Authorization Basic xxxxxxxx -``` +Additionally a POST request is send to the Personalization Engine, containing the token +and the Rest URL where the Personalization Engine can fetch the changed Content. + +The `BEARER_TOKEN` is the newest one in `ibexa_token` table having `type=1` and `identifier=update`. The token has a default lifetime of one day. -Additionally, check whether the `contenttypes` endpoint is working with the following request: +You can use this token to check what is provided to the Personalization Engine: + +```bash +curl --location '{PERSONALIZATION_HOST_URI}/api/ibexa/v2/personalization/v1/content/id/{contentId}?lang={comma_separated_languages}' \ +--header 'Accept: application/vnd.ibexa.api.Content+json' \ +--header 'Authorization: Bearer {BEARER_TOKEN}' ``` -GET http:///api/ezp/v2/ibexa_personalization/v1/contenttypes/38?page=1&page_size=10 -Accept application/vnd.ez.api.Content+json -Authorization Basic xxxxxxxx + +Additionally, check whether the `contentlist` endpoint is working with the following request: + +```bash +curl --location '{PERSONALIZATION_HOST_URI}/api/ibexa/v2/personalization/v1/contentlist/{comma_separated_content_ids}?lang={comma_separated_languages}' \ +--header 'Accept: application/vnd.ibexa.api.ContentList+json' \ +--header 'Authorization: Bearer {BEARER_TOKEN}' ``` -The `content` endpoint returns one item and the `contenttypes` endpoint returns many. +The `content` endpoint returns one item and the `contentlist` endpoint returns many. ``` json { "contentList": { - "_media-type": "application/vnd.ez.api.contentList+json", + "_media-type": "application/vnd.ibexa.api.ContentList+json", "content": [ { - "_media-type": "application/vnd.ez.api.content+json", + "_media-type": "application/vnd.ibexa.api.Content+json", "contentId": 72, "contentTypeId": 38, "identifier": "place", @@ -197,18 +204,18 @@ The `content` endpoint returns one item and the `contenttypes` endpoint returns "uri": "/Places-Tastes/Places/Kochin-India", "categoryPath": "/1/2/95/71/73/", "mainLocation": { - "_media-type": "application/vnd.ez.api.mainLocation+json", + "_media-type": "application/vnd.ibexa.api.mainLocation+json", "_href": "/api/ezp/v2/content/locations/1/2/95/71/73/" }, "locations": { - "_media-type": "application/vnd.ez.api.locations+json", + "_media-type": "application/vnd.ibexa.api.locations+json", "_href": "/api/ezp/v2/content/objects/72/locations" }, "name": "Kochin, India", - "intro": "

We got the major port city on the south west coast of India.

\n]]>", - "description": "

Kochi (formerly Cochin) ...

\n]]>", + "intro": "

We got the major port city on the south west coast of India.

\n]]>", + "description": "

Kochi (formerly Cochin) ...

\n]]>", "image": "/var/site/storage/images/places-tastes/places/kochin-india/282-5-eng-GB/Kochin-India.jpg", - "caption": "

Chinese fishing nets ...

\n]]>", + "caption": "

Chinese fishing nets ...

\n]]>", "location": "kochin, india", "authors_position": "Senior Editor", "tags": "India, Kochin", @@ -228,18 +235,7 @@ To get recommendations you must first export the item information to the Persona After you [define item types to be tracked and recommended](#set-up-item-type-tracking), start the full export. -You do it with the `ibexa:personalization:run-export` command. - -If your installation hosts only one SiteAccess, run the following command to export your data: - -``` bash -php bin/console ibexa:personalization:run-export - --item-type-identifier-list=, - -—languages=, -``` - -If your installation hosts multiple SiteAccesses with different customer IDs, -you must run the export separately for each of the ``/`` pairs. +You need to run the `ibexa:personalization:run-export command per SiteAccesses that you want to use together with Personalization. You need different customer IDs for different SiteAccesses. ``` bash php bin/console ibexa:personalization:run-export @@ -247,11 +243,11 @@ php bin/console ibexa:personalization:run-export --siteaccess= --customer-id= --license-key= - -—languages=, + --languages=, ``` The bundle exporter collects all content related to the ``/`` -pair and stores it in files. +pair and stores it in files to the folder `public/var/export/yyyy/mm/dd/hh/mm` of your project. After finishing, the system sends a POST request to the endpoint and informs the Personalization server to fetch new content. An internal workflow is then triggered, so that the generated files are downloaded @@ -310,13 +306,13 @@ The username is the customer ID and the password is the license key. - + - + - + @@ -359,7 +355,7 @@ and it eventually fetches the affected content and updates it internally. To display recommendations on your site, you must include the asset in the template using the following code: ``` html+twig -{{ encore_entry_script_tags('ezrecommendation-client-js', null, 'ezplatform') }} +{{ encore_entry_script_tags('ibexa-personalization-client-js', null, 'ibexa') }} ``` This file is responsible for sending notifications to the [Recommendation API](recommendation_api.md) after the user clicks a tracking element.