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: Analytics scroll depth #12079

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

feat: Analytics scroll depth #12079

wants to merge 9 commits into from

Conversation

a-hariti
Copy link
Collaborator

closes #12061

Copy link

vercel bot commented Dec 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
develop-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 13, 2024 4:17pm
sentry-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 13, 2024 4:17pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
changelog ⬜️ Ignored (Inspect) Visit Preview Dec 13, 2024 4:17pm

Copy link

codecov bot commented Dec 10, 2024

Bundle Report

Changes will increase total bundle size by 6.02kB (0.03%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sentry-docs-server-cjs 10.35MB 3.01kB (0.03%) ⬆️
sentry-docs-client-array-push 9.27MB 3.02kB (0.03%) ⬆️

@@ -31,6 +31,9 @@ export const metadata: Metadata = {
export default function RootLayout({children}: {children: React.ReactNode}) {
return (
<html lang="en" suppressHydrationWarning>
<head>
<PlausibleProvider domain="docs.sentry.io,rollup.sentry.io" />
Copy link
Member

Choose a reason for hiding this comment

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

do we need dev docs as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Probably, we should ask @lizokm

Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't look like we have Plausible installed on dev docs (if it is, it's not hooked up to the company account).

@@ -3,7 +3,7 @@ import './globals.css';
import {Theme} from '@radix-ui/themes';
import type {Metadata} from 'next';
import {Rubik} from 'next/font/google';
import Script from 'next/script';
import PlausibleProvider from 'next-plausible';
Copy link
Member

Choose a reason for hiding this comment

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

What is the advantage of having this instead of the script?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

send events dynamically through a hook, nice TS and local DX experience

if (document.documentElement.scrollHeight - window.innerHeight === 0) {
return () => {};
}
const debouncedTrackProgress = debounce(trackProgress, 20);
Copy link
Member

Choose a reason for hiding this comment

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

As discussed offline: this prevents events from being sent when a user very quickly scrolls to the bottom and then leaves the page - which might not count as a read anyway

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, it doesn't happen if you scroll at any reasonable reading speed

Copy link
Contributor

Choose a reason for hiding this comment

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

Have you considered using the IntersectionObserver API for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think the current approach is more precise

the marketing site / blog use the intersection observer and report 100% when the last heading is reached

a useful heuristic, but not very precise

Copy link
Contributor

Choose a reason for hiding this comment

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

The IntersectionObserver is more performant and since it's already being used by the marketing site, we should be keeping the measurement methods the same for better comparison.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

please keep in mind the measurement on the marketing sites is very rough (based on headers instead of the actual page scroll)

But I can do it @elijames-codecov

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

turns out I had bug in my debounce logic, now it works as intended

it's simple, precise and performant

maybe we should port it to the marketing site @elijames-codecov once we make sure it works well?

Copy link
Contributor

Choose a reason for hiding this comment

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

@a-hariti - Glad you got the debounce working! Since we're looking for insights as to which sections the users scroll into (to inform if there's seeing certain content and make content and some layout decisions), each section having a header, IntersectionObserver actually works well for our needs without added complexity and expensive operations...which is why we will continue to use it.

{props: {readProgress: progress, page: document.title}},
] as const;
plausible(...args);
console.log('plausible event', ...args);
Copy link
Contributor

Choose a reason for hiding this comment

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

We probably want to remove this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, the last thing before merging

@a-hariti
Copy link
Collaborator Author

Are you available to make sure things work as expected after the merge @elijames-codecov? (I don't have access to Analytics)

@elijames-codecov
Copy link
Contributor

elijames-codecov commented Dec 13, 2024

@a-hariti - Let's launch on Monday. It'll make sure we're all around to catch and fix any issues as they arise. But, I'm very happy to double check our analytics once we launch.

Are you available to make sure things work as expected after the merge @elijames-codecov? (I don't have access to Analytics)

@a-hariti
Copy link
Collaborator Author

@stephanie-anderson 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Scroll Depth tracking on Plausible
3 participants