Skip to content

Commit

Permalink
[DDW-809] Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Mazurek committed Jun 28, 2022
1 parent b4a5571 commit 2759b03
Show file tree
Hide file tree
Showing 20 changed files with 146 additions and 68 deletions.
2 changes: 1 addition & 1 deletion source/renderer/app/analytics/index.ts
@@ -1,3 +1,3 @@
export { AnalyticsAcceptanceStatus } from './types';
export { AnalyticsAcceptanceStatus, EventCategories } from './types';
export type { AnalyticsClient, AnalyticsTracker } from './types';
export { noopAnalyticsTracker } from './NoopAnalyticsTracker';
11 changes: 10 additions & 1 deletion source/renderer/app/analytics/types.ts
Expand Up @@ -13,5 +13,14 @@ export interface AnalyticsTracker {
enableTracking(): Promise<void>;
disableTracking(): void;
sendPageNavigationEvent(pageTitle: string): void;
sendEvent(category: string, name: string, action?: string): void;
sendEvent(category: EventCategories, name: string, action?: string): void;
}

export enum EventCategories {
WALLETS = 'Wallets',
STAKE_POOLS = 'Stake Pools',
SETTINGS = 'Settings',
LAYOUT = 'Layout',
SYSTEM_MENU = 'System Menu',
VOTING = 'Voting',
}
Expand Up @@ -23,7 +23,7 @@ import {
import smashSettingsIcon from '../../../assets/images/smash-settings-ic.inline.svg';
import tinySpinnerIcon from '../../../assets/images/spinner-tiny.inline.svg';
import { getSmashServerNameFromUrl } from '../../../utils/staking';
import { AnalyticsTracker } from '../../../analytics';
import { AnalyticsTracker, EventCategories } from '../../../analytics';

const messages = defineMessages({
delegatingListTitle: {
Expand Down Expand Up @@ -120,7 +120,7 @@ class StakePools extends Component<Props, State> {
sendSearchAnalyticsEvent = debounce(
() =>
this.props.analyticsTracker.sendEvent(
'Stake Pools',
EventCategories.STAKE_POOLS,
'Used stake pools search'
),
5000
Expand All @@ -147,7 +147,7 @@ class StakePools extends Component<Props, State> {
});

this.props.analyticsTracker.sendEvent(
'Stake Pools',
EventCategories.STAKE_POOLS,
'Changed view to grid view'
);
};
Expand All @@ -159,7 +159,7 @@ class StakePools extends Component<Props, State> {
});

this.props.analyticsTracker.sendEvent(
'Stake Pools',
EventCategories.STAKE_POOLS,
'Changed view to grid rewards view'
);
};
Expand All @@ -171,7 +171,7 @@ class StakePools extends Component<Props, State> {
});

this.props.analyticsTracker.sendEvent(
'Stake Pools',
EventCategories.STAKE_POOLS,
'Changed view to list view'
);
};
Expand Down
6 changes: 3 additions & 3 deletions source/renderer/app/components/wallet/WalletSendForm.tsx
Expand Up @@ -41,7 +41,7 @@ import { DiscreetWalletAmount } from '../../features/discreet-mode';
import WalletTokenPicker from './tokens/wallet-token-picker/WalletTokenPicker';
import { ClearButton } from './widgets/ClearButton';
import { Divider } from './widgets/Divider';
import { AnalyticsTracker } from '../../analytics';
import { AnalyticsTracker, EventCategories } from '../../analytics';

