diff --git a/package.json b/package.json index 2aab7c3..e0904f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aesirx-analytics", - "version": "2.4.4", + "version": "2.4.5", "license": "GPL-3.0-only", "author": "AesirX", "repository": "https://gitlab.redweb.dk/aesirx/analytics", diff --git a/src/utils/index.ts b/src/utils/index.ts index 6110edb..e4274d0 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -17,7 +17,8 @@ const startTracker = async ( url?: string, referer?: string, user_agent?: string, - attributesVisit?: any + attributesVisit?: any, + visibilitychange = false ) => { const allow = sessionStorage.getItem('aesirx-analytics-allow'); const reject = sessionStorage.getItem('aesirx-analytics-rejected'); @@ -78,6 +79,7 @@ const startTracker = async ( lang: lang, device: device?.includes('iPhone') ? 'mobile' : device?.includes('iPad') ? 'tablet' : device, timezone: userTimeZone, + ...(visibilitychange && { visibility_change: visibilitychange }), ...(attributes?.length && { event_name: 'visit', event_type: 'action', @@ -197,7 +199,7 @@ const endTrackerVisibilityState = (endPoint: string) => { endTracker(endPoint, window['event_uuid'], window['visitor_uuid']); } if (document.visibilityState === 'visible') { - const response = await startTracker(endPoint, '', '', '', window['attributes']); + const response = await startTracker(endPoint, '', '', '', window['attributes'], true); window['event_uuid'] = response?.event_uuid; } });