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: Pages with steady decline of conversion #293

Draft
wants to merge 44 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c42f301
feat: Pages with steady decline of conversion
Jul 17, 2024
7098e37
fix lint issues
Jul 18, 2024
a99194f
feat: Pages with steady decline of conversion
Jul 19, 2024
0ea09d1
merge main to branch
Jul 30, 2024
e64d279
WIP
Jul 30, 2024
1db3702
merging main to branch
Jul 30, 2024
1e86711
feat: Pages with steady decline of conversion
Aug 2, 2024
faab213
Merge branch 'main' into SITES-22537
Dereje24 Aug 2, 2024
b8c547f
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 14, 2024
5627ed5
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 14, 2024
7bd17ff
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 14, 2024
057efc4
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 14, 2024
5d6aada
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 14, 2024
2f2c53f
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 14, 2024
86f5aed
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 14, 2024
6c212b4
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 14, 2024
61d200e
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 15, 2024
3edcd69
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 19, 2024
c7e18b6
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 19, 2024
f7624c1
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 19, 2024
30358ed
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 19, 2024
3ba9258
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 19, 2024
51f2fdd
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 19, 2024
d16f567
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 19, 2024
07ff401
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 19, 2024
92156f5
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 19, 2024
b9384aa
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 19, 2024
aa877bf
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 20, 2024
311ff29
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 21, 2024
baceb4f
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 21, 2024
f56cecb
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 21, 2024
5bec5aa
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 21, 2024
9cb173d
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 21, 2024
d5e5853
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 21, 2024
88083f7
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 21, 2024
69a926d
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 21, 2024
11e4844
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 21, 2024
fb7369b
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 21, 2024
a52afa7
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 21, 2024
ff4c4e5
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 21, 2024
0f1a7ab
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 21, 2024
ebf9175
SITES-22537 [oppty] Pages with steady decline of CTR
Aug 22, 2024
9af5727
fix filtering threshold
Aug 28, 2024
45a0fb3
refactor oppty
Nov 6, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,19 @@ function handler(bundles) {
// data[bundle.url][weekKey].metrics.push({ selector: source, ctr });
// }
// Initialize an object to hold the selectors and their counts
let globalSelectors = {};
const globalSelectors = {};

for (const bundle of bundles) {
// Initialize a Set to hold the unique selectors for this bundle
let uniqueSelectors = new Set();
const uniqueSelectors = new Set();
Copy link

Choose a reason for hiding this comment

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

I'd move the declaration outside of the loop so you re-use the same variable and avoid allocation of hundreds of different ones.

    let uniqueSelectors;
    for (const bundle of bundles) {
      // Initialize a Set to hold the unique selectors for this bundle
      uniqueSelectors = new Set();


let totalClicks = 0;
Copy link

Choose a reason for hiding this comment

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

Same here, I'd move the declaration outside of the loop

for (const event of bundle.events) {
if (event.checkpoint === 'click') {
uniqueSelectors.add(event.source);
totalClicks++;
}
}

for (const event of bundle.events) {
if (event.checkpoint === 'click') {
Expand All @@ -83,13 +91,13 @@ function handler(bundles) {

// Iterate over the unique selectors and increment their count in the global selectors object
for (const source of uniqueSelectors) {
globalSelectors[source] = (globalSelectors[source] || 0) + 1;
const count = uniqueSelectors[source] || 0;
Copy link

Choose a reason for hiding this comment

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

Again here as well

if (count / totalClicks >= 0.1) {
globalSelectors[source] = count + 1;
}
}
}

// Now, globalSelectors contains the count of each selector across all bundles
// Convert the globalSelectors object to an array of objects and add it to the metrics array
// data[bundle.url][weekKey].metrics = Object.entries(globalSelectors).map(([selector, count]) => ({ selector, count }));
data[bundle.url][weekKey].metrics = Object.entries(globalSelectors).map(([selector, count]) => {
const ctr = (count / data[bundle.url][weekKey].pageViews) * 100;
return { selector, ctr };
Expand Down
Loading