Skip to content
This repository has been archived by the owner on Dec 2, 2023. It is now read-only.

Commit

Permalink
add startup tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Schramm committed Jun 1, 2020
1 parent 288fed2 commit 5f320f6
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -17,6 +18,7 @@ export const services = [
...authServices,
...submissionServices,
MailService,
InstallationMetricsService,
{
provide: 'PUB_SUB',
inject: [ConfigService, PinoLogger],
Expand Down
29 changes: 29 additions & 0 deletions src/service/installation.metrics.service.ts
Original file line number Diff line number Diff line change
@@ -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
})
}


}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 5f320f6

Please sign in to comment.