chore: ce changes decoupled mixpannel chunk (#36979)

## Description
Decoupled mixpanel script it takes about 50Kb zipped, reduces main chunk
by about 2.7%.


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

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

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/11417674158>
> Commit: 7288e912d63f4eee0ee2532934ccf4ae51cc1fff
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11417674158&attempt=2"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.All`
> Spec:
> <hr>Sat, 19 Oct 2024 17:20:19 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 user identification for analytics tracking, ensuring accurate
data collection.
- Updated user data handling in the HelpButton component to manage
consent asynchronously.

- **Bug Fixes**
- Improved clarity and control flow in user identification logic for
analytics.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Vemparala Surya Vamsi 2024-10-20 09:16:25 +05:30 committed by GitHub
parent 9a315eabdc
commit 631abe8e96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 11 deletions

View File

@ -1,4 +1,4 @@
import { call, put, race, select, take } from "redux-saga/effects";
import { call, fork, put, race, select, take } from "redux-saga/effects";
import type {
ReduxAction,
ReduxActionWithPromise,
@ -190,18 +190,27 @@ export function* getCurrentUserSaga(action?: {
}
}
function* intializeSmartLook(currentUser: User) {
if (!currentUser.isAnonymous && currentUser.username !== ANONYMOUS_USERNAME) {
yield AnalyticsUtil.identifyUser(currentUser);
}
}
export function* runUserSideEffectsSaga() {
const currentUser: User = yield select(getCurrentUser);
const { enableTelemetry } = currentUser;
const isAirgappedInstance = isAirgapped();
if (enableTelemetry) {
const promise = initializeAnalyticsAndTrackers();
// parallelize sentry and smart look initialization
if (promise instanceof Promise) {
const result: boolean = yield promise;
yield fork(intializeSmartLook, currentUser);
const initializeSentry = initializeAnalyticsAndTrackers();
if (result) {
if (initializeSentry instanceof Promise) {
const sentryInialized: boolean = yield initializeSentry;
if (sentryInialized) {
yield put(segmentInitSuccess());
} else {
yield put(segmentInitUncertain());
@ -209,10 +218,6 @@ export function* runUserSideEffectsSaga() {
}
}
if (!currentUser.isAnonymous && currentUser.username !== ANONYMOUS_USERNAME) {
enableTelemetry && AnalyticsUtil.identifyUser(currentUser);
}
const isFFFetched: boolean = yield select(getFeatureFlagsFetched);
if (!isFFFetched) {

View File

@ -102,7 +102,7 @@ export function IntercomConsent({
const instanceId = useSelector(getInstanceId);
const dispatch = useDispatch();
const sendUserDataToIntercom = () => {
const sendUserDataToIntercom = async () => {
const { email } = user || {};
updateIntercomProperties(instanceId, user);
@ -115,7 +115,7 @@ export function IntercomConsent({
showIntercomConsent(false);
if (user?.enableTelemetry) {
AnalyticsUtil.identifyUser(user, true);
await AnalyticsUtil.identifyUser(user, true);
AnalyticsUtil.logEvent("SUPPORT_REQUEST_INITIATED", {
email,
});