1
- import {
2
- Injectable ,
3
- InternalServerErrorException ,
4
- Logger ,
5
- OnApplicationBootstrap ,
6
- } from '@nestjs/common' ;
1
+ import { Injectable , InternalServerErrorException , Logger , OnApplicationBootstrap } from '@nestjs/common' ;
7
2
import { EventEmitter2 } from '@nestjs/event-emitter' ;
8
3
import config from 'src/utils/config' ;
9
4
import { AppAnalyticsEvents } from 'src/constants/app-events' ;
10
5
import { TelemetryEvents } from 'src/constants/telemetry-events' ;
11
6
import { GetServerInfoResponse } from 'src/dto/server.dto' ;
12
7
import { ServerRepository } from 'src/modules/core/repositories/server.repository' ;
13
- import { IServerProvider } from 'src/modules/core/models/server-provider.interface' ;
8
+ import { AppType , BuildType , IServerProvider } from 'src/modules/core/models/server-provider.interface' ;
14
9
import { ServerInfoNotFoundException } from 'src/constants/exceptions' ;
15
10
import { EncryptionService } from 'src/modules/core/encryption/encryption.service' ;
16
11
@@ -49,7 +44,11 @@ implements OnApplicationBootstrap, IServerProvider {
49
44
// Create default server info on first application launch
50
45
serverInfo = this . repository . create ( { } ) ;
51
46
await this . repository . save ( serverInfo ) ;
52
- this . eventEmitter . emit ( AppAnalyticsEvents . Initialize , { anonymousId : serverInfo . id , sessionId : this . sessionId } ) ;
47
+ this . eventEmitter . emit ( AppAnalyticsEvents . Initialize , {
48
+ anonymousId : serverInfo . id ,
49
+ sessionId : this . sessionId ,
50
+ appType : this . getAppType ( SERVER_CONFIG . buildType ) ,
51
+ } ) ;
53
52
this . eventEmitter . emit ( AppAnalyticsEvents . Track , {
54
53
event : TelemetryEvents . ApplicationFirstStart ,
55
54
eventData : {
@@ -61,7 +60,11 @@ implements OnApplicationBootstrap, IServerProvider {
61
60
} ) ;
62
61
} else {
63
62
this . logger . log ( 'Application started.' ) ;
64
- this . eventEmitter . emit ( AppAnalyticsEvents . Initialize , { anonymousId : serverInfo . id , sessionId : this . sessionId } ) ;
63
+ this . eventEmitter . emit ( AppAnalyticsEvents . Initialize , {
64
+ anonymousId : serverInfo . id ,
65
+ sessionId : this . sessionId ,
66
+ appType : this . getAppType ( SERVER_CONFIG . buildType ) ,
67
+ } ) ;
65
68
this . eventEmitter . emit ( AppAnalyticsEvents . Track , {
66
69
event : TelemetryEvents . ApplicationStarted ,
67
70
eventData : {
@@ -90,6 +93,7 @@ implements OnApplicationBootstrap, IServerProvider {
90
93
appVersion : SERVER_CONFIG . appVersion ,
91
94
osPlatform : process . platform ,
92
95
buildType : SERVER_CONFIG . buildType ,
96
+ appType : this . getAppType ( SERVER_CONFIG . buildType ) ,
93
97
encryptionStrategies : await this . encryptionService . getAvailableEncryptionStrategies ( ) ,
94
98
fixedDatabaseId : REDIS_STACK_CONFIG ?. id ,
95
99
} ;
@@ -100,4 +104,17 @@ implements OnApplicationBootstrap, IServerProvider {
100
104
throw new InternalServerErrorException ( ) ;
101
105
}
102
106
}
107
+
108
+ getAppType ( buildType : string ) : AppType {
109
+ switch ( buildType ) {
110
+ case BuildType . DockerOnPremise :
111
+ return AppType . Docker ;
112
+ case BuildType . Electron :
113
+ return AppType . Electron ;
114
+ case BuildType . RedisStack :
115
+ return AppType . RedisStackWeb ;
116
+ default :
117
+ return AppType . Unknown ;
118
+ }
119
+ }
103
120
}
0 commit comments