Skip to content
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

fix: dynamic messages - pass merchant id from cpnw callback, flush logger #2381

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

paypal-rosman
Copy link
Contributor

@paypal-rosman paypal-rosman commented May 1, 2024

Description

we are passing merchantID from a callback handled in an internal service. We are also flushing the logger that way on page navigation we can send up logger events

Why are we making these changes? Include references to any related Jira tasks or GitHub Issues

Reproduction Steps (if applicable)

Screenshots (if applicable)

Dependent Changes (if applicable)

Groups who should review (if applicable)

❤️ Thank you!

Comment on lines 726 to 728
getLogger().addTrackingBuilder(() => ({
[FPTI_KEY.SELLER_ID]: merchantID,
}));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when an actual merchantID is passed in as part of the SDK script (i.e. partner integration)? Will this unintentionally override that or are we still good there? Also will this impact other non-messaging events that are fired from outside the IFrame since addTrackingBuilder changes the shared logger instance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good callout, looks like it will override the partner integration so need to add a check to see if that exists first

@@ -396,7 +396,7 @@ export const getModal: (

return window[namespace].MessagesModal({
account: `client-id:${clientID}`,
merchantId: merchantID?.join(",") || undefined,
merchantId: merchantID,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the modal input here we want this value to be the SDK script merchantID value because we don't want to pass in a merchantId value unless it is a partner integration, otherwise it may impact authentication.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good callout, ill fix this one

@@ -730,7 +736,7 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
[FPTI_KEY.CONTEXT_ID]: buttonSessionID,
[FPTI_KEY.CONTEXT_TYPE]: "button_session_id",
[FPTI_KEY.EVENT_NAME]: "message_click",
[FPTI_KEY.SELLER_ID]: merchantID?.join(","),
[FPTI_KEY.SELLER_ID]: merchantID,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're including this above, do we also need it here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

going to test this to see if that is the case

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this?

Comment on lines 784 to 786
const merchantID = isPartnerMerchantIdEmpty
? serverMerchantId
: partnerMerchantId?.join();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This merchantID that we pass into getModal() we do not want to be polluted with the value that comes back from the server. The merchantID that is passed into getModal() should only be the props.merchantID value that is supplied by the merchant, and not any computed value otherwise it could negatively impact auth.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will modify this, i thought we wanted both server + partner going to it. let me change this

@@ -373,7 +373,7 @@ function buildModalBundleUrl(): string {

export const getModal: (
clientID: string,
merchantID: $ReadOnlyArray<string> | void
merchantID?: string | void
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should consider reverting this so that we more explicitly ensure we're getting the original props.merchantID value here.

@@ -730,7 +736,7 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
[FPTI_KEY.CONTEXT_ID]: buttonSessionID,
[FPTI_KEY.CONTEXT_TYPE]: "button_session_id",
[FPTI_KEY.EVENT_NAME]: "message_click",
[FPTI_KEY.SELLER_ID]: merchantID?.join(","),
[FPTI_KEY.SELLER_ID]: merchantID,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this?


// override with server id if partner does not exist
getLogger().addTrackingBuilder(() => ({
[FPTI_KEY.SELLER_ID]: merchantID,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would something similar to props.merchantID.toString() || serverMerchantId be the same result without the need for some of the code above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea that should work ill update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants