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

MWPW-141020: [Project PEP] Implement Analytics Enablement #1951

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions libs/features/webapp-prompt/webapp-prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const CONFIG = {
icon: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 133.5 118.1" title="Adobe, Inc."><defs><style>.cls-1 {fill: #eb1000;}</style></defs><g><g><polygon class="cls-1" points="84.1 0 133.5 0 133.5 118.1 84.1 0"/><polygon class="cls-1" points="49.4 0 0 0 0 118.1 49.4 0"/><polygon class="cls-1" points="66.7 43.5 98.2 118.1 77.6 118.1 68.2 94.4 45.2 94.4 66.7 43.5"/></g></g></svg>',
};

const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);

robert-bogos marked this conversation as resolved.
Show resolved Hide resolved
const getElemText = (elem) => elem?.textContent?.trim().toLowerCase();

// Note: this might be used outside of Milo,
Expand All @@ -25,12 +27,13 @@ const getMetadata = (el) => [...el.childNodes].reduce((acc, row) => {
}, {});

class AppPrompt {
constructor({ promptPath, id, profileApi } = {}) {
constructor({ promptPath, id, profileApi, entName } = {}) {
this.promptPath = promptPath;
this.id = id;
this.profileApi = profileApi;
this.elements = {};

// TODO - make sure this is still valid after we have the entitlements mapping
this.productName = capitalize(entName);
robert-bogos marked this conversation as resolved.
Show resolved Hide resolved
if (this.isDismissedPrompt()) return;

this.init();
Expand Down Expand Up @@ -108,8 +111,8 @@ class AppPrompt {

// TODO: should we allow for app icon to be set as SVG?
decorate = () => {
this.elements.closeIcon = toFragment`<button class="appPrompt-close"></button>`;
this.elements.cta = toFragment`<button class="appPrompt-cta appPrompt-cta--close">${this.cancelText}</button>`;
this.elements.closeIcon = toFragment`<button daa-ll="Close Modal" class="appPrompt-close"></button>`;
this.elements.cta = toFragment`<button daa-ll="${this.cancelText}" class="appPrompt-cta appPrompt-cta--close">${this.cancelText}</button>`;
robert-bogos marked this conversation as resolved.
Show resolved Hide resolved
robert-bogos marked this conversation as resolved.
Show resolved Hide resolved
robert-bogos marked this conversation as resolved.
Show resolved Hide resolved
this.elements.profile = Object.keys(this.profile).length
? toFragment`<div class="appPrompt-profile">
<div class="appPrompt-avatar">
Expand All @@ -122,7 +125,7 @@ class AppPrompt {
</div>`
: '';

return toFragment`<div class="appPrompt">
return toFragment`<div daa-state="true" daa-im="true" daa-lh="PEP Modal_${this.productName}" class="appPrompt">
robert-bogos marked this conversation as resolved.
Show resolved Hide resolved
${this.elements.closeIcon}
<div class="appPrompt-icon">
${this.image}
Expand Down
2 changes: 1 addition & 1 deletion libs/scripts/delayed.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
loadStyle(`${base}/features/webapp-prompt/webapp-prompt.css`),
]);

webappPrompt.default({ promptPath, id, profileApi });
webappPrompt.default({ promptPath, id, profileApi, entName });

Check warning on line 100 in libs/scripts/delayed.js

View check run for this annotation

Codecov / codecov/patch

libs/scripts/delayed.js#L100

Added line #L100 was not covered by tests
robert-bogos marked this conversation as resolved.
Show resolved Hide resolved
};

/**
Expand Down
Loading