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-135873 Compress the caas hash strings #1401

Merged
merged 13 commits into from
Oct 18, 2023
Merged

Conversation

chrischrischris
Copy link
Contributor

The hash string is now compressed using gzip: the hash length is reduced by ~60%

The new compressed hashes start with ~~ in order to differentiate them from the original non-compressed format.

The configurator at /tools/caas will now only generate the v2 hashes, but pages can use links with either format.

Resolves: MWPW-135873

Test URLs:

By compressing using gzip, the hash length is reduced by ~60%

The new compressed hashes start with `~~` in order to differentiate them from the original non-compressed format.
@chrischrischris chrischrischris added the new-feature New block or other feature label Oct 11, 2023
@aem-code-sync
Copy link
Contributor

aem-code-sync bot commented Oct 11, 2023

Hello, I'm the AEM Code Sync Bot and I will run some test suites that validate the page speed.
In case there are problems, just click the checkbox below to rerun the respective action.

  • Re-run PSI Checks

@aem-code-sync
Copy link
Contributor

aem-code-sync bot commented Oct 11, 2023

Page Scores Audits Google
/drafts/cpeyer/caas-hash-link?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@aem-code-sync
Copy link
Contributor

aem-code-sync bot commented Oct 11, 2023

Page Scores Audits Google
/drafts/cpeyer/caas-hash-link?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@chrischrischris chrischrischris added the needs-verification PR requires E2E testing by a reviewer label Oct 17, 2023
@aem-code-sync
Copy link
Contributor

aem-code-sync bot commented Oct 17, 2023

Page Scores Audits Google
/drafts/cpeyer/caas-hash-link?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@aem-code-sync
Copy link
Contributor

aem-code-sync bot commented Oct 17, 2023

Page Scores Audits Google
/drafts/cpeyer/caas-hash-link?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@@ -36,13 +43,15 @@ const updateObj = (obj, defaultObj) => {

const isValidUuid = (id) => /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(id);

const getHashConfig = () => {
const getHashConfig = async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see an await in this function, async needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

getHashConfig now can either be async (for v2 hashes) or sync (for v1 hashes). I think for clarity, since it's possible that it will be async this function should be marked as async? Otherwise you have to just know. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nevermind, am updating the code to show why it's async.

Comment on lines 949 to 959
useEffect(() => {
const setInitialState = async () => {
const initialState = await getInitialState();
dispatch({ type: 'SET_STATE', value: initialState });
};

if (!Object.keys(state).length) {
setInitialState();
}
}, [state]);

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you simplify this by putting an empty [] instead of [state] so the useEffect runs only once? Might be able to omit the check for state length on line 955 if so.

@aem-code-sync
Copy link
Contributor

aem-code-sync bot commented Oct 17, 2023

Page Scores Audits Google
/drafts/cpeyer/caas-hash-link?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@aem-code-sync
Copy link
Contributor

aem-code-sync bot commented Oct 17, 2023

Page Scores Audits Google
/drafts/cpeyer/caas-hash-link?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

Copy link
Contributor

@rgclayton rgclayton left a comment

Choose a reason for hiding this comment

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

Is the only way to verify that the truncation is/isn't happening is to go through the loc rollout process?

Copy link
Contributor

@mokimo mokimo left a comment

Choose a reason for hiding this comment

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

Fancy, one test failing ensure it's running through before merging
Culprit test: Can copy the config to a hash

const a = document.getElementById('v2-caaslink');
await init(a);
await waitForElement('#caas');
await delay(5);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shoul we use a fake timer instead? I'm fine with the delay as well if it's deterministic such as waiting for an eventListener execution and doesn't lead to flakiness.

@aem-code-sync
Copy link
Contributor

aem-code-sync bot commented Oct 18, 2023

Page Scores Audits Google
/drafts/cpeyer/caas-hash-link?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@rgclayton rgclayton added verified PR has been E2E tested by a reviewer and removed verified PR has been E2E tested by a reviewer labels Oct 18, 2023
@aem-code-sync
Copy link
Contributor

aem-code-sync bot commented Oct 18, 2023

Page Scores Audits Google
/drafts/cpeyer/caas-hash-link?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@aem-code-sync
Copy link
Contributor

aem-code-sync bot commented Oct 18, 2023

Page Scores Audits Google
/drafts/cpeyer/caas-hash-link?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@aem-code-sync
Copy link
Contributor

aem-code-sync bot commented Oct 18, 2023

Page Scores Audits Google
/drafts/cpeyer/caas-hash-link?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@aem-code-sync
Copy link
Contributor

aem-code-sync bot commented Oct 18, 2023

Page Scores Audits Google
/drafts/cpeyer/caas-hash-link?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@aem-code-sync
Copy link
Contributor

aem-code-sync bot commented Oct 18, 2023

Page Scores Audits Google
/drafts/cpeyer/caas-hash-link?martech=off PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

Merging #1401 (1a8c975) into main (89561d5) will increase coverage by 0.00%.
Report is 4 commits behind head on main.
The diff coverage is 96.46%.

@@           Coverage Diff           @@
##             main    #1401   +/-   ##
=======================================
  Coverage   96.32%   96.32%           
=======================================
  Files         144      144           
  Lines       34414    34513   +99     
=======================================
+ Hits        33148    33244   +96     
- Misses       1266     1269    +3     
Files Coverage Δ
libs/blocks/caas/caas.js 89.41% <100.00%> (+3.69%) ⬆️
libs/blocks/caas-config/caas-config.js 98.76% <96.92%> (-0.54%) ⬇️
libs/blocks/caas/utils.js 95.80% <93.33%> (-0.12%) ⬇️

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@chrischrischris chrischrischris merged commit 202c33f into main Oct 18, 2023
9 of 11 checks passed
@chrischrischris chrischrischris deleted the caaslink-135873 branch October 18, 2023 20:08
@rgclayton rgclayton added the verified PR has been E2E tested by a reviewer label Oct 18, 2023
auniverseaway added a commit that referenced this pull request Oct 18, 2023
suhjainadobe pushed a commit to suhjainadobe/milo that referenced this pull request Oct 21, 2023
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Sunil Kamat <107644736+sukamat@users.noreply.github.com>
Axelcureno pushed a commit to Axelcureno/milo that referenced this pull request Oct 25, 2023
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Sunil Kamat <107644736+sukamat@users.noreply.github.com>
vgoodric pushed a commit to vgoodric/bootcamp-milo that referenced this pull request Feb 1, 2024
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Sunil Kamat <107644736+sukamat@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-verification PR requires E2E testing by a reviewer new-feature New block or other feature verified PR has been E2E tested by a reviewer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants