Skip to content

Commit

Permalink
bugfix: make queryID optional in Algolia insights destination action (s…
Browse files Browse the repository at this point in the history
  • Loading branch information
wwalser authored Jun 20, 2023
1 parent b6e8b05 commit 0474006
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Object {
"product_id": "U[ABpE$k",
},
],
"queryID": "U[ABpE$k",
"userToken": "U[ABpE$k",
},
],
Expand Down Expand Up @@ -83,7 +82,6 @@ Object {
"positions": Array [
-1912532923056128,
],
"queryID": "LLjxSD^^GnH",
"userToken": "LLjxSD^^GnH",
},
],
Expand Down Expand Up @@ -120,7 +118,6 @@ Object {
"objectIDs": Array [
"BLFCPcmz",
],
"queryID": "BLFCPcmz",
"userToken": "BLFCPcmz",
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type EventCommon = {
userToken: string
objectIDs: string[]
timestamp?: number
queryID?: string
}

export type AlgoliaProductViewedEvent = EventCommon & {
Expand All @@ -18,7 +19,6 @@ export type AlgoliaProductViewedEvent = EventCommon & {

export type AlgoliaProductClickedEvent = EventCommon & {
eventType: 'click'
queryID: string
positions: number[]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Object {
"product_id": ")j)vR5%1AP*epuo8A%R",
},
],
"queryID": ")j)vR5%1AP*epuo8A%R",
"timestamp": 1674843786677,
"userToken": ")j)vR5%1AP*epuo8A%R",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ describe('AlgoliaInsights.conversionEvents', () => {
type: 'track',
event: 'Order Completed',
properties: {
query_id: '1234',
search_index: 'fashion_1',
products: [
{
Expand All @@ -81,4 +80,27 @@ describe('AlgoliaInsights.conversionEvents', () => {
const algoliaEvent = await testAlgoliaDestination(event)
expect(algoliaEvent.timestamp).toBe(new Date(event.timestamp as string).valueOf())
})

it('should pass queryID if present', async () => {
const event = createTestEvent({
type: 'track',
event: 'Order Completed',
properties: {
query_id: '1234',
search_index: 'fashion_1',
products: [
{
product_id: '9876',
product_name: 'skirt 1'
},
{
product_id: '5432',
product_name: 'skirt 2'
}
]
}
})
const algoliaEvent = await testAlgoliaDestination(event)
expect(algoliaEvent.queryID).toBe(event.properties?.query_id)
})
})

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export const conversionEvents: ActionDefinition<Settings, Payload> = {
},
queryID: {
label: 'Query ID',
description: 'Query ID of the list on which the item was clicked.',
description: 'Query ID of the list on which the item was purchased.',
type: 'string',
required: true,
required: false,
default: {
'@path': '$.properties.query_id'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ Object {
"positions": Array [
-8127732168785920,
],
"queryID": "tTO6#",
"timestamp": 1674843786677,
"userToken": "tTO6#",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ describe('AlgoliaInsights.productClickedEvents', () => {
type: 'track',
event: 'Product Clicked',
properties: {
query_id: '1234',
search_index: 'fashion_1',
product_id: '9876',
position: 5
Expand All @@ -65,4 +64,19 @@ describe('AlgoliaInsights.productClickedEvents', () => {
const algoliaEvent = await testAlgoliaDestination(event)
expect(algoliaEvent.timestamp).toBe(new Date(event.timestamp as string).valueOf())
})

it('should pass queryID if present', async () => {
const event = createTestEvent({
type: 'track',
event: 'Product Clicked',
properties: {
query_id: '1234',
search_index: 'fashion_1',
product_id: '9876',
position: 5
}
})
const algoliaEvent = await testAlgoliaDestination(event)
expect(algoliaEvent.queryID).toBe(event.properties?.query_id)
})
})

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const productClickedEvents: ActionDefinition<Settings, Payload> = {
label: 'Query ID',
description: 'Query ID of the list on which the item was clicked.',
type: 'string',
required: true,
required: false,
default: {
'@path': '$.properties.query_id'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Object {
"objectIDs": Array [
"og&DCP)aINw@qxe)",
],
"queryID": "og&DCP)aINw@qxe)",
"timestamp": 1674843786677,
"userToken": "og&DCP)aINw@qxe)",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ describe('AlgoliaInsights.productViewedEvents', () => {
type: 'track',
event: 'Product Viewed',
properties: {
query_id: '1234',
search_index: 'fashion_1',
product_id: '9876'
},
Expand All @@ -62,4 +61,19 @@ describe('AlgoliaInsights.productViewedEvents', () => {
const algoliaEvent = await testAlgoliaDestination(event)
expect(algoliaEvent.timestamp).toBe(new Date(event.timestamp as string).valueOf())
})

it('should pass queryId if present', async () => {
const event = createTestEvent({
type: 'track',
event: 'Product Viewed',
properties: {
query_id: '1234',
search_index: 'fashion_1',
product_id: '9876'
},
userId: undefined
})
const algoliaEvent = await testAlgoliaDestination(event)
expect(algoliaEvent.queryID).toBe(event.properties?.query_id)
})
})

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export const productViewedEvents: ActionDefinition<Settings, Payload> = {
},
queryID: {
label: 'Query ID',
description: 'Query ID of the list on which the item was clicked.',
description: 'Query ID of the list on which the item was viewed.',
type: 'string',
required: true,
required: false,
default: {
'@path': '$.properties.query_id'
}
Expand Down

0 comments on commit 0474006

Please sign in to comment.