|
1 | 1 | import { Component, EventEmitter, Inject, Input, OnInit, Output } from '@angular/core'; |
| 2 | +import { inject } from '@angular/core/testing'; |
2 | 3 | import { FormBuilder, FormGroup, Validators } from '@angular/forms'; |
3 | | -import { ApiResponseData, ApiResponseError, KnoraApiConnection, LoginResponse, LogoutResponse } from '@dasch-swiss/dsp-js'; |
4 | | -import { DspApiConnectionToken } from '../../declarations/dsp-api-tokens'; |
| 4 | +import { ApiResponseData, ApiResponseError, KnoraApiConfig, KnoraApiConnection, LoginResponse, LogoutResponse } from '@dasch-swiss/dsp-js'; |
| 5 | +import { datadogRum, RumFetchResourceEventDomainContext } from '@datadog/browser-rum'; |
| 6 | +import { DspApiConfigToken, DspApiConnectionToken, DspDataDogConfigToken } from '../../declarations/dsp-api-tokens'; |
| 7 | +import { DspDataDogConfig } from '../../declarations/dsp-dataDog-config'; |
5 | 8 | import { NotificationService } from '../../services/notification.service'; |
6 | 9 | import { Session, SessionService } from '../../services/session.service'; |
7 | 10 |
|
@@ -101,6 +104,8 @@ export class LoginFormComponent implements OnInit { |
101 | 104 |
|
102 | 105 | constructor( |
103 | 106 | @Inject(DspApiConnectionToken) private _dspApiConnection: KnoraApiConnection, |
| 107 | + @Inject(DspApiConfigToken) private _dspApiConfig: KnoraApiConfig, |
| 108 | + @Inject(DspDataDogConfigToken) private _dspDataDogConfig: DspDataDogConfig, |
104 | 109 | private _notification: NotificationService, |
105 | 110 | private _sessionService: SessionService, |
106 | 111 | private _fb: FormBuilder |
@@ -151,6 +156,29 @@ export class LoginFormComponent implements OnInit { |
151 | 156 | this.session = this._sessionService.getSession(); |
152 | 157 | this.loginSuccess.emit(true); |
153 | 158 | this.loading = false; |
| 159 | + if (this._dspDataDogConfig.dataDogLogging) { |
| 160 | + datadogRum.init({ |
| 161 | + applicationId: this._dspDataDogConfig.dataDogApplicationId, |
| 162 | + clientToken: this._dspDataDogConfig.dataDogClientToken, |
| 163 | + site: this._dspDataDogConfig.dataDogSite, |
| 164 | + service: this._dspDataDogConfig.dataDogService, |
| 165 | + // specify a version number to identify the deployed version of your application in Datadog |
| 166 | + // version: '1.0.0', |
| 167 | + sampleRate: 100, |
| 168 | + trackInteractions: true, |
| 169 | + beforeSend: (event, context) => { |
| 170 | + // collect a RUM resource's response headers |
| 171 | + if (event.type === 'resource' && event.resource.type === 'xhr') { |
| 172 | + event.context = { ...event.context, responseHeaders: (context as RumFetchResourceEventDomainContext).response.body }; |
| 173 | + } |
| 174 | + }, |
| 175 | + }); |
| 176 | + |
| 177 | + datadogRum.setUser({ |
| 178 | + id: identifier, |
| 179 | + identifierType: identifierType |
| 180 | + }); |
| 181 | + } |
154 | 182 | } |
155 | 183 | ); |
156 | 184 | }, |
|
0 commit comments