1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-29 15:50:28 +01:00
metamask-extension/shared/constants/metametrics.js
MetaMask Bot 31d5c1cf22
Version v10.18.4 RC (#15643)
* Version v10.18.4

* Fix default currency symbol for `wallet_addEthereumChain` + improve warnings for data that doesn't match our validation expectations (#15201)

* set more appropriate default for ticker symbol when wallet_addEthereumChain is called

* throw error to dapp when site suggests network with same chainId but different ticker symbol from already added network, instead of showing error and disabled notification to user

* Fix Provider Tracking Metrics (#15082)

* fix filetype audit (#15334)

* Remove decentralized 4byte function signature registry since it contains incorrect signatures and we can't algorithmically check for best option when 4byte.directory is down (#15300)

* remove decentralized 4byte function signature registry since it is griefed and we can't algorithmically check for best option when 4byte is down

* add migration

* remove nock of on chain registry call in getMethodDataAsync test

* remove audit exclusion (#15346)

* Updates `eth-lattice-keyring` to v0.10.0 (#15261)

This is mainly associated with an update in GridPlus SDK and enables
better strategies for fetching calldata decoder data.
`eth-lattice-keyring` changes:
GridPlus/eth-lattice-keyring@v0.7.3...v0.10.0
`gridplus-sdk` changes (which includes a codebase rewrite):
GridPlus/gridplus-sdk@v1.2.3...v2.2.2

* Fix 'block link explorer on custom networks' (#13870)

* Created a logic for the 'Add a block explorer URL'

Removed unused message

Message logic rollback

Modified history push operation

WIP: Pushing before rebasing

Applied requested changes

Removed unintenionally added code

* Lint fix

* Metrics fixed

* Stop injecting provider on docs.google.com (#15459)

* Fix setting of gasPrice when on non-eip 1559 networks (#15628)

* Fix setting of gasPrice when on non-eip 1559 networks

* Fix unit tests

* Fix logic

* Update ui/ducks/send/send.test.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* [GridPlus] Bumps `eth-lattice-keyring` to v0.11.0 (#15490)

* [GridPlus] Bumps `gridplus-sdk` to v2.2.4 (#15561)

* remove exclusions for mismatched object jsdoc type casing (#15351)

* Improve `tokenId` parsing and clean up `useAssetDetails` hook (#15304)

* Fix state creation in setupSentryGetStateGlobal (#15635)

* filter breadcrumbs for improved clarity while debugging sentry errors (#15639)

* Update v10.18.4 changelog (#15645)

* Auto generated changelog

* Update 10.18.4 changelog

* Run lavamoat:auto

* Call metrics event for wallet type selection at the right time (#15591)

* Fix Sentry in LavaMoat contexts (#15672)

Our Sentry setup relies upon application state, but it wasn't able to
access it in LavaMoat builds because it's running in a separate
Compartment.

A patch has been introduced to the LavaMoat runtime to allow the root
Compartment to mutate the `rootGlobals` object, which is accessible
from outside the compartment as well. This lets us expose application
state to our Sentry integration.

* Fix Sentry deduplication of events that were never sent (#15677)

The Sentry `Dedupe` integration has been filtering out our events, even
when they were never sent due to our `beforeSend` handler. It was
wrongly identifying them as duplicates because it has no knowledge of
`beforeSend` or whether they were actually sent or not.

To resolve this, the filtering we were doing in `beforeSend` has been
moved to a Sentry integration. This integration is installed ahead of
the `Dedupe` integration, so `Dedupe` should never find out about any
events that we filter out, and thus will never consider them as sent
when they were not.

* Replace `lavamoat-runtime.js` patch (#15682)

A patch made in #15672 was found to be unnecessary. Instead of setting
a `rootGlobals` object upon construction of the root compartment, we
are now creating a `sentryHooks` object in the initial top-level
compartment. I hadn't realized at the time that the root compartment
would inherit all properties of the initial compartment `globalThis`.

This accomplishes the same goals as #15672 except without needing a
patch.

* Update v10.18.4 changelog

* Fix lint issues

* Update yarn.lock

* Update `depcheck` to latest version (#15690)

`depcheck` has been updated to the latest version. This version pins
`@babel/parser` to v7.16.4 because of unresolved bugs in v7.16.5 that
result in `depcheck` failing to parse TypeScript files correctly.

We had a Yarn resolution in place to ensure `@babel/parser@7.16.4` was
being used already. That resolution is no longer needed so it has been
removed. This should resove the issue the dev team has been seeing
lately where `yarn` and `yarn-deduplicate` disagree about the state the
lockfile should be in.

* Update yarn.lock

* Update LavaMoat policy

* deduplicate

* Update LavaMoat build policy

Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
Co-authored-by: Alex Donesky <adonesky@gmail.com>
Co-authored-by: Brad Decker <bhdecker84@gmail.com>
Co-authored-by: Alex Miller <asmiller1989@gmail.com>
Co-authored-by: Filip Sekulic <filip.sekulic@consensys.net>
Co-authored-by: Erik Marks <25517051+rekmarks@users.noreply.github.com>
Co-authored-by: Dan J Miller <danjm.com@gmail.com>
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Co-authored-by: seaona <54408225+seaona@users.noreply.github.com>
Co-authored-by: seaona <mariona@gmx.es>
Co-authored-by: PeterYinusa <peter.yinusa@consensys.net>
2022-08-24 19:57:47 +01:00

338 lines
14 KiB
JavaScript

// Type Imports
/**
* @typedef {import('../../shared/constants/app').EnvironmentType} EnvironmentType
*/
// Type Declarations
/**
* Used to attach context of where the user was at in the application when the
* event was triggered. Also included as full details of the current page in
* page events.
*
* @typedef {object} MetaMetricsPageObject
* @property {string} [path] - the path of the current page (e.g /home)
* @property {string} [title] - the title of the current page (e.g 'home')
* @property {string} [url] - the fully qualified url of the current page
*/
/**
* For metamask, this is the dapp that triggered an interaction
*
* @typedef {object} MetaMetricsReferrerObject
* @property {string} [url] - the origin of the dapp issuing the
* notification
*/
/**
* We attach context to every meta metrics event that help to qualify our
* analytics. This type has all optional values because it represents a
* returned object from a method call. Ideally app and userAgent are
* defined on every event. This is confirmed in the getTrackMetaMetricsEvent
* function, but still provides the consumer a way to override these values if
* necessary.
*
* @typedef {object} MetaMetricsContext
* @property {object} app - Application metadata.
* @property {string} app.name - the name of the application tracking the event
* @property {string} app.version - the version of the application
* @property {string} userAgent - the useragent string of the user
* @property {MetaMetricsPageObject} [page] - an object representing details of
* the current page
* @property {MetaMetricsReferrerObject} [referrer] - for metamask, this is the
* dapp that triggered an interaction
*/
/**
* @typedef {object} MetaMetricsEventPayload
* @property {string} event - event name to track
* @property {string} category - category to associate event to
* @property {string} [environmentType] - The type of environment this event
* occurred in. Defaults to the background process type
* @property {object} [properties] - object of custom values to track, keys
* in this object must be in snake_case
* @property {object} [sensitiveProperties] - Object of sensitive values to
* track. Keys in this object must be in snake_case. These properties will be
* sent in an additional event that excludes the user's metaMetricsId
* @property {number} [revenue] - amount of currency that event creates in
* revenue for MetaMask
* @property {string} [currency] - ISO 4127 format currency for events with
* revenue, defaults to US dollars
* @property {number} [value] - Abstract business "value" attributable to
* customers who trigger this event
* @property {MetaMetricsPageObject} [page] - the page/route that the event
* occurred on
* @property {MetaMetricsReferrerObject} [referrer] - the origin of the dapp
* that triggered the event
*/
/**
* @typedef {object} MetaMetricsEventOptions
* @property {boolean} [isOptIn] - happened during opt in/out workflow
* @property {boolean} [flushImmediately] - When true will automatically flush
* the segment queue after tracking the event. Recommended if the result of
* tracking the event must be known before UI transition or update
* @property {boolean} [excludeMetaMetricsId] - whether to exclude the user's
* metametrics id for anonymity
* @property {string} [metaMetricsId] - an override for the metaMetricsId in
* the event one is created as part of an asynchronous workflow, such as
* awaiting the result of the metametrics opt-in function that generates the
* user's metametrics id
* @property {boolean} [matomoEvent] - is this event a holdover from matomo
* that needs further migration? when true, sends the data to a special
* segment source that marks the event data as not conforming to our schema
*/
/**
* @typedef {object} MetaMetricsEventFragment
* @property {string} successEvent - The event name to fire when the fragment
* is closed in an affirmative action.
* @property {string} [failureEvent] - The event name to fire when the fragment
* is closed with a rejection.
* @property {string} [initialEvent] - An event name to fire immediately upon
* fragment creation. This is useful for building funnels in mixpanel and for
* reduction of code duplication.
* @property {string} category - the event category to use for both the success
* and failure events
* @property {boolean} [persist] - Should this fragment be persisted in
* state and progressed after the extension is locked and unlocked.
* @property {number} [timeout] - Time in seconds the event should be persisted
* for. After the timeout the fragment will be closed as abandoned. if not
* supplied the fragment is stored indefinitely.
* @property {number} [lastUpdated] - Date.now() when the fragment was last
* updated. Used to determine if the timeout has expired and the fragment
* should be closed.
* @property {object} [properties] - Object of custom values to track, keys in
* this object must be in snake_case.
* @property {object} [sensitiveProperties] - Object of sensitive values to
* track. Keys in this object must be in snake_case. These properties will be
* sent in an additional event that excludes the user's metaMetricsId
* @property {number} [revenue] - amount of currency that event creates in
* revenue for MetaMask if fragment is successful.
* @property {string} [currency] - ISO 4127 format currency for events with
* revenue, defaults to US dollars
* @property {number} [value] - Abstract business "value" attributable to
* customers who successfully complete this fragment
* @property {MetaMetricsPageObject} [page] - the page/route that the event
* occurred on
* @property {MetaMetricsReferrerObject} [referrer] - the origin of the dapp
* that initiated the event fragment.
* @property {string} [uniqueIdentifier] - optional argument to override the
* automatic generation of UUID for the event fragment. This is useful when
* tracking events for subsystems that already generate UUIDs so to avoid
* unnecessary lookups and reduce accidental duplication.
*/
/**
* Represents the shape of data sent to the segment.track method.
*
* @typedef {object} SegmentEventPayload
* @property {string} [userId] - The metametrics id for the user
* @property {string} [anonymousId] - An anonymousId that is used to track
* sensitive data while preserving anonymity.
* @property {string} event - name of the event to track
* @property {object} properties - properties to attach to the event
* @property {MetaMetricsContext} context - the context the event occurred in
*/
/**
* @typedef {object} MetaMetricsPagePayload
* @property {string} name - The name of the page that was viewed
* @property {object} [params] - The variadic parts of the page url
* example (route: `/asset/:asset`, path: `/asset/ETH`)
* params: { asset: 'ETH' }
* @property {EnvironmentType} environmentType - the environment type that the
* page was viewed in
* @property {MetaMetricsPageObject} [page] - the details of the page
* @property {MetaMetricsReferrerObject} [referrer] - dapp that triggered the page
* view
*/
/**
* @typedef {object} MetaMetricsPageOptions
* @property {boolean} [isOptInPath] - is the current path one of the pages in
* the onboarding workflow? If true and participateInMetaMetrics is null track
* the page view
*/
/**
* @typedef {object} Traits
* @property {'address_book_entries'} ADDRESS_BOOK_ENTRIES - When the user
* adds or modifies addresses in address book the address_book_entries trait
* is identified.
* @property {'ledger_connection_type'} LEDGER_CONNECTION_TYPE - when ledger
* live connnection type is changed we identify the ledger_connection_type
* trait
* @property {'networks_added'} NETWORKS_ADDED - when user modifies networks
* we identify the networks_added trait
* @property {'networks_without_ticker'} NETWORKS_WITHOUT_TICKER - when user
* modifies networks we identify the networks_without_ticker trait for
* networks without a ticker.
* @property {'nft_autodetection_enabled'} NFT_AUTODETECTION_ENABLED - when Autodetect NFTs
* feature is toggled we identify the nft_autodetection_enabled trait
* @property {'number_of_accounts'} NUMBER_OF_ACCOUNTS - when identities
* change, we identify the new number_of_accounts trait
* @property {'number_of_nft_collections'} NUMBER_OF_NFT_COLLECTIONS - user
* trait for number of unique NFT addresses
* @property {'number_of_nfts'} NUMBER_OF_NFTS - user trait for number of all NFT addresses
* @property {'number_of_tokens'} NUMBER_OF_TOKENS - when the number of tokens change, we
* identify the new number_of_tokens trait
* @property {'opensea_api_enabled'} OPENSEA_API_ENABLED - when the OpenSea API is enabled
* we identify the opensea_api_enabled trait
* @property {'three_box_enabled'} THREE_BOX_ENABLED - when 3box feature is
* toggled we identify the 3box_enabled trait
* @property {'theme'} THEME - when the user's theme changes we identify the theme trait
* @property {'token_detection_enabled'} TOKEN_DETECTION_ENABLED - when token detection feature is toggled we
* identify the token_detection_enabled trait
*/
/**
*
* @type {Traits}
*/
export const TRAITS = {
ADDRESS_BOOK_ENTRIES: 'address_book_entries',
LEDGER_CONNECTION_TYPE: 'ledger_connection_type',
NETWORKS_ADDED: 'networks_added',
NETWORKS_WITHOUT_TICKER: 'networks_without_ticker',
NFT_AUTODETECTION_ENABLED: 'nft_autodetection_enabled',
NUMBER_OF_ACCOUNTS: 'number_of_accounts',
NUMBER_OF_NFT_COLLECTIONS: 'number_of_nft_collections',
NUMBER_OF_NFTS: 'number_of_nfts',
NUMBER_OF_TOKENS: 'number_of_tokens',
OPENSEA_API_ENABLED: 'opensea_api_enabled',
THREE_BOX_ENABLED: 'three_box_enabled',
THEME: 'theme',
TOKEN_DETECTION_ENABLED: 'token_detection_enabled',
};
/**
* @typedef {object} MetaMetricsTraits
* @property {number} [address_book_entries] - The number of entries in the
* user's address book.
* @property {'ledgerLive' | 'webhid' | 'u2f'} [ledger_connection_type] - the
* type of ledger connection set by user preference.
* @property {Array<string>} [networks_added] - An array consisting of chainIds
* that indicate the networks a user has added to their MetaMask.
* @property {Array<string>} [networks_without_ticker] - An array consisting of
* chainIds that indicate the networks added by the user that do not have a
* ticker.
* @property {number} [nft_autodetection_enabled] - does the user have the
* use collection/nft detection enabled?
* @property {number} [number_of_accounts] - A number representing the number
* of identities(accounts) added to the user's MetaMask.
* @property {number} [number_of_nft_collections] - A number representing the
* amount of different NFT collections the user possesses an NFT from.
* @property {number} [number_of_nfts] - A number representing the
* amount of all NFTs the user possesses across all networks and accounts.
* @property {number} [number_of_tokens] - The total number of token contracts
* the user has across all networks and accounts.
* @property {boolean} [opensea_api_enabled] - does the user have the OpenSea
* API enabled?
* @property {boolean} [three_box_enabled] - does the user have 3box sync
* enabled?
* @property {string} [theme] - which theme the user has selected
* @property {boolean} [token_detection_enabled] - does the user have token detection is enabled?
*/
// Mixpanel converts the zero address value to a truly anonymous event, which
// speeds up reporting
export const METAMETRICS_ANONYMOUS_ID = '0x0000000000000000';
/**
* This object is used to identify events that are triggered by the background
* process.
*
* @type {MetaMetricsPageObject}
*/
export const METAMETRICS_BACKGROUND_PAGE_OBJECT = {
path: '/background-process',
title: 'Background Process',
url: '/background-process',
};
/**
* @typedef {object} SegmentInterface
* @property {SegmentEventPayload[]} queue - A queue of events to be sent when
* the flushAt limit has been reached, or flushInterval occurs
* @property {() => void} flush - Immediately flush the queue, resetting it to
* an empty array and sending the pending events to Segment
* @property {(
* payload: SegmentEventPayload,
* callback: (err?: Error) => void
* ) => void} track - Track an event with Segment, using the internal batching
* mechanism to optimize network requests
* @property {(payload: Object) => void} page - Track a page view with Segment
* @property {() => void} identify - Identify an anonymous user. We do not
* currently use this method.
*/
export const REJECT_NOTFICIATION_CLOSE = 'Cancel Via Notification Close';
export const REJECT_NOTFICIATION_CLOSE_SIG =
'Cancel Sig Request Via Notification Close';
/**
* EVENTS
*/
export const EVENT_NAMES = {
ENCRYPTION_PUBLIC_KEY_APPROVED: 'Encryption Public Key Approved',
ENCRYPTION_PUBLIC_KEY_REJECTED: 'Encryption Public Key Rejected',
ENCRYPTION_PUBLIC_KEY_REQUESTED: 'Encryption Public Key Requested',
DECRYPTION_APPROVED: 'Decryption Approved',
DECRYPTION_REJECTED: 'Decryption Rejected',
DECRYPTION_REQUESTED: 'Decryption Requested',
PERMISSIONS_APPROVED: 'Permissions Approved',
PERMISSIONS_REJECTED: 'Permissions Rejected',
PERMISSIONS_REQUESTED: 'Permissions Requested',
PROVIDER_METHOD_CALLED: 'Provider Method Called',
SIGNATURE_APPROVED: 'Signature Approved',
SIGNATURE_REJECTED: 'Signature Rejected',
SIGNATURE_REQUESTED: 'Signature Requested',
TOKEN_ADDED: 'Token Added',
TOKEN_DETECTED: 'Token Detected',
TOKEN_HIDDEN: 'Token Hidden',
TOKEN_IMPORT_CANCELED: 'Token Import Canceled',
TOKEN_IMPORT_CLICKED: 'Token Import Clicked',
};
export const EVENT = {
CATEGORIES: {
ACCOUNTS: 'Accounts',
AUTH: 'Auth',
BACKGROUND: 'Background',
INPAGE_PROVIDER: 'inpage_provider',
MESSAGES: 'Messages',
NAVIGATION: 'Navigation',
NETWORK: 'Network',
ONBOARDING: 'Onboarding',
RETENTION: 'Retention',
SETTINGS: 'Settings',
SNAPS: 'Snaps',
SWAPS: 'Swaps',
TRANSACTIONS: 'Transactions',
WALLET: 'Wallet',
},
SOURCE: {
SWAPS: {
MAIN_VIEW: 'Main View',
TOKEN_VIEW: 'Token View',
},
TRANSACTION: {
USER: 'user',
DAPP: 'dapp',
},
TOKEN: {
CUSTOM: 'custom',
DETECTED: 'detected',
DAPP: 'dapp',
LIST: 'list',
},
},
LOCATION: {
TOKEN_DETECTION: 'token_detection',
TOKEN_MENU: 'token_menu',
TOKEN_DETAILS: 'token_details',
},
};