diff --git a/doc/cli.md b/doc/cli.md new file mode 100644 index 0000000..d43ae94 --- /dev/null +++ b/doc/cli.md @@ -0,0 +1,14 @@ +# CLI + +Run `yarn cli` to get basic information of available commands + +## user commands + +### `yarn cli user create` + +create a new user + +### `yarn cli user activate ` + +activate the given user + diff --git a/doc/environment.md b/doc/environment.md new file mode 100644 index 0000000..c6aa7f9 --- /dev/null +++ b/doc/environment.md @@ -0,0 +1,12 @@ +# Environment Variables + +| Name | Default Value | Description | +| ---- | ------------- | ----------- | +| DISABLE_INSTALLATION_METRICS | *not set* | Per default installations are [publishing](./installation.metrics.md) their existence | +| SECRET_KEY | `changeMe` | JWT Secret for authentication | +| MONGODB_URI | `mongodb://localhost/ohmyform` | MongoDB Connection | +| MAILER_URI | `smtp://localhost:1025` | [Mail Connection](https://nodemailer.com/smtp/) | +| MAILER_FROM | `OhMyForm ` | Default From path, make sure that your mail server supports the given from addres | +| CLI | *automatically* | activates pretty print for log output | +| NODE_ENV | `production` | | + diff --git a/doc/installation.metrics.md b/doc/installation.metrics.md new file mode 100644 index 0000000..a47fdfa --- /dev/null +++ b/doc/installation.metrics.md @@ -0,0 +1,11 @@ +# Installation Metrics + +OhMyForm sends a PING during startup as well as once +every hour to get instights on where OhMyForm is used. + +If you feed that this should not happen you can disable +this behavior by setting the environment variable +`DISABLE_INSTALLATION_METRICS=1` + +You can take a look [here](../src/service/installation.metrics.service.ts) to see how we trigger the metric +collection diff --git a/src/service/installation.metrics.service.ts b/src/service/installation.metrics.service.ts index 1b24059..3abfc87 100644 --- a/src/service/installation.metrics.service.ts +++ b/src/service/installation.metrics.service.ts @@ -1,4 +1,5 @@ import { Injectable, OnApplicationBootstrap } from '@nestjs/common'; +import { ConfigService } from '@nestjs/config'; import MatomoTracker from 'matomo-tracker'; import { PinoLogger } from 'nestjs-pino/dist'; @@ -8,24 +9,39 @@ export class InstallationMetricsService implements OnApplicationBootstrap { constructor( private readonly logger: PinoLogger, + private readonly configService: ConfigService, ) { } async onApplicationBootstrap(): Promise { + if (this.configService.get('DISABLE_INSTALLATION_METRICS')) { + this.logger.info('installation metrics are disabled') + return + } + const tracker = new MatomoTracker(2, this.host) tracker.on('error', () => { this.logger.error('failed to add installation metrics') }) - this.logger.info('try to add installation metrics') - + this.logger.info('try to add startup metric') tracker.track({ url: `http://localhost/version/${process.env.npm_package_version}`, // eslint-disable-next-line @typescript-eslint/camelcase action_name: 'startup', ua: process.arch }) + + setInterval(() => { + this.logger.info('try to add running metric') + tracker.track({ + url: `http://localhost/version/${process.env.npm_package_version}`, + // eslint-disable-next-line @typescript-eslint/camelcase + action_name: 'running', + ua: process.arch + }) + }, 3600000) }