feat: add userAgent to web vitals
This commit is contained in:
parent
0bdf3b4555
commit
8fdaf75c45
|
@ -266,9 +266,10 @@ class Database {
|
|||
}
|
||||
|
||||
async storeVital(metric) {
|
||||
await this.mysqlPool.execute('INSERT INTO vitals (id, name, navigation_type, rating, entries, delta, value) VALUES (?, ?, ?, ?, ?, ?, ?)', [
|
||||
await this.mysqlPool.execute('INSERT INTO vitals (id, name, user_agent, navigation_type, rating, entries, delta, value) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', [
|
||||
metric.id,
|
||||
metric.name,
|
||||
metric.userAgent,
|
||||
metric.navigationType,
|
||||
metric.rating,
|
||||
JSON.stringify(metric.entries),
|
||||
|
@ -285,6 +286,7 @@ class Database {
|
|||
id: row.id,
|
||||
time: new Date(row.time).getTime(),
|
||||
name: row.name,
|
||||
user_agent: row.user_agent,
|
||||
navigation_type: row.navigation_type,
|
||||
rating: row.rating,
|
||||
entries: JSON.parse(row.entries),
|
||||
|
|
|
@ -11,7 +11,7 @@ const nextConfig = {
|
|||
remotePatterns: [
|
||||
{
|
||||
protocol: 'https',
|
||||
hostname: 'cdn-new.theclashfruit.me',
|
||||
hostname: 'cdn.theclashfruit.me',
|
||||
port: '',
|
||||
pathname: '/**',
|
||||
},
|
||||
|
|
|
@ -17,7 +17,11 @@ export default async function handler(req, res) {
|
|||
});
|
||||
|
||||
try {
|
||||
await db.storeVital(JSON.parse(body));
|
||||
let b = JSON.parse(body);
|
||||
|
||||
b.userAgent = headers['user-agent'];
|
||||
|
||||
await db.storeVital(b);
|
||||
|
||||
res.status(200).json({
|
||||
tracked: true,
|
||||
|
|
|
@ -104,6 +104,7 @@ CREATE TABLE `vitals` (
|
|||
`id` varchar(255) NOT NULL,
|
||||
`time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`user_agent` VARCHAR(2048) NOT NULL,
|
||||
`navigation_type` varchar(255) NOT NULL,
|
||||
`rating` varchar(255) NOT NULL,
|
||||
`entries` JSON NOT NULL,
|
||||
|
|
Loading…
Reference in a new issue