o-tracking add IntersectionObserver.threshold as opt #1948
+3
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I'm configuring the App Homepage
scrolldepth
tracking event usingoTracking.view.init()
in this PR by setting a selector that will trigger this event every time a<section />
comes into the viewport. In the beginning, it was working as expected, but after some days I retested it and thescrolldepth
events were not being sent as expected.After some investigation, I realized that the problem was located in the 1.0 IntersectionObserver threshold defined here. Looking at the docs, this means that "A value of 1.0 means that the threshold isn't considered passed until every pixel is visible". This is not a problem in medium / big screens, since they can fit a whole
<section />
in the viewport (that's why it worked in the beginning), but for small screens, is rather difficult to fit the whole<section />
in it.I've considered changing the selector provided to this function by selecting only the first teaser of each
<section />
, but the payload sent to Spoor changes drastically.So, to fix this, we can modify the threshold to a lover value so the event triggers with smaller portions of the
<section />
.Issue ticket number and link
Relates to this ticket
Link to Figma designs
Checklist before requesting a review
percy
label for o-[COMPONENT] orchromatic
label for o3-[COMPONENT] on my PR before merging and after review. Find more details in CONTRIBUTING.md