Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSP-160 Search analytics for nosto products sw66 #105

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

bojand-soprex
Copy link
Collaborator

No description provided.

@bojand-soprex bojand-soprex self-assigned this Jan 16, 2025
@bojand-soprex bojand-soprex changed the title SSP-160 SW66 SSP-160 Search analytics for nosto products sw66 Jan 16, 2025
}

$dataSource = $data['dataSource'];
$payload = [
Copy link
Contributor

Choose a reason for hiding this comment

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

i think it would be a good idea to create an object for the data source within the php-sdk. This would be easier to work with, and obviously would mean that magento etc could reuse the structure of the object and what should be sent etc.

];

try {
if ($dataSource === 'search') {
Copy link
Contributor

Choose a reason for hiding this comment

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

could use constant for search and category

return new JsonResponse(['status' => 'success']);
}

return new JsonResponse(['error' => 'Failed to track analytics'], Response::HTTP_INTERNAL_SERVER_ERROR);
Copy link
Contributor

Choose a reason for hiding this comment

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

would it be a good idea to also include the actual error to the response (so it would be easier for ourselves to see what has failed when debugging merchants store)

Copy link
Contributor

Choose a reason for hiding this comment

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

This means that php-sdk should maybe be void, and if something happens or fails throw the exception that would be caught here and then we can actually return the reason of the failure

That also means less code here :)
it would go as
$tracker->track($dataSource, $payload);
return new JsonResponse(['status' => 'success']);
} catch (\Exception $e) {
......

});

if (response.ok) {
console.log('Tracking successful', await response.json());
Copy link
Contributor

Choose a reason for hiding this comment

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

we probably don't want to see console logs for info in the browser

$dataSource = $data['dataSource'];
$payload = [
'query' => $data['productNumber'],
'resultId' => $data['resultId'] ?? 'DEMODEMODEMO',
Copy link
Contributor

Choose a reason for hiding this comment

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

i think that should be the unique uuid


$dataSource = $data['dataSource'];
$payload = [
'query' => $data['productNumber'],
Copy link
Contributor

Choose a reason for hiding this comment

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

query from what i understand https://nostosolutions.atlassian.net/wiki/spaces/HD/pages/9986605082/Front-end+analytics+ingestion
should be a search value we searched for or the category

body: JSON.stringify({
dataSource,
productNumber,
productId,
Copy link
Contributor

Choose a reason for hiding this comment

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

i think this currently isn't enough (we need to know if click happened due to the specific search query or from specific category depending if its search/cm tracking

{% block element_product_listing_col_empty %}
<div class="cms-listing-col col-12">
{% block element_product_listing_col_empty_alert %}
{% sw_include '@Storefront/storefront/utilities/alert.html.twig' with {
Copy link
Contributor

Choose a reason for hiding this comment

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

looking at previous code we had pagination here, so i fonder if thats okay?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants