Skip to content

Commit

Permalink
Merge pull request #29749 from appsmithorg/chore/analytics-events-int…
Browse files Browse the repository at this point in the history
…ercom-consent-cherry-pick

chore: Analytics events for intercom consent cherry pick
  • Loading branch information
trishaanand authored Dec 20, 2023
2 parents ca2271e + 3aedf01 commit 05d4b18
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/client/src/ce/utils/analyticsUtilTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ export type EventName =
| "STARTER_BUILDING_BLOCK_HOVER"
| "STARTER_BUILDING_BLOCK_CONNECT_DATA_CLICK"
| "START_FROM_TEMPLATES_CLICK_SKIP_BUTTON"
| "SUPPORT_REQUEST_INITIATED"
| ONBOARDING_FLOW_EVENTS;

export type ONBOARDING_FLOW_EVENTS =
Expand Down
9 changes: 9 additions & 0 deletions app/client/src/pages/Editor/HelpButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export function IntercomConsent({
const dispatch = useDispatch();

const sendUserDataToIntercom = () => {
const { email } = user || {};
updateIntercomProperties(instanceId, user);
dispatch(
updateUserDetails({
Expand All @@ -114,6 +115,14 @@ export function IntercomConsent({
);
dispatch(updateIntercomConsent());
showIntercomConsent(false);

if (user?.enableTelemetry) {
AnalyticsUtil.identifyUser(user, true);
AnalyticsUtil.logEvent("SUPPORT_REQUEST_INITIATED", {
email,
});
}

window.Intercom("show");
};
return (
Expand Down
12 changes: 10 additions & 2 deletions app/client/src/utils/AnalyticsUtil.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ class AnalyticsUtil {
}
}

static identifyUser(userData: User) {
const { segment, sentry, smartLook } = getAppsmithConfigs();
static identifyUser(userData: User, sendAdditionalData?: boolean) {
const { appVersion, segment, sentry, smartLook } = getAppsmithConfigs();
const windowDoc: any = window;
const userId = userData.username;
if (windowDoc.analytics) {
Expand All @@ -205,6 +205,14 @@ class AnalyticsUtil {
const userProperties = {
userId: AnalyticsUtil.cachedAnonymoustId,
source: "ce",
...(sendAdditionalData
? {
id: AnalyticsUtil.cachedAnonymoustId,
email: userData.email,
appsmithVersion: `Appsmith ${appVersion.edition} ${appVersion.id}`,
instanceId: AnalyticsUtil.instanceId,
}
: {}),
};
log.debug(
"Identify Anonymous User " + AnalyticsUtil.cachedAnonymoustId,
Expand Down

0 comments on commit 05d4b18

Please sign in to comment.