From 8794f2cd86395347134d44be200d9b24be3d128b Mon Sep 17 00:00:00 2001 From: Venkatesh-rengasamy Date: Tue, 8 Mar 2022 17:31:49 +0530 Subject: [PATCH] Telemetry coverage for Databags Signed-off-by: Venkatesh-rengasamy --- .../create-data-bag-modal.component.spec.ts | 7 ++++++- .../create-data-bag-modal.component.ts | 5 ++++- .../create-databag-item-modal.component.spec.ts | 8 +++++++- .../create-databag-item-modal.component.ts | 5 ++++- .../data-bags-details/data-bags-details.component.spec.ts | 5 +++++ .../data-bags-details/data-bags-details.component.ts | 7 ++++++- .../data-bags-list/data-bags-list.component.spec.ts | 8 +++++++- .../data-bags-list/data-bags-list.component.ts | 6 +++++- .../edit-data-bag-item-modal.component.spec.ts | 8 ++++++++ .../edit-data-bag-item-modal.component.ts | 5 ++++- 10 files changed, 56 insertions(+), 8 deletions(-) diff --git a/components/automate-ui/src/app/modules/infra-proxy/create-data-bag-modal/create-data-bag-modal.component.spec.ts b/components/automate-ui/src/app/modules/infra-proxy/create-data-bag-modal/create-data-bag-modal.component.spec.ts index 56c24d1dc01..4c176a5554d 100644 --- a/components/automate-ui/src/app/modules/infra-proxy/create-data-bag-modal/create-data-bag-modal.component.spec.ts +++ b/components/automate-ui/src/app/modules/infra-proxy/create-data-bag-modal/create-data-bag-modal.component.spec.ts @@ -19,7 +19,11 @@ import { } from 'app/entities/data-bags/data-bags.model'; import { Regex } from 'app/helpers/auth/regex'; import { using } from 'app/testing/spec-helpers'; +import { TelemetryService } from 'app/services/telemetry/telemetry.service'; +class MockTelemetryService { + track() { } +} describe('CreateDataBagModalComponent', () => { let component: CreateDataBagModalComponent; @@ -49,7 +53,8 @@ describe('CreateDataBagModalComponent', () => { ], providers: [ HttpClient, - HttpHandler + HttpHandler, + { provide: TelemetryService, useClass: MockTelemetryService } ], schemas: [ CUSTOM_ELEMENTS_SCHEMA ] }) diff --git a/components/automate-ui/src/app/modules/infra-proxy/create-data-bag-modal/create-data-bag-modal.component.ts b/components/automate-ui/src/app/modules/infra-proxy/create-data-bag-modal/create-data-bag-modal.component.ts index 58500c60c40..50452416e79 100644 --- a/components/automate-ui/src/app/modules/infra-proxy/create-data-bag-modal/create-data-bag-modal.component.ts +++ b/components/automate-ui/src/app/modules/infra-proxy/create-data-bag-modal/create-data-bag-modal.component.ts @@ -23,6 +23,7 @@ import { CreateDataBag } from 'app/entities/data-bags/data-bags.actions'; import { Utilities } from 'app/helpers/utilities/utilities'; +import { TelemetryService } from 'app/services/telemetry/telemetry.service'; @Component({ selector: 'app-create-data-bag-modal', @@ -45,7 +46,8 @@ export class CreateDataBagModalComponent implements OnInit, OnDestroy { constructor( private store: Store, - private fb: FormBuilder + private fb: FormBuilder, + private telemetryService: TelemetryService ) { this.createForm = this.fb.group({ // Must stay in sync with error checks in create-notification-modal.component.html @@ -116,6 +118,7 @@ export class CreateDataBagModalComponent implements OnInit, OnDestroy { }; this.store.dispatch(new CreateDataBag({dataBag: dataBag})); + this.telemetryService.track('InfraServer_Databags_Create'); } private resetCreateModal(): void { diff --git a/components/automate-ui/src/app/modules/infra-proxy/create-databag-item-modal/create-databag-item-modal.component.spec.ts b/components/automate-ui/src/app/modules/infra-proxy/create-databag-item-modal/create-databag-item-modal.component.spec.ts index cf9feb3e6d0..bce76574ae0 100644 --- a/components/automate-ui/src/app/modules/infra-proxy/create-databag-item-modal/create-databag-item-modal.component.spec.ts +++ b/components/automate-ui/src/app/modules/infra-proxy/create-databag-item-modal/create-databag-item-modal.component.spec.ts @@ -18,6 +18,11 @@ import { } from 'app/entities/data-bags/data-bags.model'; import { Regex } from 'app/helpers/auth/regex'; import { using } from 'app/testing/spec-helpers'; +import { TelemetryService } from 'app/services/telemetry/telemetry.service'; + +class MockTelemetryService { + track() { } +} describe('CreateDatabagItemModalComponent', () => { let component: CreateDatabagItemModalComponent; @@ -43,7 +48,8 @@ describe('CreateDatabagItemModalComponent', () => { ], providers: [ HttpClient, - HttpHandler + HttpHandler, + { provide: TelemetryService, useClass: MockTelemetryService } ] }) .compileComponents(); diff --git a/components/automate-ui/src/app/modules/infra-proxy/create-databag-item-modal/create-databag-item-modal.component.ts b/components/automate-ui/src/app/modules/infra-proxy/create-databag-item-modal/create-databag-item-modal.component.ts index e011a43be4e..eba855d85a2 100644 --- a/components/automate-ui/src/app/modules/infra-proxy/create-databag-item-modal/create-databag-item-modal.component.ts +++ b/components/automate-ui/src/app/modules/infra-proxy/create-databag-item-modal/create-databag-item-modal.component.ts @@ -26,6 +26,7 @@ import { DataBagItemPayload, GetDataBagItems } from 'app/entities/data-bags/data-bag-details.actions'; +import { TelemetryService } from 'app/services/telemetry/telemetry.service'; @Component({ selector: 'app-create-databag-item-modal', @@ -55,7 +56,8 @@ export class CreateDatabagItemModalComponent implements OnInit, OnDestroy { constructor( private store: Store, - private fb: FormBuilder + private fb: FormBuilder, + private telemetryService: TelemetryService ) { this.createForm = this.fb.group({ itemId: ['', [Validators.required, @@ -152,6 +154,7 @@ export class CreateDatabagItemModalComponent implements OnInit, OnDestroy { }; this.store.dispatch(new CreateDataBagItem({dataBagItem})); + this.telemetryService.track('InfraServer_Databags_Details_Create'); } private resetCreateModal(): void { diff --git a/components/automate-ui/src/app/modules/infra-proxy/data-bags-details/data-bags-details.component.spec.ts b/components/automate-ui/src/app/modules/infra-proxy/data-bags-details/data-bags-details.component.spec.ts index 24f45ba737d..35232bbaccc 100644 --- a/components/automate-ui/src/app/modules/infra-proxy/data-bags-details/data-bags-details.component.spec.ts +++ b/components/automate-ui/src/app/modules/infra-proxy/data-bags-details/data-bags-details.component.spec.ts @@ -19,7 +19,11 @@ import { By } from '@angular/platform-browser'; import { GetDataBagItemsSuccess, DeleteDataBagItemSuccess } from 'app/entities/data-bags/data-bag-details.actions'; import { DataBagItems } from 'app/entities/data-bags/data-bags.model'; import { DataBagsDetailsComponent } from './data-bags-details.component'; +import { TelemetryService } from 'app/services/telemetry/telemetry.service'; +class MockTelemetryService { + track() { } +} const declarations: any[] = [ MockComponent({ selector: 'chef-icon' }), @@ -73,6 +77,7 @@ describe('DataBagsDetailsComponent', () => { TestBed.configureTestingModule({ declarations: declarations, providers: [ + { provide: TelemetryService, useClass: MockTelemetryService }, FeatureFlagsService ], imports: [ diff --git a/components/automate-ui/src/app/modules/infra-proxy/data-bags-details/data-bags-details.component.ts b/components/automate-ui/src/app/modules/infra-proxy/data-bags-details/data-bags-details.component.ts index fac8ca2dc6f..d8399021dd9 100644 --- a/components/automate-ui/src/app/modules/infra-proxy/data-bags-details/data-bags-details.component.ts +++ b/components/automate-ui/src/app/modules/infra-proxy/data-bags-details/data-bags-details.component.ts @@ -17,6 +17,7 @@ import { getAllStatus, dataBagItemList, deleteStatus } from 'app/entities/data-b import { GetDataBagItemDetails } from 'app/entities/data-bags/data-bag-item-details.actions'; import { dataBagItemDetailsFromRoute, getStatus } from 'app/entities/data-bags/data-bag-item-details.selector'; import { Regex } from 'app/helpers/auth/regex'; +import { TelemetryService } from 'app/services/telemetry/telemetry.service'; export type DataBagsDetailsTab = 'details'; @@ -56,7 +57,8 @@ export class DataBagsDetailsComponent implements OnInit, OnDestroy { constructor( private store: Store, - private layoutFacade: LayoutFacadeService + private layoutFacade: LayoutFacadeService, + private telemetryService: TelemetryService ) { } ngOnInit() { @@ -148,6 +150,7 @@ export class DataBagsDetailsComponent implements OnInit, OnDestroy { this.dataBagItems[index].active = !this.dataBagItems[index].active; this.activeClassName = 'autoHeight'; + this.telemetryService.track('InfraServer_Databags_Details_GetItems'); } refreshData(data: string) { @@ -180,6 +183,7 @@ export class DataBagsDetailsComponent implements OnInit, OnDestroy { this.total = 0; } else { this.getDataBagItemsData(); + this.telemetryService.track('InfraServer_Databags_Details_Search'); } } @@ -214,6 +218,7 @@ export class DataBagsDetailsComponent implements OnInit, OnDestroy { databag_name: this.dataBagName, name: this.dataBagItemToDelete.name })); + this.telemetryService.track('InfraServer_Databags_Details_DeleteDatabagItem'); } public closeDeleteModal(): void { diff --git a/components/automate-ui/src/app/modules/infra-proxy/data-bags-list/data-bags-list.component.spec.ts b/components/automate-ui/src/app/modules/infra-proxy/data-bags-list/data-bags-list.component.spec.ts index ec5b0f1184f..801d47d6519 100644 --- a/components/automate-ui/src/app/modules/infra-proxy/data-bags-list/data-bags-list.component.spec.ts +++ b/components/automate-ui/src/app/modules/infra-proxy/data-bags-list/data-bags-list.component.spec.ts @@ -11,6 +11,11 @@ import { By } from '@angular/platform-browser'; import { GetDataBagsSuccess } from 'app/entities/data-bags/data-bags.actions'; import { DataBag } from 'app/entities/data-bags/data-bags.model'; import { DataBagsListComponent } from './data-bags-list.component'; +import { TelemetryService } from 'app/services/telemetry/telemetry.service'; + +class MockTelemetryService { + track() { } +} describe('DataBagsListComponent', () => { let component: DataBagsListComponent; @@ -45,7 +50,8 @@ describe('DataBagsListComponent', () => { DataBagsListComponent ], providers: [ - FeatureFlagsService + FeatureFlagsService, + { provide: TelemetryService, useClass: MockTelemetryService } ], imports: [ FormsModule, diff --git a/components/automate-ui/src/app/modules/infra-proxy/data-bags-list/data-bags-list.component.ts b/components/automate-ui/src/app/modules/infra-proxy/data-bags-list/data-bags-list.component.ts index 83bf82e86d6..16297891abf 100644 --- a/components/automate-ui/src/app/modules/infra-proxy/data-bags-list/data-bags-list.component.ts +++ b/components/automate-ui/src/app/modules/infra-proxy/data-bags-list/data-bags-list.component.ts @@ -14,6 +14,7 @@ import { getAllStatus as getAllDatabagsForOrgStatus, deleteStatus } from 'app/entities/data-bags/data-bags.selectors'; +import { TelemetryService } from 'app/services/telemetry/telemetry.service'; @Component({ selector: 'app-data-bags-list', @@ -41,7 +42,8 @@ export class DataBagsListComponent implements OnInit, OnDestroy { constructor( private store: Store, - private layoutFacade: LayoutFacadeService + private layoutFacade: LayoutFacadeService, + private telemetryService: TelemetryService ) { } ngOnInit() { @@ -96,6 +98,7 @@ export class DataBagsListComponent implements OnInit, OnDestroy { this.store.dispatch(new DeleteDataBag({ server_id: this.serverId, org_id: this.orgId, name: this.dataBagToDelete.name })); + this.telemetryService.track('InfraServer_Databags_Delete'); } public closeDeleteModal(): void { @@ -121,5 +124,6 @@ export class DataBagsListComponent implements OnInit, OnDestroy { }); } this.searching = false; + this.telemetryService.track('InfraServer_Databags_Search'); } } diff --git a/components/automate-ui/src/app/modules/infra-proxy/edit-data-bag-item-modal/edit-data-bag-item-modal.component.spec.ts b/components/automate-ui/src/app/modules/infra-proxy/edit-data-bag-item-modal/edit-data-bag-item-modal.component.spec.ts index d46f6510ac1..d7398b1640e 100644 --- a/components/automate-ui/src/app/modules/infra-proxy/edit-data-bag-item-modal/edit-data-bag-item-modal.component.spec.ts +++ b/components/automate-ui/src/app/modules/infra-proxy/edit-data-bag-item-modal/edit-data-bag-item-modal.component.spec.ts @@ -6,6 +6,11 @@ import { ngrxReducers, runtimeChecks } from 'app/ngrx.reducers'; import { EditDataBagItemModalComponent } from './edit-data-bag-item-modal.component'; import { DataBagsItemDetails } from 'app/entities/data-bags/data-bags.model'; import { EventEmitter } from '@angular/core'; +import { TelemetryService } from 'app/services/telemetry/telemetry.service'; + +class MockTelemetryService { + track() { } +} describe('EditDataBagItemModalComponent', () => { let component: EditDataBagItemModalComponent; @@ -20,6 +25,9 @@ describe('EditDataBagItemModalComponent', () => { MockComponent({ selector: 'chef-form-field' }), EditDataBagItemModalComponent ], + providers: [ + { provide: TelemetryService, useClass: MockTelemetryService } + ], imports: [ ReactiveFormsModule, StoreModule.forRoot(ngrxReducers, { runtimeChecks }) diff --git a/components/automate-ui/src/app/modules/infra-proxy/edit-data-bag-item-modal/edit-data-bag-item-modal.component.ts b/components/automate-ui/src/app/modules/infra-proxy/edit-data-bag-item-modal/edit-data-bag-item-modal.component.ts index 32eb4742d90..7ed67913db6 100644 --- a/components/automate-ui/src/app/modules/infra-proxy/edit-data-bag-item-modal/edit-data-bag-item-modal.component.ts +++ b/components/automate-ui/src/app/modules/infra-proxy/edit-data-bag-item-modal/edit-data-bag-item-modal.component.ts @@ -16,6 +16,7 @@ import { Subject } from 'rxjs'; import { UpdateDataBagItem } from 'app/entities/data-bags/data-bag-details.actions'; import { updateStatus } from 'app/entities/data-bags/data-bag-details.selector'; import { Utilities } from 'app/helpers/utilities/utilities'; +import { TelemetryService } from 'app/services/telemetry/telemetry.service'; @Component({ selector: 'app-edit-data-bag-item-modal', @@ -42,7 +43,8 @@ export class EditDataBagItemModalComponent implements OnChanges, OnInit, OnDestr constructor( private fb: FormBuilder, - private store: Store + private store: Store, + private telemetryService: TelemetryService ) { this.updateForm = this.fb.group({ data: [this.itemDataJson] @@ -102,6 +104,7 @@ export class EditDataBagItemModalComponent implements OnChanges, OnInit, OnDestr data: data }; this.store.dispatch(new UpdateDataBagItem({dataBagItem: dataBagItem})); + this.telemetryService.track('InfraServer_Databags_Details_EditDatabagItem'); } onChangeJSON(event: { target: { value: string } }) {