Skip to content

Commit 4c3f1cc

Browse files
authored
Merge pull request #1991 from gmx-io/hotfix-earn-page-metrics
Hotfix update earn page metrics
2 parents 3ac206f + 95dddf2 commit 4c3f1cc

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

src/App/AppRoutes.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { REFERRAL_CODE_QUERY_PARAM, getAppBaseUrl } from "lib/legacy";
1616
import { useAccountInitedMetric, useOpenAppMetric } from "lib/metrics";
1717
import { useConfigureMetrics } from "lib/metrics/useConfigureMetrics";
1818
import { useHashQueryParams } from "lib/useHashQueryParams";
19+
import { sendEarnPageViewEvent } from "lib/userAnalytics/earnEvents";
1920
import { useConfigureUserAnalyticsProfile } from "lib/userAnalytics/useConfigureUserAnalyticsProfile";
2021
import { useWalletConnectedUserAnalyticsEvent } from "lib/userAnalytics/useWalletConnectedEvent";
2122
import useRouteQuery from "lib/useRouteQuery";
@@ -114,6 +115,13 @@ export function AppRoutes() {
114115
}
115116
}, [urlParams, history]);
116117

118+
const isEarnPage = history.location.pathname.startsWith("/earn");
119+
useEffect(() => {
120+
if (isEarnPage) {
121+
sendEarnPageViewEvent();
122+
}
123+
}, [isEarnPage]);
124+
117125
useRealChainIdWarning();
118126
useNonEoaAccountChainWarning();
119127

src/lib/userAnalytics/earnEvents.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ export type EarnAnalyticsTab = "discover" | "portfolio" | "additionalOpportuniti
44

55
export type EarnPageViewEvent = {
66
event: "EarnPageView";
7-
data: {
8-
tab: EarnAnalyticsTab;
9-
};
7+
data: {};
108
};
119

1210
export type EarnPageActionEvent = {
@@ -20,7 +18,7 @@ export type EarnPageActionEvent = {
2018
export type EarnRecommendationContext = "AboutTokens" | "YieldLandscape" | "PortfolioRecommendations";
2119
export type EarnRecommendationToken = "GM" | "GLV" | "GMX";
2220
export type EarnPageRecommendationClickedEvent = {
23-
event: "EarnPage";
21+
event: "EarnPageAction";
2422
data: {
2523
action: "RecommendationClicked";
2624
activeTab: EarnAnalyticsTab;
@@ -32,7 +30,7 @@ export type EarnPageRecommendationClickedEvent = {
3230
export type EarnPagePortfolioItem = "GMX" | "esGMX" | "GLV" | "GM";
3331
export type EarnPagePortfolioItemType = "stake" | "vest" | "buy" | "sell" | "details";
3432
export type EarnPagePortfolioItemClickEvent = {
35-
event: "EarnPage";
33+
event: "EarnPageAction";
3634
data: {
3735
action: "PortfolioItemClick";
3836
item: EarnPagePortfolioItem;
@@ -50,27 +48,25 @@ export type EarnPageOpportunitiesAnalyticsFilter =
5048
| "YieldTrading";
5149

5250
export type EarnPageOpportunitiesFilterAppliedEvent = {
53-
event: "EarnPage";
51+
event: "EarnPageAction";
5452
data: {
5553
action: "OpportunitiesFilterApplied";
5654
filter: EarnPageOpportunitiesAnalyticsFilter;
5755
};
5856
};
5957

6058
export type EarnPageOpportunityClickedEvent = {
61-
event: "EarnPage";
59+
event: "EarnPageAction";
6260
data: {
6361
action: "OpportunityClicked";
6462
name: string;
6563
};
6664
};
6765

68-
export function sendEarnPageViewEvent(tab: EarnAnalyticsTab) {
66+
export function sendEarnPageViewEvent() {
6967
userAnalytics.pushEvent<EarnPageViewEvent>({
7068
event: "EarnPageView",
71-
data: {
72-
tab,
73-
},
69+
data: {},
7470
});
7571
}
7672

@@ -94,7 +90,7 @@ export function sendEarnRecommendationClickedEvent({
9490
token: EarnRecommendationToken;
9591
}) {
9692
userAnalytics.pushEvent<EarnPageRecommendationClickedEvent>({
97-
event: "EarnPage",
93+
event: "EarnPageAction",
9894
data: {
9995
action: "RecommendationClicked",
10096
activeTab,
@@ -112,7 +108,7 @@ export function sendEarnPortfolioItemClickEvent({
112108
type: EarnPagePortfolioItemType;
113109
}) {
114110
userAnalytics.pushEvent<EarnPagePortfolioItemClickEvent>({
115-
event: "EarnPage",
111+
event: "EarnPageAction",
116112
data: {
117113
action: "PortfolioItemClick",
118114
item,
@@ -123,7 +119,7 @@ export function sendEarnPortfolioItemClickEvent({
123119

124120
export function sendEarnOpportunitiesFilterAppliedEvent(filter: EarnPageOpportunitiesAnalyticsFilter) {
125121
userAnalytics.pushEvent<EarnPageOpportunitiesFilterAppliedEvent>({
126-
event: "EarnPage",
122+
event: "EarnPageAction",
127123
data: {
128124
action: "OpportunitiesFilterApplied",
129125
filter,
@@ -133,7 +129,7 @@ export function sendEarnOpportunitiesFilterAppliedEvent(filter: EarnPageOpportun
133129

134130
export function sendEarnOpportunityClickedEvent(name: string) {
135131
userAnalytics.pushEvent<EarnPageOpportunityClickedEvent>({
136-
event: "EarnPage",
132+
event: "EarnPageAction",
137133
data: {
138134
action: "OpportunityClicked",
139135
name,

src/pages/Earn/EarnPageLayout.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useLocation } from "react-router-dom";
44

55
import { LAST_EARN_TAB_KEY } from "config/localStorage";
66
import { useLocalStorageSerializeKey } from "lib/localStorage";
7-
import { sendEarnPageTabViewEvent, sendEarnPageViewEvent, EarnAnalyticsTab } from "lib/userAnalytics/earnEvents";
7+
import { sendEarnPageTabViewEvent, EarnAnalyticsTab } from "lib/userAnalytics/earnEvents";
88

99
import AppPageLayout from "components/AppPageLayout/AppPageLayout";
1010
import Button from "components/Button/Button";
@@ -73,7 +73,6 @@ export default function EarnPageLayout({ children }: EarnPageLayoutProps) {
7373
return;
7474
}
7575

76-
sendEarnPageViewEvent(analyticsTab);
7776
sendEarnPageTabViewEvent(analyticsTab);
7877
}, [analyticsTab]);
7978

0 commit comments

Comments
 (0)