Skip to content
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

Telemetry coverage for Chef Infra Server Databags tab #6775

Merged
merged 1 commit into from
Mar 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -49,7 +53,8 @@ describe('CreateDataBagModalComponent', () => {
],
providers: [
HttpClient,
HttpHandler
HttpHandler,
{ provide: TelemetryService, useClass: MockTelemetryService }
],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -45,7 +46,8 @@ export class CreateDataBagModalComponent implements OnInit, OnDestroy {

constructor(
private store: Store<NgrxStateAtom>,
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
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -43,7 +48,8 @@ describe('CreateDatabagItemModalComponent', () => {
],
providers: [
HttpClient,
HttpHandler
HttpHandler,
{ provide: TelemetryService, useClass: MockTelemetryService }
]
})
.compileComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -55,7 +56,8 @@ export class CreateDatabagItemModalComponent implements OnInit, OnDestroy {

constructor(
private store: Store<NgrxStateAtom>,
private fb: FormBuilder
private fb: FormBuilder,
private telemetryService: TelemetryService
) {
this.createForm = this.fb.group({
itemId: ['', [Validators.required,
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' }),
Expand Down Expand Up @@ -73,6 +77,7 @@ describe('DataBagsDetailsComponent', () => {
TestBed.configureTestingModule({
declarations: declarations,
providers: [
{ provide: TelemetryService, useClass: MockTelemetryService },
FeatureFlagsService
],
imports: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -56,7 +57,8 @@ export class DataBagsDetailsComponent implements OnInit, OnDestroy {

constructor(
private store: Store<NgrxStateAtom>,
private layoutFacade: LayoutFacadeService
private layoutFacade: LayoutFacadeService,
private telemetryService: TelemetryService
) { }

ngOnInit() {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -180,6 +183,7 @@ export class DataBagsDetailsComponent implements OnInit, OnDestroy {
this.total = 0;
} else {
this.getDataBagItemsData();
this.telemetryService.track('InfraServer_Databags_Details_Search');
}
}

Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -45,7 +50,8 @@ describe('DataBagsListComponent', () => {
DataBagsListComponent
],
providers: [
FeatureFlagsService
FeatureFlagsService,
{ provide: TelemetryService, useClass: MockTelemetryService }
],
imports: [
FormsModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -41,7 +42,8 @@ export class DataBagsListComponent implements OnInit, OnDestroy {

constructor(
private store: Store<NgrxStateAtom>,
private layoutFacade: LayoutFacadeService
private layoutFacade: LayoutFacadeService,
private telemetryService: TelemetryService
) { }

ngOnInit() {
Expand Down Expand Up @@ -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 {
Expand All @@ -121,5 +124,6 @@ export class DataBagsListComponent implements OnInit, OnDestroy {
});
}
this.searching = false;
this.telemetryService.track('InfraServer_Databags_Search');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,6 +25,9 @@ describe('EditDataBagItemModalComponent', () => {
MockComponent({ selector: 'chef-form-field' }),
EditDataBagItemModalComponent
],
providers: [
{ provide: TelemetryService, useClass: MockTelemetryService }
],
imports: [
ReactiveFormsModule,
StoreModule.forRoot(ngrxReducers, { runtimeChecks })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -42,7 +43,8 @@ export class EditDataBagItemModalComponent implements OnChanges, OnInit, OnDestr

constructor(
private fb: FormBuilder,
private store: Store<NgrxStateAtom>
private store: Store<NgrxStateAtom>,
private telemetryService: TelemetryService
) {
this.updateForm = this.fb.group({
data: [this.itemDataJson]
Expand Down Expand Up @@ -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 } }) {
Expand Down