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

DCXY-20504: Don't pre-render dropzone when l2 limit is hit and upsell is shown #489

Merged
merged 21 commits into from
Dec 7, 2023
Merged
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
80ce70d
DCXY-19397: don't prerender dropzone when l2 limit is hit and upsell …
kbenelli-adobe Nov 21, 2023
cc9a138
DCXY-19397: match org cookie
kbenelli-adobe Nov 21, 2023
7955712
destructure cookies from doc
kbenelli-adobe Nov 21, 2023
688369c
DCXY-19397-New: Update per comments. Don't need verbinclude l2 list a…
kbenelli-adobe Nov 22, 2023
5ff289a
DCXY-19397-New: include create pdf
kbenelli-adobe Nov 22, 2023
ee4dc94
faster string check
kbenelli-adobe Nov 22, 2023
379b69e
DCXY-19397-New: pdf convert is create pdf group
kbenelli-adobe Nov 22, 2023
51627c5
DCXY-19397-New: unit test coverage for skip prerender cases
kbenelli-adobe Nov 29, 2023
3d7517b
DCXY-19397-New: fixed eslint error
kbenelli-adobe Nov 29, 2023
8eeabad
DCXY-19397-New: don't need to work with this eslint fix
kbenelli-adobe Nov 29, 2023
7e8974e
DCXY-19397-New: don't need to work with this eslint fix
kbenelli-adobe Nov 30, 2023
841c61c
DCXY-19397-New: remove duplicate window location
kbenelli-adobe Nov 30, 2023
65541fc
DCXY-19397-New: Updated cookie names to avoid chrome viewer extension…
kbenelli-adobe Dec 1, 2023
24f5a30
DCXY-19397-New: Supports cname convention for 1 pass cookie search.
kbenelli-adobe Dec 1, 2023
f2a4761
DCXY-19397-New: Updated tests to match cnames
kbenelli-adobe Dec 1, 2023
33ffe16
DCXY-19397-New: simplify look up to to-pdf, pdf-to, or verb name
kbenelli-adobe Dec 1, 2023
6aae123
DCXY-19397-New: check and map env prefix respectively
kbenelli-adobe Dec 1, 2023
cb96217
edge worker inlined snippet, remove the snipped from dom if exhausted
kbenelli-adobe Dec 4, 2023
c9893e7
Merge branch 'stage' into DCXY-19397-New
kbenelli-adobe Dec 4, 2023
1ee08cd
don't allow for undefined cookie name
kbenelli-adobe Dec 5, 2023
36fbd72
Merge branch 'stage' into DCXY-19397-New
seanchoi-dev Dec 7, 2023
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
29 changes: 27 additions & 2 deletions acrobat/blocks/dc-converter-widget/dc-converter-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,21 @@ const verbRedirMap = {
'number-pages': 'number',
};

const exhCreateLimitCookie = 'cr_p_c_e';
const exhExportLimitCookie = 'ex_p_c_e';
const exhOrganizeLimitCookie = 'or_p_c_e';
const exhCompressLimitCookie = 'cm_p_ops_e';

const exhLimitCookieMap = {
'to-pdf': exhCreateLimitCookie,
'pdf-to': exhExportLimitCookie,
'compress-pdf': exhCompressLimitCookie,
'rotate-pages': exhOrganizeLimitCookie,
};

const url = window.location;
const cookies = document.cookie;

const langFromPath = url.pathname.split('/')[1];
const pageLang = localeMap[langFromPath] || 'en-us';

Expand Down Expand Up @@ -208,18 +222,29 @@ export default async function init(element) {

const isReturningUser = window.localStorage.getItem('pdfnow.auth');
const isRedirection = /redirect_(?:conversion|files)=true/.test(window.location.search);
const preRenderDropZone = !isReturningUser && !isRedirection;
let isLimitExhausted = false;
const isExportVerb = VERB.includes('pdf-to');
const isCreateVerb = VERB.includes('to-pdf');
if (exhLimitCookieMap[VERB]) {
isLimitExhausted = cookies.includes(exhLimitCookieMap[VERB]);
} else if (isExportVerb) {
isLimitExhausted = cookies.includes(exhLimitCookieMap['pdf-to']);
} else if (isCreateVerb) {
isLimitExhausted = cookies.includes(exhLimitCookieMap['to-pdf']);
}

const verbIncludeList = ['compress-pdf', 'fillsign', 'sendforsignature', 'add-comment',
'delete-pages', 'reorder-pages', 'split-pdf', 'insert-pdf', 'extract-pages', 'crop-pages', 'number-pages'];

const preRenderDropZone = verbIncludeList.includes(VERB) || (!isReturningUser && !isRedirection);

const INLINE_SNIPPET = widget.querySelector(':scope > section#edge-snippet');
if (INLINE_SNIPPET) {
widgetContainer.dataset.rendered = 'true';
widgetContainer.appendChild(...INLINE_SNIPPET.childNodes);
widget.removeChild(INLINE_SNIPPET);
performance.mark('milo-move-snippet');
} else if (verbIncludeList.includes(VERB) || preRenderDropZone) {
} else if (!isLimitExhausted && preRenderDropZone) {
const response = await fetch(DC_GENERATE_CACHE_URL || `${DC_DOMAIN}/dc-generate-cache/dc-hosted-${DC_GENERATE_CACHE_VERSION}/${VERB}-${pageLang}.html`);
switch (response.status) {
case 200: {
Expand Down