PluginProbe
Extendify / trunk
Extendify vtrunk
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
← All changes | src/AutoLaunch/fetchers/get-plugins.js +21 -6 3.0.4 → trunk View file →
@@ -4,11 +4,12 @@
4 4 fetchWithTimeout,
5 5 retryTwice,
6 6 setStatus,
7 7 } from '@auto-launch/functions/helpers';
8 +import { launchStrings } from '@auto-launch/strings';
8 9 import { AI_HOST } from '@constants';
10 +import { digest } from '@shared/api/digest';
9 11 import { reqDataBasics } from '@shared/lib/data';
10 -import { __ } from '@wordpress/i18n';
11 12 import { z } from 'zod';
12 13
13 14 const { pluginGroupId } = window.extSharedData;
14 15 const fallback = { sitePlugins: [] };
@@ -26,9 +27,9 @@
26 27 showStatus = true,
27 28 }) => {
28 29 if (showStatus) {
29 30 // translators: this is for a action log UI. Keep it short
30 - setStatus(__('Setting up site functionality', 'extendify-local'));
31 + setStatus(launchStrings().statusPlugins);
31 32 }
32 33
33 34 const body = JSON.stringify({
34 35 ...reqDataBasics,
@@ -40,13 +41,27 @@
40 41 });
41 42
42 43 const response = await retryTwice(() =>
43 44 fetchWithTimeout(url, { method, headers, body }),
44 - );
45 + ).catch((error) => {
46 + return { ok: false, statusText: error.message, status: 0 };
47 + });
45 48
46 - if (!response?.ok) return fallback;
49 + if (!response?.ok) {
50 + digest({
51 + error: {
52 + message: response.statusText,
53 + name: 'FetchError',
54 + status: response.status,
55 + },
56 + details: { source: 'auto-launch', caller: 'handleSitePlugins' },
57 + });
58 + return fallback;
59 + }
47 60
48 - const { selectedPlugins } = await failWithFallback(async () =>
49 - shapeLocal.parse(await response.json(), fallback),
61 + const { selectedPlugins } = await failWithFallback(
62 + async () => shapeLocal.parse(await response.json()),
63 + fallback,
64 + { caller: 'handleSitePlugins' },
50 65 );
51 66 return getPluginsShape.parse({ sitePlugins: selectedPlugins });
52 67 };