diff --git a/components/automate-ui/src/app/page-components/data-feed-table/data-feed-table.component.spec.ts b/components/automate-ui/src/app/page-components/data-feed-table/data-feed-table.component.spec.ts index 8144cf36c8c..65795a96d40 100644 --- a/components/automate-ui/src/app/page-components/data-feed-table/data-feed-table.component.spec.ts +++ b/components/automate-ui/src/app/page-components/data-feed-table/data-feed-table.component.spec.ts @@ -8,8 +8,11 @@ import { DataFeedTableComponent } from './data-feed-table.component'; import { DestinationRequests } from 'app/entities/destinations/destination.requests'; import { StoreModule } from '@ngrx/store'; import { Destination } from 'app/entities/destinations/destination.model'; +import { TelemetryService } from 'app/services/telemetry/telemetry.service'; -// +class MockTelemetryService { + track() { } +} describe('DataFeedTableComponent', () => { let component: DataFeedTableComponent; @@ -48,7 +51,8 @@ describe('DataFeedTableComponent', () => { MockComponent({ selector: 'a', inputs: ['routerLink'] }) ], providers: [ - DestinationRequests + DestinationRequests, + { provide: TelemetryService, useClass: MockTelemetryService } ], imports: [ StoreModule.forRoot(ngrxReducers, { runtimeChecks }) diff --git a/components/automate-ui/src/app/page-components/data-feed-table/data-feed-table.component.ts b/components/automate-ui/src/app/page-components/data-feed-table/data-feed-table.component.ts index 68f7749fe68..f8000be2816 100644 --- a/components/automate-ui/src/app/page-components/data-feed-table/data-feed-table.component.ts +++ b/components/automate-ui/src/app/page-components/data-feed-table/data-feed-table.component.ts @@ -8,6 +8,7 @@ import { Destination } from 'app/entities/destinations/destination.model'; import { Observable } from 'rxjs'; import { Store } from '@ngrx/store'; import { NgrxStateAtom } from 'app/ngrx.reducers'; +import { TelemetryService } from 'app/services/telemetry/telemetry.service'; @Component({ selector: 'app-data-feed-table', @@ -33,7 +34,8 @@ export class DataFeedTableComponent { serviceShow = true; constructor( - private store: Store + private store: Store, + private telemetryService: TelemetryService ) {} @@ -62,6 +64,7 @@ export class DataFeedTableComponent { public deleteDataFeed(): void { this.closeDeleteModal(); this.store.dispatch(new DeleteDestination(this.dataFeedToDelete)); + this.telemetryService.track('Settings_DataFeeds_Delete'); } public closeDeleteModal(): void { @@ -92,6 +95,11 @@ export class DataFeedTableComponent { enable: val }; this.store.dispatch(new EnableDisableDestination({enableDisable: destinationEnableObj})); + if (val) { + this.telemetryService.track('Settings_DataFeeds_Enable'); + } else { + this.telemetryService.track('Settings_DataFeeds_Disable'); + } } diff --git a/components/automate-ui/src/app/pages/data-feed-create/data-feed-create.component.spec.ts b/components/automate-ui/src/app/pages/data-feed-create/data-feed-create.component.spec.ts index 01dc4a1851b..c1671350f9b 100644 --- a/components/automate-ui/src/app/pages/data-feed-create/data-feed-create.component.spec.ts +++ b/components/automate-ui/src/app/pages/data-feed-create/data-feed-create.component.spec.ts @@ -10,6 +10,11 @@ import { ngrxReducers, runtimeChecks } from 'app/ngrx.reducers'; import { FeatureFlagsService } from 'app/services/feature-flags/feature-flags.service'; import { Regex } from 'app/helpers/auth/regex'; import { Destination } from 'app/entities/destinations/destination.model'; +import { TelemetryService } from 'app/services/telemetry/telemetry.service'; + +class MockTelemetryService { + track() { } +} describe('DataFeedCreateComponent', () => { let component: DataFeedCreateComponent; @@ -43,7 +48,8 @@ describe('DataFeedCreateComponent', () => { DataFeedCreateComponent ], providers: [ - FeatureFlagsService + FeatureFlagsService, + { provide: TelemetryService, useClass: MockTelemetryService } ], imports: [ FormsModule, diff --git a/components/automate-ui/src/app/pages/data-feed-create/data-feed-create.component.ts b/components/automate-ui/src/app/pages/data-feed-create/data-feed-create.component.ts index 1c9e57da7ba..b0469d7465a 100644 --- a/components/automate-ui/src/app/pages/data-feed-create/data-feed-create.component.ts +++ b/components/automate-ui/src/app/pages/data-feed-create/data-feed-create.component.ts @@ -11,6 +11,7 @@ import { FormGroup } from '@angular/forms'; import { Revision } from 'app/entities/revisions/revision.model'; import { Regex } from 'app/helpers/auth/regex'; import { regions } from 'app/entities/destinations/destination.model'; +import { TelemetryService } from 'app/services/telemetry/telemetry.service'; export enum WebhookIntegrationTypes { SERVICENOW = 'ServiceNow', @@ -100,6 +101,10 @@ export class DataFeedCreateComponent { customToken: false }; + constructor( + private telemetryService: TelemetryService + ) { } + set saveDone(done: boolean) { this.saveInProgress = done; } @@ -281,6 +286,7 @@ export class DataFeedCreateComponent { auth: this.authSelected, region: this.dropDownVal }); + this.telemetryService.track('Settings_DataFeeds_TestConnection_' + this.integTitle); } public validateForm() { @@ -295,15 +301,13 @@ export class DataFeedCreateComponent { case AuthTypes.ACCESSTOKEN: { if (this.createForm.get('name').valid && this.createForm.get('url').valid && this.createForm.get('tokenType').valid && this.createForm.get('token').valid) { - if (this.integTitle === WebhookIntegrationTypes.CUSTOM && this.headerChecked && - this.validHeadersValue && this.flagHeaders) { - return true; - } else if (this.integTitle === WebhookIntegrationTypes.CUSTOM && - !this.headerChecked && this.flagHeaders) { - return true; - } else if (this.integTitle !== WebhookIntegrationTypes.CUSTOM) { - return true; - } + if ((this.integTitle === WebhookIntegrationTypes.CUSTOM && this.headerChecked && + this.validHeadersValue && this.flagHeaders) + || (this.integTitle === WebhookIntegrationTypes.CUSTOM && + !this.headerChecked && this.flagHeaders) || + (this.integTitle !== WebhookIntegrationTypes.CUSTOM)) { + return true; + } } break; } @@ -312,13 +316,11 @@ export class DataFeedCreateComponent { if (this.createForm.get('name').valid && this.createForm.get('url').valid && this.createForm.get('username').valid && this.createForm.get('password').valid) { - if (this.integTitle === WebhookIntegrationTypes.CUSTOM && this.headerChecked && - this.validHeadersValue && this.flagHeaders) { - return true; - } else if (this.integTitle === WebhookIntegrationTypes.CUSTOM && - !this.headerChecked && this.flagHeaders) { - return true; - } else if (this.integTitle !== WebhookIntegrationTypes.CUSTOM) { + if ((this.integTitle === WebhookIntegrationTypes.CUSTOM && this.headerChecked && + this.validHeadersValue && this.flagHeaders) + || (this.integTitle === WebhookIntegrationTypes.CUSTOM && + !this.headerChecked && this.flagHeaders) || + (this.integTitle !== WebhookIntegrationTypes.CUSTOM)) { return true; } } @@ -360,6 +362,7 @@ export class DataFeedCreateComponent { auth: this.authSelected, region: this.dropDownVal }); + this.telemetryService.track('Settings_DataFeeds_NewIntegration_' + this.integTitle); } public dismissNotification() { diff --git a/components/automate-ui/src/app/pages/data-feed-details/data-feed-details.component.spec.ts b/components/automate-ui/src/app/pages/data-feed-details/data-feed-details.component.spec.ts index 1ecc471df12..c35e2947eb5 100644 --- a/components/automate-ui/src/app/pages/data-feed-details/data-feed-details.component.spec.ts +++ b/components/automate-ui/src/app/pages/data-feed-details/data-feed-details.component.spec.ts @@ -10,6 +10,11 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { Destination } from 'app/entities/destinations/destination.model'; import { Regex } from 'app/helpers/auth/regex'; import { By } from '@angular/platform-browser'; +import { TelemetryService } from 'app/services/telemetry/telemetry.service'; + +class MockTelemetryService { + track() { } +} describe('DataFeedDetailsComponent', () => { let component: DataFeedDetailsComponent; @@ -22,7 +27,8 @@ describe('DataFeedDetailsComponent', () => { DataFeedDetailsComponent ], providers: [ - FeatureFlagsService + FeatureFlagsService, + { provide: TelemetryService, useClass: MockTelemetryService } ], imports: [ FormsModule, diff --git a/components/automate-ui/src/app/pages/data-feed-details/data-feed-details.component.ts b/components/automate-ui/src/app/pages/data-feed-details/data-feed-details.component.ts index 0c93f45c843..26b5e8d830b 100644 --- a/components/automate-ui/src/app/pages/data-feed-details/data-feed-details.component.ts +++ b/components/automate-ui/src/app/pages/data-feed-details/data-feed-details.component.ts @@ -30,6 +30,7 @@ import { Destination, regions } from 'app/entities/destinations/destination.mode import { Router } from '@angular/router'; import { trigger, state, animate, transition, style, keyframes } from '@angular/animations'; import { KVData } from 'app/entities/node-credentials/node-credential.model'; +import { TelemetryService } from 'app/services/telemetry/telemetry.service'; const fadeEnable = trigger('fadeEnable', [ state('inactive', style({})), @@ -114,7 +115,8 @@ export class DataFeedDetailsComponent implements OnInit, OnDestroy { private fb: FormBuilder, private store: Store, private layoutFacade: LayoutFacadeService, - private router: Router + private router: Router, + private telemetryService: TelemetryService ) { } ngOnInit(): void { @@ -215,6 +217,7 @@ export class DataFeedDetailsComponent implements OnInit, OnDestroy { }; this.store.dispatch(new UpdateDestination({ destination: destinationObj })); this.destination = destinationObj; + this.telemetryService.track('Settings_DataFeeds_Details_Save'); } public sendTestForDataFeedUrl(): void { @@ -241,6 +244,7 @@ export class DataFeedDetailsComponent implements OnInit, OnDestroy { this.testInProgress = false; } }); + this.telemetryService.track('Settings_DataFeeds_Details_TestDataFeeds'); } public get nameCtrl(): FormControl { @@ -269,6 +273,11 @@ export class DataFeedDetailsComponent implements OnInit, OnDestroy { this.destination.enable = val; } }); + if (val) { + this.telemetryService.track('Settings_DataFeeds_Details_Enable'); + } else { + this.telemetryService.track('Settings_DataFeeds_Details_Disable'); + } } public deleteDataFeed() { this.store.dispatch(new DeleteDestination(this.destination)); @@ -281,6 +290,7 @@ export class DataFeedDetailsComponent implements OnInit, OnDestroy { this.router.navigate(['/settings/data-feeds']); } }); + this.telemetryService.track('Settings_DataFeeds_Details_Delete'); } public closeDeleteModal(): void { this.deleteModalVisible = false; @@ -309,7 +319,7 @@ export class DataFeedDetailsComponent implements OnInit, OnDestroy { } public showUrl() { - return !(this.destination?.integration_types === IntegrationTypes.STORAGE) + return (this.destination?.integration_types !== IntegrationTypes.STORAGE) || this.destination?.services === StorageIntegrationTypes.MINIO; } public enableBtn() { diff --git a/components/automate-ui/src/app/pages/data-feed/data-feed.component.spec.ts b/components/automate-ui/src/app/pages/data-feed/data-feed.component.spec.ts index df8419f655b..22034871999 100644 --- a/components/automate-ui/src/app/pages/data-feed/data-feed.component.spec.ts +++ b/components/automate-ui/src/app/pages/data-feed/data-feed.component.spec.ts @@ -21,6 +21,11 @@ import { WebhookIntegrationTypes } from '../data-feed-create/data-feed-create.component'; import { of, throwError } from 'rxjs'; +import { TelemetryService } from 'app/services/telemetry/telemetry.service'; + +class MockTelemetryService { + track() { } +} describe('DataFeedComponent', () => { let component: DataFeedComponent; @@ -63,7 +68,8 @@ describe('DataFeedComponent', () => { FeatureFlagsService, DestinationRequests, HttpClient, - HttpHandler + HttpHandler, + { provide: TelemetryService, useClass: MockTelemetryService } ], imports: [ FormsModule,