feat: API优化
This commit is contained in:
@@ -274,7 +274,69 @@ export const useConceptEvents = ({ navigate } = {}) => {
|
|||||||
});
|
});
|
||||||
}, [track]);
|
}, [track]);
|
||||||
|
|
||||||
|
// ========== 别名函数 - 为保持向后兼容性 ==========
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 追踪概念搜索(别名函数)
|
||||||
|
* @alias trackSearchQuerySubmitted
|
||||||
|
*/
|
||||||
|
const trackConceptSearched = useCallback((query, resultCount = 0) => {
|
||||||
|
return trackSearchQuerySubmitted(query, resultCount);
|
||||||
|
}, [trackSearchQuerySubmitted]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 追踪筛选器应用(通用包装函数)
|
||||||
|
* @param {string} filterType - 筛选类型 (sort/date/view_mode)
|
||||||
|
* @param {any} filterValue - 筛选值
|
||||||
|
* @param {any} previousValue - 之前的值
|
||||||
|
*/
|
||||||
|
const trackFilterApplied = useCallback((filterType, filterValue, previousValue = null) => {
|
||||||
|
if (filterType === 'sort') {
|
||||||
|
return trackSortChanged(filterValue, previousValue);
|
||||||
|
} else if (filterType === 'date') {
|
||||||
|
return trackDateChanged(filterValue, previousValue);
|
||||||
|
} else if (filterType === 'view_mode') {
|
||||||
|
return trackViewModeChanged(filterValue, previousValue);
|
||||||
|
}
|
||||||
|
}, [trackSortChanged, trackDateChanged, trackViewModeChanged]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 追踪概念股票列表查看
|
||||||
|
* @param {string} conceptName - 概念名称
|
||||||
|
* @param {number} stockCount - 股票数量
|
||||||
|
*/
|
||||||
|
const trackConceptStocksViewed = useCallback((conceptName, stockCount = 0) => {
|
||||||
|
track(RETENTION_EVENTS.CONCEPT_DETAIL_VIEWED, {
|
||||||
|
concept_name: conceptName,
|
||||||
|
stock_count: stockCount,
|
||||||
|
view_type: 'stocks_list',
|
||||||
|
source: 'concept_center',
|
||||||
|
});
|
||||||
|
|
||||||
|
logger.debug('useConceptEvents', '📈 Concept Stocks Viewed', {
|
||||||
|
conceptName,
|
||||||
|
stockCount,
|
||||||
|
});
|
||||||
|
}, [track]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 追踪概念时间轴查看(别名函数)
|
||||||
|
* @alias trackConceptDetailViewed
|
||||||
|
*/
|
||||||
|
const trackConceptTimelineViewed = useCallback((conceptName, conceptId) => {
|
||||||
|
return trackConceptDetailViewed(conceptName, conceptId);
|
||||||
|
}, [trackConceptDetailViewed]);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 追踪分页变化(别名函数 - 不同时态)
|
||||||
|
* @alias trackPageChanged
|
||||||
|
*/
|
||||||
|
const trackPageChange = useCallback((page, filters = {}) => {
|
||||||
|
return trackPageChanged(page, filters);
|
||||||
|
}, [trackPageChanged]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
// 原有函数
|
||||||
trackConceptListViewed,
|
trackConceptListViewed,
|
||||||
trackSearchInitiated,
|
trackSearchInitiated,
|
||||||
trackSearchQuerySubmitted,
|
trackSearchQuerySubmitted,
|
||||||
@@ -288,5 +350,12 @@ export const useConceptEvents = ({ navigate } = {}) => {
|
|||||||
trackStockDetailViewed,
|
trackStockDetailViewed,
|
||||||
trackPaywallShown,
|
trackPaywallShown,
|
||||||
trackUpgradeClicked,
|
trackUpgradeClicked,
|
||||||
|
|
||||||
|
// 别名函数 - 为保持向后兼容性
|
||||||
|
trackConceptSearched,
|
||||||
|
trackFilterApplied,
|
||||||
|
trackConceptStocksViewed,
|
||||||
|
trackConceptTimelineViewed,
|
||||||
|
trackPageChange,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user