add origin to events
This commit is contained in:
@@ -41,11 +41,11 @@ export async function incomingEvent(job: Job<EventsQueuePayloadIncomingEvent>) {
|
|||||||
| undefined) ?? undefined
|
| undefined) ?? undefined
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
const { origin, ua } = headers;
|
const { ua } = headers;
|
||||||
const profileId = body.profileId ?? '';
|
const profileId = body.profileId ?? '';
|
||||||
const createdAt = new Date(body.timestamp);
|
const createdAt = new Date(body.timestamp);
|
||||||
const url = getProperty('__path');
|
const url = getProperty('__path');
|
||||||
const { path, hash, query } = parsePath(url);
|
const { path, hash, query, origin } = parsePath(url);
|
||||||
const referrer = isSameDomain(getProperty('__referrer'), url)
|
const referrer = isSameDomain(getProperty('__referrer'), url)
|
||||||
? null
|
? null
|
||||||
: parseReferrer(getProperty('__referrer'));
|
: parseReferrer(getProperty('__referrer'));
|
||||||
@@ -80,6 +80,7 @@ export async function incomingEvent(job: Job<EventsQueuePayloadIncomingEvent>) {
|
|||||||
model: event?.model ?? '',
|
model: event?.model ?? '',
|
||||||
duration: 0,
|
duration: 0,
|
||||||
path: event?.path ?? '',
|
path: event?.path ?? '',
|
||||||
|
origin: event?.origin ?? '',
|
||||||
referrer: event?.referrer ?? '',
|
referrer: event?.referrer ?? '',
|
||||||
referrerName: event?.referrerName ?? '',
|
referrerName: event?.referrerName ?? '',
|
||||||
referrerType: event?.referrerType ?? '',
|
referrerType: event?.referrerType ?? '',
|
||||||
@@ -170,6 +171,7 @@ export async function incomingEvent(job: Job<EventsQueuePayloadIncomingEvent>) {
|
|||||||
model: uaInfo?.model ?? '',
|
model: uaInfo?.model ?? '',
|
||||||
duration: 0,
|
duration: 0,
|
||||||
path: path,
|
path: path,
|
||||||
|
origin: origin,
|
||||||
referrer: referrer?.url,
|
referrer: referrer?.url,
|
||||||
referrerName: referrer?.name || utmReferrer?.name || '',
|
referrerName: referrer?.name || utmReferrer?.name || '',
|
||||||
referrerType: referrer?.type || utmReferrer?.type || '',
|
referrerType: referrer?.type || utmReferrer?.type || '',
|
||||||
@@ -264,7 +266,6 @@ export async function incomingEvent(job: Job<EventsQueuePayloadIncomingEvent>) {
|
|||||||
job.log(
|
job.log(
|
||||||
`event is queued ${JSON.stringify(
|
`event is queued ${JSON.stringify(
|
||||||
{
|
{
|
||||||
origin,
|
|
||||||
ua,
|
ua,
|
||||||
uaInfo,
|
uaInfo,
|
||||||
referrer,
|
referrer,
|
||||||
|
|||||||
@@ -11,11 +11,13 @@ export function parseSearchParams(
|
|||||||
export function parsePath(path?: string): {
|
export function parsePath(path?: string): {
|
||||||
query?: Record<string, string>;
|
query?: Record<string, string>;
|
||||||
path: string;
|
path: string;
|
||||||
|
origin: string;
|
||||||
hash?: string;
|
hash?: string;
|
||||||
} {
|
} {
|
||||||
if (!path) {
|
if (!path) {
|
||||||
return {
|
return {
|
||||||
path: '',
|
path: '',
|
||||||
|
origin: '',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,10 +27,12 @@ export function parsePath(path?: string): {
|
|||||||
query: parseSearchParams(url.searchParams),
|
query: parseSearchParams(url.searchParams),
|
||||||
path: url.pathname,
|
path: url.pathname,
|
||||||
hash: url.hash || undefined,
|
hash: url.hash || undefined,
|
||||||
|
origin: url.origin,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return {
|
return {
|
||||||
path,
|
path,
|
||||||
|
origin: '',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ CREATE TABLE openpanel.events (
|
|||||||
`project_id` String,
|
`project_id` String,
|
||||||
`session_id` String,
|
`session_id` String,
|
||||||
`path` String,
|
`path` String,
|
||||||
|
`origin` String,
|
||||||
`referrer` String,
|
`referrer` String,
|
||||||
`referrer_name` String,
|
`referrer_name` String,
|
||||||
`referrer_type` String,
|
`referrer_type` String,
|
||||||
@@ -58,9 +59,9 @@ ORDER BY
|
|||||||
ALTER TABLE
|
ALTER TABLE
|
||||||
events
|
events
|
||||||
ADD
|
ADD
|
||||||
COLUMN session_id String
|
COLUMN origin String
|
||||||
AFTER
|
AFTER
|
||||||
project_id;
|
path;
|
||||||
|
|
||||||
ALTER TABLE
|
ALTER TABLE
|
||||||
events DROP COLUMN id;
|
events DROP COLUMN id;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ export interface IClickhouseEvent {
|
|||||||
project_id: string;
|
project_id: string;
|
||||||
session_id: string;
|
session_id: string;
|
||||||
path: string;
|
path: string;
|
||||||
|
origin: string;
|
||||||
referrer: string;
|
referrer: string;
|
||||||
referrer_name: string;
|
referrer_name: string;
|
||||||
referrer_type: string;
|
referrer_type: string;
|
||||||
@@ -78,6 +79,7 @@ export function transformEvent(
|
|||||||
model: event.model,
|
model: event.model,
|
||||||
duration: event.duration,
|
duration: event.duration,
|
||||||
path: event.path,
|
path: event.path,
|
||||||
|
origin: event.origin,
|
||||||
referrer: event.referrer,
|
referrer: event.referrer,
|
||||||
referrerName: event.referrer_name,
|
referrerName: event.referrer_name,
|
||||||
referrerType: event.referrer_type,
|
referrerType: event.referrer_type,
|
||||||
@@ -112,6 +114,7 @@ export interface IServiceCreateEventPayload {
|
|||||||
model?: string | undefined;
|
model?: string | undefined;
|
||||||
duration: number;
|
duration: number;
|
||||||
path: string;
|
path: string;
|
||||||
|
origin: string;
|
||||||
referrer: string | undefined;
|
referrer: string | undefined;
|
||||||
referrerName: string | undefined;
|
referrerName: string | undefined;
|
||||||
referrerType: string | undefined;
|
referrerType: string | undefined;
|
||||||
@@ -134,6 +137,7 @@ export interface IServiceEventMinimal {
|
|||||||
brand?: string | undefined;
|
brand?: string | undefined;
|
||||||
duration: number;
|
duration: number;
|
||||||
path: string;
|
path: string;
|
||||||
|
origin: string;
|
||||||
referrer: string | undefined;
|
referrer: string | undefined;
|
||||||
meta: EventMeta | undefined;
|
meta: EventMeta | undefined;
|
||||||
minimal: boolean;
|
minimal: boolean;
|
||||||
@@ -171,6 +175,7 @@ export function transformMinimalEvent(
|
|||||||
brand: event.brand,
|
brand: event.brand,
|
||||||
duration: event.duration,
|
duration: event.duration,
|
||||||
path: maskString(event.path),
|
path: maskString(event.path),
|
||||||
|
origin: event.origin,
|
||||||
referrer: event.referrer,
|
referrer: event.referrer,
|
||||||
meta: event.meta,
|
meta: event.meta,
|
||||||
minimal: true,
|
minimal: true,
|
||||||
@@ -262,6 +267,7 @@ export async function createEvent(
|
|||||||
session_id: payload.sessionId,
|
session_id: payload.sessionId,
|
||||||
properties: toDots(omit(['_path'], payload.properties)),
|
properties: toDots(omit(['_path'], payload.properties)),
|
||||||
path: payload.path ?? '',
|
path: payload.path ?? '',
|
||||||
|
origin: payload.origin ?? '',
|
||||||
created_at: formatClickhouseDate(payload.createdAt),
|
created_at: formatClickhouseDate(payload.createdAt),
|
||||||
country: payload.country ?? '',
|
country: payload.country ?? '',
|
||||||
city: payload.city ?? '',
|
city: payload.city ?? '',
|
||||||
|
|||||||
Reference in New Issue
Block a user