click subpath

This commit is contained in:
2025-04-10 18:07:10 +08:00
parent 48d5bdafa4
commit b8cd3716c4
5 changed files with 68 additions and 10 deletions

View File

@@ -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);
}
// 添加团队筛选