logdna / logdna/logdna-browser

[2.0.3] Export `captureError` from root.

Open
#32 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
23
Forks
10
PR merge metrics
No merged PRs in 30d

Description

In `v1.x.x` I was able to (albeit indirectly) access `captureError` which was really useful when I just needed to pipe an error directly from a `catch` without a lot dealing with the full logger.

I previously was destructuring this from the instantiated root logger (https://github.com/logdna/logdna-browser/blob/v1.1.4/src/index.ts#L165) but as far as I can tell there is no direct access anymore via the root `methods` export (https://github.com/logdna/logdna-browser/blob/v2.0.3/src/LogDNAMethods.ts)

It would be awesome to get access to https://github.com/logdna/logdna-browser/blob/v2.0.3/src/capture.ts#L34 from the root index exports.

```typescript
// index.ts

import { LogDNAMethods } from './LogDNAMethods';

import { init, config, methods } from './init';
import plugins from './plugins';
import { addContext } from './context-manager';
import { setSessionId } from './session-manager';
import { captureError } from './capture';

// ...

export { captureError }
export default methods;

```

### Example use case

```typescript

import { captureError, debug } from "./logger"

const fooAsync = async () => {
try {
// ...
} catch (error) {
captureError(error)
} finally {
debug(`Completed foo.`)
}
}

const barSync = (url: string) => {
fetch(url).then(() => {
// ...
}).catch(captureError)
}

```

Contributor guide

Open the contributing guide

Research direction

Start with src/index.ts and compare its root exports with src/LogDNAMethods.ts and the captureError implementation in src/capture.ts. Verify that captureError is available from the package root without changing the existing default methods export, and confirm the documented import and callback use case works.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, frontend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.