Skip to content

Commit

Permalink
chore: ce changes decoupled mixpannel chunk (#36979)
Browse files Browse the repository at this point in the history
## 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: 7288e91
> <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 -->
  • Loading branch information
vsvamsi1 authored Oct 20, 2024
1 parent 9a315ea commit 631abe8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
23 changes: 14 additions & 9 deletions app/client/src/ce/sagas/userSagas.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -190,29 +190,34 @@ 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());
}
}
}

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

const isFFFetched: boolean = yield select(getFeatureFlagsFetched);

if (!isFFFetched) {
Expand Down
4 changes: 2 additions & 2 deletions app/client/src/pages/Editor/HelpButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
});
Expand Down

0 comments on commit 631abe8

Please sign in to comment.