-
Notifications
You must be signed in to change notification settings - Fork 85
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
added for moengage and tested #153
Conversation
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.
add code comments heavily.
change the PR description and other fields specific to this one. (fixes #1) etc is not helpful here,
import each from "@ndhoule/each"; | ||
import logger from "../../utils/logUtil"; | ||
|
||
class MoEngage { |
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.
please include comments involving the destination documentation
any special case handling and why it is required and where it's mentioned in destination docs etc
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
integrations/MoEngage/browser.js
Outdated
window, | ||
document, | ||
"script", | ||
"https://cdn.moengage.com/webpush/moe_webSdk.min.latest.js", |
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.
can we add this with Scriptloader? Also include the check that which protocol the website site is opened with (http/https etc) and depending on that get the destination sdk min file.
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
integrations/MoEngage/browser.js
Outdated
if (rudderElement.message) { | ||
const { anonymousId, event, properties } = rudderElement.message; | ||
if (anonymousId) { | ||
if (this.initialAnonId !== anonymousId) { |
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.
also reinitialise this.initialAnonId to new anonymousID?
also, it's almost expected that anonId will not change, is it better to perform this using userID?
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.
changed to user id
integrations/MoEngage/browser.js
Outdated
this.moeClient.track_event(event); | ||
} | ||
} else { | ||
logger.error("Event name not present"); |
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.
perform this and below check earlier to reduce if/else condition?
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 did not get this.
integrations/MoEngage/browser.js
Outdated
reset() { | ||
logger.debug("inside reset"); | ||
// reset the anonymous id | ||
this.initialAnonId = window.rudderanalytics.getAnonymousId(); |
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.
also, it's almost expected that anonId will not change, is it better to perform this using userID?
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
integrations/MoEngage/browser.js
Outdated
this.moeClient.add_unique_user_id(userId); | ||
} | ||
// custom traits mapping context.traits --> moengage properties | ||
const traitsMap = { |
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.
move this const outside of the class?
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
// if any of the custom properties are present it will be sent | ||
// For example : email is present in username then the method will be add_user_name | ||
|
||
if (Object.prototype.hasOwnProperty.call(traitsMap, key)) { |
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.
can the below 3 loops be merged into one?
perform lookup to traitsMap, if present use add${key_name} else use add_user_attribute
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.
but we have to loop through traits too right? to send the remaining attributes?
@@ -33,8 +33,9 @@ | |||
})(method); | |||
} | |||
|
|||
rudderanalytics.load("1cA1w20Fe34TdZrtGshutNY8Fm1", "http://localhost:8080", { |
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.
include this test file inside the moengage dest folder.
also remove so many commented lines and use the final tests that were run.
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 created a test folder with different cases which I finally ran including the results.
integrations/MoEngage/browser.js
Outdated
identify(rudderElement) { | ||
const self = this; | ||
const { anonymousId, userId } = rudderElement.message; | ||
const { traits } = rudderElement.message.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.
put a check if context is present or not.
in general, whenever there is more than one indirection, it's better to check for existence.
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
email: "email", | ||
phone: "mobile", | ||
name: "user_name", | ||
username: "user_name", |
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're supporting camelCase, should we support userName
as well?
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
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
Description of the change
Type of change
Related issues
Checklists
Development
Code review
This change is