Skip to content

Commit 66f0f87

Browse files
authored
Add failsafe for bog-analytics routes (#223)
1 parent 68eef62 commit 66f0f87

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

‎packages/analytics-service/src/modules/analytics/analytics.service.ts‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ export class AnalyticsService implements OnModuleInit {
117117
}
118118

119119
const response = await logger.logClickEvent(event);
120+
121+
if (!response) {
122+
throw new RpcException({
123+
code: status.INVALID_ARGUMENT,
124+
message: 'Invalid analytics configuration',
125+
});
126+
}
127+
120128
return {
121129
id: response._id,
122130
category: response.category,
@@ -165,6 +173,14 @@ export class AnalyticsService implements OnModuleInit {
165173
}
166174

167175
const response = await logger.logInputEvent(event);
176+
177+
if (!response) {
178+
throw new RpcException({
179+
code: status.INVALID_ARGUMENT,
180+
message: 'Invalid analytics configuration',
181+
});
182+
}
183+
168184
return {
169185
id: response._id,
170186
category: response.category,
@@ -211,6 +227,14 @@ export class AnalyticsService implements OnModuleInit {
211227
}
212228

213229
const response = await logger.logVisitEvent(event);
230+
231+
if (!response) {
232+
throw new RpcException({
233+
code: status.INVALID_ARGUMENT,
234+
message: 'Invalid analytics configuration',
235+
});
236+
}
237+
214238
return {
215239
id: response._id,
216240
category: response.category,
@@ -263,6 +287,14 @@ export class AnalyticsService implements OnModuleInit {
263287
subcategory,
264288
properties,
265289
);
290+
291+
if (!response) {
292+
throw new RpcException({
293+
code: status.INVALID_ARGUMENT,
294+
message: 'Invalid analytics configuration',
295+
});
296+
}
297+
266298
return {
267299
id: response._id,
268300
eventTypeId: response.eventTypeId,

0 commit comments

Comments
 (0)