Skip to content

Commit b276479

Browse files
authored
fix(algolia-insights): allow click position of 0 (#3513)
* fix(algolia-insights): allow click position of 0 * update description * resolve: yarn types
1 parent 324591f commit b276479

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

packages/destination-actions/src/destinations/algolia-insights/productClickedEvents/__tests__/index.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,19 @@ describe('AlgoliaInsights.productClickedEvents', () => {
144144
expect(algoliaEvent.userToken).toBe(event.anonymousId)
145145
expect(algoliaEvent.authenticatedUserToken).toBe(event.userId)
146146
})
147+
148+
it('should pass position if 0', async () => {
149+
const event = createTestEvent({
150+
type: 'track',
151+
event: 'Product Clicked',
152+
properties: {
153+
query_id: '1234',
154+
search_index: 'fashion_1',
155+
product_id: '9876',
156+
position: 0
157+
}
158+
})
159+
const algoliaEvent = await testAlgoliaDestination(event)
160+
expect(algoliaEvent.positions?.[0]).toBe(event.properties?.position)
161+
})
147162
})

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

Lines changed: 1 addition & 1 deletion
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/productClickedEvents/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const productClickedEvents: ActionDefinition<Settings, Payload> = {
4141
},
4242
position: {
4343
label: 'Position',
44-
description: 'Position of the click in the list of Algolia search results.',
44+
description: 'Position of the click in the list of Algolia search results. Positions should start from 1, not 0.',
4545
type: 'integer',
4646
required: false,
4747
default: {
@@ -116,7 +116,7 @@ export const productClickedEvents: ActionDefinition<Settings, Payload> = {
116116
objectIDs: [data.payload.objectID],
117117
userToken: data.payload.userToken,
118118
authenticatedUserToken: data.payload.authenticatedUserToken,
119-
positions: data.payload.position ? [data.payload.position] : undefined,
119+
positions: data.payload.position != null ? [data.payload.position] : undefined,
120120
timestamp: data.payload.timestamp ? new Date(data.payload.timestamp).valueOf() : undefined
121121
}
122122
const insightPayload = { events: [insightEvent] }

0 commit comments

Comments
 (0)