-
Notifications
You must be signed in to change notification settings - Fork 11
feat: adding error handler and track directive #1127
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1127 +/- ##
==========================================
+ Coverage 85.18% 85.20% +0.02%
==========================================
Files 825 827 +2
Lines 17082 17121 +39
Branches 2216 2222 +6
==========================================
+ Hits 14551 14588 +37
- Misses 2500 2502 +2
Partials 31 31
Continue to review full report at Codecov.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@@ -28,3 +28,8 @@ export interface UserTraits extends Dictionary<unknown> { | |||
name?: string; | |||
displayName?: string; | |||
} | |||
|
|||
export const enum TrackUserEventsType { | |||
Click = 'click', |
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.
Any reason to limit to these two events?
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.
It makes sense to keep it flexible (string), but I want to expand this list after I test their behavior, how many events they generate and any perf impact. From Product/Marketing standpoint, the 4 event types we discussed previously are important. Events like MouseOver, MouseOut are not useful.
import { ErrorHandler, Injectable, Injector } from '@angular/core'; | ||
import { UserTelemetryImplService } from '../user-telemetry-impl.service'; | ||
|
||
@Injectable() |
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.
This should be registered as part of the telemetry module, right? or intentionally keeping it as a separate registration?
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.
No, I need to provide it in the module. I missed it in this PR
} | ||
|
||
if (changes.label) { | ||
this.trackedEventLabel = this.label ?? (this.host.nativeElement as HTMLElement)?.tagName; |
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.
tag name doesnt seem very useful, maybe we should require label? Could make that the main arg and the event name the addtl arg since that's easier to default.
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.
So, the autotrack based telemetry tools extract certain fields from the element. I am yet to figure out the relevant ones. After I do that, I will add those fields here.
Imo htTrack= "events" is more readable. You can always miss providing a directive input and angular won't complain. So let's keep the default logic. I will use a better field than just with a later PR.
This comment has been minimized.
This comment has been minimized.
this.userTelemetryImplService.trackEvent(`${userEvent}: ${this.trackedEventLabel}`, { | ||
target: eventObj.target, | ||
...(eventObj.target as HTMLElement), |
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.
why are you spreading the whole element onto the event?
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.
I wasn't sure what all fields would be interesting. Anyway, I have added few properties only now.
This comment has been minimized.
This comment has been minimized.
this.userTelemetryImplService.trackEvent(`${userEvent}: ${this.trackedEventLabel}`, { | ||
...(eventObj.target as HTMLElement), | ||
tagName: targetElement.tagName, | ||
innerHTML: targetElement.innerHTML, |
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.
This still feels like over-reporting (and potentially can report PII data). Why do we need the innerHTML of a clicked (for example) element? Can we start minimal and add stuff as use cases come up?
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.
I can remove innerHtml. But btw, you need to put controls in your telemetry tool to protect against storing pii. It shouldn't be completely dependent on the code
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.
done
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Unit Test Results 4 files 270 suites 17m 35s ⏱️ Results for commit 6ed8f86. |
Description
Please include a summary of the change, motivation and context.
feat: adding error handler and track directive
Testing
Please describe the tests that you ran to verify your changes. Please summarize what did you test and what needs to be tested e.g. deployed and tested helm chart locally.
Checklist:
Documentation
Make sure that you have documented corresponding changes in this repository or hypertrace docs repo if required.