Skip to content

Commit

Permalink
Merge pull request input-output-hk#3041 from input-output-hk/feat/ddw…
Browse files Browse the repository at this point in the history
…-1125-analytics-prepare-release-backup

 [DDW-1125] Analytics
  • Loading branch information
danielmain authored Sep 26, 2022
2 parents 8f04188 + ef36d89 commit 8e6b5b5
Show file tree
Hide file tree
Showing 70 changed files with 886 additions and 191 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## vNext

### Features

- Added analytics data collection ([PR 2927](https://github.com/input-output-hk/daedalus/pull/2927), [PR 2989](https://github.com/input-output-hk/daedalus/pull/2989), [PR 3003](https://github.com/input-output-hk/daedalus/pull/3003), [PR 3028](https://github.com/input-output-hk/daedalus/pull/3028))

## 5.0.0

### Features
Expand Down
32 changes: 32 additions & 0 deletions matomo.docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: "3"
services:
mariadb:
image: docker.io/bitnami/mariadb:10.6
environment:
- ALLOW_EMPTY_PASSWORD=yes
- MARIADB_USER=bn_matomo
- MARIADB_DATABASE=bitnami_matomo
- MARIADB_EXTRA_FLAGS=--max_allowed_packet=64MB
volumes:
- "matomo_db_data:/bitnami/mariadb"
matomo:
image: docker.io/bitnami/matomo:4
ports:
- "8080:8080"
environment:
- MATOMO_DATABASE_HOST=mariadb
- MATOMO_DATABASE_PORT_NUMBER=3306
- MATOMO_DATABASE_USER=bn_matomo
- MATOMO_DATABASE_NAME=bitnami_matomo
- MATOMO_USERNAME=user
- MATOMO_PASSWORD=password
- ALLOW_EMPTY_PASSWORD=yes
volumes:
- "matomo_data:/bitnami/matomo"
depends_on:
- mariadb
volumes:
matomo_db_data:
driver: local
matomo_data:
driver: local
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@
"inquirer": "7.3.3",
"json-bigint": "1.0.0",
"lodash": "4.17.21",
"lodash-es": "4.17.21",
"lodash-es": "4.17.15",
"matomo-tracker": "2.2.4",
"mime-types": "2.1.27",
"mkdirp": "1.0.4",
"mobx": "5.15.7",
Expand Down
2 changes: 1 addition & 1 deletion source/main/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const isPreview = checkIsPreview(NETWORK);
const isShelleyQA = checkIsShelleyQA(NETWORK);
const isSelfnode = checkIsSelfnode(NETWORK);
const isDevelopment = checkIsDevelopment(NETWORK);
const analyticsFeatureEnabled = isMainnet || isStaging || isTestnet;
const analyticsFeatureEnabled = true;
const keepLocalClusterRunning = process.env.KEEP_LOCAL_CLUSTER_RUNNING;
const API_VERSION = process.env.API_VERSION || 'dev';
const NODE_VERSION = '1.35.3'; // TODO: pick up this value from process.env
Expand Down
24 changes: 1 addition & 23 deletions source/main/ipc/electronStoreConversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,7 @@ const unset = async (key: StorageKey) =>
});

const reset = async () => {
await unset(keys.APP_AUTOMATIC_UPDATE_FAILED);
await unset(keys.APP_UPDATE_COMPLETED);
await unset(keys.CURRENCY_ACTIVE);
await unset(keys.CURRENCY_SELECTED);
await unset(keys.DATA_LAYER_MIGRATION_ACCEPTANCE);
await unset(keys.DISCREET_MODE_ENABLED);
await unset(keys.DOWNLOAD_MANAGER);
await unset(keys.HARDWARE_WALLET_DEVICES);
await unset(keys.HARDWARE_WALLETS);
await unset(keys.READ_NEWS);
await unset(keys.SMASH_SERVER);
await unset(keys.STAKING_INFO_WAS_OPEN);
await unset(keys.STAKE_POOLS_LIST_VIEW_TOOLTIP);
await unset(keys.TERMS_OF_USE_ACCEPTANCE);
await unset(keys.THEME);
await unset(keys.USER_DATE_FORMAT_ENGLISH);
await unset(keys.USER_DATE_FORMAT_JAPANESE);
await unset(keys.USER_LOCALE);
await unset(keys.USER_NUMBER_FORMAT);
await unset(keys.USER_TIME_FORMAT);
await unset(keys.WALLET_MIGRATION_STATUS);
await unset(keys.WALLETS);
await unset(keys.WINDOW_BOUNDS);
await Promise.all(Object.values(keys).map(unset));
};

