mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Merge branch 'dev' into jajaja
# Conflicts: # package.json # pnpm-lock.yaml
This commit is contained in:
commit
94b4b66a3d
122 changed files with 41347 additions and 2747 deletions
|
|
@ -1,18 +1,18 @@
|
|||
-----------------------------------------------------
|
||||
-- postgreSQL
|
||||
-- PostgreSQL
|
||||
-----------------------------------------------------
|
||||
UPDATE "website_event" we
|
||||
SET fbclid = url.fbclid,
|
||||
gclid = url.gclid,
|
||||
li_fat_id = url.li_fat_id,
|
||||
msclkid = url.msclkid,
|
||||
ttclid = url.ttclid,
|
||||
twclid = url.twclid,
|
||||
utm_campaign = url.utm_campaign,
|
||||
utm_content = url.utm_content,
|
||||
utm_medium = url.utm_medium,
|
||||
utm_source = url.utm_source,
|
||||
utm_term = url.utm_term
|
||||
SET fbclid = LEFT(url.fbclid, 255),
|
||||
gclid = LEFT(url.gclid, 255),
|
||||
li_fat_id = LEFT(url.li_fat_id, 255),
|
||||
msclkid = LEFT(url.msclkid, 255),
|
||||
ttclid = LEFT(url.ttclid, 255),
|
||||
twclid = LEFT(url.twclid, 255),
|
||||
utm_campaign = LEFT(url.utm_campaign, 255),
|
||||
utm_content = LEFT(url.utm_content, 255),
|
||||
utm_medium = LEFT(url.utm_medium, 255),
|
||||
utm_source = LEFT(url.utm_source, 255),
|
||||
utm_term = LEFT(url.utm_term, 255)
|
||||
FROM (SELECT event_id, website_id, session_id,
|
||||
(regexp_matches(url_query, '(?:[&?]|^)fbclid=([^&]+)', 'i'))[1] AS fbclid,
|
||||
(regexp_matches(url_query, '(?:[&?]|^)gclid=([^&]+)', 'i'))[1] AS gclid,
|
||||
|
|
@ -31,18 +31,18 @@ WHERE we.event_id = url.event_id
|
|||
and we.website_id = url.website_id;
|
||||
|
||||
-----------------------------------------------------
|
||||
-- mySQL
|
||||
-- MySQL
|
||||
-----------------------------------------------------
|
||||
UPDATE `website_event`
|
||||
SET fbclid = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)fbclid=[^&]+'), '=', -1), '&', 1),
|
||||
gclid = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)gclid=[^&]+'), '=', -1), '&', 1),
|
||||
li_fat_id = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)li_fat_id=[^&]+'), '=', -1), '&', 1),
|
||||
msclkid = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)msclkid=[^&]+'), '=', -1), '&', 1),
|
||||
ttclid = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)ttclid=[^&]+'), '=', -1), '&', 1),
|
||||
twclid = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)twclid=[^&]+'), '=', -1), '&', 1),
|
||||
utm_campaign = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_campaign=[^&]+'), '=', -1), '&', 1),
|
||||
utm_content = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_content=[^&]+'), '=', -1), '&', 1),
|
||||
utm_medium = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_medium=[^&]+'), '=', -1), '&', 1),
|
||||
utm_source = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_source=[^&]+'), '=', -1), '&', 1),
|
||||
utm_term = SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_term=[^&]+'), '=', -1), '&', 1)
|
||||
WHERE 1 = 1;
|
||||
SET fbclid = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)fbclid=[^&]+'), '=', -1), '&', 1), 255),
|
||||
gclid = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)gclid=[^&]+'), '=', -1), '&', 1), 255),
|
||||
li_fat_id = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)li_fat_id=[^&]+'), '=', -1), '&', 1), 255),
|
||||
msclkid = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)msclkid=[^&]+'), '=', -1), '&', 1), 255),
|
||||
ttclid = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)ttclid=[^&]+'), '=', -1), '&', 1), 255),
|
||||
twclid = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)twclid=[^&]+'), '=', -1), '&', 1), 255),
|
||||
utm_campaign = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_campaign=[^&]+'), '=', -1), '&', 1), 255),
|
||||
utm_content = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_content=[^&]+'), '=', -1), '&', 1), 255),
|
||||
utm_medium = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_medium=[^&]+'), '=', -1), '&', 1), 255),
|
||||
utm_source = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_source=[^&]+'), '=', -1), '&', 1), 255),
|
||||
utm_term = LEFT(SUBSTRING_INDEX(SUBSTRING_INDEX(REGEXP_SUBSTR(url_query, '(?:[&?]|^)utm_term=[^&]+'), '=', -1), '&', 1), 255)
|
||||
WHERE 1 = 1;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,30 @@ const asyncForEach = async (array, callback) => {
|
|||
}
|
||||
};
|
||||
|
||||
const downloadFile = (url, filepath) =>
|
||||
new Promise(resolve => {
|
||||
https
|
||||
.get(url, res => {
|
||||
if (res.statusCode === 200) {
|
||||
const fileStream = fs.createWriteStream(filepath);
|
||||
res.pipe(fileStream);
|
||||
fileStream.on('finish', () => {
|
||||
fileStream.close();
|
||||
console.log('Downloaded', chalk.greenBright('->'), filepath);
|
||||
resolve();
|
||||
});
|
||||
} else {
|
||||
res.resume();
|
||||
console.warn(`Warning: ${url} returned ${res.statusCode}`);
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
.on('error', err => {
|
||||
console.error(`Error downloading ${url}:`, err.message);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
const download = async files => {
|
||||
await fs.ensureDir(dest);
|
||||
|
||||
|
|
@ -25,12 +49,8 @@ const download = async files => {
|
|||
|
||||
const filename = path.join(dest, file);
|
||||
if (!fs.existsSync(filename)) {
|
||||
await new Promise(resolve => {
|
||||
https.get(getUrl(locale), res => {
|
||||
console.log('Downloaded', chalk.greenBright('->'), filename);
|
||||
resolve(res.pipe(fs.createWriteStream(filename)));
|
||||
});
|
||||
});
|
||||
const url = getUrl(locale);
|
||||
await downloadFile(url, filename);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,6 +17,30 @@ const asyncForEach = async (array, callback) => {
|
|||
}
|
||||
};
|
||||
|
||||
const downloadFile = (url, filepath) =>
|
||||
new Promise(resolve => {
|
||||
https
|
||||
.get(url, res => {
|
||||
if (res.statusCode === 200) {
|
||||
const fileStream = fs.createWriteStream(filepath);
|
||||
res.pipe(fileStream);
|
||||
fileStream.on('finish', () => {
|
||||
fileStream.close();
|
||||
console.log('Downloaded', chalk.greenBright('->'), filepath);
|
||||
resolve();
|
||||
});
|
||||
} else {
|
||||
res.resume();
|
||||
console.warn(`Warning: ${url} returned ${res.statusCode}`);
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
.on('error', err => {
|
||||
console.error(`Error downloading ${url}:`, err.message);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
const download = async files => {
|
||||
await fs.ensureDir(dest);
|
||||
|
||||
|
|
@ -25,12 +49,8 @@ const download = async files => {
|
|||
|
||||
const filename = path.join(dest, file);
|
||||
if (!fs.existsSync(filename)) {
|
||||
await new Promise(resolve => {
|
||||
https.get(getUrl(locale), res => {
|
||||
console.log('Downloaded', chalk.greenBright('->'), filename);
|
||||
resolve(res.pipe(fs.createWriteStream(filename)));
|
||||
});
|
||||
});
|
||||
const url = getUrl(locale);
|
||||
await downloadFile(url, filename);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@ const routesManifestPath = path.resolve(process.cwd(), '.next/routes-manifest.js
|
|||
const originalPath = path.resolve(process.cwd(), '.next/routes-manifest-orig.json');
|
||||
const originalManifest = require(originalPath);
|
||||
|
||||
const API_PATH = '/api/:path*';
|
||||
const TRACKER_SCRIPT = '/script.js';
|
||||
const basePath = originalManifest.basePath;
|
||||
|
||||
const API_PATH = basePath + '/api/:path*';
|
||||
const TRACKER_SCRIPT = basePath + '/script.js';
|
||||
|
||||
const collectApiEndpoint = process.env.COLLECT_API_ENDPOINT;
|
||||
const trackerScriptName = process.env.TRACKER_SCRIPT_NAME;
|
||||
|
|
@ -23,14 +25,16 @@ if (collectApiEndpoint) {
|
|||
const apiRoute = originalManifest.headers.find(route => route.source === API_PATH);
|
||||
const routeRegex = new RegExp(apiRoute.regex);
|
||||
|
||||
const normalizedSource = basePath + collectApiEndpoint;
|
||||
|
||||
rewrites.push({
|
||||
source: collectApiEndpoint,
|
||||
destination: '/api/send',
|
||||
source: normalizedSource,
|
||||
destination: basePath + '/api/send',
|
||||
});
|
||||
|
||||
if (!routeRegex.test(collectApiEndpoint)) {
|
||||
if (!routeRegex.test(normalizedSource)) {
|
||||
headers.push({
|
||||
source: collectApiEndpoint,
|
||||
source: normalizedSource,
|
||||
headers: apiRoute.headers,
|
||||
});
|
||||
}
|
||||
|
|
@ -43,7 +47,7 @@ if (trackerScriptName) {
|
|||
|
||||
if (names) {
|
||||
names.forEach(name => {
|
||||
const normalizedSource = `/${name.replace(/^\/+/, '')}`;
|
||||
const normalizedSource = `${basePath}/${name.replace(/^\/+/, '')}`;
|
||||
|
||||
rewrites.push({
|
||||
source: normalizedSource,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue