Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Move idx auth event to p1e lib
Browse files Browse the repository at this point in the history
  • Loading branch information
solocommand committed Feb 16, 2024
1 parent fbb9eac commit 117cf16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
6 changes: 6 additions & 0 deletions packages/marko-web-p1-events/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,19 @@ export default (Browser) => {
action: 'Submit',
label: 'Profile',
}],
['identity-x-authenticated', {
category: 'Identity',
action: 'Click',
label: 'Login Link',
}],
]).entries()].forEach(([event, payload]) => {
EventBus.$on(event, (args) => {
if (!window.p1events) return;
const { actionSource, newsletterSignupType, contentGatingType } = args;
window.p1events('track', {
...payload,
props: {
idxEntity: args.entity,
...(actionSource && { actionSource }),
...(newsletterSignupType && { newsletterSignupType }),
...(contentGatingType && { contentGatingType }),
Expand Down
24 changes: 1 addition & 23 deletions packages/marko-web-theme-monorail/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,6 @@ const setP1EventsIdentity = ({ p1events, brandKey, encryptedId }) => {
p1events('setIdentity', `omeda.${brandKey}.customer*${encryptedId}~encrypted`);
};

const dispatchP1EAuthenticate = (args) => {
const {
loginSource: actionSource,
newsletterSignupType,
contentGatingType,
} = args;
window.p1events('track', {
category: 'Identity',
action: 'Click',
label: 'Login Link',
props: {
...(actionSource && { actionSource }),
...(newsletterSignupType && { newsletterSignupType }),
...(contentGatingType && { contentGatingType }),
},
});
};

/**
* @typedef ThemeConfig
* @prop {boolean} [enableOmedaIdentityX=true]
Expand Down Expand Up @@ -82,26 +64,22 @@ export default (Browser, configOverrides = {}) => {
}

/**
* Sets the P1E Identity and explicitly dispatches the authenticate converion event
* @see @parameter1/marko-web-p1-events/browser for post-auth conversion events
* Sets the P1E Identity. @see @parameter1/marko-web-p1-events/browser other events
*/
if (enableOmedaIdentityX) {
EventBus.$on('omeda-identity-x-authenticated', (args) => {
const { brandKey, encryptedId } = args;
setP1EventsIdentity({ p1events: window.p1events, brandKey, encryptedId });
dispatchP1EAuthenticate(args);
});
EventBus.$on('omeda-identity-x-rapid-identify-response', (args) => {
const { brandKey, encryptedId } = args;
setP1EventsIdentity({ p1events: window.p1events, brandKey, encryptedId });
dispatchP1EAuthenticate(args);
});
} else {
EventBus.$on('identity-x-authenticated', (args) => {
const { applicationId, user } = args;
if (!window.p1events || !applicationId || !user) return;
window.p1events('setIdentity', `identity-x.${applicationId}.app-user*${user.id}`);
dispatchP1EAuthenticate(args);
});
}

Expand Down

0 comments on commit 117cf16

Please sign in to comment.