PluginProbe
Extendify / 3.1.1
Extendify v3.1.1
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / AutoLaunch / functions / insights.js

insights.js in Extendify 3.1.1, at src/AutoLaunch/functions/insights.js

68 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { useLaunchDataStore } from '@auto-launch/state/launch-data';
2 import { INSIGHTS_HOST } from '@constants';
3 import { reqDataBasics } from '@shared/lib/data';
4
5 const headers = {
6 'Content-type': 'application/json',
7 Accept: 'application/json',
8 'X-Extendify': 'true',
9 };
10
11 const { urlParams, activeTests } = window.extLaunchData;
12 export const checkIn = ({
13 stage,
14 siteProfile = {},
15 sitePlugins = [],
16 siteStyle = {},
17 } = {}) => {
18 const { type, category, structure, objective } = siteProfile;
19 const { siteId, partnerId, homeUrl, wpLanguage } = reqDataBasics;
20 const attempt = useLaunchDataStore.getState()?.attempt || 1;
21
22 const payload = JSON.stringify({
23 ...reqDataBasics,
24 autoLaunch: true,
25 stage,
26 attempt,
27 activeTests: Object.keys(activeTests ?? {}).length
28 ? JSON.stringify(activeTests)
29 : undefined,
30 skippedDescription: Boolean(urlParams?.title || urlParams?.description),
31 insightsId: siteId,
32 hostpartner: partnerId,
33 siteURL: homeUrl,
34 language: wpLanguage,
35 sitePlugins: sitePlugins?.map((p) => p?.name),
36 urlParameters: urlParams,
37 siteStyle,
38 style: siteStyle?.colorPalette,
39 siteProfile,
40 siteType: type,
41 siteCategory: category,
42 siteStructure: structure,
43 siteObjective: objective,
44 extra: {
45 userAgent: window?.navigator?.userAgent,
46 vendor: window?.navigator?.vendor || 'unknown',
47 platform:
48 window?.navigator?.userAgentData?.platform ||
49 window?.navigator?.platform ||
50 'unknown',
51 mobile: window?.navigator?.userAgentData?.mobile,
52 width: window.innerWidth,
53 height: window.innerHeight,
54 screenHeight: window.screen.height,
55 screenWidth: window.screen.width,
56 orientation: window.screen.orientation?.type,
57 touchSupport: 'ontouchstart' in window || navigator.maxTouchPoints > 0,
58 },
59 });
60
61 return fetch(`${INSIGHTS_HOST}/api/v1/launch`, {
62 method: 'POST',
63 headers,
64 body: payload,
65 keepalive: true,
66 });
67 };
68