Skip to content

Commit

Permalink
feat(dgw): add analytics to gateway standalone (#813)
Browse files Browse the repository at this point in the history
* seems to work, waiting for opeansearch to set up

* WIP:still not working,waiting for changes from the server side

* WIP

* mute error in production

* mute error in production

* review fix:typo

* review fix:use token instead of username and password
  • Loading branch information
irvingoujAtDevolution authored Apr 17, 2024
1 parent 5f635ba commit 55d3749
Show file tree
Hide file tree
Showing 12 changed files with 254 additions and 25 deletions.
16 changes: 14 additions & 2 deletions webapp/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,27 @@
"maximumWarning": "2kb"
}
],
"outputHashing": "all"
"outputHashing": "all",
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.production.ts"
}
]
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
"namedChunks": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.development.ts"
}
]
}
},
"defaultConfiguration": "development"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {UserInteraction, SessionEvent, UserIronRdpError, DesktopSize} from '@dev
import '@devolutions/iron-remote-gui-vnc/iron-remote-gui-vnc.umd.cjs';
import {v4 as uuidv4} from "uuid";
import {ExtractedHostnamePort} from "@shared/services/utils/string.service";
import { AnalyticService, ProtocolString } from "@gateway/shared/services/analytic.service";

enum UserIronRdpErrorKind {
General = 0,
Expand Down Expand Up @@ -75,8 +76,10 @@ export class WebClientArdComponent extends WebClientBaseComponent implements On
protected utils: UtilsService,
protected gatewayAlertMessageService: GatewayAlertMessageService,
private webSessionService: WebSessionService,
private webClientService: WebClientService) {
super(gatewayAlertMessageService);
private webClientService: WebClientService,
protected analyticService: AnalyticService
) {
super(gatewayAlertMessageService, analyticService);
}
@HostListener('document:mousemove', ['$event'])
onMouseMove(event: MouseEvent): void {
Expand Down Expand Up @@ -349,6 +352,7 @@ export class WebClientArdComponent extends WebClientBaseComponent implements On

this.notifyUser(event.type, event.data);
this.disableComponentStatus();
super.webClientConnectionClosed();
}

private handleIronRDPConnectStarted(): void {
Expand Down Expand Up @@ -413,4 +417,8 @@ export class WebClientArdComponent extends WebClientBaseComponent implements On
return 'Connection error: Please verify your connection settings.';
}
}

protected getProtocol() : ProtocolString{
return "ARD";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {RdpFormDataInput} from "@shared/interfaces/forms.interfaces";

import {UserInteraction, SessionEvent, UserIronRdpError, DesktopSize} from '@devolutions/iron-remote-gui';
import '@devolutions/iron-remote-gui/iron-remote-gui.umd.cjs';
import { AnalyticService, ProtocolString } from '@gateway/shared/services/analytic.service';


enum UserIronRdpErrorKind {
Expand Down Expand Up @@ -76,8 +77,10 @@ export class WebClientRdpComponent extends WebClientBaseComponent implements On
protected utils: UtilsService,
protected gatewayAlertMessageService: GatewayAlertMessageService,
private webSessionService: WebSessionService,
private webClientService: WebClientService) {
super(gatewayAlertMessageService);
private webClientService: WebClientService,
protected analyticService : AnalyticService
) {
super(gatewayAlertMessageService,analyticService);
}

@HostListener('document:mousemove', ['$event'])
Expand Down Expand Up @@ -353,6 +356,7 @@ export class WebClientRdpComponent extends WebClientBaseComponent implements On

this.notifyUser(event.type, event.data);
this.disableComponentStatus();
super.webClientConnectionClosed();
}

private handleIronRDPConnectStarted(): void {
Expand Down Expand Up @@ -418,4 +422,8 @@ export class WebClientRdpComponent extends WebClientBaseComponent implements On
return 'Connection error: Please verify your connection settings.';
}
}

