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

feat: add button session id to modals #1078

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/modal/v2/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export const getContent = memoize(
contextualComponents,
devTouchpoint,
disableSetCookie,
features
features,
buttonSessionId
}) => {
const query = objectEntries({
currency,
Expand All @@ -44,7 +45,8 @@ export const getContent = memoize(
contextual_components: contextualComponents,
devTouchpoint,
disableSetCookie,
features
features,
buttonSessionId
})
.filter(([, val]) => Boolean(val))
.reduce(
Expand Down
6 changes: 4 additions & 2 deletions src/library/controllers/modal/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ const memoizedModal = memoizeOnProps(
contextualComponents,
cspNonce,
integrationIdentifier,
features
features,
buttonSessionId
}) => {
addPerformanceMeasure(PERFORMANCE_MEASURE_KEYS.FIRST_MODAL_RENDER_DELAY);

Expand All @@ -68,7 +69,8 @@ const memoizedModal = memoizeOnProps(
contextualComponents,
cspNonce,
integrationIdentifier,
features
features,
buttonSessionId
});
// Fired from inside the default onReady callback
let renderProm;
Expand Down
11 changes: 11 additions & 0 deletions src/library/zoid/message/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,17 @@ export default {

return undefined;
},
buttonSessionId: ({ props: { buttonSessionId } }) => {
if (typeof buttonSessionId !== 'undefined') {
if (!validateType(Types.STRING, buttonSessionId)) {
logInvalidType('buttonSessionId', Types.STRING, buttonSessionId);
} else {
return buttonSessionId;
}
}

return undefined;
},
contextualComponents: ({ props: { contextualComponents } }) => {
// Return early if contextualComponents is undefined
if (typeof contextualComponents === 'undefined') {
Expand Down
10 changes: 8 additions & 2 deletions src/library/zoid/modal/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ export default createGlobalVariableGetter('__paypal_credit_modal__', () =>
required: false,
value: validate.ecToken
},
buttonSessionId: {
type: 'string',
queryParam: 'button_session_id',
required: false,
value: validate.buttonSessionId
},
pageType: {
type: 'string',
queryParam: 'page_type',
Expand All @@ -159,7 +165,6 @@ export default createGlobalVariableGetter('__paypal_credit_modal__', () =>

return ({ linkName, src }) => {
const { index, refIndex } = props;

logger.track({
index,
refIndex,
Expand Down Expand Up @@ -284,7 +289,7 @@ export default createGlobalVariableGetter('__paypal_credit_modal__', () =>
type: 'function',
queryParam: false,
value: ({ props, state, event }) => {
const { onReady } = props;
const { onReady, buttonSessionId } = props;
// Fired anytime we fetch new content (e.g. amount change)
return ({ products, meta, ts }) => {
const { index, offer, merchantId, account, refIndex, messageRequestId } = props;
Expand Down Expand Up @@ -318,6 +323,7 @@ export default createGlobalVariableGetter('__paypal_credit_modal__', () =>
[index]: {
type: 'modal',
messageRequestId,
buttonSessionId,
account: merchantId || account,
partnerClientId,
trackingDetails
Expand Down
5 changes: 3 additions & 2 deletions src/utils/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ function generateLogPayload(account, { meta, events: bizEvents, tracking }) {
const components = Object.entries(meta)
.filter(([, component]) => component.account === account)
.map(([index, component]) => {
const { type, messageRequestId, stats = {}, trackingDetails } = component;

// buttonSessionId could be undefined here
const { type, buttonSessionId, messageRequestId, stats = {}, trackingDetails } = component;
const { clickUrl } = trackingDetails;
delete trackingDetails.clickUrl;

Expand Down Expand Up @@ -58,6 +58,7 @@ function generateLogPayload(account, { meta, events: bizEvents, tracking }) {
return {
component_type: type,
instance_id: messageRequestId,
button_session_id: buttonSessionId,
fdata,
merchant_events: bizEvents.filter(event => event.payload?.index === index),
...trackingDetails,
Expand Down