Skip to content

Commit 199b5a1

Browse files
committed
update productIDs mapping
1 parent 1fd104f commit 199b5a1

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

packages/destination-actions/src/destinations/algolia-insights/productListViewedEvents/generated-types.ts

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/destination-actions/src/destinations/algolia-insights/productListViewedEvents/index.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,26 @@ export const productListViewedEvents: ActionDefinition<Settings, Payload> = {
1111
description:
1212
'Product list viewed events act as a positive signal for associated record objects — the associated Product IDs. Query ID is optional and indicates that the view events are the result of a search query.',
1313
fields: {
14-
objectIDs: {
15-
label: 'Product IDs',
16-
description: 'Product IDs of the viewed items. Defaults to an array of `products.product_id`.',
17-
type: 'string',
14+
products: {
15+
label: 'Product Details',
16+
description:
17+
'The viewed products. Populates the ObjectIDs field in the Algolia Insights API. Each object must contain a product_id field.',
18+
type: 'object',
19+
defaultObjectUI: 'keyvalue',
1820
multiple: true,
1921
required: true,
22+
properties: {
23+
product_id: { label: 'product_id', type: 'string', required: true }
24+
},
2025
default: {
21-
'@arrayPath': ['$.properties.products', { '@path': '$.product_id' }]
26+
'@arrayPath': [
27+
'$.properties.products',
28+
{
29+
product_id: {
30+
'@path': '$.product_id'
31+
}
32+
}
33+
]
2234
}
2335
},
2436
index: {
@@ -108,7 +120,7 @@ export const productListViewedEvents: ActionDefinition<Settings, Payload> = {
108120
eventType: (data.payload.eventType as AlgoliaEventType) ?? ('view' as AlgoliaEventType),
109121
index: data.payload.index,
110122
queryID: data.payload.queryID,
111-
objectIDs: data.payload.objectIDs,
123+
objectIDs: data.payload.products.map((obj) => obj.product_id),
112124
timestamp: data.payload.timestamp ? new Date(data.payload.timestamp).valueOf() : undefined,
113125
userToken: data.payload.userToken,
114126
authenticatedUserToken: data.payload.authenticatedUserToken

0 commit comments

Comments
 (0)