Skip to content

feat: using telemetry tracker in few atomic components #1129

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

Merged
merged 21 commits into from
Sep 28, 2021

Conversation

anandtiwary
Copy link
Contributor

@anandtiwary anandtiwary commented Sep 15, 2021

Description

Please include a summary of the change, motivation and context.

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.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Base automatically changed from user-telemetry-3 to main September 27, 2021 21:39
@anandtiwary anandtiwary changed the title feat: using telemetry in with link components feat: using telemetry tracker in few atomic components Sep 27, 2021
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@@ -9,7 +9,7 @@ import { UserTelemetryService } from './user-telemetry.service';
export class UserTelemetryImplService extends UserTelemetryService {
private telemetryProviders: UserTelemetryInternalConfig[] = [];

public constructor(private readonly injector: Injector, private readonly router: Router) {
public constructor(private readonly injector: Injector, @Optional() private readonly router?: Router) {
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, if I don't make Router optional then I get test errors wherever the atomic component (that uses htTrack) is used. Alternatively, I will have to provide Router Mock service everywhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

But shouldn't we be mocking the component in those tests? Why are they use the real track component?

@anandtiwary anandtiwary marked this pull request as ready for review September 28, 2021 01:02
@anandtiwary anandtiwary requested a review from a team as a code owner September 28, 2021 01:02
@github-actions

This comment has been minimized.

@codecov
Copy link

codecov bot commented Sep 28, 2021

Codecov Report

Merging #1129 (b187f00) into main (1e04e81) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1129      +/-   ##
==========================================
+ Coverage   85.02%   85.04%   +0.02%     
==========================================
  Files         829      831       +2     
  Lines       17175    17208      +33     
  Branches     2233     2235       +2     
==========================================
+ Hits        14603    14635      +32     
- Misses       2540     2541       +1     
  Partials       32       32              
Impacted Files Coverage Δ
...omponents/src/breadcrumbs/breadcrumbs.component.ts 94.11% <ø> (ø)
projects/components/src/button/button.component.ts 100.00% <ø> (ø)
projects/components/src/link/link.component.ts 100.00% <ø> (ø)
projects/common/src/public-api.ts 100.00% <100.00%> (ø)
.../telemetry/track/user-telemetry-tracking.module.ts 100.00% <100.00%> (ø)
...ommon/src/telemetry/user-telemetry-impl.service.ts 92.50% <100.00%> (+2.50%) ⬆️
...ects/common/src/telemetry/user-telemetry.module.ts 60.00% <100.00%> (+60.00%) ⬆️
...s/components/src/breadcrumbs/breadcrumbs.module.ts 100.00% <100.00%> (ø)
projects/components/src/button/button.module.ts 100.00% <100.00%> (ø)
projects/components/src/link/link.module.ts 100.00% <100.00%> (ø)
... and 5 more

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 1e04e81...b187f00. Read the comment docs.

@github-actions

This comment has been minimized.

@@ -9,7 +9,7 @@ import { UserTelemetryService } from './user-telemetry.service';
export class UserTelemetryImplService extends UserTelemetryService {
private telemetryProviders: UserTelemetryInternalConfig[] = [];

public constructor(private readonly injector: Injector, private readonly router: Router) {
public constructor(private readonly injector: Injector, @Optional() private readonly router?: Router) {
Copy link
Contributor

Choose a reason for hiding this comment

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

But shouldn't we be mocking the component in those tests? Why are they use the real track component?

@@ -13,7 +15,8 @@ describe('BreadcrumbsComponent', () => {
const createHost = createHostFactory({
declareComponent: false,
component: BreadcrumbsComponent,
imports: [BreadcrumbsModule, HttpClientTestingModule, IconLibraryTestingModule],
imports: [BreadcrumbsModule, HttpClientTestingModule, IconLibraryTestingModule, RouterTestingModule],
declarations: [MockDirective(TrackDirective)],
Copy link
Contributor

Choose a reason for hiding this comment

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

So here's an example. The mocked track component should be sufficient, we shouldn't need the router testing module too (and in general, this test needs to be converted be shallow)

Copy link
Contributor Author

@anandtiwary anandtiwary Sep 28, 2021

Choose a reason for hiding this comment

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

The MockDirective still tries to inject Router since it is in the constructor.

Copy link
Contributor

Choose a reason for hiding this comment

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

really? that seems off...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, they try to inject the services. I have seen it at few other places.

@@ -10,7 +10,7 @@ import { ButtonRole, ButtonSize, ButtonStyle } from './button';
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ht-event-blocker event="click" class="button-container" [enabled]="this.disabled">
<button class="button" [ngClass]="this.getStyleClasses()">
<button class="button" [ngClass]="this.getStyleClasses()" [htTrack] [htTrackLabel]="this.label">
Copy link
Contributor

Choose a reason for hiding this comment

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

do we capture something like the route path or url here? Seems like it's worth not just tracking "Submit" for example, but where that submit is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. URL change is tracked via router events and it can be enabled via enablePageTracking option

Copy link
Contributor

Choose a reason for hiding this comment

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

but those are separate events. If I'm looking at a click event for a button labeled "submit" how do I know what page it's on? Or do the tools provide that by tracking the event timeline?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are the things we can capture and add to the "eventData" object from inside the telemetryImpl service. But AFAIU, the telemetry tools will timestamp these anyway, so we can connect the dots there. Let's iterate over this.

@anandtiwary anandtiwary merged commit 2018fb2 into main Sep 28, 2021
@anandtiwary anandtiwary deleted the user-telemetry-4 branch September 28, 2021 21:34
@github-actions
Copy link

Unit Test Results

    4 files  ±0  270 suites  ±0   19m 19s ⏱️ +41s
968 tests ±0  968 ✔️ ±0  0 💤 ±0  0 ❌ ±0 
975 runs  ±0  975 ✔️ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 2018fb2. ± Comparison against base commit 1e04e81.

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