Skip to content

Conversation

anandtiwary
Copy link
Contributor

@anandtiwary anandtiwary commented Sep 15, 2021

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:

  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

Documentation

Make sure that you have documented corresponding changes in this repository or hypertrace docs repo if required.

@codecov
Copy link

codecov bot commented Sep 15, 2021

Codecov Report

Merging #1127 (1296635) into main (be9edf4) will increase coverage by 0.02%.
The diff coverage is 88.67%.

Impacted file tree graph

@@            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              
Impacted Files Coverage Δ
...ects/common/src/telemetry/user-telemetry.module.ts 0.00% <0.00%> (ø)
...ry/error-handler/telemetry-global-error-handler.ts 100.00% <100.00%> (ø)
...ects/common/src/telemetry/track/track.directive.ts 100.00% <100.00%> (ø)
...ommon/src/telemetry/user-telemetry-impl.service.ts 90.00% <100.00%> (ø)
...cts/common/src/telemetry/user-telemetry.service.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update be9edf4...1296635. Read the comment docs.

@github-actions

This comment has been minimized.

Base automatically changed from user-telemetry-1 to main September 21, 2021 21:24
@anandtiwary anandtiwary marked this pull request as ready for review September 22, 2021 00:44
@anandtiwary anandtiwary requested a review from a team as a code owner September 22, 2021 00:44
@github-actions

This comment has been minimized.

@anandtiwary anandtiwary changed the title feat: adding error handler and a track directive feat: adding error handler and track directive Sep 22, 2021
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

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',
Copy link
Contributor

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?

Copy link
Contributor Author

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()
Copy link
Contributor

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?

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@anandtiwary anandtiwary requested a review from a team September 25, 2021 00:06
@github-actions

This comment has been minimized.

this.userTelemetryImplService.trackEvent(`${userEvent}: ${this.trackedEventLabel}`, {
target: eventObj.target,
...(eventObj.target as HTMLElement),
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@github-actions

This comment has been minimized.

this.userTelemetryImplService.trackEvent(`${userEvent}: ${this.trackedEventLabel}`, {
...(eventObj.target as HTMLElement),
tagName: targetElement.tagName,
innerHTML: targetElement.innerHTML,
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@github-actions

This comment has been minimized.

@anandtiwary anandtiwary requested review from aaron-steinfeld and a team and removed request for aaron-steinfeld September 27, 2021 16:56
@github-actions

This comment has been minimized.

@anandtiwary anandtiwary merged commit 6ed8f86 into main Sep 27, 2021
@anandtiwary anandtiwary deleted the user-telemetry-2 branch September 27, 2021 19:21
@github-actions
Copy link

Unit Test Results

    4 files  270 suites   17m 35s ⏱️
968 tests 968 ✔️ 0 💤 0 ❌
975 runs  975 ✔️ 0 💤 0 ❌

Results for commit 6ed8f86.

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.

2 participants