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

Merged
merged 11 commits into from
Jan 9, 2025
Merged

feat: Analytics scroll depth #12079

merged 11 commits into from
Jan 9, 2025

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 Jan 7, 2025 1:10pm
sentry-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2025 1:10pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
changelog ⬜️ Ignored (Inspect) Visit Preview Jan 7, 2025 1:10pm

Copy link

codecov bot commented Dec 10, 2024

Bundle Report

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

Detailed changes
Bundle name Size Change
sentry-docs-server-cjs 10.37MB 3.1kB (0.03%) ⬆️
sentry-docs-client-array-push 9.28MB 800 bytes (0.01%) ⬆️
View changes by path for bundle: sentry-docs-server-cjs
File path Size Change
/[[...path]] 513.0kB 80 bytes (0.02%)
/ 62.44kB 65 bytes (-0.1%)
/platform-redirect 30.67kB 81 bytes (0.26%)

@@ -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 👀

@getsantry
Copy link
Contributor

getsantry bot commented Jan 7, 2025

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Jan 7, 2025
@chargome
Copy link
Member

chargome commented Jan 7, 2025

@a-hariti can we merge this one? We have some upcoming tasks for plausible and would like to make use of that integration

@a-hariti
Copy link
Collaborator Author

a-hariti commented Jan 7, 2025

Yes, it just needs someone to make sure events are sent properly

@chargome
Copy link
Member

chargome commented Jan 7, 2025

I can check that

@getsantry getsantry bot removed the Stale label Jan 8, 2025
@a-hariti a-hariti merged commit 6954056 into master Jan 9, 2025
13 checks passed
@a-hariti a-hariti deleted the analytics-scroll-depth branch January 9, 2025 14:56
@github-actions github-actions bot locked and limited conversation to collaborators Jan 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Scroll Depth tracking on Plausible
3 participants