Bug Report: Cannot filter steps by custom subscriber data #2787
iampearceman
started this conversation in
Feature Feedback
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
📜 Description
Hi - first time contributing, so please be gracious!
I noticed that we're not able to filter event trigger steps by custom subscriber data. In the following screenshot, if a subscriber has custom attributes
{customKey: customValue}and the event is triggered to them, they will not receive the notification.👟 Reproduction steps
"data": { "customKey": "customValue" }👍 Expected behavior
I expect the app to apply step filters to custom subscriber data. In the scenario described above, a subscriber with matching customKey/customValue pair should receive the notification.
👎 Actual Behavior with Screenshots
If you add a filter for
data.customKey,EQUALS,customValue, and there is a subscriber withdata.customKey: customValue, that subscriber will not receive a notification from the event.It's not pictured, but the same happens if I use
customValueinstead ofdata.customValueas the key in the step filter.📃 Provide any additional context for the Bug.
I may be missing something since I'm new to this codebase, but it looks like a one-line code change in the
processFilterEquality(variables, fieldFilter, filterProcessingDetails)function inapi/src/app/events/usecases/trigger-event/message-matcher.service.ts.We currently extract the field filter value from the subscriber data using
_.get(variables, [fieldFilter.on, fieldFilter.field])wherevariablescontains the keys:payload,subscriber, andwebhookfieldFilter.oncontains the string value 'subscriber' or 'payload'fieldFilter.fieldcontains user input to search by (in the above example,data.customKey).lodash .get() can iterate through the keys of an object with either a string (eg
"key1[0].key2.key3") or with an array (eg["key1", "0", "key2", "key3]). The current implementation uses an array, but since the user passes a string input (eg"data.customKey"), we call the function as_.get( {...}, ["subscriber", "data.customKey"] ), using a mix of array and string values to define the path. It can be fixed if we build a single string for the path ("subscriber.data.customKey") or if we.split('.')the field and build an array for the path (["subscriber", "data", "customKey"])Locally, I replaced
with
and it works as expected - but I haven't tested it very thoroughly.
👀 Have you spent some time to check if this bug has been raised before?
🏢 Have you read the Contributing Guidelines?
Are you willing to submit PR?
Yes I am willing to submit a PR!
NV-1670
Beta Was this translation helpful? Give feedback.
All reactions