Skip to content

Commit

Permalink
Merge pull request #7554 from ever-co/feat/#7415-ssl-certificate-setup
Browse files Browse the repository at this point in the history
[Feat] #7415 SSL Certificate Setup
  • Loading branch information
rahul-rocket authored Feb 20, 2024
2 parents 50c4a3f + a64692c commit 538a48e
Show file tree
Hide file tree
Showing 43 changed files with 732 additions and 478 deletions.
4 changes: 2 additions & 2 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
"seed:prod:build": "yarn ng run api:seed -c=production"
},
"dependencies": {
"@gauzy/changelog-plugin": "^0.1.0",
"@gauzy/core": "^0.1.0",
"@gauzy/jitsu-analytics-plugin": "^0.1.0",
"@gauzy/changelog-plugin": "^0.1.0",
"@gauzy/knowledge-base-plugin": "^0.1.0",
"@gauzy/jitsu-analytics-plugin": "^0.1.0",
"@gauzy/sentry-plugin": "^0.1.0",
"dotenv": "^16.0.3",
"yargs": "^17.5.0"
Expand Down
38 changes: 7 additions & 31 deletions apps/api/src/plugin-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,21 @@ import * as path from 'path';
import * as chalk from 'chalk';
import { ApplicationPluginConfig, DEFAULT_API_PORT, DEFAULT_GRAPHQL_API_PATH, DEFAULT_API_HOST, DEFAULT_API_BASE_URL } from '@gauzy/common';
import { dbTypeOrmConnectionConfig, dbMikroOrmConnectionConfig, environment, dbKnexConnectionConfig } from '@gauzy/config';
import { ChangelogPlugin } from '@gauzy/changelog-plugin';
import { JitsuAnalyticsPlugin } from '@gauzy/jitsu-analytics-plugin';
import { KnowledgeBasePlugin } from '@gauzy/knowledge-base-plugin';
import { SentryService } from '@gauzy/sentry-plugin';
import { Sentry as SentryPlugin } from './sentry';
import { SentryTracing as SentryPlugin } from './sentry';
import { version } from './../version';
import { plugins } from './plugins';

const { jitsu } = environment;

let assetPath: any;
let assetPublicPath: any;
const { sentry } = environment;

console.log(chalk.magenta(`API Version %s`), version);
console.log('Plugin Config -> __dirname: ' + __dirname);
console.log('Plugin Config -> process.cwd: ' + process.cwd());

// TODO: maybe better to use process.cwd() instead of __dirname?

let assetPath: any;
let assetPublicPath: any;
// for Docker
if (__dirname.startsWith('/srv/gauzy')) {
assetPath = '/srv/gauzy/apps/api/src/assets';
Expand Down Expand Up @@ -65,27 +62,6 @@ export const pluginConfig: ApplicationPluginConfig = {
assetPath: assetPath,
assetPublicPath: assetPublicPath
},
...(environment.sentry && environment.sentry.dsn ? {
logger: new SentryService(SentryPlugin.options)
} : {}),
plugins: [
// Indicates the inclusion or intention to use the ChangelogPlugin in the codebase.
ChangelogPlugin,
// Indicates the inclusion or intention to use the KnowledgeBasePlugin in the codebase.
KnowledgeBasePlugin,
// Initializes the Jitsu Analytics Plugin by providing a configuration object.
JitsuAnalyticsPlugin.init({
config: {
host: jitsu.serverHost,
writeKey: jitsu.serverWriteKey,
debug: jitsu.debug,
echoEvents: jitsu.echoEvents
}
}),
...(environment.sentry && environment.sentry.dsn
? [
SentryPlugin
]
: []),
]
...(sentry?.dsn ? { logger: new SentryService(SentryPlugin.options) } : {}),
plugins,
};
28 changes: 28 additions & 0 deletions apps/api/src/plugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { environment } from '@gauzy/config';
import { ChangelogPlugin } from '@gauzy/changelog-plugin';
import { JitsuAnalyticsPlugin } from '@gauzy/jitsu-analytics-plugin';
import { KnowledgeBasePlugin } from '@gauzy/knowledge-base-plugin';
import { SentryTracing as SentryPlugin } from './sentry';

const { jitsu, sentry } = environment;

/**
* An array of plugins to be included or used in the codebase.
*/
export const plugins = [
// Indicates the inclusion or intention to use the ChangelogPlugin in the codebase.
ChangelogPlugin,
// Indicates the inclusion or intention to use the KnowledgeBasePlugin in the codebase.
KnowledgeBasePlugin,
// Initializes the Jitsu Analytics Plugin by providing a configuration object.
JitsuAnalyticsPlugin.init({
config: {
host: jitsu.serverHost,
writeKey: jitsu.serverWriteKey,
debug: jitsu.debug,
echoEvents: jitsu.echoEvents
}
}),
// Includes the SentryPlugin based on the presence of Sentry configuration.
...(sentry && sentry.dsn ? [SentryPlugin] : []),
];
2 changes: 1 addition & 1 deletion apps/api/src/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ export function initializeSentry(): typeof SentryPlugin {
});
}

