-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: enrich with geo location data during destination transformation #2803
Conversation
Signed-off-by: Sai Sankeerth <[email protected]>
Signed-off-by: Sai Sankeerth <[email protected]>
…to feat.enrich-geo-location
Signed-off-by: Sai Sankeerth <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #2803 +/- ##
===========================================
+ Coverage 87.11% 87.13% +0.02%
===========================================
Files 768 770 +2
Lines 28653 28714 +61
Branches 6726 6740 +14
===========================================
+ Hits 24960 25021 +61
Misses 3350 3350
Partials 343 343 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Sai Sankeerth <[email protected]>
- add router transformation test-case - change test-case for helper for first-key found logic Signed-off-by: Sai Sankeerth <[email protected]>
Signed-off-by: Sai Sankeerth <[email protected]>
Signed-off-by: Sai Sankeerth <[email protected]>
Signed-off-by: Sai Sankeerth <[email protected]>
…ints & asynchronise geolocation enricher Signed-off-by: Sai Sankeerth <[email protected]>
…to feat.enrich-geo-location
- simplify logic for finding addressKey - update name of first matching key-value pair finder function - simplify logic for finding first key-value pair - add validation on message to be an object to perform search operation Signed-off-by: Sai Sankeerth <[email protected]>
Signed-off-by: Sai Sankeerth <[email protected]>
…tead of identifying the valid values manually, added test-cases Signed-off-by: Sai Sankeerth <[email protected]>
Signed-off-by: Sai Sankeerth <[email protected]>
…null message cases Signed-off-by: Sai Sankeerth <[email protected]>
properties: object; | ||
traits: object; | ||
[key: string]: FixMe; | ||
}>; | ||
|
||
type RouterTransformationRequestData = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is low level struct used in both process & routerTransform flow, so shouldn't the name be neutral ?
type RouterTransformationRequestData = { | |
type EventRequestData = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically it was named as RouterTransformationRequestData
previously but since the elements in the type were common, I used it as a low-level struct.
Tried to change name, there are many files which are using this type. I feel this is a little bigger change & out of scope of this task. May be we can handle this in a backlog item and make a change independent of this task. But yeah, let me know if we are ok with making this change as part of this PR.
| 'alias' | ||
| 'audiencelist'; | ||
|
||
type RudderMessageSchema = Partial<{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's RudderMessage
too -
rudder-transformer/src/types/index.ts
Line 178 in e4c6bb2
type RudderMessage = { |
Do we need both of them ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used RudderMessage
itself but there were too many changes that were needed in order for the tests to pass & compile. So, kind of yes, we need both of them.
[Backlog] We have to plan to get rid of both of these types & stick with only one type.
receivedAt: '2020-04-17T20:12:44.758+05:30', | ||
request_ip: '[::1]:53513', | ||
sentAt: '2020-04-17T14:42:44.722Z', | ||
traits: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the test case meant to have address but not context.geo ?
Next test case is exactly same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the case to have address but not context.geo
message: { | ||
anonymousId: 'ac7722c2-ccb6-4ae2-baf6-1effe861f4cd', | ||
channel: 'web', | ||
context: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we are not asserting other attributes & that's not the scope in unit test here, can keep the context object simple by restricting to only context.geo
or empty context
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Incorporated the suggestions
key: 'rivals.spain', | ||
}, | ||
}, | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we also have a test case where both 'spain.rivals', 'rivals.spain' would be present in the object ?
If the customer instruments address at both the places ? ["traits.address", "context.traits.address"]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Will include one such case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Signed-off-by: Sai Sankeerth <[email protected]>
…to feat.enrich-geo-location
Signed-off-by: Sai Sankeerth <[email protected]>
src/helpers/geoLocation.ts
Outdated
return { key: addressKey, value }; | ||
} | ||
|
||
public static getMessageWithGeoLocationData( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you think about name enrichMessageAddressWithGeoData
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/middlewares/enricher.ts
Outdated
private static enrichWithGeoInfo( | ||
data: RouterTransformationRequestData[], | ||
): RouterTransformationRequestData[] { | ||
return data.map((inpEv) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
acronyms like inpEv
might not be readable, let's name them as input
or event
or inputEvent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorporated
- update enricher class name, method, var name & update related test-cases - return value as undefined when anything apart from Array or object is sent for searching - make use of msg rather than message Signed-off-by: Sai Sankeerth <[email protected]>
…to feat.enrich-geo-location
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except for one last comment made, the changes to me look good.
Signed-off-by: Sai Sankeerth <[email protected]>
…to feat.enrich-geo-location
…to feat.enrich-geo-location
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…to feat.enrich-geo-location
- move DTRequest to types/index.ts - remove unnecessary optional chaining Signed-off-by: Sai Sankeerth <[email protected]>
Signed-off-by: Sai Sankeerth <[email protected]>
…to feat.enrich-geo-location
Kudos, SonarCloud Quality Gate passed! |
Closing this PR as these changes are not necessary |
Description of the change
We are enriching the event payload with geo-location data just before destination transformation
Type of change
Related issues
Resolves INT-1000
Resolved INT-1001
Checklists
Development
Code review