Truncate URL lengths.

This commit is contained in:
Mike Cao 2021-03-12 23:45:19 -08:00
parent efd53f8a03
commit 247afc8c33
2 changed files with 12 additions and 4 deletions

View File

@ -86,6 +86,8 @@ export const DESKTOP_SCREEN_WIDTH = 1920;
export const LAPTOP_SCREEN_WIDTH = 1024;
export const MOBILE_SCREEN_WIDTH = 479;
export const URL_LENGTH = 500;
export const DESKTOP_OS = [
'Windows 3.11',
'Windows 95',

View File

@ -1,7 +1,13 @@
import moment from 'moment-timezone';
import prisma from 'lib/db';
import { subMinutes } from 'date-fns';
import { MYSQL, POSTGRESQL, MYSQL_DATE_FORMATS, POSTGRESQL_DATE_FORMATS } from 'lib/constants';
import {
MYSQL,
POSTGRESQL,
MYSQL_DATE_FORMATS,
POSTGRESQL_DATE_FORMATS,
URL_LENGTH,
} from 'lib/constants';
export function getDatabase() {
const type =
@ -190,8 +196,8 @@ export async function savePageView(website_id, session_id, url, referrer) {
session_id,
},
},
url,
referrer,
url: url.substr(0, URL_LENGTH),
referrer: referrer.substr(0, URL_LENGTH),
},
}),
);
@ -211,7 +217,7 @@ export async function saveEvent(website_id, session_id, url, event_type, event_v
session_id,
},
},
url,
url: url.substr(0, URL_LENGTH),
event_type,
event_value,
},