-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #207 from jerriclynsjohn/axiom-svelte
Fixing Sveltekit package and example issues
- Loading branch information
Showing
12 changed files
with
92 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { HandleClientError } from '@sveltejs/kit'; | ||
|
||
import { Logger } from '@axiomhq/sveltekit'; | ||
|
||
import { dev, browser, version } from '$app/environment' | ||
|
||
|
||
const logger = new Logger({ | ||
args: { dev, browser, version } | ||
}); | ||
|
||
|
||
export const handleError: HandleClientError = async ({ error, event, status, message }) => { | ||
|
||
const url = new URL(event.url); | ||
console.log({ url }) | ||
logger.error(`${message}`, { | ||
exception: error, request: { | ||
host: url.hostname, | ||
path: url.pathname, | ||
status: status | ||
}, | ||
source: 'hooks', | ||
}); | ||
|
||
await logger.flush() | ||
|
||
return { message } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import { AXIOM_TOKEN, AXIOM_DATASET } from '$env/static/private'; | ||
import type { RequestHandler } from '@sveltejs/kit'; | ||
|
||
import { AxiomWithoutBatching } from '@axiomhq/js' | ||
import { PUBLIC_AXIOM_URL } from '$env/static/public'; | ||
|
||
const axiom = new AxiomWithoutBatching({ token: AXIOM_TOKEN, url: PUBLIC_AXIOM_URL }); | ||
import { AXIOM_TOKEN, AXIOM_DATASET, AXIOM_URL } from '$env/static/private'; | ||
|
||
const axiom = new AxiomWithoutBatching({ token: AXIOM_TOKEN, url: AXIOM_URL }); | ||
|
||
/** @type {import('./$types').RequestHandler} */ | ||
export async function POST({ url, platform, request }) { | ||
console.log({ url, platform }) | ||
export const POST: RequestHandler = async ({ request }) => { | ||
|
||
const events = await request.json() | ||
axiom.ingest(AXIOM_DATASET, events) | ||
|
||
|
||
return new Response("OK"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { RequestHandler } from '@sveltejs/kit'; | ||
|
||
export const GET: RequestHandler = async () => { | ||
throw new Error(" Example API Route Error"); | ||
}; |
7 changes: 7 additions & 0 deletions
7
examples/svelte-app/src/routes/client-error-sample/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div> | ||
<main> | ||
<p> | ||
If it works | ||
</p> | ||
</main> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { PageLoad } from "../$types"; | ||
|
||
export const load: PageLoad = async () => { | ||
throw new Error(" Example Page Load Error"); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<script lang="ts"> | ||
async function failure() { | ||
const res = await fetch('/api/error'); | ||
if (!res.ok) { | ||
throw new Error('Example Frontend Error'); | ||
} | ||
} | ||
</script> | ||
|
||
<div> | ||
<main> | ||
<button type="button" on:click|preventDefault={failure}> Throw error! </button> | ||
</main> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.