Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { HttpException, Injectable } from '@nestjs/common';
import { TelemetryBaseService } from 'src/modules/analytics/telemetry.base.service';
import { EventEmitter2 } from '@nestjs/event-emitter';
import { TelemetryEvents } from 'src/constants';
import { CloudSubscriptionCapiService } from '../subscription/cloud-subscription.capi.service';
import { CloudSubscriptionType } from '../subscription/models';
import { CloudCapiAuthDto } from '../common/dto';
import { catchAclError } from 'src/utils';

@Injectable()
export class CloudDatabaseAnalytics extends TelemetryBaseService {
Expand All @@ -13,7 +17,30 @@ export class CloudDatabaseAnalytics extends TelemetryBaseService {
this.sendEvent(TelemetryEvents.CloudFreeDatabaseCreated, eventData);
}

sendCloudFreeDatabaseFailed(exception: HttpException, eventData: object = {}) {
this.sendFailedEvent(TelemetryEvents.CloudFreeDatabaseFailed, exception, eventData);
async sendCloudFreeDatabaseFailed(
exception: HttpException,
eventData: object = {},
cloudSubscriptionCapiService: CloudSubscriptionCapiService,
data: { planId: number, capiCredentials: CloudCapiAuthDto },
) {
try {
const fixedPlans = await cloudSubscriptionCapiService.getSubscriptionsPlans(
data.capiCredentials,
CloudSubscriptionType.Fixed,
);

const selectedPlan = CloudSubscriptionCapiService.findFreePlanById(fixedPlans, data.planId);

this.sendFailedEvent(
TelemetryEvents.CloudFreeDatabaseFailed,
exception,
{
region: selectedPlan?.region || '',
provider: selectedPlan?.provider || '',
...eventData,
},
);
} catch (error) {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,15 @@ export class CreateFreeDatabaseCloudJob extends CloudJob {

return database;
} catch (e) {
this.dependencies.cloudDatabaseAnalytics.sendCloudFreeDatabaseFailed(e, {
region: freeSubscription?.region || '',
provider: freeSubscription?.provider || '',
});
this.dependencies.cloudDatabaseAnalytics.sendCloudFreeDatabaseFailed(
e,
{
region: freeSubscription?.region || '',
provider: freeSubscription?.provider || '',
},
this.dependencies.cloudSubscriptionCapiService,
this.data,
);

throw e;
}
Expand Down