Svelte documentation
SVELTE@fintechiq/logwatcher-svelte — wraps the
JavaScript SDK for Svelte and SvelteKit:
handleError hook factory, navigation-transition logging, deep-link stores. Everything from the core SDK
is re-exported, so one import covers both.
Getting started
You need an application key. Create an account, add an app in the dashboard, and copy the key shown on its card. Every SDK call is tied to that key.
Install the SDK
The Svelte package wraps @fintechiq/logwatcher (installed automatically as a
file: dependency). From a checkout of the repository:
npm install file:path/to/client-sdks/svelte/logwatcher-sdk
Initialize
Initialize once — for SvelteKit, the root layout or the client hooks file is the natural place:
// e.g. src/routes/+layout.svelte or hooks.client.js
import { initLogWatcher } from '@fintechiq/logwatcher-svelte';
initLogWatcher('YOUR_APP_KEY', {
apiUrl: 'https://fintechiq-logwatcher-19133922986.europe-west1.run.app',
});
Same options as the JavaScript SDK; the wrapper reports sdk_type: "svelte".
Send logs
The per-level helpers are plain named exports:
import { d, i, w, e, logNavigation } from '@fintechiq/logwatcher-svelte';
d('PaymentFlow', 'card inserted · reading chip');
i('PaymentFlow', 'auth approved · code 00');
Record SvelteKit navigations as TRANSITION rows in the dashboard's log viewer:
<!-- src/routes/+layout.svelte -->
<script>
import { afterNavigate } from '$app/navigation';
import { logNavigation } from '@fintechiq/logwatcher-svelte';
afterNavigate((nav) => logNavigation(nav));
</script>
| Level | Method | Wire value |
|---|---|---|
| Debug | d() | 0 |
| Warning | w() | 1 |
| Error | e() | 2 |
| Trace | t() | 3 |
| Info | i() | 4 |
| Fatal | f() | 5 |
The non-sequential wire values are part of the LogWatcher wire protocol — the SDK handles the mapping.
Crash reporting
Wire LogWatcher into SvelteKit's error hooks — one line per side:
// hooks.client.js and hooks.server.js
import { createHandleError } from '@fintechiq/logwatcher-svelte';
export const handleError = createHandleError();
Every unexpected error is reported as a crash (with stack and route) and the hook returns a safe
{ message } for the user. Browser-global errors are captured too when
enableCrashReporting is set at init.
Issues & user feedback
Report a noteworthy condition as an issue, or collect a message from the user. Each call returns a deep-link to the item in your dashboard.
import { sendIssue, sendUserFeedback } from '@fintechiq/logwatcher-svelte';
const url = sendIssue('Sync failed', '3 retries exhausted on /settle');
sendUserFeedback('From the merchant', 'Receipt printed twice today');
Device key-values
Attach searchable properties to a device — a store number, a merchant id, a build flavour:
import { setDeviceString, setDeviceInteger } from '@fintechiq/logwatcher-svelte';
setDeviceString('store', 'ATH-0042');
setDeviceInteger('lane', 2);
Remote device control
On every launch the SDK registers the device and receives its remote flags. From the dashboard you can enable log collection for a single device while the rest of the fleet stays quiet — no release, no restart loop. To force collection locally regardless of the remote flag:
import { setForceEnabled, forceSendOnce } from '@fintechiq/logwatcher-svelte';
setForceEnabled(true); // override the remote toggle
forceSendOnce(); // flush the queue right now
Advanced options
| Export | What it does |
|---|---|
initLogWatcher(appKey, options) | Initializes the core SDK with sdk_type: "svelte". Same options as the JavaScript SDK. |
createHandleError(opts) | Returns a SvelteKit handleError hook that reports crashes and returns a safe message. |
logNavigation(navigation) | Logs a SvelteKit navigation as a TRANSITION row (pair with afterNavigate). |
deviceUrl / sessionUrl | Svelte-store contract (subscribe) resolving to the dashboard deep-links after init — use directly with $deviceUrl. |
| Core re-exports | Everything from @fintechiq/logwatcher: t/d/i/w/e/f, log, transition, sendIssue/sendCrash/sendUserFeedback, key-value setters, setForceEnabled, forceSendOnce, setMaximumLocalStorageSize, getDeviceUrl/getSessionUrl, flush(). |