add startup tracking
This commit is contained in:
parent
288fed2ecf
commit
5f320f6b77
@ -49,6 +49,7 @@
|
||||
"html-to-text": "^5.1.1",
|
||||
"inquirer": "^7.1.0",
|
||||
"ioredis": "^4.17.1",
|
||||
"matomo-tracker": "^2.2.2",
|
||||
"migrate-mongoose": "^4.0.0",
|
||||
"mjml": "^4.6.3",
|
||||
"mongoose": "^5.9.11",
|
||||
|
||||
@ -5,6 +5,7 @@ import Redis from 'ioredis';
|
||||
import { PinoLogger } from 'nestjs-pino/dist';
|
||||
import { authServices } from './auth';
|
||||
import { formServices } from './form';
|
||||
import { InstallationMetricsService } from './installation.metrics.service';
|
||||
import { MailService } from './mail.service';
|
||||
import { profileServices } from './profile';
|
||||
import { submissionServices } from './submission';
|
||||
@ -17,6 +18,7 @@ export const services = [
|
||||
...authServices,
|
||||
...submissionServices,
|
||||
MailService,
|
||||
InstallationMetricsService,
|
||||
{
|
||||
provide: 'PUB_SUB',
|
||||
inject: [ConfigService, PinoLogger],
|
||||
|
||||
29
src/service/installation.metrics.service.ts
Normal file
29
src/service/installation.metrics.service.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { Injectable, OnApplicationBootstrap } from '@nestjs/common';
|
||||
import MatomoTracker from 'matomo-tracker';
|
||||
import { PinoLogger } from 'nestjs-pino/dist';
|
||||
|
||||
@Injectable()
|
||||
export class InstallationMetricsService implements OnApplicationBootstrap {
|
||||
private host = 'https://metrics.ohmyform.com/matomo.php'
|
||||
|
||||
constructor(
|
||||
private readonly logger: PinoLogger,
|
||||
) {
|
||||
}
|
||||
|
||||
async onApplicationBootstrap(): Promise<void> {
|
||||
const tracker = new MatomoTracker(1, this.host)
|
||||
|
||||
tracker.on('error', () => {
|
||||
this.logger.error('failed to register instance')
|
||||
})
|
||||
|
||||
tracker.track({
|
||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||
action_name: 'startup',
|
||||
ua: process.arch
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -6816,6 +6816,11 @@ map-visit@^1.0.0:
|
||||
dependencies:
|
||||
object-visit "^1.0.0"
|
||||
|
||||
matomo-tracker@^2.2.2:
|
||||
version "2.2.2"
|
||||
resolved "https://registry.yarnpkg.com/matomo-tracker/-/matomo-tracker-2.2.2.tgz#685937f90b318fbda6768260f11cacab471d9bcd"
|
||||
integrity sha512-xAeojX+LwXn+UHd6A72DbVkqc4a1a6SKCiQPBwpKA6x4R1qy1Nysg3kEfsh6Xq+bzPjcvn2ppDQb9JXcktmJDQ==
|
||||
|
||||
md5.js@^1.3.4:
|
||||
version "1.3.5"
|
||||
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user