@@ -2,6 +2,10 @@ import { HttpException, Injectable } from '@nestjs/common';
2
2
import { TelemetryBaseService } from 'src/modules/analytics/telemetry.base.service' ;
3
3
import { EventEmitter2 } from '@nestjs/event-emitter' ;
4
4
import { TelemetryEvents } from 'src/constants' ;
5
+ import { CloudSubscriptionCapiService } from '../subscription/cloud-subscription.capi.service' ;
6
+ import { CloudSubscriptionType } from '../subscription/models' ;
7
+ import { CloudCapiAuthDto } from '../common/dto' ;
8
+ import { catchAclError } from 'src/utils' ;
5
9
6
10
@Injectable ( )
7
11
export class CloudDatabaseAnalytics extends TelemetryBaseService {
@@ -13,7 +17,30 @@ export class CloudDatabaseAnalytics extends TelemetryBaseService {
13
17
this . sendEvent ( TelemetryEvents . CloudFreeDatabaseCreated , eventData ) ;
14
18
}
15
19
16
- sendCloudFreeDatabaseFailed ( exception : HttpException , eventData : object = { } ) {
17
- this . sendFailedEvent ( TelemetryEvents . CloudFreeDatabaseFailed , exception , eventData ) ;
20
+ async sendCloudFreeDatabaseFailed (
21
+ exception : HttpException ,
22
+ eventData : object = { } ,
23
+ cloudSubscriptionCapiService : CloudSubscriptionCapiService ,
24
+ data : { planId : number , capiCredentials : CloudCapiAuthDto } ,
25
+ ) {
26
+ try {
27
+ const fixedPlans = await cloudSubscriptionCapiService . getSubscriptionsPlans (
28
+ data . capiCredentials ,
29
+ CloudSubscriptionType . Fixed ,
30
+ ) ;
31
+
32
+ const selectedPlan = CloudSubscriptionCapiService . findFreePlanById ( fixedPlans , data . planId ) ;
33
+
34
+ this . sendFailedEvent (
35
+ TelemetryEvents . CloudFreeDatabaseFailed ,
36
+ exception ,
37
+ {
38
+ region : selectedPlan ?. region || '' ,
39
+ provider : selectedPlan ?. provider || '' ,
40
+ ...eventData ,
41
+ } ,
42
+ ) ;
43
+ } catch ( error ) {
44
+ }
18
45
}
19
46
}
0 commit comments