protected getProtocol() : ProtocolString{
return "RDP";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import {v4 as uuidv4} from "uuid";
import {MessageService} from "primeng/api";
import {EMPTY, from, Observable, of, Subject, throwError} from "rxjs";
import {catchError, map, switchMap, takeUntil} from "rxjs/operators";
import {catchError, map, switchMap, takeUntil, tap} from "rxjs/operators";

import {WebClientBaseComponent} from "@shared/bases/base-web-client.component";
import {UtilsService} from "@shared/services/utils.service";
Expand All @@ -30,6 +30,7 @@ import {
TerminalConnectionStatus
} from "@devolutions/web-ssh-gui";
import {ExtractedHostnamePort} from "@shared/services/utils/string.service";
import { AnalyticService, ProtocolString } from "@gateway/shared/services/analytic.service";

@Component({
templateUrl: 'web-client-ssh.component.html',
Expand Down Expand Up @@ -68,8 +69,10 @@ export class WebClientSshComponent extends WebClientBaseComponent implements OnI
protected utils: UtilsService,
protected gatewayAlertMessageService: GatewayAlertMessageService,
private webSessionService: WebSessionService,
private webClientService: WebClientService) {
super(gatewayAlertMessageService);
private webClientService: WebClientService,
protected analyticService: AnalyticService
) {
super(gatewayAlertMessageService,analyticService);
}

ngOnInit(): void {
Expand Down Expand Up @@ -191,7 +194,7 @@ export class WebClientSshComponent extends WebClientBaseComponent implements OnI
connectionParameters.privateKey,
)
).pipe(
catchError(error => throwError(error))
catchError(error => throwError(error)),
);
}

Expand Down Expand Up @@ -260,6 +263,7 @@ export class WebClientSshComponent extends WebClientBaseComponent implements OnI

this.notifyUser(status);
this.disableComponentStatus();
super.webClientConnectionClosed();
}

private notifyUser(status: TerminalConnectionStatus): void {
Expand All @@ -279,6 +283,7 @@ export class WebClientSshComponent extends WebClientBaseComponent implements OnI
private handleClientConnectStarted(): void {
this.loading = false;
this.webSessionService.updateWebSessionIcon(this.webSessionId, WebClientSshComponent.DVL_SSH_ICON);
super.webClientConnectionSuccess();
}

private handleSshError(error: string): void {
Expand Down Expand Up @@ -307,4 +312,8 @@ export class WebClientSshComponent extends WebClientBaseComponent implements OnI
return 'Unknown Error';
}
}

protected getProtocol() : ProtocolString{
return "SSH";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
TerminalConnectionStatus,
} from '@devolutions/web-telnet-gui';
import {ExtractedHostnamePort} from "@shared/services/utils/string.service";
import { AnalyticService, ProtocolString } from "@gateway/shared/services/analytic.service";


