diff --git a/packages/destination-actions/src/destinations/algolia-insights/productClickedEvents/__tests__/index.test.ts b/packages/destination-actions/src/destinations/algolia-insights/productClickedEvents/__tests__/index.test.ts index 81918ad22bc..173c605c785 100644 --- a/packages/destination-actions/src/destinations/algolia-insights/productClickedEvents/__tests__/index.test.ts +++ b/packages/destination-actions/src/destinations/algolia-insights/productClickedEvents/__tests__/index.test.ts @@ -144,4 +144,19 @@ describe('AlgoliaInsights.productClickedEvents', () => { expect(algoliaEvent.userToken).toBe(event.anonymousId) expect(algoliaEvent.authenticatedUserToken).toBe(event.userId) }) + + it('should pass position if 0', async () => { + const event = createTestEvent({ + type: 'track', + event: 'Product Clicked', + properties: { + query_id: '1234', + search_index: 'fashion_1', + product_id: '9876', + position: 0 + } + }) + const algoliaEvent = await testAlgoliaDestination(event) + expect(algoliaEvent.positions?.[0]).toBe(event.properties?.position) + }) }) diff --git a/packages/destination-actions/src/destinations/algolia-insights/productClickedEvents/generated-types.ts b/packages/destination-actions/src/destinations/algolia-insights/productClickedEvents/generated-types.ts index 7e545089b36..00997c84f66 100644 --- a/packages/destination-actions/src/destinations/algolia-insights/productClickedEvents/generated-types.ts +++ b/packages/destination-actions/src/destinations/algolia-insights/productClickedEvents/generated-types.ts @@ -14,7 +14,7 @@ export interface Payload { */ queryID?: string /** - * Position of the click in the list of Algolia search results. + * Position of the click in the list of Algolia search results. Positions should start from 1, not 0. */ position?: number /** diff --git a/packages/destination-actions/src/destinations/algolia-insights/productClickedEvents/index.ts b/packages/destination-actions/src/destinations/algolia-insights/productClickedEvents/index.ts index d8286fe97c6..3a19be88e76 100644 --- a/packages/destination-actions/src/destinations/algolia-insights/productClickedEvents/index.ts +++ b/packages/destination-actions/src/destinations/algolia-insights/productClickedEvents/index.ts @@ -41,7 +41,7 @@ export const productClickedEvents: ActionDefinition = { }, position: { label: 'Position', - description: 'Position of the click in the list of Algolia search results.', + description: 'Position of the click in the list of Algolia search results. Positions should start from 1, not 0.', type: 'integer', required: false, default: { @@ -116,7 +116,7 @@ export const productClickedEvents: ActionDefinition = { objectIDs: [data.payload.objectID], userToken: data.payload.userToken, authenticatedUserToken: data.payload.authenticatedUserToken, - positions: data.payload.position ? [data.payload.position] : undefined, + positions: data.payload.position != null ? [data.payload.position] : undefined, timestamp: data.payload.timestamp ? new Date(data.payload.timestamp).valueOf() : undefined } const insightPayload = { events: [insightEvent] }