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": "@isimplifyme/ui",
"version": "1.6.0",
"version": "1.7.0",
"description": "React/Next.js UI library for iSimplifyMe properties \u2014 design system, article layouts, SEO helpers, bot middleware, and the iSM Concierge widget.",
"homepage": "https://isimplifyme.com",
"type": "module",
Expand Down
30 changes: 30 additions & 0 deletions src/concierge.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,33 @@ describe('the disclaimer band exists before it has anything to say', () => {
expect(after?.textContent).toContain('Not a person.');
});
});

// ── Open beacon (apex `{"event":"open"}`, fleet audit 2026-11-05) ──────────
// Ships to every site on a `^` range, so the default path is pinned too: no
// focus, no beacon.
describe('open beacon', () => {
function beacons() {
const calls = (globalThis.fetch as unknown as { mock: { calls: [string, RequestInit?][] } }).mock.calls;
return calls.filter(([, init]) => typeof init?.body === 'string' && init.body.includes('"event":"open"'));
}

it('sends nothing before the input is focused', () => {
render();
expect(beacons()).toHaveLength(0);
});

it('sends exactly one beacon, to the configured endpoint, on first focus', () => {
const { input } = render({ endpoint: '/api/x' });
act(() => {
input.focus();
});
act(() => {
input.blur();
input.focus();
});
const sent = beacons();
expect(sent).toHaveLength(1);
expect(sent[0][0]).toBe('/api/x');
expect(JSON.parse(String(sent[0][1]?.body))).toEqual({ event: 'open', pathname: window.location.pathname });
});
});
17 changes: 17 additions & 0 deletions src/concierge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,23 @@ export default function ConciergeWidget({
const [isLoading, setIsLoading] = useState(false);
const [sessionId, setSessionId] = useState<string | null>(null);
const [isFocused, setIsFocused] = useState(false);

// Count the visitor's first engagement per page load: apex `{"event":"open"}`
// through the same proxy (apex lib/concierge/opens, #578). This bar is always
// visible and `isOpen` only flips on the first send, so the step before a
// conversation is the first focus of the input. Until 2026-11 nothing
// recorded it. Best effort; never blocks the bar.
const openCounted = useRef(false);
useEffect(() => {
if (!isFocused || openCounted.current) return;
openCounted.current = true;
fetch(endpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ event: 'open', pathname: window.location.pathname }),
keepalive: true,
}).catch(() => {});
}, [isFocused, endpoint]);
const [error, setError] = useState<string | null>(null);
const [isMac, setIsMac] = useState(true);
// Narrow viewports get no keyboard shortcut chip. Starts false so the
Expand Down
Loading