messages.fieldIsRequired = globalMessages.fieldIsRequired;
type AdaInputState = 'restored' | 'updated' | 'reset' | 'none';
Expand Down Expand Up @@ -709,7 +709,7 @@ class WalletSendForm extends Component<Props, State> {
this.removeAssetFields(uniqueId);
await this.calculateTransactionFee(true);
this.props.analyticsTracker.sendEvent(
'Wallets',
EventCategories.WALLETS,
'Removed token from transaction'
);
}
Expand Down Expand Up @@ -1170,7 +1170,7 @@ class WalletSendForm extends Component<Props, State> {
onTokenPickerDialogClose();
checked.forEach(this.addAssetRow);
this.props.analyticsTracker.sendEvent(
'Wallets',
EventCategories.WALLETS,
'Added token to transaction'
);
}}
Expand Down
Expand Up @@ -16,7 +16,7 @@ import { SimpleTransactionList } from './render-strategies/SimpleTransactionList
import { TransactionInfo, TransactionsGroup } from './types';
import type { Row } from './types';
import { getNonZeroAssetTokens } from '../../../utils/assets';
import { AnalyticsTracker } from '../../../analytics';
import { AnalyticsTracker, EventCategories } from '../../../analytics';

const messages = defineMessages({
today: {
Expand Down Expand Up @@ -206,7 +206,7 @@ class WalletTransactionsList extends Component<Props, State> {
if (this.props.onShowMoreTransactions) {
this.props.onShowMoreTransactions(walletId);
this.props.analyticsTracker.sendEvent(
'Wallet Details',
EventCategories.WALLETS,
'Clicked Show More Transactions button'
);
}
Expand Down
6 changes: 3 additions & 3 deletions source/renderer/app/features/discreet-mode/feature.ts
Expand Up @@ -5,7 +5,7 @@ import { DiscreetModeApi } from './api';
import { SENSITIVE_DATA_SYMBOL } from './config';
import { defaultReplacer } from './replacers/defaultReplacer';
import type { ReplacerFn } from './types';
import { AnalyticsTracker } from '../../analytics';
import { AnalyticsTracker, EventCategories } from '../../analytics';

export class DiscreetMode extends Feature {
constructor(
Expand Down Expand Up @@ -52,7 +52,7 @@ export class DiscreetMode extends Feature {
toggleDiscreetMode = () => {
this.isDiscreetMode = !this.isDiscreetMode;
this.analyticsTracker.sendEvent(
'Settings',
EventCategories.SETTINGS,
this.isDiscreetMode
? 'Turned on discreet mode'
: 'Turned off discreet mode'
Expand All @@ -67,7 +67,7 @@ export class DiscreetMode extends Feature {
this.openInDiscreetMode = nextSetting;
});
this.analyticsTracker.sendEvent(
'Settings',
EventCategories.SETTINGS,
this.isDiscreetMode
? 'Turned on discreet mode by default'
: 'Turned off discreet mode by default'
Expand Down
30 changes: 18 additions & 12 deletions source/renderer/app/stores/AppStore.ts
Expand Up @@ -15,6 +15,7 @@ import { getGPUStatusChannel } from '../ipc/get-gpu-status.ipc';
import { generateFileNameWithTimestamp } from '../../../common/utils/files';
import type { GpuStatus } from '../types/gpuStatus';
import type { ApplicationDialog } from '../types/applicationDialogTypes';
import { EventCategories } from '../analytics';

export default class AppStore extends Store {
@observable
Expand Down Expand Up @@ -89,7 +90,7 @@ export default class AppStore extends Store {
this.newsFeedIsOpen = !this.newsFeedIsOpen;

if (this.newsFeedIsOpen) {
this._sendAnalyticsEvent('Topbar', 'Opened newsfeed');
this.analytics.sendEvent(EventCategories.LAYOUT, 'Opened newsfeed');
}
};
@action
Expand Down Expand Up @@ -118,37 +119,46 @@ export default class AppStore extends Store {
case DIALOGS.ABOUT:
// @ts-ignore ts-migrate(2345) FIXME: Argument of type 'string' is not assignable to par... Remove this comment to see the full error message
this._updateActiveDialog(DIALOGS.ABOUT);
this._sendAnalyticsEvent('System menu', 'Showed about dialog');
this.analytics.sendEvent(
EventCategories.SYSTEM_MENU,
'Showed about dialog'
);
break;

case DIALOGS.DAEDALUS_DIAGNOSTICS:
// @ts-ignore ts-migrate(2345) FIXME: Argument of type 'string' is not assignable to par... Remove this comment to see the full error message
this._updateActiveDialog(DIALOGS.DAEDALUS_DIAGNOSTICS);
this._sendAnalyticsEvent('System menu', 'Showed diagnostics dialog');
this.analytics.sendEvent(
EventCategories.SYSTEM_MENU,
'Showed diagnostics dialog'
);

break;

case DIALOGS.TOGGLE_RTS_FLAGS_MODE:
// @ts-ignore ts-migrate(2345) FIXME: Argument of type 'string' is not assignable to par... Remove this comment to see the full error message
this._updateActiveDialog(DIALOGS.TOGGLE_RTS_FLAGS_MODE);
this._sendAnalyticsEvent(
'System menu',
this.analytics.sendEvent(
EventCategories.SYSTEM_MENU,
'Showed toggle RTS flags dialog'
);
break;

case DIALOGS.ITN_REWARDS_REDEMPTION:
// @ts-ignore ts-migrate(2554) FIXME: Expected 1 arguments, but got 0.
this.actions.staking.onRedeemStart.trigger();
this._sendAnalyticsEvent(
'System menu',
this.analytics.sendEvent(
EventCategories.SYSTEM_MENU,
'Showed ITN rewards redemption dialog'
);
break;

case NOTIFICATIONS.DOWNLOAD_LOGS:
this._downloadLogs();
this._sendAnalyticsEvent('System menu', 'Downloaded logs');
this.analytics.sendEvent(
EventCategories.SYSTEM_MENU,
'Downloaded logs'
);
break;

case PAGES.SETTINGS:
Expand Down Expand Up @@ -247,8 +257,4 @@ export default class AppStore extends Store {
_setIsDownloadingLogs = (isDownloadNotificationVisible: boolean) => {
this.isDownloadNotificationVisible = isDownloadNotificationVisible;
};

_sendAnalyticsEvent = (category: string, actionName: string) => {
this.analytics.sendEvent(category, actionName);
};
}
8 changes: 6 additions & 2 deletions source/renderer/app/stores/AssetsStore.ts
Expand Up @@ -6,6 +6,7 @@ import Asset from '../domains/Asset';
import { ROUTES } from '../routes-config';
import { ellipsis } from '../utils/strings';
import type { GetAssetsResponse, AssetToken } from '../api/assets/types';
import { EventCategories } from '../analytics';

type WalletId = string;
export default class AssetsStore extends Store {
Expand Down Expand Up @@ -108,7 +109,10 @@ export default class AssetsStore extends Store {
decimals,
});

this.analytics.sendEvent('Wallets', 'Changed native token settings');
this.analytics.sendEvent(
EventCategories.WALLETS,
'Changed native token settings'
);
};
@action
_onEditedAssetUnset = () => {
Expand Down Expand Up @@ -197,7 +201,7 @@ export default class AssetsStore extends Store {
await this.favoritesRequest.execute();

this.analytics.sendEvent(
'Wallets',
EventCategories.WALLETS,
!isFavorite
? 'Added token from favorites'
: 'Removed token from favorites'
Expand Down
9 changes: 7 additions & 2 deletions source/renderer/app/stores/CurrencyStore.ts
Expand Up @@ -7,6 +7,7 @@ import {
getCurrencyFromCode,
} from '../config/currencyConfig';
import type { Currency, LocalizedCurrency } from '../types/currencyTypes';
import { EventCategories } from '../analytics';

export default class CurrencyStore extends Store {
@observable
Expand Down Expand Up @@ -128,15 +129,19 @@ export default class CurrencyStore extends Store {
await this.api.localStorage.setCurrencySelected(selected.code);
}

this.analytics.sendEvent('Settings', 'Changed currency', code);
this.analytics.sendEvent(
EventCategories.SETTINGS,
'Changed currency',
code
);
};
@action
_toggleCurrencyIsActive = () => {
this.isActive = !this.isActive;
this.api.localStorage.setCurrencyIsActive(this.isActive);

this.analytics.sendEvent(
'Settings',
EventCategories.SETTINGS,
`Turned ${
this.isActive ? 'on' : 'off'
} displaying ada balances in other currency`
Expand Down
5 changes: 3 additions & 2 deletions source/renderer/app/stores/HardwareWalletsStore.ts
Expand Up @@ -101,6 +101,7 @@ import type {
TrezorWitness,
} from '../../../common/types/hardware-wallets.types';
import { logger } from '../utils/logging';
import { EventCategories } from '../analytics';

export type TxSignRequestTypes = {
coinSelection: CoinSelectionsResponse;
Expand Down Expand Up @@ -526,7 +527,7 @@ export default class HardwareWalletsStore extends Store {
);

this.analytics.sendEvent(
'Wallets',
EventCategories.WALLETS,
'Transaction made',
'Hardware wallet'
);
Expand Down Expand Up @@ -1472,7 +1473,7 @@ export default class HardwareWalletsStore extends Store {
}

this.analytics.sendEvent(
'Wallets',
EventCategories.WALLETS,
'Verified wallet address with hardware wallet'
);
} else {
Expand Down
3 changes: 2 additions & 1 deletion source/renderer/app/stores/NetworkStatusStore.ts
Expand Up @@ -42,6 +42,7 @@ import type { CheckDiskSpaceResponse } from '../../../common/types/no-disk-space
import { TlsCertificateNotValidError } from '../api/nodes/errors';
import { openLocalDirectoryChannel } from '../ipc/open-local-directory';
import { toggleRTSFlagsModeChannel } from '../ipc/toggleRTSFlagsModeChannel';
import { EventCategories } from '../analytics';

// DEFINE CONSTANTS -------------------------
const NETWORK_STATUS = {
Expand Down Expand Up @@ -432,7 +433,7 @@ export default class NetworkStatusStore extends Store {
// DEFINE ACTIONS
@action _toggleRTSFlagsMode = async () => {
this.analytics.sendEvent(
'Settings',
EventCategories.SETTINGS,
`RTS flags ${this.isRTSFlagsModeEnabled ? 'disabled' : 'enabled'}`
);
await toggleRTSFlagsModeChannel.send();
Expand Down
10 changes: 7 additions & 3 deletions source/renderer/app/stores/ProfileStore.ts
Expand Up @@ -41,7 +41,7 @@ import {
TIME_OPTIONS,
} from '../config/profileConfig';
import { buildSystemInfo } from '../utils/buildSystemInfo';
import { AnalyticsAcceptanceStatus } from '../analytics/types';
import { AnalyticsAcceptanceStatus, EventCategories } from '../analytics/types';

export default class ProfileStore extends Store {
@observable
Expand Down Expand Up @@ -370,15 +370,19 @@ export default class ProfileStore extends Store {
this.stores.wallets.refreshWalletsData();
}

this.analytics.sendEvent('Settings', 'Changed user settings', param);
this.analytics.sendEvent(
EventCategories.SETTINGS,
'Changed user settings',
param
);
};
_updateTheme = async ({ theme }: { theme: string }) => {
// @ts-ignore ts-migrate(1320) FIXME: Type of 'await' operand must either be a valid pro... Remove this comment to see the full error message
await this.setThemeRequest.execute(theme);
// @ts-ignore ts-migrate(1320) FIXME: Type of 'await' operand must either be a valid pro... Remove this comment to see the full error message
await this.getThemeRequest.execute();

this.analytics.sendEvent('Settings', 'Changed theme', theme);
this.analytics.sendEvent(EventCategories.SETTINGS, 'Changed theme', theme);
};
_acceptTermsOfUse = async () => {
// @ts-ignore ts-migrate(1320) FIXME: Type of 'await' operand must either be a valid pro... Remove this comment to see the full error message
Expand Down

0 comments on commit 2759b03

Please sign in to comment.