export const Sentry = initializeSentry();
export const SentryTracing = initializeSentry();
12 changes: 6 additions & 6 deletions apps/desktop-timer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@
"@ngneat/until-destroy": "^9.2.0",
"@ngx-translate/core": "^14.0.0",
"@ngx-translate/http-loader": "^7.0.0",
"@sentry/angular": "^7.90.0",
"@sentry/electron": "^4.17.0",
"@sentry/node": "^7.90.0",
"@sentry/profiling-node": "^1.3.2",
"@sentry/tracing": "^7.90.0",
"@sentry/types": "^7.90.0",
"@sentry/angular-ivy": "^7.101.1",
"@sentry/electron": "^4.18.0",
"@sentry/node": "^7.101.1",
"@sentry/profiling-node": "^7.101.1",
"@sentry/tracing": "^7.101.1",
"@sentry/types": "^7.101.1",
"app-root-path": "^3.0.0",
"auto-launch": "5.0.5",
"consolidate": "^0.16.0",
Expand Down
17 changes: 16 additions & 1 deletion apps/desktop-timer/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,25 @@ import { NgSelectModule } from '@ng-select/ng-select';
import { AppModuleGuard } from './app.module.guards';
import { Router } from '@angular/router';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import * as Sentry from '@sentry/angular';
import * as Sentry from '@sentry/angular-ivy';
import { environment as gauzyEnvironment } from '@env/environment';
import { environment } from '../environments/environment';
import { initializeSentry } from './sentry';

/**
* Initializes Sentry based on the environment configuration.
* If a valid Sentry DSN is provided, Sentry is initialized with the specified configuration.
* If the DSN is set to 'DOCKER_SENTRY_DSN', a warning is logged indicating that the environment
* is running inside Docker without a Sentry DSN.
*/
if (environment.SENTRY_DSN) {
if (environment.SENTRY_DSN === 'DOCKER_SENTRY_DSN') {
console.warn('You are running inside Docker but does not have SENTRY_DSN env set');
} else {
console.log(`Enabling Sentry with DSN: ${environment.SENTRY_DSN}`);
initializeSentry();
}
}

