click subpath
This commit is contained in:
@@ -481,8 +481,20 @@ function AnalyticsContent() {
|
||||
|
||||
// 处理子路径点击
|
||||
const handlePathClick = (path: string) => {
|
||||
console.log('Path clicked:', path);
|
||||
setSelectedSubpath(path);
|
||||
console.log('====== ANALYTICS PAGE PATH DEBUG ======');
|
||||
console.log('Original path:', path);
|
||||
|
||||
// 从路径中提取 subpath 部分,移除前导斜杠
|
||||
// 示例:如果路径是 "/slug/subpath",我们需要提取 "subpath" 部分
|
||||
// 或者直接使用原始路径,取决于您的路径结构
|
||||
const pathParts = path.split('/').filter(Boolean);
|
||||
// 如果路径包含多个部分,获取第二部分(subpath)
|
||||
const subpath = pathParts.length > 1 ? pathParts[1] : path;
|
||||
|
||||
console.log('Extracted subpath:', subpath);
|
||||
console.log('=====================================');
|
||||
|
||||
setSelectedSubpath(subpath);
|
||||
// 重置到第一页
|
||||
setCurrentPage(1);
|
||||
};
|
||||
|
||||
@@ -14,6 +14,7 @@ export async function GET(request: NextRequest) {
|
||||
const linkId = searchParams.get('linkId') || undefined;
|
||||
const linkSlug = searchParams.get('linkSlug') || undefined;
|
||||
const userId = searchParams.get('userId') || undefined;
|
||||
const subpath = searchParams.get('subpath') || undefined;
|
||||
|
||||
// 获取可能存在的多个团队、项目和标签ID
|
||||
const teamIds = searchParams.getAll('teamId');
|
||||
@@ -26,6 +27,7 @@ export async function GET(request: NextRequest) {
|
||||
const sortOrder = (searchParams.get('sortOrder') as 'asc' | 'desc') || undefined;
|
||||
|
||||
console.log("API接收到的tagIds:", tagIds); // 添加日志便于调试
|
||||
console.log("API接收到的subpath:", subpath); // 添加日志便于调试
|
||||
|
||||
// 获取事件列表
|
||||
const params: EventsQueryParams = {
|
||||
@@ -35,6 +37,7 @@ export async function GET(request: NextRequest) {
|
||||
linkId,
|
||||
linkSlug,
|
||||
userId,
|
||||
subpath,
|
||||
teamIds: teamIds.length > 0 ? teamIds : undefined,
|
||||
projectIds: projectIds.length > 0 ? projectIds : undefined,
|
||||
tagIds: tagIds.length > 0 ? tagIds : undefined,
|
||||
@@ -44,6 +47,9 @@ export async function GET(request: NextRequest) {
|
||||
sortOrder
|
||||
};
|
||||
|
||||
// 记录完整的参数用于调试
|
||||
console.log("完整请求参数:", JSON.stringify(params));
|
||||
|
||||
const result = await getEvents(params);
|
||||
|
||||
const response: ApiResponse<typeof result.events> = {
|
||||
|
||||
@@ -11,10 +11,11 @@ interface UtmData {
|
||||
conversions: number;
|
||||
}
|
||||
|
||||
// 格式化日期时间字符串为ClickHouse支持的格式
|
||||
const formatDateTime = (dateStr: string): string => {
|
||||
return dateStr.replace('T', ' ').replace('Z', '');
|
||||
};
|
||||
// 辅助函数,将日期格式化为标准格式
|
||||
function formatDateTime(dateString: string): string {
|
||||
const date = new Date(dateString);
|
||||
return date.toISOString().split('.')[0];
|
||||
}
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
@@ -67,7 +68,25 @@ export async function GET(request: NextRequest) {
|
||||
|
||||
// 添加子路径筛选
|
||||
if (subpath) {
|
||||
conditions.push(`positionCaseInsensitive(url, '/${subpath}') > 0`);
|
||||
console.log('====== UTM API SUBPATH DEBUG ======');
|
||||
console.log('Raw subpath param:', subpath);
|
||||
console.log('Subpath type:', typeof subpath);
|
||||
console.log('Subpath length:', subpath.length);
|
||||
console.log('Subpath chars:', Array.from(subpath).map(c => c.charCodeAt(0)));
|
||||
|
||||
// 确保没有前导斜杠,避免双斜杠问题
|
||||
const cleanSubpath = subpath.startsWith('/')
|
||||
? subpath.substring(1)
|
||||
: subpath;
|
||||
|
||||
console.log('Cleaned subpath:', cleanSubpath);
|
||||
|
||||
// 在event_attributes JSON的full_url字段中查找subpath
|
||||
const condition = `JSONExtractString(event_attributes, 'full_url') LIKE '%${cleanSubpath}%'`;
|
||||
console.log('Final SQL condition:', condition);
|
||||
console.log('==================================');
|
||||
|
||||
conditions.push(condition);
|
||||
}
|
||||
|
||||
// 添加团队筛选
|
||||
|
||||
@@ -86,6 +86,12 @@ const PathAnalytics: React.FC<PathAnalyticsProps> = ({ startTime, endTime, linkI
|
||||
|
||||
const handlePathClick = (path: string, e: React.MouseEvent) => {
|
||||
e.preventDefault();
|
||||
console.log('====== PATH CLICK DEBUG ======');
|
||||
console.log('Path value:', path);
|
||||
console.log('Path type:', typeof path);
|
||||
console.log('Path length:', path.length);
|
||||
console.log('Path chars:', Array.from(path).map(c => c.charCodeAt(0)));
|
||||
console.log('==============================');
|
||||
if (onPathClick) {
|
||||
onPathClick(path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user