Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aesirx-analytics",
"version": "2.4.3",
"version": "2.4.4",
"license": "GPL-3.0-only",
"author": "AesirX",
"repository": "https://gitlab.redweb.dk/aesirx/analytics",
Expand Down
18 changes: 17 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const startTracker = async (
}
};

const trackEvent = async (endpoint: string, referer?: string, data?: object, _url?: string) => {
const trackEvent = async (endpoint: string, referer?: string, data?: any, _url?: string) => {
const allow = sessionStorage.getItem('aesirx-analytics-allow');
const reject = sessionStorage.getItem('aesirx-analytics-rejected');
if (allow === '0' || reject === 'true') {
Expand All @@ -131,6 +131,22 @@ const trackEvent = async (endpoint: string, referer?: string, data?: object, _ur
const ip = '';
const userTimeZone = Intl.DateTimeFormat().resolvedOptions()?.timeZone;

const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const attributesVisit = data?.attributes;
const attributes = [];
for (const key of urlParams.keys()) {
if (key.startsWith('utm_') || key.startsWith('gad_')) {
urlParams.get(key) && attributes.push({ name: key, value: urlParams.get(key) });
}
}
if (attributesVisit?.length) {
attributesVisit?.forEach((element: any) => {
element?.name && attributes.push({ name: element?.name, value: element?.value });
});
}
data.attributes = attributes;

const fingerprint = getFingerprint();
const headers = { type: 'application/json' };
const blobData = new Blob(
Expand Down
Loading