Skip to content

Commit

Permalink
fix: Rename DAPP_VISITED to DAPP_VIEWED (#8838)
Browse files Browse the repository at this point in the history
## **Description**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

These changes renames `Dapp Visited` -> `Dapp Viewed` to match event
name with extension

Original mobile ticket here -
#8520

## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**


https://github.com/MetaMask/metamask-mobile/assets/10508597/b4aedbc6-6c8d-49c4-a9cb-20420636f789

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've clearly explained what problem this PR is solving and how it
is solved.
- [ ] I've linked related issues
- [ ] I've included manual testing steps
- [ ] I've included screenshots/recordings if applicable
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
- [ ] I’ve properly set the pull request status:
  - [ ] In case it's not yet "ready for review", I've set it to "draft".
- [ ] In case it's "ready for review", I've changed it from "draft" to
"non-draft".

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
Cal-L authored Mar 6, 2024
1 parent aa8536e commit f743ea0
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 248 deletions.
8 changes: 4 additions & 4 deletions app/actions/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
* Browser actions for Redux
*/
export const BrowserActionTypes = {
ADD_TO_VISITED_DAPP: 'ADD_TO_VISITED_DAPP',
ADD_TO_VIEWED_DAPP: 'ADD_TO_VIEWED_DAPP',
};

/**
* Adds a new entry to visited dapps
* Adds a new entry to viewed dapps
*
* @param {string} hostname - Dapp hostname
* @returns
*/
export function addToVisitedDapp(hostname) {
export function addToViewedDapp(hostname) {
return {
type: BrowserActionTypes.ADD_TO_VISITED_DAPP,
type: BrowserActionTypes.ADD_TO_VIEWED_DAPP,
hostname,
};
}
Expand Down
12 changes: 6 additions & 6 deletions app/components/Views/AccountConnect/AccountConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import useFavicon from '../../hooks/useFavicon/useFavicon';
import URLParse from 'url-parse';
import SDKConnect from '../../../core/SDKConnect/SDKConnect';
import AppConstants from '../../../../app/core/AppConstants';
import { trackDappVisitedEvent } from '../../../util/metrics';
import { trackDappViewedEvent } from '../../../util/metrics';
import { useMetrics } from '../../../components/hooks/useMetrics';
import { RootState } from '../../../../app/reducers';

Expand Down Expand Up @@ -171,10 +171,10 @@ const AccountConnect = (props: AccountConnectProps) => {
],
);

const triggerDappVisitedEvent = useCallback(
const triggerDappViewedEvent = useCallback(
(numberOfConnectedAccounts: number) =>
// Track dapp visited event
trackDappVisitedEvent({ hostname, numberOfConnectedAccounts }),
// Track dapp viewed event
trackDappViewedEvent({ hostname, numberOfConnectedAccounts }),
[hostname],
);

Expand Down Expand Up @@ -205,7 +205,7 @@ const AccountConnect = (props: AccountConnectProps) => {
request,
);

triggerDappVisitedEvent(connectedAccountLength);
triggerDappViewedEvent(connectedAccountLength);

trackEvent(MetaMetricsEvents.CONNECT_REQUEST_COMPLETED, {
number_of_accounts: accountsLength,
Expand Down Expand Up @@ -250,7 +250,7 @@ const AccountConnect = (props: AccountConnectProps) => {
toastRef,
accountsLength,
metadataOrigin,
triggerDappVisitedEvent,
triggerDappViewedEvent,
trackEvent,
]);

Expand Down
12 changes: 6 additions & 6 deletions app/components/Views/BrowserTab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ import { regex } from '../../../../app/util/regex';
import { selectChainId } from '../../../selectors/networkController';
import { BrowserViewSelectorsIDs } from '../../../../e2e/selectors/BrowserView.selectors';
import { useMetrics } from '../../../components/hooks/useMetrics';
import trackDappVisitedEvent from '../../../util/metrics/trackDappVisited';
import { trackDappViewedEvent } from '../../../util/metrics';
import trackErrorAsAnalytics from '../../../util/metrics/TrackError/trackErrorAsAnalytics';

const { HOMEPAGE_URL, NOTIFICATION_NAMES } = AppConstants;
Expand Down Expand Up @@ -531,7 +531,7 @@ export const BrowserTab = (props) => {
[goBack, props.ipfsGateway, setIpfsBannerVisible, props.chainId],
);

const triggerDappVisitedEvent = (url) => {
const triggerDappViewedEvent = (url) => {
const permissionsControllerState =
Engine.context.PermissionController.state;
const hostname = new URL(url).hostname;
Expand All @@ -545,8 +545,8 @@ export const BrowserTab = (props) => {
return;
}

// Track dapp visited event
trackDappVisitedEvent({
// Track dapp viewed event
trackDappViewedEvent({
hostname,
numberOfConnectedAccounts: connectedAccounts.length,
});
Expand Down Expand Up @@ -596,7 +596,7 @@ export const BrowserTab = (props) => {

// Skip tracking on initial open
if (!initialCall) {
triggerDappVisitedEvent(urlToGo);
triggerDappViewedEvent(urlToGo);
}

setProgress(0);
Expand Down Expand Up @@ -627,7 +627,7 @@ export const BrowserTab = (props) => {
const { current } = webviewRef;

current && current.reload();
triggerDappVisitedEvent(url.current);
triggerDappViewedEvent(url.current);
}, []);

/**
Expand Down
4 changes: 2 additions & 2 deletions app/core/Analytics/MetaMetrics.events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ enum EVENT_NAME {
BROWSER_RELOAD = 'Reload Browser',
BROWSER_ADD_FAVORITES = 'Added Site To Favorites',
BROWSER_SWITCH_TAB = 'Switched tab within Browser',
DAPP_VISITED = 'Dapp Visited',
DAPP_VIEWED = 'Dapp Viewed',

// Security & Privacy Settings
VIEW_SECURITY_SETTINGS = 'Views Security & Privacy',
Expand Down Expand Up @@ -534,7 +534,7 @@ const events = {
BROWSER_SHARE_SITE: generateOpt(EVENT_NAME.BROWSER_SHARE_SITE),
BROWSER_RELOAD: generateOpt(EVENT_NAME.BROWSER_RELOAD),
BROWSER_ADD_FAVORITES: generateOpt(EVENT_NAME.BROWSER_ADD_FAVORITES),
DAPP_VISITED: generateOpt(EVENT_NAME.DAPP_VISITED),
DAPP_VIEWED: generateOpt(EVENT_NAME.DAPP_VIEWED),
// Security & Privacy Settings
VIEW_SECURITY_SETTINGS: generateOpt(EVENT_NAME.VIEW_SECURITY_SETTINGS),
// Reveal SRP
Expand Down
4 changes: 2 additions & 2 deletions app/reducers/browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ const initialState = {
tabs: [],
favicons: [],
activeTab: null,
// Keep track of visited Dapps, which is used for MetaMetricsEvents.DAPP_VIEWED event
// Keep track of viewed Dapps, which is used for MetaMetricsEvents.DAPP_VIEWED event
visitedDappsByHostname: {},
};
const browserReducer = (state = initialState, action) => {
switch (action.type) {
case BrowserActionTypes.ADD_TO_VISITED_DAPP: {
case BrowserActionTypes.ADD_TO_VIEWED_DAPP: {
const { hostname } = action;
return {
...state,
Expand Down
4 changes: 2 additions & 2 deletions app/util/metrics/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import DeviceAnalyticsMetaData from './DeviceAnalyticsMetaData/generateDeviceAnalyticsMetaData';
import UserSettingsAnalyticsMetaData from './UserSettingsAnalyticsMetaData/generateUserProfileAnalyticsMetaData';
import TrackAfterInteractions from './TrackAfterInteraction/trackAfterInteractions';
import trackDappVisitedEvent from './trackDappVisitedEvent';
import trackDappViewedEvent from './trackDappViewedEvent';

export default DeviceAnalyticsMetaData;
export { UserSettingsAnalyticsMetaData };
export { TrackAfterInteractions };
export { trackDappVisitedEvent };
export { trackDappViewedEvent };
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import trackDappVisitedEvent from './index';
import trackDappViewedEvent from './index';
import { MetaMetrics, MetaMetricsEvents } from '../../../core/Analytics';

jest.mock('../../../core/Analytics/MetaMetrics');
Expand Down Expand Up @@ -34,7 +34,7 @@ jest.mock('../../../store', () => {
};
});

describe('trackDappVisitedEvent', () => {
describe('trackDappViewedEvent', () => {
afterEach(() => {
jest.clearAllMocks();
});
Expand All @@ -60,13 +60,13 @@ describe('trackDappVisitedEvent', () => {
source: 'in-app browser',
};

trackDappVisitedEvent({
trackDappViewedEvent({
hostname: 'uniswap.org',
numberOfConnectedAccounts: 1,
});

expect(mockMetrics.trackEvent).toBeCalledWith(
MetaMetricsEvents.DAPP_VISITED,
MetaMetricsEvents.DAPP_VIEWED,
expectedMetrics,
);
});
Expand All @@ -92,13 +92,13 @@ describe('trackDappVisitedEvent', () => {
source: 'in-app browser',
};

trackDappVisitedEvent({
trackDappViewedEvent({
hostname: 'uniswap.org',
numberOfConnectedAccounts: 1,
});

expect(mockMetrics.trackEvent).toBeCalledWith(
MetaMetricsEvents.DAPP_VISITED,
MetaMetricsEvents.DAPP_VIEWED,
expectedMetrics,
);
});
Expand All @@ -124,13 +124,13 @@ describe('trackDappVisitedEvent', () => {
source: 'in-app browser',
};

trackDappVisitedEvent({
trackDappViewedEvent({
hostname: 'uniswap.org',
numberOfConnectedAccounts: 1,
});

expect(mockMetrics.trackEvent).toBeCalledWith(
MetaMetricsEvents.DAPP_VISITED,
MetaMetricsEvents.DAPP_VIEWED,
expectedMetrics,
);
});
Expand All @@ -156,13 +156,13 @@ describe('trackDappVisitedEvent', () => {
source: 'in-app browser',
};

trackDappVisitedEvent({
trackDappViewedEvent({
hostname: 'uniswap.org',
numberOfConnectedAccounts: 1,
});

expect(mockMetrics.trackEvent).toBeCalledWith(
MetaMetricsEvents.DAPP_VISITED,
MetaMetricsEvents.DAPP_VIEWED,
expectedMetrics,
);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { store } from '../../../store';
import { selectIdentities } from '../../../selectors/preferencesController';
import { addToVisitedDapp } from '../../../actions/browser';
import { addToViewedDapp } from '../../../actions/browser';
import { MetaMetrics, MetaMetricsEvents } from '../../../core/Analytics';

/**
* Tracks Dapp visited event
* Tracks Dapp viewed event
*
* This is used to track when a user visits a Dapp in the in-app browser
* This is used to track when a user viewed a Dapp in the in-app browser
*
* @param params - The parameter object for the tracking function
* @param params.hostname - Hostname of the Dapp
* @param params.numberOfConnectedAccounts - Number of connected accounts that are connected to the Dapp
*/
const trackDappVisitedEvent = ({
const trackDappViewedEvent = ({
hostname,
numberOfConnectedAccounts,
}: {
Expand All @@ -25,15 +25,15 @@ const trackDappVisitedEvent = ({
const accountByAddress = selectIdentities(store.getState());
const numberOfWalletAccounts = Object.keys(accountByAddress).length;

// Add Dapp hostname to visited dapps
store.dispatch(addToVisitedDapp(hostname));
// Add Dapp hostname to viewed dapps
store.dispatch(addToViewedDapp(hostname));

MetaMetrics.getInstance().trackEvent(MetaMetricsEvents.DAPP_VISITED, {
MetaMetrics.getInstance().trackEvent(MetaMetricsEvents.DAPP_VIEWED, {
is_first_visit: isFirstVisit,
number_of_accounts: numberOfWalletAccounts,
number_of_accounts_connected: numberOfConnectedAccounts,
source: 'in-app browser',
});
};

export default trackDappVisitedEvent;
export default trackDappViewedEvent;
Loading

0 comments on commit f743ea0

Please sign in to comment.