Skip to content

Commit

Permalink
feat: Improve MEV analytics (#8434)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcayuelas-ledger authored Nov 22, 2024
1 parent cd565e3 commit 3eee976
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/afraid-poems-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"ledger-live-desktop": minor
"live-mobile": minor
---

Improve MEV analytics
14 changes: 14 additions & 0 deletions apps/ledger-live-desktop/src/renderer/analytics/segment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
languageSelector,
lastSeenDeviceSelector,
localeSelector,
mevProtectionSelector,
shareAnalyticsSelector,
sharePersonalizedRecommendationsSelector,
sidebarCollapsedSelector,
Expand Down Expand Up @@ -77,6 +78,17 @@ const getLedgerSyncAttributes = (state: State) => {
};
};

const getMEVAttributes = (state: State) => {
if (!analyticsFeatureFlagMethod) return false;
const mevProtection = analyticsFeatureFlagMethod("llMevProtection");

const hasMEVActivated = mevProtectionSelector(state);

return {
MEVProtectionActivated: !mevProtection?.enabled ? "Null" : hasMEVActivated ? "Yes" : "No",
};
};

const getPtxAttributes = () => {
if (!analyticsFeatureFlagMethod) return {};
const fetchAdditionalCoins = analyticsFeatureFlagMethod("fetchAdditionalCoins");
Expand Down Expand Up @@ -148,6 +160,7 @@ const extraProperties = (store: ReduxStore) => {
const ptxAttributes = getPtxAttributes();

const ledgerSyncAtributes = getLedgerSyncAttributes(state);
const mevProtectionAtributes = getMEVAttributes(state);

const deviceInfo = device
? {
Expand Down Expand Up @@ -203,6 +216,7 @@ const extraProperties = (store: ReduxStore) => {
...ptxAttributes,
...deviceInfo,
...ledgerSyncAtributes,
...mevProtectionAtributes,
};
};

Expand Down
14 changes: 14 additions & 0 deletions apps/ledger-live-mobile/src/analytics/segment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
userNpsSelector,
personalizedRecommendationsEnabledSelector,
hasSeenAnalyticsOptInPromptSelector,
mevProtectionSelector,
} from "../reducers/settings";
import { knownDevicesSelector } from "../reducers/ble";
import { DeviceLike, State } from "../reducers/types";
Expand Down Expand Up @@ -117,6 +118,17 @@ const getRebornAttributes = () => {
};
};

const getMEVAttributes = (state: State) => {
if (!analyticsFeatureFlagMethod) return false;
const mevProtection = analyticsFeatureFlagMethod("llMevProtection");

const hasMEVActivated = mevProtectionSelector(state);

return {
MEVProtectionActivated: !mevProtection?.enabled ? "Null" : hasMEVActivated ? "Yes" : "No",
};
};

const getMandatoryProperties = async (store: AppStore) => {
const state: State = store.getState();
const { user } = await getOrCreateUser();
Expand Down Expand Up @@ -197,6 +209,7 @@ const extraProperties = async (store: AppStore) => {

const ledgerSyncAtributes = getLedgerSyncAttributes(state);
const rebornAttributes = getRebornAttributes();
const mevProtectionAtributes = getMEVAttributes(state);

return {
...mandatoryProperties,
Expand Down Expand Up @@ -234,6 +247,7 @@ const extraProperties = async (store: AppStore) => {
stakingProvidersEnabled: stakingProvidersCount || "flag not loaded",
...ledgerSyncAtributes,
...rebornAttributes,
...mevProtectionAtributes,
};
};

Expand Down

0 comments on commit 3eee976

Please sign in to comment.