-
Notifications
You must be signed in to change notification settings - Fork 11
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
Changes from all commits
99388e6
76ef6f3
a93db20
8a4b536
aa91d22
6161655
a8b308d
9ce27b3
1358760
8395555
4db25a3
8abcc0a
ab55e02
816baec
771c129
226edaa
f27a899
0da628a
f82244d
aef030a
b187f00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
import { TrackDirective } from './track.directive'; | ||
|
||
@NgModule({ | ||
imports: [CommonModule], | ||
declarations: [TrackDirective], | ||
exports: [TrackDirective] | ||
}) | ||
export class UserTelemetryTrackingModule {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { HttpClientTestingModule } from '@angular/common/http/testing'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { IconLibraryTestingModule } from '@hypertrace/assets-library'; | ||
import { NavigationService } from '@hypertrace/common'; | ||
import { NavigationService, TrackDirective } from '@hypertrace/common'; | ||
import { byText, createHostFactory, mockProvider, Spectator } from '@ngneat/spectator/jest'; | ||
import { MockDirective } from 'ng-mocks'; | ||
import { EMPTY } from 'rxjs'; | ||
import { BreadcrumbsComponent } from './breadcrumbs.component'; | ||
import { BreadcrumbsModule } from './breadcrumbs.module'; | ||
|
@@ -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)], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. really? that seems off... There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
providers: [ | ||
mockProvider(NavigationService, { | ||
navigation$: EMPTY, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
<ht-icon | ||
*ngIf="this.icon && !this.trailingIcon" | ||
[icon]="this.icon" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
import { RouterModule } from '@angular/router'; | ||
import { UserTelemetryTrackingModule } from '@hypertrace/common'; | ||
import { LetAsyncModule } from '../let-async/let-async.module'; | ||
import { LinkComponent } from './link.component'; | ||
|
||
@NgModule({ | ||
declarations: [LinkComponent], | ||
exports: [LinkComponent], | ||
imports: [CommonModule, RouterModule, LetAsyncModule] | ||
imports: [CommonModule, RouterModule, LetAsyncModule, UserTelemetryTrackingModule] | ||
}) | ||
export class LinkModule {} |
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, 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.
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.
But shouldn't we be mocking the component in those tests? Why are they use the real track component?