click subpath
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
// 添加团队筛选
|
||||
|
||||
Reference in New Issue
Block a user