mirror of
https://github.com/rybbit-io/rybbit.git
synced 2025-05-11 04:15:36 +02:00
Enhance channel detection and self-referral handling in tracking
- Introduced a new function to check for self-referrals, allowing for better categorization of internal traffic. - Updated the getChannel function to treat self-referrals without UTM parameters as "Internal" traffic. - Modified pageviewQueue to clear self-referrer data when applicable, improving data accuracy. - Added a utility function to clear self-referrer if it matches the current hostname, enhancing tracking precision.
This commit is contained in:
parent
d7bd778bd6
commit
ecf69fb828
3 changed files with 58 additions and 6 deletions
|
@ -3,6 +3,7 @@ import clickhouse from "../db/clickhouse/clickhouse.js";
|
|||
import { TrackingPayload } from "../types.js";
|
||||
import { getDeviceType } from "../utils.js";
|
||||
import { getChannel } from "./getChannel.js";
|
||||
import { clearSelfReferrer } from "./trackingUtils.js";
|
||||
|
||||
type TotalPayload = TrackingPayload & {
|
||||
userId: string;
|
||||
|
@ -67,6 +68,9 @@ class PageviewQueue {
|
|||
const longitude = dataForIp?.data?.longitude || 0;
|
||||
const city = dataForIp?.data?.city || "";
|
||||
|
||||
// Check if referrer is from the same domain and clear it if so
|
||||
let referrer = clearSelfReferrer(pv.referrer || "", pv.hostname || "");
|
||||
|
||||
return {
|
||||
site_id: pv.site_id,
|
||||
timestamp: DateTime.fromISO(pv.timestamp).toFormat(
|
||||
|
@ -78,8 +82,8 @@ class PageviewQueue {
|
|||
pathname: pv.pathname || "",
|
||||
querystring: pv.querystring || "",
|
||||
page_title: pv.page_title || "",
|
||||
referrer: pv.referrer || "",
|
||||
channel: getChannel(pv.referrer, pv.querystring),
|
||||
referrer: referrer,
|
||||
channel: getChannel(referrer, pv.querystring, pv.hostname),
|
||||
browser: pv.ua.browser.name || "",
|
||||
browser_version: pv.ua.browser.major || "",
|
||||
operating_system: pv.ua.os.name || "",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue