Skip to content
Open
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 index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { DuckBugWrapper, useDuckBug } from './src/DuckBugWrapper'
export { DuckBugWrapper, DuckBugProvider, useDuckBug } from './src/DuckBugWrapper'
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "duckbug-react",
"version": "1.0.2",
"version": "1.0.3",
"description": "React SDK for DuckBug error tracking",
"main": "./dist/index.umd.js",
"module": "./dist/index.es.js",
Expand All @@ -20,7 +20,7 @@
"sdk",
"error-tracking"
],
"author": "Your Name",
"author": "Evgeniy Dolgov",
"license": "MIT",
"scripts": {
"build": "vite build",
Expand Down
11 changes: 5 additions & 6 deletions src/DuckBugWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ import { DuckBugProvider, DuckSDK, LogProviderConfig } from '@duckbug/js';

type Props = {
children: React.ReactNode
dsn: string
providers: DuckBugProvider[]
config?: LogProviderConfig
}

let duck: DuckSDK | null = null;

export const DuckBugWrapper = ({children, dsn, config}: Props) => {

const providers = [new DuckBugProvider({ dsn: dsn })];
export const DuckBugWrapper = ({children, config, providers}: Props) => {
duck = new DuckSDK(providers, config);

window.onerror = (message, source, error) => {
Expand All @@ -31,10 +29,11 @@ export const DuckBugWrapper = ({children, dsn, config}: Props) => {
)
}


export const useDuckBug = () => {
if (!duck) {
throw new Error('DuckBug not initialized. Use DuckBugWrapper first.');
}
return duck;
}
}

export { DuckBugProvider }