SvelteKit
The following is an example of how to use monitro with sveltekit, this is a simple example and not the best way to use monitro, but it should give you an idea of how to use it.
$lib/server.ts
//$lib/server.ts
import { Monitro } from 'monitro'
import { API_KEY } from '$env/static/private'
export const monitroClient = new Monitro('monitro-dev', API_KEY, { hookExceptions: true, dev: false});
// this can be any file in your project, but just make it accessible to all your server functions
+page.server.ts
//+page.server.tss
import { monitroClient } from '$lib/server'
export const load = async () => {
try {
const result = await getUser('abcedfg')
}
catch(e){
monitroClient.error('Failed To Get User', 'getUser() function threw an error', { error: e, userId: 'abcedfg' })
return { result: null }
}
return { result }
}
Monitro's cleint can be used anywhere in svelte but keep it on the server side, you can use this on the clients browser but it is NOT recomended as currently the API key has no protection to abuse, we plan on adding this in the future.