WordPress plugin 1.0.0: proxy drops Content-Type (all events rejected) and inline SDK is always rejected
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 73/100
Hướng nghiên cứu
Bắt đầu với openpanel.php, tập trung vào collect_request_headers(), proxy_request() và is_valid_javascript_content(). Theo dõi cách các header của request và việc xác thực SDK inline ảnh hưởng đến việc chuyển tiếp sự kiện, sau đó kiểm tra cách xử lý phản hồi của proxy. Công việc được xem là hoàn tất khi proxy chuyển tiếp Content-Type, chấp nhận tập lệnh SDK được mô tả và trả về phản hồi upstream dưới dạng đối tượng JSON; issue không nêu bài kiểm thử nào cần chạy.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The WordPress plugin (v1.0.0) doesn't track anything on our site, because of two bugs in openpanel.php.
1. Proxy drops the Content-Type header, so every event is rejected
collect_request_headers() only forwards $_SERVER keys starting with HTTP_. PHP stores the Content-Type under CONTENT_TYPE, without that prefix, so the proxy never forwards it. The API then rejects every event:
POST /wp-json/openpanel/track → 400 {"status":400,"error":"Error","message":"body/type Invalid input"}
The same request sent directly to api.openpanel.dev/track returns 200.
Fix in proxy_request():
$content_type = $request->get_header('content_type');
if ($content_type) {
$incoming['Content-Type'] = $content_type;
}
2. The inline op1.js always fails validation, so the plugin falls back to the CDN script, which ad blockers block
is_valid_javascript_content() rejects any script that matches /on\w+\s*=/i. op1.js contains r.onload=, r.onerror= and this.options=, so the inlined SDK is rejected on every page load. The plugin then loads https://openpanel.dev/op1.js, which Safari and ad blockers block, which defeats the purpose of the proxy.
Fix: remove on\w+\s*= from the pattern. op1.js comes from your own HTTPS endpoint, so the check doesn't protect against anything.
if (preg_match('/(?:javascript:|data:|vbscript:)/i', $js_content)) {
With both changes, events arrive correctly, including from browsers with tracker blocking.
Smaller issue: proxy_request() passes the raw upstream body string to WP_REST_Response, which JSON-encodes it again. The browser therefore receives "{\"deviceId\":...}", a JSON string rather than an object. Decoding it first (json_decode($bodyOut)) would fix that.
Disclaimer: I wrote this Issue Description with the help of AI
- Ngôn ngữ chính
- TypeScript
- Star
- 7.2k
- Fork
- 523
- Merge trung bình
- 15 giờ 24 phút
- Pull request đã merge (30 ngày)
- 41
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Openpanel-dev/openpanel
-
Insights never generated on self-hosted: daily job filters on raw `subscriptionStatus = 'active'`Có thể đã có người làm @grootbro đã nhận 4 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Openpanel-dev/openpanel#597 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Duplicate /track requests return plain text 'Duplicate event', SDK throws JSON parse errorCó thể đã có người làm @grootbro đã nhận 4 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Openpanel-dev/openpanel#579 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ClickHouse retry logs print CLICKHOUSE_URL with its passwordCó thể đã có người làm @ppjsw đã nhận 7 ngày trước. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 92/100
Openpanel-dev/openpanel#551 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
login page needs refinementCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Openpanel-dev/openpanel#495 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Session-grouped queries treat every sessionless event as one session (wrong results, ClickHouse OOM)Có thể đã có người làm @grootbro đã nhận 4 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
Openpanel-dev/openpanel#575 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Openpanel-dev/openpanel
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 84/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
keptinventory/kept#336 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
-
hemi-earn
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
vetro-protocol/vetro-monorepo#1013 ·
Maintainer thường phản hồi trong vòng 1 ngày