| // Copyright 2024 The Chromium Authors |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef IOS_CHROME_BROWSER_NTP_SHARED_METRICS_FEED_METRICS_CONSTANTS_H_ |
| #define IOS_CHROME_BROWSER_NTP_SHARED_METRICS_FEED_METRICS_CONSTANTS_H_ |
| |
| #import <Foundation/Foundation.h> |
| |
| #import "base/time/time.h" |
| |
| // If cached user setting info is older than this, it will not be reported. |
| constexpr base::TimeDelta kUserSettingsMaxAge = base::Days(14); |
| |
| // Minimum scrolling amount to record a FeedEngagementType::kFeedEngaged due to |
| // scrolling. |
| extern const int kMinScrollThreshold; |
| |
| // Time spent by the user in feed to consider it a |
| // FeedEngagementType::kFeedGoodVisit. |
| extern const int kGoodVisitTimeInFeedSeconds; |
| |
| // Minimum time spent in an article to be considered a non-short click. A |
| // non-short click is any click on an article lasting more than the value |
| // assigned to this constant. Calculated when back in the feed. |
| extern const int kNonShortClickSeconds; |
| |
| // Time between two metrics recorded to consider it a new session. |
| extern const int kMinutesBetweenSessions; |
| |
| // The max amount of cards in the Discover Feed. |
| extern const int kMaxCardsInFeed; |
| |
| // Stores the time when the user visits an article on the feed. |
| extern const char kArticleVisitTimestampKey[]; |
| // Stores the time elapsed on the feed when the user leaves. |
| extern const char kLongDiscoverFeedVisitTimeAggregateKey[]; |
| // Stores the last interaction time for Good Visits (NSDate). |
| extern const char kLastInteractionTimeForDiscoverGoodVisits[]; |
| // Stores the last day the Time in Feed was reported on UMA. It stores the |
| // midnight (beginning of the day) of the last interaction. |
| extern const char kLastDayTimeInFeedReportedKey[]; |
| // Stores the time spent on the feed for a day. |
| extern const char kTimeSpentInFeedAggregateKey[]; |
| // Stores the last time the activity bucket was reported. |
| extern const char kActivityBucketLastReportedDateKey[]; |
| // Stores the last 28 days of activity bucket reported days. |
| extern const char kActivityBucketLastReportedDateArrayKey[]; |
| |
| #pragma mark - Enums |
| |
| // DO NOT CHANGE. Values are from enums.xml representing what could be broken in |
| // the NTP view hierarchy. These values are persisted to logs. Entries should |
| // not be renumbered and numeric values should never be reused. |
| enum class BrokenNTPHierarchyRelationship { |
| kContentSuggestionsParent = 0, |
| kELMCollectionParent = 1, |
| kDiscoverFeedParent = 2, |
| kDiscoverFeedWrapperParent = 3, |
| kContentSuggestionsReset = 4, |
| kFeedHeaderParent = 5, |
| kContentSuggestionsHeaderParent = 6, |
| |
| // Change this to match max value. |
| kMaxValue = 6, |
| }; |
| |
| // Values from enums.xml that represent the triggers where feed refreshes are |
| // requested. These values are persisted to logs. Entries should not be |
| // renumbered and numeric values should never be reused. |
| enum class FeedRefreshTrigger { |
| kOther = 0, |
| kBackgroundColdStart = 1, |
| kBackgroundWarmStart = 2, |
| kForegroundFeedStart = 3, |
| kForegroundAccountChange = 4, |
| kForegroundUserTriggered = 5, |
| kForegroundFeedVisibleOther = 6, |
| kForegroundNotForced = 7, |
| kForegroundFeedNotVisible = 8, |
| kForegroundNewFeedViewController = 9, |
| kForegroundAppClose = 10, |
| kBackgroundColdStartAppClose = 11, |
| kBackgroundWarmStartAppClose = 12, |
| |
| // Change this to match max value. |
| kMaxValue = kBackgroundWarmStartAppClose, |
| }; |
| |
| // Values for the UMA ContentSuggestions.Feed.LoadStreamStatus.LoadMore |
| // histogram. These values are persisted to logs. Entries should not be |
| // renumbered and numeric values should never be reused. This must be kept |
| // in sync with FeedLoadStreamStatus in enums.xml. |
| enum class FeedLoadStreamStatus { |
| kNoStatus = 0, |
| kLoadedFromStore = 1, |
| // Bottom of feed was reached, triggering infinite feed. |
| kLoadedFromNetwork = 2, |
| kFailedWithStoreError = 3, |
| kNoStreamDataInStore = 4, |
| kModelAlreadyLoaded = 5, |
| kNoResponseBody = 6, |
| kProtoTranslationFailed = 7, |
| kDataInStoreIsStale = 8, |
| kDataInStoreIsStaleTimestampInFuture = 9, |
| kCannotLoadFromNetworkSupressedForHistoryDelete_DEPRECATED = 10, |
| kCannotLoadFromNetworkOffline = 11, |
| kCannotLoadFromNetworkThrottled = 12, |
| kLoadNotAllowedEulaNotAccepted = 13, |
| kLoadNotAllowedArticlesListHidden = 14, |
| kCannotParseNetworkResponseBody = 15, |
| kLoadMoreModelIsNotLoaded = 16, |
| kLoadNotAllowedDisabledByEnterprisePolicy = 17, |
| kNetworkFetchFailed = 18, |
| kCannotLoadMoreNoNextPageToken = 19, |
| // Highest enumerator. Recommended by Histogram metrics best practices. |
| kMaxValue = kCannotLoadMoreNoNextPageToken, |
| }; |
| |
| // Values for the UMA ContentSuggestions.Feed.UserSettingsOnStart |
| // histogram. These values are persisted to logs. Entries should not be |
| // renumbered and numeric values should never be reused. This must be kept |
| // in sync with FeedUserSettingsOnStart in enums.xml. |
| // Reports last known state of user settings which affect Feed content. |
| // This includes WAA (whether activity is recorded), and DP (whether |
| // Discover personalization is enabled). |
| enum class UserSettingsOnStart { |
| // The Feed is disabled by enterprise policy. |
| kFeedNotEnabledByPolicy = 0, |
| // The Feed is enabled by enterprise policy, but the user has hidden and |
| // disabled the Feed, so other user settings beyond sign-in status are not |
| // available. |
| kFeedNotVisibleSignedOut = 1, |
| kFeedNotVisibleSignedIn = 2, |
| // The Feed is enabled, the user is not signed in. |
| kSignedOut = 3, |
| // The Feed is enabled, the user is signed in, and setting states are known. |
| kSignedInWaaOnDpOn = 4, |
| kSignedInWaaOnDpOff = 5, |
| kSignedInWaaOffDpOn = 6, |
| kSignedInWaaOffDpOff = 7, |
| // The Feed is enabled, but there is no recent Feed data, so user settings |
| // state is unknown. |
| kSignedInNoRecentData = 8, |
| // Highest enumerator. Recommended by Histogram metrics best practices. |
| kMaxValue = kSignedInNoRecentData, |
| }; |
| |
| // The values for the Feed Activity Buckets metric. |
| enum class FeedActivityBucket { |
| // No activity bucket for users active 0/28 days. |
| kNoActivity = 0, |
| // Low activity bucket for users active 1-7/28 days. |
| kLowActivity = 1, |
| // Medium activity bucket for users active 8-15/28 days. |
| kMediumActivity = 2, |
| // High activity bucket for users active 16+/28 days. |
| kHighActivity = 3, |
| // Highest enumerator. Recommended by Histogram metrics best practices. |
| kMaxValue = kHighActivity, |
| }; |
| |
| #pragma mark - Histograms |
| |
| // Histogram name for the Time Spent in Feed. |
| extern const char kTimeSpentInFeedHistogram[]; |
| // Histogram name for the Discover feed user actions. |
| extern const char kDiscoverFeedUserActionHistogram[]; |
| |
| // Histogram name for the Discover feed user actions commands. |
| extern const char kDiscoverFeedUserActionCommandHistogram[]; |
| |
| // Histogram name for the feed engagement. |
| extern const char kDiscoverFeedEngagementTypeHistogram[]; |
| |
| // Histogram name for the feed activity bucket metric. |
| extern const char kAllFeedsActivityBucketsHistogram[]; |
| |
| // Histogram name for a Discover feed card shown at index. |
| extern const char kDiscoverFeedCardShownAtIndex[]; |
| |
| // Histogram name to capture Feed Notice card impressions. |
| extern const char kDiscoverFeedNoticeCardFulfilled[]; |
| |
| // Histogram name to measure the time it took the Feed to fetch articles |
| // successfully. |
| extern const char kDiscoverFeedArticlesFetchNetworkDurationSuccess[]; |
| |
| // Histogram name to measure the time it took the Feed to fetch articles |
| // unsuccessfully. |
| extern const char kDiscoverFeedArticlesFetchNetworkDurationFailure[]; |
| |
| // Histogram name to measure the time it took the Feed to fetch more articles |
| // successfully. |
| extern const char kDiscoverFeedMoreArticlesFetchNetworkDurationSuccess[]; |
| |
| // Histogram name to measure the time it took the Feed to fetch more articles |
| // unsuccessfully. |
| extern const char kDiscoverFeedMoreArticlesFetchNetworkDurationFailure[]; |
| |
| // Histogram name to measure the time it took the Feed to upload actions |
| // successfully. |
| extern const char kDiscoverFeedUploadActionsNetworkDurationSuccess[]; |
| |
| // Histogram name to measure the time it took the Feed to upload actions |
| // unsuccessfully. |
| extern const char kDiscoverFeedUploadActionsNetworkDurationFailure[]; |
| |
| // Histogram name to measure the time it took the Feed to perform a network |
| // operation. |
| extern const char kDiscoverFeedNetworkDuration[]; |
| |
| // Histogram name to track opened articles from the Discover feed. |
| extern const char kDiscoverFeedURLOpened[]; |
| |
| // Histogram name to capture if the last Feed fetch had logging enabled. |
| extern const char kDiscoverFeedActivityLoggingEnabled[]; |
| |
| // Histogram name for broken NTP view hierarchy logs. |
| // TODO(crbug.com/40799579): Remove this when issue is fixed. |
| extern const char kDiscoverFeedBrokenNTPHierarchy[]; |
| |
| // Histogram name for triggers causing feed refreshes. |
| extern const char kDiscoverFeedRefreshTrigger[]; |
| |
| // Histogram name for the value of Discover uniformity flag. |
| extern const char kDiscoverUniformityFlag[]; |
| |
| // Histogram name for the Feed settings when the App is being start. |
| extern const char kFeedUserSettingsOnStart[]; |
| |
| // Histogram name for sign-in related UI triggered by Feed entry points. |
| extern const char kFeedSignInUI[]; |
| |
| // Histogram name for Feed sync related UI triggered by Feed entry points. |
| extern const char kFeedSyncPromo[]; |
| |
| // Histogram name prefix for feed handling errors. |
| extern const char kFeedHandlingErrorPrefix[]; |
| |
| #pragma mark - User Actions |
| |
| // User action names for the device orientation having changed. |
| extern const char kDiscoverFeedHistogramDeviceOrientationChangedToPortrait[]; |
| extern const char kDiscoverFeedHistogramDeviceOrientationChangedToLandscape[]; |
| |
| // User action names for feed back of card items. |
| extern const char kDiscoverFeedUserActionOpenSameTab[]; |
| extern const char kDiscoverFeedUserActionOpenIncognitoTab[]; |
| extern const char kDiscoverFeedUserActionOpenNewTab[]; |
| extern const char kDiscoverFeedUserActionReadLaterTapped[]; |
| extern const char kDiscoverFeedUserActionSendFeedbackOpened[]; |
| extern const char kDiscoverFeedUserActionContextMenuOpened[]; |
| extern const char kDiscoverFeedUserActionHideStory[]; |
| extern const char kDiscoverFeedUserActionCloseContextMenu[]; |
| extern const char kDiscoverFeedUserActionNativeActionSheetOpened[]; |
| extern const char kDiscoverFeedUserActionNativeContextMenuOpened[]; |
| extern const char kDiscoverFeedUserActionNativeContextMenuClosed[]; |
| extern const char kDiscoverFeedUserActionNativePulldownMenuOpened[]; |
| extern const char kDiscoverFeedUserActionNativePulldownMenuClosed[]; |
| extern const char kDiscoverFeedUserActionReportContentOpened[]; |
| extern const char kDiscoverFeedUserActionReportContentClosed[]; |
| extern const char kDiscoverFeedUserActionPreviewTapped[]; |
| |
| // User action name for engaging with feed. |
| extern const char kDiscoverFeedUserActionEngaged[]; |
| |
| // User action indicating that the feed will refresh. |
| extern const char kFeedWillRefresh[]; |
| |
| // User action triggered when the NTP view hierarchy was fixed after being |
| // detected as broken. |
| // TODO(crbug.com/40799579): Remove this when issue is fixed. |
| extern const char kNTPViewHierarchyFixed[]; |
| |
| #pragma mark - User Actions for Feed Sign-in Promo |
| |
| // User actions triggered when a user taps on Feed Back of Card menu |
| // personalization options when not signed in. |
| extern const char kShowFeedSignInOnlyUIWithUserId[]; |
| extern const char kShowFeedSignInOnlyUIWithoutUserId[]; |
| |
| // User actions triggered when a user taps on Feed personalization controls and |
| // a corresponding sign-in related UI is shown. Ex. a sign-in only flow, or a |
| // disabled toast is shown. |
| extern const char kShowSignInOnlyFlowFromFeed[]; |
| extern const char kShowSignInDisableToastFromFeed[]; |
| |
| #pragma mark - User Actions for Feed Sync Promo |
| |
| // User actions triggered when a user taps on the Feed sync promo and a sync |
| // related UI is shown. |
| extern const char kShowSyncFlowFromFeed[]; |
| extern const char kShowDisableToastFromFeed[]; |
| |
| #endif // IOS_CHROME_BROWSER_NTP_SHARED_METRICS_FEED_METRICS_CONSTANTS_H_ |