export const requestElectronStore = (request: ElectronStoreMessage) => {
Expand Down
2 changes: 2 additions & 0 deletions source/renderer/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import NewsFeedContainer from './containers/news/NewsFeedContainer';
import ToggleRTSFlagsDialogContainer from './containers/knownIssues/ToggleRTSFlagsDialogContainer';
import RTSFlagsRecommendationOverlayContainer from './containers/knownIssues/RTSFlagsRecommendationOverlayContainer';
import { MenuUpdater } from './containers/MenuUpdater';
import { AnalyticsProvider } from './components/analytics';
import { AnalyticsTracker } from './analytics';

@observer
class App extends Component<{
Expand Down
93 changes: 68 additions & 25 deletions source/renderer/app/Routes.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Switch, Route, Redirect, withRouter } from 'react-router-dom';
import { Redirect, Route, Switch, withRouter } from 'react-router-dom';
import { ROUTES } from './routes-config';
// PAGES
import Root from './containers/Root';
Expand Down Expand Up @@ -35,6 +35,7 @@ import WalletUtxoPage from './containers/wallet/WalletUtxoPage';
import VotingRegistrationPage from './containers/voting/VotingRegistrationPage';
import { IS_STAKING_INFO_PAGE_AVAILABLE } from './config/stakingConfig';
import AnalyticsConsentPage from './containers/profile/AnalyticsConsentPage';
import TrackedRoute from './analytics/TrackedRoute';

export const Routes = withRouter(() => (
<Route path={ROUTES.ROOT}>
Expand All @@ -54,37 +55,58 @@ export const Routes = withRouter(() => (
path={ROUTES.PROFILE.ANALYTICS}
component={AnalyticsConsentPage}
/>
<Route
<TrackedRoute
pageTitle="Data Layer Migration Page"
path={ROUTES.PROFILE.DATA_LAYER_MIGRATION}
component={DataLayerMigrationPage}
/>
<Route path={ROUTES.WALLETS.ADD} component={WalletAddPage} />
<TrackedRoute
pageTitle="Add Wallet"
path={ROUTES.WALLETS.ADD}
component={WalletAddPage}
/>
<Route path={ROUTES.WALLETS.ROOT}>
<Wallet>
<Route
exact
path={ROUTES.WALLETS.ROOT}
component={() => <Redirect to={ROUTES.WALLETS.SUMMARY} />}
/>
<Route
<TrackedRoute
pageTitle="Wallet Summary"
path={ROUTES.WALLETS.SUMMARY}
component={WalletSummaryPage}
/>
<Route path={ROUTES.WALLETS.SEND} component={WalletSendPage} />
<Route
<TrackedRoute
pageTitle="Send Screen"
path={ROUTES.WALLETS.SEND}
component={WalletSendPage}
/>
<TrackedRoute
pageTitle="Receive Screen"
path={ROUTES.WALLETS.RECEIVE}
component={WalletReceivePage}
/>
<Route path={ROUTES.WALLETS.TOKENS} component={WalletTokensPage} />
<Route
<TrackedRoute
pageTitle="Tokens"
path={ROUTES.WALLETS.TOKENS}
component={WalletTokensPage}
/>
<TrackedRoute
pageTitle="Transactions"
path={ROUTES.WALLETS.TRANSACTIONS}
component={WalletTransactionsPage}
/>
<Route
<TrackedRoute
pageTitle="Wallet Settings"
path={ROUTES.WALLETS.SETTINGS}
component={WalletSettingsPage}
/>
<Route path={ROUTES.WALLETS.UTXO} component={WalletUtxoPage} />
<TrackedRoute
pageTitle="Wallet UTxO distribution"
path={ROUTES.WALLETS.UTXO}
component={WalletUtxoPage}
/>
</Wallet>
</Route>
<Route path={ROUTES.SETTINGS.ROOT}>
Expand All @@ -94,31 +116,38 @@ export const Routes = withRouter(() => (
path={ROUTES.SETTINGS.ROOT}
component={() => <Redirect to={ROUTES.SETTINGS.GENERAL} />}
/>
<Route
<TrackedRoute
pageTitle="General Settings"
path={ROUTES.SETTINGS.GENERAL}
component={GeneralSettingsPage}
/>
<Route
<TrackedRoute
pageTitle="Wallets Settings"
path={ROUTES.SETTINGS.WALLETS}
component={WalletsSettingsPage}
/>
<Route
<TrackedRoute
pageTitle="Stake Pools Settings"
path={ROUTES.SETTINGS.STAKE_POOLS}
component={StakePoolsSettingsPage}
/>
<Route
<TrackedRoute
pageTitle="Terms of Use"
path={ROUTES.SETTINGS.TERMS_OF_USE}
component={TermsOfUseSettingsPage}
/>
<Route
<TrackedRoute
pageTitle="Support"
path={ROUTES.SETTINGS.SUPPORT}
component={SupportSettingsPage}
/>
<Route
<TrackedRoute
pageTitle="Display Settings"
path={ROUTES.SETTINGS.DISPLAY}
component={DisplaySettingsPage}
/>
<Route
<TrackedRoute
pageTitle="Security Settings"
path={ROUTES.SETTINGS.SECURITY}
component={SecuritySettingsPage}
/>
Expand All @@ -137,33 +166,47 @@ export const Routes = withRouter(() => (
<Redirect to={ROUTES.STAKING.DELEGATION_CENTER} />
)}
/>
<Route
<TrackedRoute
pageTitle="Staking Countdown"
path={ROUTES.STAKING.COUNTDOWN}
component={StakingCountdownPage}
/>
<Route
<TrackedRoute
pageTitle="Delegation Center"
path={ROUTES.STAKING.DELEGATION_CENTER}
component={DelegationCenterPage}
/>
<Route
<TrackedRoute
pageTitle="Stake Pools List"
path={ROUTES.STAKING.STAKE_POOLS}
component={StakePoolsListPage}
/>
<Route
<TrackedRoute
pageTitle="Staking Rewards"
path={ROUTES.STAKING.REWARDS}
component={StakingRewardsPage}
/>
<Route path={ROUTES.STAKING.EPOCHS} component={StakingEpochsPage} />
<TrackedRoute
pageTitle="Staking Epochs"
path={ROUTES.STAKING.EPOCHS}
component={StakingEpochsPage}
/>
{IS_STAKING_INFO_PAGE_AVAILABLE && (
<Route path={ROUTES.STAKING.INFO} component={StakingInfoPage} />
<TrackedRoute
pageTitle="Staking info"
path={ROUTES.STAKING.INFO}
component={StakingInfoPage}
/>
)}
</Staking>
<Route
<TrackedRoute
pageTitle="Redeem ITN rewards"
path={ROUTES.REDEEM_ITN_REWARDS}
component={RedeemItnRewardsContainer}
/>
</Route>
<Route
<TrackedRoute
pageTitle="Voting Registration"
path={ROUTES.VOTING.REGISTRATION}
component={VotingRegistrationPage}
/>
Expand Down
3 changes: 3 additions & 0 deletions source/renderer/app/actions/wallets-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
import type { CsvFileContent } from '../../../common/types/csv-request.types';
import type { QuitStakePoolRequest } from '../api/staking/types';
import type { AssetToken } from '../api/assets/types';
import Wallet from '../domains/Wallet';

export type WalletImportFromFileParams = {
filePath: string;
Expand Down Expand Up @@ -76,13 +77,15 @@ export default class WalletsActions {
note: string;
address: string;
filePath: string;
wallet: Wallet;
}> = new Action();
generateAddressPDFSuccess: Action<{
walletAddress: string;
}> = new Action();
saveQRCodeImage: Action<{
address: string;
filePath: string;
wallet: Wallet;
}> = new Action();
saveQRCodeImageSuccess: Action<{
walletAddress: string;
Expand Down
47 changes: 47 additions & 0 deletions source/renderer/app/analytics/MatomoAnalyticsTracker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { AnalyticsAcceptanceStatus, AnalyticsTracker } from '.';
import { AnalyticsClient } from './types';
import { Environment } from '../../../common/types/environment.types';
import LocalStorageApi from '../api/utils/localStorage';
import { MatomoClient } from './MatomoClient';
import { NoopAnalyticsClient } from './noopAnalyticsClient';

export class MatomoAnalyticsTracker implements AnalyticsTracker {
#analyticsClient: AnalyticsClient;

constructor(
private environment: Environment,
private localStorageApi: LocalStorageApi
) {
this.#analyticsClient = NoopAnalyticsClient;
this.#enableTrackingIfAccepted();
}

async enableTracking() {
this.#analyticsClient = new MatomoClient(
this.environment,
await this.localStorageApi.getUserID()
);
}

disableTracking() {
this.#analyticsClient = NoopAnalyticsClient;
}

sendPageNavigationEvent(pageTitle: string) {
return this.#analyticsClient.sendPageNavigationEvent(pageTitle);
}

sendEvent(category: string, name: string, action?: string) {
return this.#analyticsClient.sendEvent(category, name, action);
}

async #enableTrackingIfAccepted() {
const analyticsAccepted =
(await this.localStorageApi.getAnalyticsAcceptance()) ===
AnalyticsAcceptanceStatus.ACCEPTED;

if (this.environment.analyticsFeatureEnabled && analyticsAccepted) {
this.enableTracking();
}
}
}
Loading

0 comments on commit 8e6b5b5

Please sign in to comment.