-
Notifications
You must be signed in to change notification settings - Fork 550
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: Add page view instrumentation plugin #2386
base: main
Are you sure you want to change the base?
feat: Add page view instrumentation plugin #2386
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2386 +/- ##
=======================================
Coverage 90.74% 90.74%
=======================================
Files 156 156
Lines 7728 7728
Branches 1590 1590
=======================================
Hits 7013 7013
Misses 715 715 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple small changes, but overall looks good. Failing tests need to be fixed.
plugins/web/opentelemetry-instrumentation-page-view/package.json
Outdated
Show resolved
Hide resolved
plugins/web/opentelemetry-instrumentation-page-view/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
57ab371
to
3c980fa
Compare
plugins/web/opentelemetry-instrumentation-page-view/src/instrumentation.ts
Outdated
Show resolved
Hide resolved
…mentation.ts Co-authored-by: Martin Kuba <[email protected]>
bee412c
to
e204c33
Compare
@Abinet18 I have approved the PR, but forgot to mention that also these files should be updated:
|
@martinkuba , when can this be merged. I would fix the conflict just before the merge time so that I don't have to do it every time the main branch changes |
* executes callback {_onDOMContentLoaded } when the page is viewed | ||
*/ | ||
private _waitForPageLoad() { | ||
document.addEventListener('DOMContentLoaded', this._onPageView.bind(this)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: it might make sense to use a buffered PerformanceObserver to listen for PerformanceNavigationTimings, insead of DOMEventListener for DOMContentLoaded. I have seen users be unable to find their PageViews because eventListener needs registered at runtime before DOMContentLoaded in order to scrape any data. This problem will also be worse for those have want to install this package via CDN
/** | ||
* callback to be executed when using hard navigation | ||
*/ | ||
private _onPageView() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: can we also teardown the event listener for DomContentLoaded
? I believe it only happens once, so there's no need for it anymore.
Part of the client sdk project, Implement PageView event instrumentation
#2372
This PR adds the page view instrumentation which sends an event when a page is loaded (as soon as the html is loaded) or when a route change happens (tracking the history push and replace states)
Tested on an example app with generic routes that use the history api