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 Data feeds #6863

Merged
merged 2 commits into from
Apr 21, 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 @@ -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;
Expand Down Expand Up @@ -48,7 +51,8 @@ describe('DataFeedTableComponent', () => {
MockComponent({ selector: 'a', inputs: ['routerLink'] })
],
providers: [
DestinationRequests
DestinationRequests,
{ provide: TelemetryService, useClass: MockTelemetryService }
],
imports: [
StoreModule.forRoot(ngrxReducers, { runtimeChecks })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -33,7 +34,8 @@ export class DataFeedTableComponent {
serviceShow = true;

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


Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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');
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -43,7 +48,8 @@ describe('DataFeedCreateComponent', () => {
DataFeedCreateComponent
],
providers: [
FeatureFlagsService
FeatureFlagsService,
{ provide: TelemetryService, useClass: MockTelemetryService }
],
imports: [
FormsModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -100,6 +101,10 @@ export class DataFeedCreateComponent {
customToken: false
};

constructor(
private telemetryService: TelemetryService
) { }

set saveDone(done: boolean) {
this.saveInProgress = done;
}
Expand Down Expand Up @@ -281,6 +286,7 @@ export class DataFeedCreateComponent {
auth: this.authSelected,
region: this.dropDownVal
});
this.telemetryService.track('Settings_DataFeeds_TestConnection_' + this.integTitle);
}

public validateForm() {
Expand All @@ -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;
}
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -360,6 +362,7 @@ export class DataFeedCreateComponent {
auth: this.authSelected,
region: this.dropDownVal
});
this.telemetryService.track('Settings_DataFeeds_NewIntegration_' + this.integTitle);
}

public dismissNotification() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,7 +27,8 @@ describe('DataFeedDetailsComponent', () => {
DataFeedDetailsComponent
],
providers: [
FeatureFlagsService
FeatureFlagsService,
{ provide: TelemetryService, useClass: MockTelemetryService }
],
imports: [
FormsModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({})),
Expand Down Expand Up @@ -114,7 +115,8 @@ export class DataFeedDetailsComponent implements OnInit, OnDestroy {
private fb: FormBuilder,
private store: Store<NgrxStateAtom>,
private layoutFacade: LayoutFacadeService,
private router: Router
private router: Router,
private telemetryService: TelemetryService
) { }

ngOnInit(): void {
Expand Down Expand Up @@ -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 {
Expand All @@ -241,6 +244,7 @@ export class DataFeedDetailsComponent implements OnInit, OnDestroy {
this.testInProgress = false;
}
});
this.telemetryService.track('Settings_DataFeeds_Details_TestDataFeeds');
}

public get nameCtrl(): FormControl {
Expand Down Expand Up @@ -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));
Expand All @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -63,7 +68,8 @@ describe('DataFeedComponent', () => {
FeatureFlagsService,
DestinationRequests,
HttpClient,
HttpHandler
HttpHandler,
{ provide: TelemetryService, useClass: MockTelemetryService }
],
imports: [
FormsModule,
Expand Down