Skip to content

Commit

Permalink
fix: Bug where identifyUser not called in cloud (#37329)
Browse files Browse the repository at this point in the history
## Description

Fix the bug where return was called before the await for cloud
conditions. This made the identifyUser case being skipped almost always


Missed in #37303


## Automation

/ok-to-test tags="@tag.Sanity"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!IMPORTANT]
> 🟣 🟣 🟣 Your tests are running.
> Tests running at:
<https://github.com/appsmithorg/appsmith/actions/runs/11791461362>
> Commit: 94bc989
> Workflow: `PR Automation test suite`
> Tags: `@tag.Sanity`
> Spec: ``
> <hr>Tue, 12 Nov 2024 05:44:55 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**
- Enhanced analytics initialization process to ensure completion before
user identification.
  
- **Bug Fixes**
	- Improved error handling for analytics setup with Sentry logging.

- **Documentation**
	- Updated function signatures for clarity and consistency.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
hetunandu authored Nov 12, 2024
1 parent b24b66f commit 12ab7e6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions app/client/src/utils/AppsmithUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,23 @@ export const initializeAnalyticsAndTrackers = async (currentUser: User) => {
if (appsmithConfigs.segment.enabled && !(window as any).analytics) {
if (appsmithConfigs.segment.apiKey) {
// This value is only enabled for Appsmith's cloud hosted version. It is not set in self-hosted environments
return AnalyticsUtil.initializeSegment(appsmithConfigs.segment.apiKey);
await AnalyticsUtil.initializeSegment(appsmithConfigs.segment.apiKey);
} else if (appsmithConfigs.segment.ceKey) {
// This value is set in self-hosted environments. But if the analytics are disabled, it's never used.
return AnalyticsUtil.initializeSegment(appsmithConfigs.segment.ceKey);
await AnalyticsUtil.initializeSegment(appsmithConfigs.segment.ceKey);
}
}

if (
!currentUser.isAnonymous &&
currentUser.username !== ANONYMOUS_USERNAME
) {
await AnalyticsUtil.identifyUser(currentUser);
}
} catch (e) {
Sentry.captureException(e);
log.error(e);
}

if (!currentUser.isAnonymous && currentUser.username !== ANONYMOUS_USERNAME) {
await AnalyticsUtil.identifyUser(currentUser);
}
};

export const mapToPropList = (map: Record<string, string>): Property[] => {
Expand Down

0 comments on commit 12ab7e6

Please sign in to comment.