From 0845f783d0302d7d303527f88a5e7fe364def82d Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Kandula Date: Thu, 2 Feb 2023 12:09:01 +0530 Subject: [PATCH] chore: Fix Installation complete event not being sent (#20301) The problem was that the Mono returned by `analyticsService.sendEvent` was returned inside a `.map` call, which, (almost) always results in a bug. This PR fixes that. --- .../main/java/com/appsmith/server/helpers/ExchangeUtils.java | 2 ++ .../com/appsmith/server/solutions/ce/UserSignupCEImpl.java | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ExchangeUtils.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ExchangeUtils.java index c0f6771c6a..3d8be57517 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ExchangeUtils.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ExchangeUtils.java @@ -21,6 +21,8 @@ public class ExchangeUtils { contextView.get(ServerWebExchange.class).getRequest().getHeaders().getFirst(HEADER_ANONYMOUS_USER_ID), FieldName.ANONYMOUS_USER )) + // An error is thrown when the context is not available. We don't want to fail the request in this case. + .onErrorResume(error -> Mono.empty()) .defaultIfEmpty(FieldName.ANONYMOUS_USER); } diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/UserSignupCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/UserSignupCEImpl.java index 2c655f6faf..711f367960 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/UserSignupCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/UserSignupCEImpl.java @@ -225,7 +225,7 @@ public class UserSignupCEImpl implements UserSignupCE { return Mono.when( userDataService.updateForUser(user, userData), configService.getInstanceId() - .map(instanceId -> { + .flatMap(instanceId -> { log.debug("Installation setup complete."); analyticsService.identifyInstance(instanceId, userData.getRole(), userData.getUseCase()); return analyticsService.sendEvent( @@ -239,7 +239,7 @@ public class UserSignupCEImpl implements UserSignupCE { "goal", ObjectUtils.defaultIfNull(userData.getUseCase(), "") ), false - ).thenReturn(instanceId); + ); }), envManager.applyChanges(Map.of( APPSMITH_DISABLE_TELEMETRY.name(),