Skip to content

Commit

Permalink
refactor: improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
subotic committed Jun 7, 2023
1 parent e5046d4 commit 3e2d884
Show file tree
Hide file tree
Showing 13 changed files with 2,516 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Expand Up @@ -114,7 +114,10 @@ jobs:
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- run: make docker-publish
with:
DATADOG_API_KEY: ${{secrets.DATADOG_API_KEY}}

trigger-dev-deployment:
name: Trigger deployment to DEV
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Expand Up @@ -50,6 +50,11 @@ docker-image-tag: ## prints the docker image tag

.PHONY: docker-publish-app
docker-publish-app: app-build-prod ## publish DSP-APP Docker image to Docker-Hub for AMD64 and ARM64
# publish source maps to DataDog
datadog-ci sourcemaps upload ${CURRENT_DIR}/dist/apps/dsp-app \
--service=dsp-app \
--release-version=${BUILD_TAG} \
--minified-path-prefix=/
docker buildx build --platform linux/amd64,linux/arm64/v8 -t $(DSP_APP_IMAGE) --push .

.PHONY: docker-publish
Expand Down
4 changes: 3 additions & 1 deletion apps/dsp-app/project.json
Expand Up @@ -61,7 +61,9 @@
"maximumWarning": "9kb"
}
],
"outputHashing": "all"
"outputHashing": "all",
"optimization": true,
"sourceMap": true
},
"development": {
"buildOptimizer": false,
Expand Down
4 changes: 2 additions & 2 deletions apps/dsp-app/src/app/main/help/help.component.ts
Expand Up @@ -13,7 +13,7 @@ import {
} from '@dasch-swiss/vre/shared/app-config';
import { ErrorHandlerService } from '../services/error-handler.service';
import { GridItem } from '../grid/grid.component';
import packageJson from '../../../../../../package.json';
import { environment } from '@dsp-app/src/environments/environment';

@Component({
selector: 'app-help',
Expand All @@ -26,7 +26,7 @@ export class HelpComponent implements OnInit {
dsp: DspConfig;
releaseNotesUrl: string;

appVersion: string = packageJson.version;
appVersion: string = environment.version;
apiStatus: HealthResponse;
apiVersion: VersionResponse;

Expand Down
42 changes: 23 additions & 19 deletions apps/dsp-app/src/app/main/services/datadog-rum.service.ts
Expand Up @@ -3,33 +3,37 @@ import {
datadogRum,
RumFetchResourceEventDomainContext,
} from '@datadog/browser-rum';
import { DspInstrumentationToken } from '@dasch-swiss/vre/shared/app-config';
import { DspInstrumentationConfig } from '@dasch-swiss/vre/shared/app-config';
import {
DspInstrumentationConfig,
DspInstrumentationToken,
} from '@dasch-swiss/vre/shared/app-config';
import { Session, SessionService } from './session.service';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { version: appVersion } = require('../../../../../../package.json');
import { environment } from '@dsp-app/src/environments/environment';

@Injectable({
providedIn: 'root',
})
export class DatadogRumService {
constructor(
@Inject(DspInstrumentationToken)
private _dspInstrumentationConfig: DspInstrumentationConfig,
private _session: SessionService
private _c: DspInstrumentationConfig,
private _s: SessionService
) {
if (this._dspInstrumentationConfig.dataDog.enabled) {
if (this._c.dataDog.enabled) {
datadogRum.init({
applicationId:
this._dspInstrumentationConfig.dataDog.applicationId,
clientToken: this._dspInstrumentationConfig.dataDog.clientToken,
site: this._dspInstrumentationConfig.dataDog.site,
service: this._dspInstrumentationConfig.dataDog.service,
env: this._dspInstrumentationConfig.environment,
version: appVersion,
sampleRate: 100,
trackInteractions: true,
applicationId: this._c.dataDog.applicationId,
clientToken: this._c.dataDog.clientToken,
site: this._c.dataDog.site,
service: this._c.dataDog.service,
env: this._c.environment,
version: environment.version,
sessionSampleRate: 100,
sessionReplaySampleRate: 100, // if not included, the default is 100
trackResources: true,
trackLongTasks: true,
trackUserInteractions: true,
trackFrustrations: true,
useSecureSessionCookie: true,
beforeSend: (event, context) => {
// collect a RUM resource's response headers
if (
Expand All @@ -47,9 +51,9 @@ export class DatadogRumService {
});

// if session is valid: setActiveUser
this._session.isSessionValid().subscribe((response: boolean) => {
this._s.isSessionValid().subscribe((response: boolean) => {
if (response) {
const session: Session = this._session.getSession();
const session: Session = this._s.getSession();
this.setActiveUser(session.user.name, 'username');
}
});
Expand Down
3 changes: 3 additions & 0 deletions apps/dsp-app/src/environments/environment.dev-server.ts
Expand Up @@ -4,9 +4,12 @@
* The list of file replacements can be found in `angular.json`.
*/

import packageJson from '../../../../package.json';

export const environment = {
name: 'dev-server',
production: false,
version: packageJson.version,
};

/*
Expand Down
3 changes: 3 additions & 0 deletions apps/dsp-app/src/environments/environment.ls-test-server.ts
Expand Up @@ -4,9 +4,12 @@
* The list of file replacements can be found in `angular.json`.
*/

import packageJson from '../../../../package.json';

export const environment = {
name: 'ls-test-server',
production: false,
version: packageJson.version,
};

/*
Expand Down
3 changes: 3 additions & 0 deletions apps/dsp-app/src/environments/environment.prod.ts
@@ -1,4 +1,7 @@
import packageJson from '../../../../package.json';

export const environment = {
name: 'prod',
production: true,
version: packageJson.version,
};
3 changes: 3 additions & 0 deletions apps/dsp-app/src/environments/environment.staging-server.ts
Expand Up @@ -4,9 +4,12 @@
* The list of file replacements can be found in `angular.json`.
*/

import packageJson from '../../../../package.json';

export const environment = {
name: 'staging-server',
production: false,
version: packageJson.version,
};

/*
Expand Down
3 changes: 3 additions & 0 deletions apps/dsp-app/src/environments/environment.test-server.ts
Expand Up @@ -4,9 +4,12 @@
* The list of file replacements can be found in `angular.json`.
*/

import packageJson from '../../../../package.json';

export const environment = {
name: 'test-server',
production: false,
version: packageJson.version,
};

/*
Expand Down
3 changes: 3 additions & 0 deletions apps/dsp-app/src/environments/environment.ts
Expand Up @@ -4,9 +4,12 @@
* The list of file replacements can be found in `angular.json`.
*/

import packageJson from '../../../../package.json';

export const environment = {
name: 'dev',
production: false,
version: packageJson.version,
};

/*
Expand Down

0 comments on commit 3e2d884

Please sign in to comment.