# extendify/3.2.2/src/Shared/api/digest.js

Extendify, version 3.2.2. 82 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.2.2/code/src/Shared/api/digest.js
- Raw: https://pluginprobe.com/plugins/extendify/3.2.2/raw/src/Shared/api/digest.js
- Modified: 2026-10-01T15:30:38+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/3.2.2/code/src/Shared/api/digest.js#L10-L20`.

```javascript
import { AI_HOST } from '@constants';
import { reqDataBasics } from '@shared/lib/data';

// Retried steps re-report the same failure; one site sent 89k rows before this.
const sent = new Set();

const describeError = (e) => {
	if (!e) return { message: 'Unknown error', name: 'Error', stack: '' };
	if (e instanceof Response) {
		return {
			message: `HTTP ${e.status}: ${e.statusText}`,
			name: 'FetchError',
			stack: '',
		};
	}
	return {
		message:
			e?.response?.statusText ||
			e?.response?.message ||
			e?.statusText ||
			e?.message ||
			(typeof e === 'string' ? e : 'Unknown error'),
		name: e?.name || 'Error',
		// WordPress localizes the message; the code is what groups it.
		code: e?.code,
	};
};

export const digest = ({ type = 'error', error, details = {} } = {}) => {
	if (Boolean(reqDataBasics?.devbuild) === true) return;

	const errorData = describeError(error);
	const key = JSON.stringify([type, details, errorData]);
	if (sent.has(key)) return;
	sent.add(key);

	const extra = {
		userAgent: window?.navigator?.userAgent,
		vendor: window?.navigator?.vendor || 'unknown',
		platform:
			window?.navigator?.userAgentData?.platform ||
			window?.navigator?.platform ||
			'unknown',
		mobile: window?.navigator?.userAgentData?.mobile,
		width: window.innerWidth,
		height: window.innerHeight,
		screenHeight: window.screen.height,
		screenWidth: window.screen.width,
		orientation: window.screen.orientation?.type,
		touchSupport: 'ontouchstart' in window || navigator.maxTouchPoints > 0,
	};

	const payload = JSON.stringify({
		...reqDataBasics,
		siteProfile: {
			type: reqDataBasics?.siteProfile?.type,
			title: reqDataBasics?.siteProfile?.title,
			description: reqDataBasics?.siteProfile?.description,
			descriptionRaw: reqDataBasics?.siteProfile?.descriptionRaw,
			objective: reqDataBasics?.siteProfile?.objective,
			category: reqDataBasics?.siteProfile?.category,
			structure: reqDataBasics?.siteProfile?.structure,
			imageSearchTerms: reqDataBasics?.siteProfile?.imageSearchTerms,
		},
		...details,
		error: errorData,
		type,
		extra,
	});

	return fetch(`${AI_HOST}/api/digest`, {
		method: 'POST',
		headers: {
			'Content-Type': 'application/json',
			Accept: 'application/json',
			'X-Extendify': 'true',
		},
		body: payload,
		keepalive: true,
	}).catch(() => {});
};

```
