223 lines
14 KiB
TypeScript
223 lines
14 KiB
TypeScript
// Metro module 10101 (f10102).
|
|
import ChannelStore from "../../../../stores/ChannelStore";
|
|
import SearchQueryStore from "../stores/SearchQueryStore";
|
|
import { SEARCH_HISTORY_TO_ANALYTICS_SEARCH_HISTORY } from "./TrackingConstants";
|
|
import { AnalyticEvents, SearchTokenTypes } from "../../../../Constants";
|
|
import SearchSessionAnalyticsManager from "../../managers/native/SearchSessionAnalyticsManager";
|
|
import { getChannelIdFromSearchContext, getGuildIdFromSearchContext } from "../../SearchUtils";
|
|
import AppAnalyticsUtils from "../../../app_analytics/AppAnalyticsUtils";
|
|
import { v4 } from "../../../../_bundle/Module514";
|
|
import { SearchResultExactCountEnabled } from "../../../user_settings/UserSettings";
|
|
const r24 = {
|
|
trackSearchOpened: function trackSearchOpened({ searchContext, searchLocation }) {
|
|
SearchSessionAnalyticsManager.initialize(searchContext, searchLocation);
|
|
const channelIdFromSearchContext = getChannelIdFromSearchContext(searchContext);
|
|
const channel = ChannelStore.getChannel(channelIdFromSearchContext);
|
|
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.SEARCH_OPENED_MOBILE, {
|
|
search_session_id: SearchSessionAnalyticsManager.getSessionId(searchContext),
|
|
search_location: searchLocation,
|
|
guild_id: getGuildIdFromSearchContext(searchContext),
|
|
channel_id: channelIdFromSearchContext,
|
|
channel_type: channel?.type
|
|
});
|
|
},
|
|
trackSearchStarted: function trackSearchStarted({ searchContext }) {
|
|
if (!SearchQueryStore.isInitialSearchQuery(searchContext)) {
|
|
SearchSessionAnalyticsManager.refreshQueryId(searchContext);
|
|
const channelIdFromSearchContext = getChannelIdFromSearchContext(searchContext);
|
|
const channel = ChannelStore.getChannel(channelIdFromSearchContext);
|
|
const queryString = SearchQueryStore.getQueryString(searchContext);
|
|
const textInputValue = SearchQueryStore.getTextInputValue(searchContext);
|
|
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.SEARCH_STARTED_MOBILE, {
|
|
search_session_id: SearchSessionAnalyticsManager.getSessionId(searchContext),
|
|
search_query_id: SearchSessionAnalyticsManager.getQueryId(searchContext),
|
|
search_location: SearchSessionAnalyticsManager.getLocation(searchContext),
|
|
guild_id: getGuildIdFromSearchContext(searchContext),
|
|
channel_id: channelIdFromSearchContext,
|
|
channel_type: channel?.type,
|
|
search_query_length: queryString.trim().length,
|
|
search_query_content_length: textInputValue.trim().length
|
|
});
|
|
}
|
|
},
|
|
trackSearchResultClicked: function trackSearchResultClicked({ searchContext, index, messageId, channelId, userId, entityType }) {
|
|
if (!SearchQueryStore.isInitialSearchQuery(searchContext)) {
|
|
const guildIdFromSearchContext = getGuildIdFromSearchContext(searchContext);
|
|
const channelIdFromSearchContext = getChannelIdFromSearchContext(searchContext);
|
|
const channel = ChannelStore.getChannel(channelIdFromSearchContext);
|
|
const channel2 = ChannelStore.getChannel(channelId);
|
|
const queryString = SearchQueryStore.getQueryString(searchContext);
|
|
const textInputValue = SearchQueryStore.getTextInputValue(searchContext);
|
|
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.SEARCH_RESULT_CLICKED_MOBILE, {
|
|
search_session_id: SearchSessionAnalyticsManager.getSessionId(searchContext),
|
|
search_location: SearchSessionAnalyticsManager.getLocation(searchContext),
|
|
search_query_id: SearchSessionAnalyticsManager.getQueryId(searchContext),
|
|
search_query_length: queryString.trim().length,
|
|
search_query_content_length: textInputValue.trim().length,
|
|
search_tab_selected: SearchSessionAnalyticsManager.getSelectedTab(searchContext),
|
|
search_result_index: index,
|
|
search_result_click_id: v4(),
|
|
search_result_content_entity_type: entityType,
|
|
search_result_user_id: userId,
|
|
search_result_message_id: messageId,
|
|
search_result_channel_id: channelId,
|
|
search_result_guild_id: guildIdFromSearchContext,
|
|
search_result_channel_type: channel2?.type,
|
|
guild_id: guildIdFromSearchContext,
|
|
channel_id: channelIdFromSearchContext,
|
|
channel_type: channel?.type
|
|
});
|
|
}
|
|
},
|
|
trackSearchResultReturned: function trackSearchResultReturned({ searchContext, searchResultTotalCount, numMemberTabReturnedResults, numChannelTabReturnedResults, numPeopleTabReturnedResults, numMessageTabReturnedResults, numMediaTabReturnedResults, numFileTabReturnedResults, numLinkTabReturnedResults }) {
|
|
if (!SearchQueryStore.isInitialSearchQuery(searchContext)) {
|
|
const guildIdFromSearchContext = getGuildIdFromSearchContext(searchContext);
|
|
const channelIdFromSearchContext = getChannelIdFromSearchContext(searchContext);
|
|
const channel = ChannelStore.getChannel(channelIdFromSearchContext);
|
|
const queryString = SearchQueryStore.getQueryString(searchContext);
|
|
const textInputValue = SearchQueryStore.getTextInputValue(searchContext);
|
|
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.SEARCH_RESULT_RETURNED_MOBILE, {
|
|
search_session_id: SearchSessionAnalyticsManager.getSessionId(searchContext),
|
|
search_location: SearchSessionAnalyticsManager.getLocation(searchContext),
|
|
search_query_id: SearchSessionAnalyticsManager.getQueryId(searchContext),
|
|
search_query_length: queryString.trim().length,
|
|
search_query_content_length: textInputValue.trim().length,
|
|
search_result_total_count: searchResultTotalCount,
|
|
num_member_tab_returned_results: numMemberTabReturnedResults,
|
|
num_channel_tab_returned_results: numChannelTabReturnedResults,
|
|
num_people_tab_returned_results: numPeopleTabReturnedResults,
|
|
num_message_tab_returned_results: numMessageTabReturnedResults,
|
|
num_media_tab_returned_results: numMediaTabReturnedResults,
|
|
num_file_tab_returned_results: numFileTabReturnedResults,
|
|
num_link_tab_returned_results: numLinkTabReturnedResults,
|
|
exact_search_result_count_setting_enabled: SearchResultExactCountEnabled.getSetting(),
|
|
guild_id: guildIdFromSearchContext,
|
|
channel_id: channelIdFromSearchContext,
|
|
channel_type: channel?.type
|
|
});
|
|
}
|
|
},
|
|
trackSearchEmptyResult: function trackSearchEmptyResult({ searchContext }) {
|
|
if (!SearchQueryStore.isInitialSearchQuery(searchContext)) {
|
|
const guildIdFromSearchContext = getGuildIdFromSearchContext(searchContext);
|
|
const channelIdFromSearchContext = getChannelIdFromSearchContext(searchContext);
|
|
const channel = ChannelStore.getChannel(channelIdFromSearchContext);
|
|
const queryString = SearchQueryStore.getQueryString(searchContext);
|
|
const textInputValue = SearchQueryStore.getTextInputValue(searchContext);
|
|
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.SEARCH_EMPTY_RESULT_MOBILE, {
|
|
search_session_id: SearchSessionAnalyticsManager.getSessionId(searchContext),
|
|
search_location: SearchSessionAnalyticsManager.getLocation(searchContext),
|
|
search_query_id: SearchSessionAnalyticsManager.getQueryId(searchContext),
|
|
search_query_length: queryString.trim().length,
|
|
search_query_content_length: textInputValue.trim().length,
|
|
guild_id: guildIdFromSearchContext,
|
|
channel_id: channelIdFromSearchContext,
|
|
channel_type: channel?.type
|
|
});
|
|
}
|
|
},
|
|
trackSearchEmptyMessageResult: function trackSearchEmptyMessageResult({ searchContext }) {
|
|
if (!SearchQueryStore.isInitialSearchQuery(searchContext)) {
|
|
const guildIdFromSearchContext = getGuildIdFromSearchContext(searchContext);
|
|
const channelIdFromSearchContext = getChannelIdFromSearchContext(searchContext);
|
|
const channel = ChannelStore.getChannel(channelIdFromSearchContext);
|
|
const queryString = SearchQueryStore.getQueryString(searchContext);
|
|
const textInputValue = SearchQueryStore.getTextInputValue(searchContext);
|
|
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.SEARCH_EMPTY_MESSAGE_RESULT_MOBILE, {
|
|
search_session_id: SearchSessionAnalyticsManager.getSessionId(searchContext),
|
|
search_location: SearchSessionAnalyticsManager.getLocation(searchContext),
|
|
search_query_id: SearchSessionAnalyticsManager.getQueryId(searchContext),
|
|
search_query_length: queryString.trim().length,
|
|
search_query_content_length: textInputValue.trim().length,
|
|
guild_id: guildIdFromSearchContext,
|
|
channel_id: channelIdFromSearchContext,
|
|
channel_type: channel?.type
|
|
});
|
|
}
|
|
},
|
|
trackSearchClosed: function trackSearchClosed(a0) {
|
|
SearchSessionAnalyticsManager.terminate(a0.searchContext);
|
|
},
|
|
trackSearchIndexing: function trackSearchIndexing(a0) {
|
|
const searchContext = a0.searchContext;
|
|
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.SEARCH_V2_INDEXING_VIEWED, {
|
|
is_historical_indexing: a0.isHistoricalIndexing,
|
|
documents_indexed: a0.documentsIndexed,
|
|
search_tab_selected: SearchSessionAnalyticsManager.getSelectedTab(searchContext),
|
|
search_location: SearchSessionAnalyticsManager.getLocation(searchContext),
|
|
search_session_id: SearchSessionAnalyticsManager.getSessionId(searchContext),
|
|
search_query_id: SearchSessionAnalyticsManager.getQueryId(searchContext)
|
|
});
|
|
},
|
|
trackSearchHistoryClicked: function trackSearchHistoryClicked(a0) {
|
|
const { searchContext, searchHistoryItemType } = a0;
|
|
const channel = ChannelStore.getChannel(a0.channelId);
|
|
const search_history_type = SEARCH_HISTORY_TO_ANALYTICS_SEARCH_HISTORY[searchHistoryItemType];
|
|
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.SEARCH_V2_HISTORY_CLICKED, {
|
|
search_tab_selected: SearchSessionAnalyticsManager.getSelectedTab(searchContext),
|
|
search_location: SearchSessionAnalyticsManager.getLocation(searchContext),
|
|
search_session_id: SearchSessionAnalyticsManager.getSessionId(searchContext),
|
|
search_result_channel_type: channel?.type,
|
|
search_history_type
|
|
});
|
|
},
|
|
trackSuggestedSearchClicked: function trackSuggestedSearchClicked(a0) {
|
|
const searchContext = a0.searchContext;
|
|
const channel = ChannelStore.getChannel(a0.channelId);
|
|
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.SEARCH_V2_SUGGESTED_CLICKED, {
|
|
search_tab_selected: SearchSessionAnalyticsManager.getSelectedTab(searchContext),
|
|
search_location: SearchSessionAnalyticsManager.getLocation(searchContext),
|
|
search_session_id: SearchSessionAnalyticsManager.getSessionId(searchContext),
|
|
search_result_channel_type: channel?.type
|
|
});
|
|
},
|
|
trackSearchFilterAdd: function trackSearchFilterAdd({ searchContext, searchTokenType, location: location2 }) {
|
|
const SEARCH_V2_FILTER_ADD = AnalyticEvents.SEARCH_V2_FILTER_ADD;
|
|
const r18 = {
|
|
search_tab_selected: SearchSessionAnalyticsManager.getSelectedTab(searchContext),
|
|
search_location: SearchSessionAnalyticsManager.getLocation(searchContext),
|
|
search_session_id: SearchSessionAnalyticsManager.getSessionId(searchContext),
|
|
search_query_id: SearchSessionAnalyticsManager.getQueryId(searchContext),
|
|
search_filter_type: null,
|
|
location: null
|
|
};
|
|
r18.search_filter_type = SearchTokenTypes.FILTER_FROM !== searchTokenType ? SearchTokenTypes.FILTER_MENTIONS !== searchTokenType ? SearchTokenTypes.FILTER_IN !== searchTokenType ? SearchTokenTypes.FILTER_HAS !== searchTokenType ? SearchTokenTypes.FILTER_ON !== searchTokenType ? SearchTokenTypes.FILTER_AFTER !== searchTokenType ? SearchTokenTypes.FILTER_BEFORE === searchTokenType ? "filter_before" : null : "filter_after" : "filter_on" : "filter_has" : "filter_in" : "filter_mentions" : "filter_from";
|
|
r18.location = location2;
|
|
AppAnalyticsUtils.trackWithMetadata(SEARCH_V2_FILTER_ADD, r18);
|
|
},
|
|
trackSearchFilterRemove: function trackSearchFilterRemove({ searchContext, searchTokenType, isDefault }) {
|
|
const SEARCH_V2_FILTER_REMOVE = AnalyticEvents.SEARCH_V2_FILTER_REMOVE;
|
|
const r18 = {
|
|
search_tab_selected: SearchSessionAnalyticsManager.getSelectedTab(searchContext),
|
|
search_location: SearchSessionAnalyticsManager.getLocation(searchContext),
|
|
search_session_id: SearchSessionAnalyticsManager.getSessionId(searchContext),
|
|
search_query_id: SearchSessionAnalyticsManager.getQueryId(searchContext),
|
|
search_filter_type: null,
|
|
is_default_search_filter: null
|
|
};
|
|
r18.search_filter_type = SearchTokenTypes.FILTER_FROM !== searchTokenType ? SearchTokenTypes.FILTER_MENTIONS !== searchTokenType ? SearchTokenTypes.FILTER_IN !== searchTokenType ? SearchTokenTypes.FILTER_HAS !== searchTokenType ? SearchTokenTypes.FILTER_ON !== searchTokenType ? SearchTokenTypes.FILTER_AFTER !== searchTokenType ? SearchTokenTypes.FILTER_BEFORE === searchTokenType ? "filter_before" : null : "filter_after" : "filter_on" : "filter_has" : "filter_in" : "filter_mentions" : "filter_from";
|
|
r18.is_default_search_filter = isDefault;
|
|
AppAnalyticsUtils.trackWithMetadata(SEARCH_V2_FILTER_REMOVE, r18);
|
|
},
|
|
trackSearchTabSelected: function trackSearchTabSelected({ searchContext }) {
|
|
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.SEARCH_V2_TAB_SELECTED, {
|
|
search_session_id: SearchSessionAnalyticsManager.getSessionId(searchContext),
|
|
search_query_id: SearchSessionAnalyticsManager.getQueryId(searchContext),
|
|
search_tab_selected: SearchSessionAnalyticsManager.getSelectedTab(searchContext),
|
|
search_location: SearchSessionAnalyticsManager.getLocation(searchContext)
|
|
});
|
|
},
|
|
trackSearchJumpToMessage: function trackSearchJumpToMessage({ searchContext, channelId }) {
|
|
const channel = ChannelStore.getChannel(channelId);
|
|
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.SEARCH_V2_JUMP_TO_MESSAGE, {
|
|
search_tab_selected: SearchSessionAnalyticsManager.getSelectedTab(searchContext),
|
|
search_location: SearchSessionAnalyticsManager.getLocation(searchContext),
|
|
search_session_id: SearchSessionAnalyticsManager.getSessionId(searchContext),
|
|
search_query_id: SearchSessionAnalyticsManager.getQueryId(searchContext),
|
|
search_result_channel_type: channel?.type,
|
|
search_result_channel_id: channelId
|
|
});
|
|
}
|
|
};
|
|
export default r24;
|