Skip to content

Commit

Permalink
fix(algolia): added check for objectIds or filters to be non empty (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishmalik authored Feb 28, 2024
1 parent 657b780 commit d619c97
Show file tree
Hide file tree
Showing 2 changed files with 212 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cdk/v2/destinations/algolia/procWorkflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ steps:
const filters = $.context.payload.filters;
const objectIDs = $.context.payload.objectIDs;
$.assert(!(filters && objectIDs), "event can't have both objectIds and filters at the same time.");
$.assert(filters || objectIDs, "Either filters or objectIds is required.");
$.assert(filters.length || objectIDs.length, "Either filters or objectIds is required and must be non empty.");
- name: validatePayloadForClickEvent
condition: $.context.payload.eventType === "click"
Expand Down
212 changes: 211 additions & 1 deletion test/integrations/destinations/algolia/processor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ export const data = [
body: [
{
error:
'Either filters or objectIds is required.: Workflow: procWorkflow, Step: validateDestPayload, ChildStep: undefined, OriginalError: Either filters or objectIds is required.',
'Either filters or objectIds is required and must be non empty.: Workflow: procWorkflow, Step: validateDestPayload, ChildStep: undefined, OriginalError: Either filters or objectIds is required and must be non empty.',
statTags: {
destType: 'ALGOLIA',
errorCategory: 'dataValidation',
Expand Down Expand Up @@ -1417,4 +1417,214 @@ export const data = [
},
},
},
{
name: 'algolia',
description: 'Eventype must be one of click, conversion pr view',
feature: 'processor',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
message: {
channel: 'web',
context: {
app: {
build: '1.0.0',
name: 'RudderLabs JavaScript SDK',
namespace: 'com.rudderlabs.javascript',
version: '1.0.0',
},
traits: {
email: '[email protected]',
firstName: 'test',
lastName: 'one',
},
library: {
name: 'RudderLabs JavaScript SDK',
version: '1.0.0',
},
userAgent:
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36',
locale: 'en-US',
ip: '0.0.0.0',
os: {
name: '',
version: '',
},
screen: {
density: 2,
},
page: {
path: '/destinations/ometria',
referrer: '',
search: '',
title: '',
url: 'https://docs.rudderstack.com/destinations/ometria',
category: 'destination',
initial_referrer: 'https://docs.rudderstack.com',
initial_referring_domain: 'docs.rudderstack.com',
},
},
type: 'track',
messageId: '84e26acc-56a5-4835-8233-591137fca468',
session_id: '3049dc4c-5a95-4ccd-a3e7-d74a7e411f22',
originalTimestamp: '2019-10-14T09:03:17.562Z',
anonymousId: '123456',
event: 'product clicked',
userId: 'testuserId1',
properties: {
index: 'products',
filters: ['field1:hello', 'val1:val2'],
},
integrations: {
All: true,
},
sentAt: '2019-10-14T09:03:22.563Z',
},
destination: {
DestinationDefinition: {
Config: {
cdkV2Enabled: true,
excludeKeys: [],
includeKeys: [],
},
},
Config: {
apiKey: 'dummyApiKey',
applicationId: 'O2YARRI15I',
eventTypeSettings: [
{
from: 'product clicked',
to: 'abcd',
},
],
},
},
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
},
output: {
response: {
status: 200,
body: [
{
error:
'eventType can be either click, view or conversion: Workflow: procWorkflow, Step: preparePayload, ChildStep: undefined, OriginalError: eventType can be either click, view or conversion',
statTags: {
destType: 'ALGOLIA',
errorCategory: 'dataValidation',
errorType: 'instrumentation',
feature: 'processor',
implementation: 'cdkV2',
module: 'destination',
destinationId: 'destId',
workspaceId: 'wspId',
},
statusCode: 400,
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
},
},
{
name: 'algolia',
description: 'filters or objectIds must be non empty',
feature: 'processor',
module: 'destination',
version: 'v0',
input: {
request: {
body: [
{
message: {
type: 'track',
event: 'product clicked',
sentAt: '2024-02-25T17:55:36.882Z',
userId: '12345',
channel: 'web',
properties: {
index: 'products',
list_id: 'search_results_page',
queryId: '8e737',
products: [],
eventName: 'productListView',
list_name: 'Search Results Page',
objectIds: [],
positions: [],
userToken: 'e494',
additional_attributes: {},
},
receivedAt: '2024-02-25T17:55:38.089Z',
request_ip: '107.130.37.100',
anonymousId: '68e9f4b8-fd4d-4c56-8ca4-858de2fd1df8',
integrations: {
All: true,
},
originalTimestamp: '2024-02-25T17:55:36.880Z',
},
destination: {
DestinationDefinition: {
Config: {
cdkV2Enabled: true,
excludeKeys: [],
includeKeys: [],
},
},
Config: {
apiKey: 'dummyApiKey',
applicationId: 'O2YARRI15I',
eventTypeSettings: [
{
from: 'product clicked',
to: 'cLick ',
},
],
},
},
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
},
output: {
response: {
status: 200,
body: [
{
error:
'Either filters or objectIds is required and must be non empty.: Workflow: procWorkflow, Step: validateDestPayload, ChildStep: undefined, OriginalError: Either filters or objectIds is required and must be non empty.',
statTags: {
destType: 'ALGOLIA',
errorCategory: 'dataValidation',
errorType: 'instrumentation',
feature: 'processor',
implementation: 'cdkV2',
module: 'destination',
destinationId: 'destId',
workspaceId: 'wspId',
},
statusCode: 400,
metadata: {
destinationId: 'destId',
workspaceId: 'wspId',
},
},
],
},
},
},
];

0 comments on commit d619c97

Please sign in to comment.