chore: Tracking organizationId in analytics for cloud billing (#40719)
## Description Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /test sanity ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!CAUTION] > 🔴 🔴 🔴 Some tests have failed. > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/15163916169> > Commit: 3695abfed6d9db0af99289e71dbb7447ff68311d > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=15163916169&attempt=1&selectiontype=test&testsstatus=failed&specsstatus=fail" target="_blank">Cypress dashboard</a>. > Tags: @tag.Sanity > Spec: > The following are new failures, please fix them before merging the PR: <ol> > <li>cypress/e2e/Regression/ClientSide/Widgets/TableV2/AddNewRow2_spec.js</ol> > <a href="https://internal.appsmith.com/app/cypress-dashboard/identified-flaky-tests-65890b3c81d7400d08fa9ee3?branch=master" target="_blank">List of identified flaky tests</a>. > <hr>Wed, 21 May 2025 14:33:26 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Analytics events and user identification now include organization ID for enhanced tracking and reporting. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
d64361e225
commit
c733ae0b63
|
|
@ -125,6 +125,7 @@ public class AnalyticsServiceCEImpl implements AnalyticsServiceCE {
|
||||||
String name = savedUser.getName();
|
String name = savedUser.getName();
|
||||||
String email = savedUser.getEmail();
|
String email = savedUser.getEmail();
|
||||||
final String emailDomainHash = getEmailDomainHash(email);
|
final String emailDomainHash = getEmailDomainHash(email);
|
||||||
|
String organizationId = savedUser.getOrganizationId();
|
||||||
|
|
||||||
if (!commonConfig.isCloudHosting()) {
|
if (!commonConfig.isCloudHosting()) {
|
||||||
username = hash(username);
|
username = hash(username);
|
||||||
|
|
@ -135,15 +136,26 @@ public class AnalyticsServiceCEImpl implements AnalyticsServiceCE {
|
||||||
analytics.enqueue(IdentifyMessage.builder()
|
analytics.enqueue(IdentifyMessage.builder()
|
||||||
.userId(ObjectUtils.defaultIfNull(username, ""))
|
.userId(ObjectUtils.defaultIfNull(username, ""))
|
||||||
.traits(Map.of(
|
.traits(Map.of(
|
||||||
"name", ObjectUtils.defaultIfNull(name, ""),
|
"name",
|
||||||
"email", ObjectUtils.defaultIfNull(email, ""),
|
ObjectUtils.defaultIfNull(name, ""),
|
||||||
"emailDomainHash", emailDomainHash,
|
"email",
|
||||||
"isSuperUser", isSuperUser,
|
ObjectUtils.defaultIfNull(email, ""),
|
||||||
"instanceId", instanceId,
|
"emailDomainHash",
|
||||||
"mostRecentlyUsedWorkspaceId", tuple.getT4(),
|
emailDomainHash,
|
||||||
"role", "",
|
"isSuperUser",
|
||||||
"proficiency", ObjectUtils.defaultIfNull(userData.getProficiency(), ""),
|
isSuperUser,
|
||||||
"goal", ObjectUtils.defaultIfNull(userData.getUseCase(), ""))));
|
"instanceId",
|
||||||
|
instanceId,
|
||||||
|
"organizationId",
|
||||||
|
ObjectUtils.defaultIfNull(organizationId, ""),
|
||||||
|
"mostRecentlyUsedWorkspaceId",
|
||||||
|
tuple.getT4(),
|
||||||
|
"role",
|
||||||
|
"",
|
||||||
|
"proficiency",
|
||||||
|
ObjectUtils.defaultIfNull(userData.getProficiency(), ""),
|
||||||
|
"goal",
|
||||||
|
ObjectUtils.defaultIfNull(userData.getUseCase(), ""))));
|
||||||
analytics.flush();
|
analytics.flush();
|
||||||
return savedUser;
|
return savedUser;
|
||||||
});
|
});
|
||||||
|
|
@ -329,11 +341,14 @@ public class AnalyticsServiceCEImpl implements AnalyticsServiceCE {
|
||||||
return Mono.just(object);
|
return Mono.just(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String organizationId = user.getOrganizationId();
|
||||||
|
|
||||||
final String username = (object instanceof User objectAsUser ? objectAsUser : user).getUsername();
|
final String username = (object instanceof User objectAsUser ? objectAsUser : user).getUsername();
|
||||||
|
|
||||||
HashMap<String, Object> analyticsProperties = new HashMap<>();
|
HashMap<String, Object> analyticsProperties = new HashMap<>();
|
||||||
analyticsProperties.put("id", id);
|
analyticsProperties.put("id", id);
|
||||||
analyticsProperties.put("oid", ((Identifiable) object).getId());
|
analyticsProperties.put("oid", ((Identifiable) object).getId());
|
||||||
|
analyticsProperties.put("organizationId", ObjectUtils.defaultIfNull(organizationId, ""));
|
||||||
if (extraProperties != null) {
|
if (extraProperties != null) {
|
||||||
analyticsProperties.putAll(extraProperties);
|
analyticsProperties.putAll(extraProperties);
|
||||||
// To avoid sending extra event data to analytics
|
// To avoid sending extra event data to analytics
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user