@Component({
Expand Down Expand Up @@ -70,8 +71,10 @@ export class WebClientTelnetComponent extends WebClientBaseComponent implements
protected utils: UtilsService,
protected gatewayAlertMessageService: GatewayAlertMessageService,
private webSessionService: WebSessionService,
private webClientService: WebClientService) {
super(gatewayAlertMessageService);
private webClientService: WebClientService,
protected analyticService: AnalyticService
) {
super(gatewayAlertMessageService, analyticService);
}

ngOnInit(): void {
Expand Down Expand Up @@ -246,6 +249,7 @@ export class WebClientTelnetComponent extends WebClientBaseComponent implements
private handleSessionStarted(): void {
this.handleClientConnectStarted();
this.currentStatus.isInitialized = true;
super.webClientConnectionSuccess();
}

private handleSessionEndedOrError(status: TerminalConnectionStatus): void {
Expand All @@ -257,6 +261,7 @@ export class WebClientTelnetComponent extends WebClientBaseComponent implements

this.notifyUser(status);
this.disableComponentStatus();
super.webClientConnectionClosed();
}

private notifyUser(status: TerminalConnectionStatus): void {
Expand Down Expand Up @@ -306,4 +311,8 @@ export class WebClientTelnetComponent extends WebClientBaseComponent implements
return 'Unknown Error';
}
}

protected getProtocol() : ProtocolString{
return "Telnet";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {UserInteraction, SessionEvent, UserIronRdpError, DesktopSize} from '@dev
import '@devolutions/iron-remote-gui-vnc/iron-remote-gui-vnc.umd.cjs';
import {v4 as uuidv4} from "uuid";
import {ExtractedHostnamePort} from "@shared/services/utils/string.service";
import { AnalyticService, ProtocolString } from "@gateway/shared/services/analytic.service";

enum UserIronRdpErrorKind {
General = 0,
Expand Down Expand Up @@ -74,8 +75,10 @@ export class WebClientVncComponent extends WebClientBaseComponent implements On
protected utils: UtilsService,
protected gatewayAlertMessageService: GatewayAlertMessageService,
private webSessionService: WebSessionService,
private webClientService: WebClientService) {
super(gatewayAlertMessageService);
private webClientService: WebClientService,
protected analyticService: AnalyticService
) {
super(gatewayAlertMessageService,analyticService);
}
@HostListener('document:mousemove', ['$event'])
onMouseMove(event: MouseEvent): void {
Expand Down Expand Up @@ -349,6 +352,7 @@ export class WebClientVncComponent extends WebClientBaseComponent implements On

this.notifyUser(event.type, event.data);
this.disableComponentStatus();
super.webClientConnectionClosed();
}

private handleIronRDPConnectStarted(): void {
Expand Down Expand Up @@ -414,4 +418,8 @@ export class WebClientVncComponent extends WebClientBaseComponent implements On
return 'Connection error: Please verify your connection settings.';
}
}

protected getProtocol() : ProtocolString{
return "VNC";
}
}
19 changes: 11 additions & 8 deletions webapp/src/client/app/shared/bases/base-web-client.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Directive } from '@angular/core';
import { BaseComponent } from '@shared/bases/base.component';
import {GatewayAlertMessageService} from "@shared/components/gateway-alert-message/gateway-alert-message.service";
import { AnalyticService, ConnectionIdentifier, ProtocolString } from '../services/analytic.service';

@Directive()
export abstract class WebClientBaseComponent extends BaseComponent {
Expand All @@ -10,7 +11,9 @@ export abstract class WebClientBaseComponent extends BaseComponent {
hideSpinnerOnly: boolean = false;
error: string;

protected constructor(protected gatewayAlertMessageService: GatewayAlertMessageService) {
analyticHandle: ConnectionIdentifier

protected constructor(protected gatewayAlertMessageService: GatewayAlertMessageService, protected analyticService:AnalyticService) {
super();
}

Expand All @@ -24,6 +27,7 @@ export abstract class WebClientBaseComponent extends BaseComponent {
message = 'Connection successful';
}
this.gatewayAlertMessageService.addSuccess(message);
this.analyticHandle = this.analyticService.sendOpenEvent(this.getProtocol());
}

protected webClientConnectionFail(message?:string, trace?: string): void {
Expand All @@ -39,14 +43,13 @@ export abstract class WebClientBaseComponent extends BaseComponent {
if (trace) {
console.error(trace);
}

this.analyticService.sendCloseEvent(this.analyticHandle);
}

protected webClientConnectionClosed(message?:string): void {
if (!message) {
//For translation 'connection closed'
message = 'Connection error: Please verify your connection settings.';
}
this.gatewayAlertMessageService.addInfo(message);
console.warn(message);
protected webClientConnectionClosed(): void {
this.analyticService.sendCloseEvent(this.analyticHandle);
}

protected abstract getProtocol(): ProtocolString;
}
Loading

0 comments on commit 55d3749

Please sign in to comment.