Skip to content

Commit 042331b

Browse files
committed
new klepper sdk endpoint, added appId, fixes
1 parent 8bf0d46 commit 042331b

6 files changed

Lines changed: 15 additions & 8 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "klepper",
3-
"version": "0.0.41-alpha",
3+
"version": "0.0.43-alpha",
44
"license": "MIT",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/core/http.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,22 @@ import { getGlobalClientData } from "./global";
66
import { isClientConnected } from "./is";
77

88
const KLEPPER_HOST = process.env.KLEPPER_HOST || "localhost";
9-
const KLEPPER_API = process.env.KLEPPER_API || "/test";
10-
const KLEPPER_PORT = process.env.KLEPPER_PORT || 3000;
9+
const KLEPPER_API = process.env.KLEPPER_API || "/sdk/incident";
10+
const KLEPPER_PORT = process.env.KLEPPER_PORT || 8080;
1111

1212
const createHttpOptions = (event: KlepperEvent): http.RequestOptions => {
1313
const client = getGlobalClientData();
1414

15-
const { privateKey } = client;
15+
const { privateKey, appId } = client;
1616
const baseOptions: RequestOptions = {
1717
hostname: KLEPPER_HOST,
1818
port: +KLEPPER_PORT,
1919
method: "POST",
2020
headers: {
2121
"Content-Type": "application/json",
2222
"Content-Length": `${Buffer.byteLength(JSON.stringify(event))}`,
23-
"Klepper-Project-Key": privateKey as string,
23+
"klepper-project-key": String(privateKey),
24+
"klepper-app-id": String(appId),
2425
},
2526
};
2627

@@ -74,7 +75,7 @@ export const sendEvent = async (
7475

7576
res.on("error", reject);
7677
});
77-
78+
7879
request.on("error", reject);
7980

8081
request.on("timeout", () => {

src/node/middlewares.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getGlobalClientData } from "../core/global";
12
import { sendEvent } from "../core/http";
23
import { isClientConnected, isLocalhost } from "../core/is";
34
import { KlepperError } from "../transport/base";
@@ -14,7 +15,10 @@ import {
1415
import { getIp, getProtocol, mapRequestData } from "./helpers";
1516

1617
/**
17-
* Base middleware to catch and intercept error across the app.
18+
* Base middleware to catch and intercept error across the express app.
19+
* This middleware catch errors only from the no-async methods.
20+
*
21+
* To catch errors from async functions, we suggest to use `catchException` instead.
1822
*
1923
* The simplest way to use it in Express.js and JavaScript:
2024
*

src/node/sdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { setGlobalClientData } from "../core/global";
22
import { isClientConnected } from "../core/is";
33
import { KlepperOptions } from "../transport/options";
44

5-
export const defaultBooleanCallback = () => true;
5+
const defaultBooleanCallback = () => true;
66

77
/**
88
*

src/transport/base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export interface BaseObject {
77
export interface KlepperGlobal {
88
environment?: Environment;
99
privateKey?: string;
10+
appId?: string;
1011
}
1112

1213
export interface KlepperError extends Error {}

src/transport/options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Environment } from "./types";
44
export interface KlepperOptions {
55
environment?: Environment;
66
privateKey: string;
7+
appId: string;
78
}
89

910
export interface ErrorMiddlewareOptions {

0 commit comments

Comments
 (0)