Skip to content

Release 5.0.7 fixes#3140

Open
mnocon wants to merge 2 commits intorelease-5.0.7from
release-5.0.7-fixes
Open

Release 5.0.7 fixes#3140
mnocon wants to merge 2 commits intorelease-5.0.7from
release-5.0.7-fixes

Conversation

@mnocon
Copy link
Copy Markdown
Contributor

@mnocon mnocon commented Apr 15, 2026

Small fixes to issues found when reviewing the code

Contains fixes from #3139

@@ -1,37 +1,29 @@
{{ ibexa_tracking_track_event(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default_model: gemini-flash-latest
default_max_tokens: 4096
default_temperature: 1.0
ibexa_connector_gemini:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed indent to make it easier to copy-paste this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be moved to a .yaml file

| `enabled` | `false` | Enables the connector. |
| `instance_url` | string | Base URL of your [[= pim_product_name =]] instance, for example `https://example.quable.com`. |
| `api_token` | string | [Read Access API token](https://docs.quable.com/v5-EN/docs/system-api-tokens) used to authenticate requests to [[= pim_product_name =]]. |
| `api_token` | string | [Read Access API token](https://docs.quable.com/v5-EN/docs/api-tokens) used to authenticate requests to [[= pim_product_name =]]. |
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quable changed their doc and link broke

@@ -1,5 +1,5 @@
---
description: Quable API
description: Learn how to use PHP and REST APIs to retrieve product data from Quable
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It loads the initial script into `window.raptor`.
The script then enables event tracking, such as page visits, product views, or buys, from the front end.
It can be overridden in multiple ways to support custom implementations and to render code snippet through [[= product_name_base =]] in the [design engine](design_engine.md).
It can be overridden in multiple ways to support custom implementations and to render code snippet through [[= product_name =]] in the [design engine](design_engine.md).
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

product_name_base - Ibexa
product_name - Ibexa DXP

"templating/twig_function_reference/field_twig_functions",
"templating/twig_function_reference/page_twig_functions",
"templating/twig_function_reference/product_twig_functions",
"templating/twig_function_reference/recommendations_twig_functions",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was missing

@github-actions
Copy link
Copy Markdown

code_samples/ change report

Before (on target branch)After (in current PR)

code_samples/recommendations/templates/tracking/custom_visit.html.twig

docs/templating/twig_function_reference/recommendations_twig_functions.md@169:``` html+twig
docs/templating/twig_function_reference/recommendations_twig_functions.md@170:[[= include_file('code_samples/recommendations/templates/tracking/custom_visit.html.twig') =]]
docs/templating/twig_function_reference/recommendations_twig_functions.md@171:```


code_samples/recommendations/templates/tracking/custom_visit.html.twig

docs/templating/twig_function_reference/recommendations_twig_functions.md@169:``` html+twig
docs/templating/twig_function_reference/recommendations_twig_functions.md@170:[[= include_file('code_samples/recommendations/templates/tracking/custom_visit.html.twig') =]]
docs/templating/twig_function_reference/recommendations_twig_functions.md@171:```

001⫶{{ ibexa_tracking_track_event(
002⫶ 'visit',
003⫶ product,
004⫶ {},
005⫶ '@App/tracking/custom_visit.html.twig'
006⫶) }}
007⫶```
008⫶
009⫶{# templates/tracking/custom_visit.html.twig #}
001⫶{# templates/tracking/custom_visit.html.twig #}
002⫶
003⫶{#
004⫶# Custom visit tracking template
005⫶#
006⫶# Available variables:
007⫶# - parameters: array of Raptor tracking parameters (p1, p2, p3, etc.)
008⫶# - debug: boolean flag to enable debug console messages
009⫶#}
010⫶
010⫶
011⫶  {#
012⫶ # Custom visit tracking template
013⫶ #
014⫶ # Available variables:
015⫶ # - parameters: array of Raptor tracking parameters (p1, p2, p3, etc.)
016⫶ # - debug: boolean flag to enable debug console messages
017⫶ #}
018⫶
019⫶ <script type="text/javascript">
020⫶ {% autoescape 'js' %}
021⫶ (function () {
022⫶ // Custom logic before tracking
023⫶ console.log('Custom visit tracking template');
024⫶ console.log('Tracking parameters:', {{ parameters|json_encode|raw }});
025⫶
026⫶ // Send the tracking event (REQUIRED for tracking to work)
027⫶ const event = 'trackEvent';
028⫶ const params = {{ parameters|json_encode|raw }};
029⫶ window.raptor.push(event, params);
030⫶
031⫶ // Custom logic after tracking
032⫶ {% if debug %}
033⫶ console.log('Visit event tracked successfully');
034⫶ {% endif %}
035⫶ })();
036⫶ {% endautoescape %}
037⫶ </script>
011⫶<script type="text/javascript">
012⫶ {% autoescape 'js' %}
013⫶ (function () {
014⫶ // Custom logic before tracking
015⫶ console.log('Custom visit tracking template');
016⫶ console.log('Tracking parameters:', {{ parameters|json_encode|raw }});
017⫶
018⫶ // Send the tracking event (REQUIRED for tracking to work)
019⫶ const event = 'trackEvent';
020⫶ const params = {{ parameters|json_encode|raw }};
021⫶ window.raptor.push(event, params);
022⫶
023⫶ // Custom logic after tracking
024⫶ {% if debug %}
025⫶ console.log('Visit event tracked successfully');
026⫶ {% endif %}
027⫶ })();
028⫶ {% endautoescape %}
029⫶</script>


Download colorized diff

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@adriendupuis adriendupuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oportunity to re-read the examples

default_model: gemini-flash-latest
default_max_tokens: 4096
default_temperature: 1.0
ibexa_connector_gemini:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be moved to a .yaml file

Comment on lines +14 to +16
// Custom logic before tracking
console.log('Custom visit tracking template');
console.log('Tracking parameters:', {{ parameters|json_encode|raw }});
Copy link
Copy Markdown
Contributor

@adriendupuis adriendupuis Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, parameters variable could look like this?:

Suggested change
// Custom logic before tracking
console.log('Custom visit tracking template');
console.log('Tracking parameters:', {{ parameters|json_encode|raw }});
// Custom logic before tracking
{% set parameters = {'p1': 'visit', 'p2': product.code} %}
{% if debug %}
console.log('Custom visit tracking template');
console.log('Tracking parameters:', {{ parameters|json_encode|raw }});
{% endif %}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "Custom templates" section needs a reminder of https://content.raptorservices.com/help-center/tracking-events-for-recommendation ressource

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the parameters variable should not be set in the template like that.
The parameters variable is already constructed by the backend before being passed to the template.

When you call ibexa_tracking_track_event('visit', product, ...):

  1. The backend's EventMapper processes the product object
  2. Creates the full parameters array with all required fields (p1, p2, p3, p4, p6, p12, p18, etc.)
  3. Passes this ready-to-use array to the template

The template receives parameters already populated like:
[
'p1' => 'visit',
'p2' => 'PRODUCT-CODE-123',
'p3' => 'Product Name',
'p4' => '1#Electronics;2#Laptops',
'p6' => 'USD',
'p12' => '999.99',
'p18' => 'BASE-PRODUCT-CODE'
]

Important: The product object is NOT available in the template - only parameters and debug are passed.

If you need to customize parameters, you can modify them (not replace):
{% set parameters = parameters|merge({'p7': 'custom-website-id'}) %}
But don't overwrite the entire array - you'd lose all the backend-prepared data.

Copy link
Copy Markdown
Contributor

@adriendupuis adriendupuis Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get it! So we could remind that this is a received value. Even show that it could be edited:

Suggested change
// Custom logic before tracking
console.log('Custom visit tracking template');
console.log('Tracking parameters:', {{ parameters|json_encode|raw }});
// Custom logic before tracking
{# For example, alway override the website ID by editing the received parameters: #}
{% set parameters = parameters|merge({'p7': 'custom-website-id'}) %}
{% if debug %}
console.log('Custom visit tracking template');
console.log('Tracking parameters:', {{ parameters|json_encode|raw }});
{% endif %}

const params = {{ parameters|json_encode|raw }};
window.raptor.push(event, params);
// Send the tracking event (REQUIRED for tracking to work)
const event = 'trackEvent';
Copy link
Copy Markdown
Contributor

@adriendupuis adriendupuis Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this must not be confused with p1. What are the possible values?
Seing https://github.com/ibexa/connector-raptor/blob/main/src/bundle/Resources/views/themes/standard/ibexa/tracking/script.html.twig I wonder if this can be changed.

Suggested change
const event = 'trackEvent';
const event = 'trackEvent'; // Don't change this value.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is indeed confusing and needs clarification.
The event parameter is NOT the same as p1:

  • event = Raptor JavaScript API method name (e.g., 'trackEvent')
  • p1 = Event type parameter (e.g., 'visit', 'buy', 'basket', 'pageview')

For event tracking, the value should always be 'trackEvent' (Raptor API method). This shouldn't be changed unless you're calling a different Raptor API method.

Your suggestion is good:
const event = 'trackEvent'; // Don't change this - Raptor API method name

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const event = 'trackEvent';
const event = 'trackEvent'; // Don't change this - Raptor API method name

{#
# Custom visit tracking template
#
# Available variables:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Available variables:
# Available variables (passed to the template by `ibexa_tracking_track_event`):

Comment on lines +14 to +16
// Custom logic before tracking
console.log('Custom visit tracking template');
console.log('Tracking parameters:', {{ parameters|json_encode|raw }});
Copy link
Copy Markdown
Contributor

@adriendupuis adriendupuis Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get it! So we could remind that this is a received value. Even show that it could be edited:

Suggested change
// Custom logic before tracking
console.log('Custom visit tracking template');
console.log('Tracking parameters:', {{ parameters|json_encode|raw }});
// Custom logic before tracking
{# For example, alway override the website ID by editing the received parameters: #}
{% set parameters = parameters|merge({'p7': 'custom-website-id'}) %}
{% if debug %}
console.log('Custom visit tracking template');
console.log('Tracking parameters:', {{ parameters|json_encode|raw }});
{% endif %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants