add long and lat to events
This commit is contained in:
@@ -7,21 +7,24 @@ interface RemoteIpLookupResponse {
|
|||||||
country: string | undefined;
|
country: string | undefined;
|
||||||
city: string | undefined;
|
city: string | undefined;
|
||||||
stateprov: string | undefined;
|
stateprov: string | undefined;
|
||||||
continent: string | undefined;
|
longitude: number | undefined;
|
||||||
|
latitude: number | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GeoLocation {
|
interface GeoLocation {
|
||||||
country: string | undefined;
|
country: string | undefined;
|
||||||
city: string | undefined;
|
city: string | undefined;
|
||||||
region: string | undefined;
|
region: string | undefined;
|
||||||
continent: string | undefined;
|
longitude: number | undefined;
|
||||||
|
latitude: number | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const geo: GeoLocation = {
|
const geo: GeoLocation = {
|
||||||
country: undefined,
|
country: undefined,
|
||||||
city: undefined,
|
city: undefined,
|
||||||
region: undefined,
|
region: undefined,
|
||||||
continent: undefined,
|
longitude: undefined,
|
||||||
|
latitude: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ignore = ['127.0.0.1', '::1'];
|
const ignore = ['127.0.0.1', '::1'];
|
||||||
@@ -45,7 +48,8 @@ export async function parseIp(ip?: string): Promise<GeoLocation> {
|
|||||||
country: res.country,
|
country: res.country,
|
||||||
city: res.city,
|
city: res.city,
|
||||||
region: res.stateprov,
|
region: res.stateprov,
|
||||||
continent: res.continent,
|
longitude: res.longitude,
|
||||||
|
latitude: res.latitude,
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error('Failed to fetch geo location for ip', e);
|
logger.error('Failed to fetch geo location for ip', e);
|
||||||
|
|||||||
@@ -122,13 +122,6 @@ export function EventDetails({ event, open, setOpen }: Props) {
|
|||||||
setFilter('country', event.country ?? '');
|
setFilter('country', event.country ?? '');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'Continent',
|
|
||||||
value: event.continent,
|
|
||||||
onClick() {
|
|
||||||
setFilter('continent', event.continent ?? '');
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'Device',
|
name: 'Device',
|
||||||
value: event.device,
|
value: event.device,
|
||||||
|
|||||||
@@ -68,7 +68,8 @@ export async function incomingEvent(job: Job<EventsQueuePayloadIncomingEvent>) {
|
|||||||
country: event?.country || geo.country || '',
|
country: event?.country || geo.country || '',
|
||||||
city: event?.city || geo.city || '',
|
city: event?.city || geo.city || '',
|
||||||
region: event?.region || geo.region || '',
|
region: event?.region || geo.region || '',
|
||||||
continent: event?.continent || geo.continent || '',
|
longitude: geo.longitude,
|
||||||
|
latitude: geo.latitude,
|
||||||
os: event?.os ?? '',
|
os: event?.os ?? '',
|
||||||
osVersion: event?.osVersion ?? '',
|
osVersion: event?.osVersion ?? '',
|
||||||
browser: event?.browser ?? '',
|
browser: event?.browser ?? '',
|
||||||
@@ -150,7 +151,8 @@ export async function incomingEvent(job: Job<EventsQueuePayloadIncomingEvent>) {
|
|||||||
country: geo.country,
|
country: geo.country,
|
||||||
city: geo.city,
|
city: geo.city,
|
||||||
region: geo.region,
|
region: geo.region,
|
||||||
continent: geo.continent,
|
longitude: geo.longitude,
|
||||||
|
latitude: geo.latitude,
|
||||||
os: uaInfo?.os ?? '',
|
os: uaInfo?.os ?? '',
|
||||||
osVersion: uaInfo?.osVersion ?? '',
|
osVersion: uaInfo?.osVersion ?? '',
|
||||||
browser: uaInfo?.browser ?? '',
|
browser: uaInfo?.browser ?? '',
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ CREATE TABLE openpanel.events (
|
|||||||
`country` String,
|
`country` String,
|
||||||
`city` String,
|
`city` String,
|
||||||
`region` String,
|
`region` String,
|
||||||
`continent` String,
|
`longitude` Int16,
|
||||||
|
`latitude` Int16,
|
||||||
`os` String,
|
`os` String,
|
||||||
`os_version` String,
|
`os_version` String,
|
||||||
`browser` String,
|
`browser` String,
|
||||||
@@ -77,6 +78,16 @@ ALTER TABLE
|
|||||||
ADD
|
ADD
|
||||||
COLUMN id UUID DEFAULT generateUUIDv4() FIRST;
|
COLUMN id UUID DEFAULT generateUUIDv4() FIRST;
|
||||||
|
|
||||||
|
ALTER TABLE
|
||||||
|
events
|
||||||
|
ADD
|
||||||
|
COLUMN longitude Nullable(Int16);
|
||||||
|
|
||||||
|
ALTER TABLE
|
||||||
|
events
|
||||||
|
ADD
|
||||||
|
COLUMN latitude Nullable(Int16);
|
||||||
|
|
||||||
--- Materialized views (DAU)
|
--- Materialized views (DAU)
|
||||||
CREATE MATERIALIZED VIEW dau_mv ENGINE = AggregatingMergeTree() PARTITION BY toYYYYMMDD(date)
|
CREATE MATERIALIZED VIEW dau_mv ENGINE = AggregatingMergeTree() PARTITION BY toYYYYMMDD(date)
|
||||||
ORDER BY
|
ORDER BY
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ export interface IClickhouseEvent {
|
|||||||
country: string;
|
country: string;
|
||||||
city: string;
|
city: string;
|
||||||
region: string;
|
region: string;
|
||||||
|
longitude: number | null;
|
||||||
|
latitude: number | null;
|
||||||
os: string;
|
os: string;
|
||||||
os_version: string;
|
os_version: string;
|
||||||
browser: string;
|
browser: string;
|
||||||
@@ -65,6 +67,8 @@ export function transformEvent(
|
|||||||
country: event.country,
|
country: event.country,
|
||||||
city: event.city,
|
city: event.city,
|
||||||
region: event.region,
|
region: event.region,
|
||||||
|
longitude: event.longitude,
|
||||||
|
latitude: event.latitude,
|
||||||
os: event.os,
|
os: event.os,
|
||||||
osVersion: event.os_version,
|
osVersion: event.os_version,
|
||||||
browser: event.browser,
|
browser: event.browser,
|
||||||
@@ -97,7 +101,8 @@ export interface IServiceCreateEventPayload {
|
|||||||
country?: string | undefined;
|
country?: string | undefined;
|
||||||
city?: string | undefined;
|
city?: string | undefined;
|
||||||
region?: string | undefined;
|
region?: string | undefined;
|
||||||
continent?: string | undefined;
|
longitude?: number | undefined | null;
|
||||||
|
latitude?: number | undefined | null;
|
||||||
os?: string | undefined;
|
os?: string | undefined;
|
||||||
osVersion?: string | undefined;
|
osVersion?: string | undefined;
|
||||||
browser?: string | undefined;
|
browser?: string | undefined;
|
||||||
@@ -121,6 +126,8 @@ export interface IServiceEventMinimal {
|
|||||||
sessionId: string;
|
sessionId: string;
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
country?: string | undefined;
|
country?: string | undefined;
|
||||||
|
longitude?: number | undefined | null;
|
||||||
|
latitude?: number | undefined | null;
|
||||||
os?: string | undefined;
|
os?: string | undefined;
|
||||||
browser?: string | undefined;
|
browser?: string | undefined;
|
||||||
device?: string | undefined;
|
device?: string | undefined;
|
||||||
@@ -156,6 +163,8 @@ export function transformMinimalEvent(
|
|||||||
sessionId: event.sessionId,
|
sessionId: event.sessionId,
|
||||||
createdAt: event.createdAt,
|
createdAt: event.createdAt,
|
||||||
country: event.country,
|
country: event.country,
|
||||||
|
longitude: event.longitude,
|
||||||
|
latitude: event.latitude,
|
||||||
os: event.os,
|
os: event.os,
|
||||||
browser: event.browser,
|
browser: event.browser,
|
||||||
device: event.device,
|
device: event.device,
|
||||||
@@ -228,6 +237,8 @@ export async function createEvent(
|
|||||||
country: payload.country,
|
country: payload.country,
|
||||||
city: payload.city,
|
city: payload.city,
|
||||||
region: payload.region,
|
region: payload.region,
|
||||||
|
longitude: payload.longitude,
|
||||||
|
latitude: payload.latitude,
|
||||||
os: payload.os,
|
os: payload.os,
|
||||||
os_version: payload.osVersion,
|
os_version: payload.osVersion,
|
||||||
browser: payload.browser,
|
browser: payload.browser,
|
||||||
@@ -255,6 +266,8 @@ export async function createEvent(
|
|||||||
country: payload.country ?? '',
|
country: payload.country ?? '',
|
||||||
city: payload.city ?? '',
|
city: payload.city ?? '',
|
||||||
region: payload.region ?? '',
|
region: payload.region ?? '',
|
||||||
|
longitude: payload.longitude ?? null,
|
||||||
|
latitude: payload.latitude ?? null,
|
||||||
os: payload.os ?? '',
|
os: payload.os ?? '',
|
||||||
os_version: payload.osVersion ?? '',
|
os_version: payload.osVersion ?? '',
|
||||||
browser: payload.browser ?? '',
|
browser: payload.browser ?? '',
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ export interface EventsQueuePayloadIncomingEvent {
|
|||||||
country: string | undefined;
|
country: string | undefined;
|
||||||
city: string | undefined;
|
city: string | undefined;
|
||||||
region: string | undefined;
|
region: string | undefined;
|
||||||
continent: string | undefined;
|
longitude: number | undefined;
|
||||||
|
latitude: number | undefined;
|
||||||
};
|
};
|
||||||
headers: {
|
headers: {
|
||||||
origin: string | undefined;
|
origin: string | undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user