@NgModule({
declarations: [AppComponent],
Expand Down
43 changes: 43 additions & 0 deletions apps/desktop-timer/src/app/sentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import * as Sentry from '@sentry/angular-ivy';
import { environment } from '../environments/environment';
import { version } from '../../version';

/**
* Initializes and configures the Sentry module.
* @returns The configured Sentry instance.
*/
export function initializeSentry(): void {
return Sentry.init({
dsn: environment.SENTRY_DSN,
environment: environment.production ? 'production' : 'development',
debug: !environment.production,
integrations: [
// Registers and configures the Tracing integration,
// which automatically instruments your application to monitor its
// performance, including custom Angular routing instrumentation
Sentry.browserTracingIntegration(),
// Registers the Replay integration,
// which automatically captures Session Replays
Sentry.replayIntegration()
],

// Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
tracePropagationTargets: [
'localhost',
/^https:\/\/api\.gauzy\.co\/api/,
/^https:\/\/apistage\.gauzy\.co\/api/,
/^https:\/\/apidemo\.gauzy\.co\/api/
],
// The release identifier used when uploading respective source maps.
release: 'gauzy@' + version,
// Capture Replay for 10% of all sessions,
// plus for 100% of sessions with an error
replaysSessionSampleRate: environment.SENTRY_TRACES_SAMPLE_RATE ? parseInt(environment.SENTRY_TRACES_SAMPLE_RATE) : 0.01,
replaysOnErrorSampleRate: 1.0,

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: environment.SENTRY_TRACES_SAMPLE_RATE ? parseInt(environment.SENTRY_TRACES_SAMPLE_RATE) : 0.01
});
}
39 changes: 5 additions & 34 deletions apps/desktop-timer/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,55 +1,26 @@
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { akitaConfig, enableAkitaProdMode, persistState } from '@datorama/akita';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

import { enableAkitaProdMode, persistState } from '@datorama/akita';
import { akitaConfig } from '@datorama/akita';
import * as Sentry from '@sentry/angular';

if (environment.production) {
enableProdMode();
enableAkitaProdMode();
}

persistState({
key: '_gauzyStore',
key: '_gauzyStore'
});

akitaConfig({
resettable: true,
});

Sentry.init({
dsn: environment.SENTRY_DSN,
environment: environment.production ? 'production' : 'development',
debug: !environment.production,
integrations: [
// Registers and configures the Tracing integration,
// which automatically instruments your application to monitor its
// performance, including custom Angular routing instrumentation
new Sentry.BrowserTracing({
tracePropagationTargets: [
'localhost',
'https://apidemo.gauzy.co',
'https://apistage.gauzy.co',
'https://api.gauzy.co',
],
routingInstrumentation: Sentry.routingInstrumentation,
}),
],

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: environment.SENTRY_TRACES_SAMPLE_RATE
? parseInt(environment.SENTRY_TRACES_SAMPLE_RATE)
: 0.01,
resettable: true
});

platformBrowserDynamic()
.bootstrapModule(AppModule, {
preserveWhitespaces: false,
preserveWhitespaces: false
})
.then((success) => console.log(`Bootstrap success`))
.catch((err) => console.error(err));
10 changes: 5 additions & 5 deletions apps/desktop-timer/src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@
"@gauzy/contracts": "^0.1.0",
"@gauzy/desktop-libs": "^0.1.0",
"@gauzy/desktop-window": "^0.1.0",
"@sentry/electron": "^4.17.0",
"@sentry/profiling-node": "^1.3.2",
"@sentry/node": "^7.90.0",
"@sentry/tracing": "^7.90.0",
"@sentry/types": "^7.90.0",
"@sentry/electron": "^4.18.0",
"@sentry/profiling-node": "^7.101.1",
"@sentry/node": "^7.101.1",
"@sentry/tracing": "^7.101.1",
"@sentry/types": "^7.101.1",
"auto-launch": "5.0.5",
"consolidate": "^0.16.0",
"electron-log": "^4.4.8",
Expand Down
14 changes: 14 additions & 0 deletions apps/desktop-timer/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @description
* Current version of the Gauzy Desktop Timer Application.
*
* @example
* ```
* import { version } from './version';
*
* console.log('Gauzy Desktop Timer Application Version:', version);
* ```
*
* @since 0.1.0
*/
export const version: string = require('./package.json').version;
12 changes: 6 additions & 6 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@
"@ngneat/until-destroy": "^9.2.0",
"@ngx-translate/core": "^14.0.0",
"@ngx-translate/http-loader": "^7.0.0",
"@sentry/angular": "^7.90.0",
"@sentry/electron": "^4.17.0",
"@sentry/node": "^7.90.0",
"@sentry/tracing": "^7.90.0",
"@sentry/types": "^7.90.0",
"@sentry/profiling-node": "^1.3.2",
"@sentry/angular-ivy": "^7.101.1",
"@sentry/electron": "^4.18.0",
"@sentry/node": "^7.101.1",
"@sentry/tracing": "^7.101.1",
"@sentry/types": "^7.101.1",
"@sentry/profiling-node": "^7.101.1",
"app-root-path": "^3.0.0",
"auto-launch": "5.0.5",
"consolidate": "^0.16.0",
Expand Down
18 changes: 17 additions & 1 deletion apps/desktop/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,26 @@ import {
import { NbCardModule, NbButtonModule } from '@nebular/theme';
import { RouterModule } from '@angular/router';
import { HTTP_INTERCEPTORS } from '@angular/common/http';
import * as Sentry from "@sentry/angular";
import * as Sentry from "@sentry/angular-ivy";
import { Router } from '@angular/router';
import { environment as gauzyEnvironment } from '@env/environment';
import { environment } from '../environments/environment';
import { initializeSentry } from './sentry';

/**
* Initializes Sentry based on the environment configuration.
* If a valid Sentry DSN is provided, Sentry is initialized with the specified configuration.
* If the DSN is set to 'DOCKER_SENTRY_DSN', a warning is logged indicating that the environment
* is running inside Docker without a Sentry DSN.
*/
if (environment.SENTRY_DSN) {
if (environment.SENTRY_DSN === 'DOCKER_SENTRY_DSN') {
console.warn('You are running inside Docker but does not have SENTRY_DSN env set');
} else {
console.log(`Enabling Sentry with DSN: ${environment.SENTRY_DSN}`);
initializeSentry();
}
}

@NgModule({
declarations: [AppComponent],
Expand Down
43 changes: 43 additions & 0 deletions apps/desktop/src/app/sentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import * as Sentry from "@sentry/angular-ivy";
import { environment } from "../environments/environment";
import { version } from '../../version';

/**
* Initializes and configures the Sentry module.
* @returns The configured Sentry instance.
*/
export function initializeSentry(): void {
return Sentry.init({
dsn: environment.SENTRY_DSN,
environment: environment.production ? 'production' : 'development',
debug: !environment.production,
integrations: [
// Registers and configures the Tracing integration,
// which automatically instruments your application to monitor its
// performance, including custom Angular routing instrumentation
Sentry.browserTracingIntegration(),
// Registers the Replay integration,
// which automatically captures Session Replays
Sentry.replayIntegration()
],

// Set `tracePropagationTargets` to control for which URLs distributed tracing should be enabled
tracePropagationTargets: [
'localhost',
/^https:\/\/api\.gauzy\.co\/api/,
/^https:\/\/apistage\.gauzy\.co\/api/,
/^https:\/\/apidemo\.gauzy\.co\/api/
],
// The release identifier used when uploading respective source maps.
release: 'gauzy@' + version,
// Capture Replay for 10% of all sessions,
// plus for 100% of sessions with an error
replaysSessionSampleRate: environment.SENTRY_TRACES_SAMPLE_RATE ? parseInt(environment.SENTRY_TRACES_SAMPLE_RATE) : 0.01,
replaysOnErrorSampleRate: 1.0,

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: environment.SENTRY_TRACES_SAMPLE_RATE ? parseInt(environment.SENTRY_TRACES_SAMPLE_RATE) : 0.01
});
}
Loading

0 comments on commit 538a48e

Please sign in to comment.