Skip to content

Commit

Permalink
Remove unused UserData.role
Browse files Browse the repository at this point in the history
  • Loading branch information
sharat87 committed Nov 14, 2024
1 parent d90faa2 commit 986fc89
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 58 deletions.
1 change: 0 additions & 1 deletion app/client/src/ce/api/UserApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export interface UpdateUserRequest {
name?: string;
email?: string;
proficiency?: string;
role?: string;
useCase?: string;
intercomConsentGiven?: boolean;
}
Expand Down
3 changes: 1 addition & 2 deletions app/client/src/ce/sagas/userSagas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -417,14 +417,13 @@ export function* inviteUsers(

export function* updateUserDetailsSaga(action: ReduxAction<UpdateUserRequest>) {
try {
const { email, intercomConsentGiven, name, proficiency, role, useCase } =
const { email, intercomConsentGiven, name, proficiency, useCase } =
action.payload;

const response: ApiResponse = yield callAPI(UserApi.updateUser, {
email,
name,
proficiency,
role,
useCase,
intercomConsentGiven,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public class UserData extends BaseDomain {
@JsonView(Views.Internal.class)
String userId;

// Role of the user in their workspace, example, Designer, Developer, Product Lead etc.
@JsonView(Views.Public.class)
@Deprecated
private String role;

// The development proficiency of the user for example, Beginner, Novice, Intermediate, Advanced.
@JsonView(Views.Public.class)
private String proficiency;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public class UserSignupRequestDTO {

private String password;

@Deprecated
private String role;

private String proficiency;

private String useCase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
public class UserUpdateCE_DTO {
private String name;

private String role;

private String proficiency;

private String useCase;
Expand All @@ -22,6 +20,6 @@ public boolean hasUserUpdates() {
}

public boolean hasUserDataUpdates() {
return role != null || proficiency != null || useCase != null || isIntercomConsentGiven;
return proficiency != null || useCase != null || isIntercomConsentGiven;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ public interface AnalyticsServiceCE {
Mono<User> identifyUser(User user, UserData userData, String recentlyUsedWorkspaceId);

void identifyInstance(
String instanceId,
String role,
String proficiency,
String useCase,
String adminEmail,
String adminFullName,
String ip);
String instanceId, String proficiency, String useCase, String adminEmail, String adminFullName, String ip);

Mono<Void> sendEvent(String event, String userId, Map<String, ?> properties);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public Mono<User> identifyUser(User user, UserData userData, String recentlyUsed
"isSuperUser", isSuperUser,
"instanceId", instanceId,
"mostRecentlyUsedWorkspaceId", tuple.getT4(),
"role", ObjectUtils.defaultIfNull(userData.getRole(), ""),
"role", "",
"proficiency", ObjectUtils.defaultIfNull(userData.getProficiency(), ""),
"goal", ObjectUtils.defaultIfNull(userData.getUseCase(), ""))));
analytics.flush();
Expand All @@ -150,13 +150,7 @@ public Mono<User> identifyUser(User user, UserData userData, String recentlyUsed
}

public void identifyInstance(
String instanceId,
String role,
String proficiency,
String useCase,
String adminEmail,
String adminFullName,
String ip) {
String instanceId, String proficiency, String useCase, String adminEmail, String adminFullName, String ip) {
if (!isActive()) {
return;
}
Expand All @@ -167,7 +161,7 @@ public void identifyInstance(
"isInstance",
true, // Is this "identify" data-point for a user or an instance?
ROLE,
ObjectUtils.defaultIfNull(role, ""),
"",
PROFICIENCY,
ObjectUtils.defaultIfNull(proficiency, ""),
GOAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,6 @@ public Mono<User> updateCurrentUser(final UserUpdateDTO allUpdates, ServerWebExc

if (allUpdates.hasUserDataUpdates()) {
final UserData updates = new UserData();
if (StringUtils.hasLength(allUpdates.getRole())) {
updates.setRole(allUpdates.getRole());
}
if (StringUtils.hasLength(allUpdates.getProficiency())) {
updates.setProficiency(allUpdates.getProficiency());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ public Mono<User> signupAndLoginSuper(
})
.flatMap(user -> {
final UserData userData = new UserData();
userData.setRole(userFromRequest.getRole());
userData.setProficiency(userFromRequest.getProficiency());
userData.setUseCase(userFromRequest.getUseCase());

Expand Down Expand Up @@ -380,9 +379,6 @@ public Mono<Void> signupAndLoginSuperFromFormData(String originHeader, ServerWeb
if (formData.containsKey(FieldName.NAME)) {
user.setName(formData.getFirst(FieldName.NAME));
}
if (formData.containsKey("role")) {
user.setRole(formData.getFirst("role"));
}
if (formData.containsKey("proficiency")) {
user.setProficiency(formData.getFirst("proficiency"));
}
Expand Down Expand Up @@ -446,7 +442,7 @@ private Mono<Void> sendInstallationSetupAnalytics(
analyticsProps.put(DISABLE_TELEMETRY, !userFromRequest.isAllowCollectingAnonymousData());
analyticsProps.put(SUBSCRIBE_MARKETING, userFromRequest.isSignupForNewsletter());
analyticsProps.put(EMAIL, newsletterSignedUpUserEmail);
analyticsProps.put(ROLE, ObjectUtils.defaultIfNull(userData.getRole(), ""));
analyticsProps.put(ROLE, "");
analyticsProps.put(PROFICIENCY, ObjectUtils.defaultIfNull(userData.getProficiency(), ""));
analyticsProps.put(GOAL, ObjectUtils.defaultIfNull(userData.getUseCase(), ""));
// ip is a reserved keyword for tracking events in Mixpanel though this is allowed in
Expand All @@ -460,7 +456,6 @@ private Mono<Void> sendInstallationSetupAnalytics(

analyticsService.identifyInstance(
instanceId,
userData.getRole(),
userData.getProficiency(),
userData.getUseCase(),
newsletterSignedUpUserEmail,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class CommonConfigTest {
@Test
public void objectMapper_BeanCreated_WithPublicJsonViewAsDefault() throws JsonProcessingException {
UserData userData = new UserData();
userData.setRole("new_role");
userData.setProficiency("abcd"); // this is public field
userData.setUserId("userId"); // this is internal field
userData.setUserPermissions(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,21 +425,6 @@ public void updateNameOfUser_WithAccentedCharacters_IsValid() {
.verifyComplete();
}

@Test
@WithUserDetails(value = "api_user")
public void updateRoleOfUser() {
UserUpdateDTO updateUser = new UserUpdateDTO();
updateUser.setRole("New role of user");
final Mono<UserData> resultMono =
userService.updateCurrentUser(updateUser, null).then(userDataService.getForUserEmail("api_user"));
StepVerifier.create(resultMono)
.assertNext(userData -> {
assertNotNull(userData);
assertThat(userData.getRole()).isEqualTo("New role of user");
})
.verifyComplete();
}

@Test
@WithUserDetails(value = "api_user")
public void updateIntercomConsentOfUser() {
Expand Down Expand Up @@ -499,10 +484,9 @@ public void getIntercomConsentOfUserOnCloudHosting_AlwaysTrue() {

@Test
@WithUserDetails(value = "api_user")
public void updateNameRoleAndUseCaseOfUser() {
public void updateNameAndUseCaseOfUser() {
UserUpdateDTO updateUser = new UserUpdateDTO();
updateUser.setName("New name of user here");
updateUser.setRole("New role of user");
updateUser.setUseCase("New use case");
final Mono<Tuple2<User, UserData>> resultMono = userService
.updateCurrentUser(updateUser, null)
Expand All @@ -514,7 +498,6 @@ public void updateNameRoleAndUseCaseOfUser() {
assertNotNull(user);
assertNotNull(userData);
assertEquals("New name of user here", user.getName());
assertEquals("New role of user", userData.getRole());
assertEquals("New use case", userData.getUseCase());
})
.verifyComplete();
Expand Down

0 comments on commit 986fc89

Please sign in to comment.