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