Skip to content

Commit e4809d1

Browse files
committed
0.0.76
1 parent a46106b commit e4809d1

11 files changed

Lines changed: 22 additions & 53 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": "traceo-sdk",
3-
"version": "0.0.72-alpha",
3+
"version": "0.0.76-alpha",
44
"license": "MIT",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/core/global.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { TraceoGlobal } from "../transport/base";
22

3-
export const getGlobalClientData = (): TraceoGlobal =>
4-
global.__TRACEO__ || {};
3+
export const getGlobalClientData = (): TraceoGlobal => global.__TRACEO__ || {};
54

65
export const setGlobalClientData = (data: TraceoGlobal): void => {
76
global.__TRACEO__ = { ...data };

src/core/http.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const createHttpOptions = ({
3030
headers: {
3131
"Content-Type": "application/json",
3232
"Content-Length": `${Buffer.byteLength(JSON.stringify(event))}`,
33-
"traceo-secret-key": secretKey
33+
"traceo-secret-key": secretKey,
3434
},
3535
};
3636

@@ -43,7 +43,7 @@ const createHttpOptions = ({
4343
const statusFromCode = (code: number) =>
4444
code >= 200 && code <= 299 ? RequestStatus.SUCCESS : RequestStatus.ERROR;
4545

46-
export const sendConnection = (connectionData: TraceoReleaseEvent): void => {
46+
export const sendRelease = (connectionData: TraceoReleaseEvent): void => {
4747
const httpOptions = createHttpOptions({
4848
event: connectionData,
4949
api: "release",
@@ -56,9 +56,7 @@ export const sendConnection = (connectionData: TraceoReleaseEvent): void => {
5656
request.end();
5757
};
5858

59-
export const sendEvent = async (
60-
event: TraceoEvent
61-
): Promise<EventResponse> => {
59+
export const sendEvent = async (event: TraceoEvent): Promise<EventResponse> => {
6260
const client = getGlobalClientData();
6361

6462
const baseData = {

src/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import { Middleware, catchException } from "./node/middlewares";
22
import * as Traceo from "./node/sdk";
3-
import { ExceptionPriority } from "./transport/enums";
4-
import { CatchExceptionsOptions } from "./transport/options";
53

64
export {
75
Middleware,
86
Traceo,
97
catchException,
10-
CatchExceptionsOptions,
11-
ExceptionPriority,
128
};

src/node/helpers.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,13 @@ export const getOsPlatform = (): Platform => {
6262
};
6363

6464
export const sanitizeDsn = (dsn: string) => {
65-
const [secretKey, rest] = dsn.replace("https://", "").split(":");
65+
//TODO: check for https
66+
const [secretKey, rest] = dsn.replace("http://", "").split(":");
6667
const [host, appId] = rest.split("/");
6768

6869
return {
69-
secretKey, host, appId
70-
}
71-
}
70+
secretKey,
71+
host,
72+
appId,
73+
};
74+
};

src/node/middlewares.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@ import { sendEvent } from "../core/http";
22
import { isClientConnected, isLocalhost } from "../core/is";
33
import { TraceoError } from "../transport/base";
44
import { TraceoEvent } from "../transport/events";
5+
import { TraceoIncomingMessage, TraceoServerResponse } from "../transport/http";
56
import {
6-
TraceoIncomingMessage,
7-
TraceoServerResponse,
8-
} from "../transport/http";
9-
import {
10-
CatchExceptionsOptions,
117
ErrorMiddlewareOptions,
128
} from "../transport/options";
139
import { getIp, getProtocol } from "./helpers";
@@ -77,7 +73,6 @@ const isToCatch = (
7773
};
7874

7975
interface Catch {
80-
// options?: CatchExceptionsOptions;
8176
shouldBeCatched?: (error: any) => boolean;
8277
}
8378

@@ -122,10 +117,9 @@ export const catchException = async (error: any, catchOptions?: Catch) => {
122117
const handleException = async (
123118
error: TraceoError,
124119
req?: TraceoIncomingMessage,
125-
options?: CatchExceptionsOptions
126120
) => {
127121
try {
128-
const event: TraceoEvent = await prepareException(error, options, req);
122+
const event: TraceoEvent = await prepareException(error, req);
129123
await sendEvent(event);
130124
} catch (err) {
131125
//

src/node/parse.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Trace } from "../transport/trace";
22
import { promises, existsSync } from "fs";
33
import { TraceoError } from "../transport/base";
4-
import { CatchExceptionsOptions } from "../transport/options";
54
import { TraceoEvent } from "../transport/events";
65
import { TraceoIncomingMessage } from "../transport/http";
76
import { getOsPlatform, mapRequestData } from "./helpers";
@@ -125,7 +124,6 @@ const readFileAsync = async (path: string): Promise<string> => {
125124

126125
export const prepareException = async (
127126
error: TraceoError,
128-
options?: CatchExceptionsOptions,
129127
req?: TraceoIncomingMessage
130128
): Promise<TraceoEvent> => {
131129
const { message, name } = error;
@@ -138,7 +136,6 @@ export const prepareException = async (
138136
message,
139137
traces,
140138
stack: String(error.stack),
141-
options,
142139
platform,
143140
};
144141

src/node/sdk.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
import { setGlobalClientData } from "../core/global";
2-
import { sendConnection } from "../core/http";
2+
import { sendRelease } from "../core/http";
33
import { isClientConnected } from "../core/is";
44
import { TraceoReleaseEvent } from "../transport/events";
55
import { TraceoOptions } from "../transport/options";
66
import { getOsPlatform } from "./helpers";
77

88
/**
99
*
10-
* Function to connect client with Traceo App.
10+
* Function to connect client with Traceo Instance.
1111
*
1212
* @param options
1313
*
1414
*/
15-
export const init = (
16-
options: TraceoOptions
17-
): void => {
15+
export const init = (options: TraceoOptions): void => {
1816
if (!isClientConnected()) {
1917
setGlobalClientData({
20-
...options
18+
...options,
2119
});
2220
}
2321

@@ -27,5 +25,5 @@ export const init = (
2725
os: getOsPlatform(),
2826
};
2927

30-
sendConnection(conn);
28+
sendRelease(conn);
3129
};

src/transport/enums.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,3 @@ export enum RequestStatus {
1414
SUCCESS = "success",
1515
ERROR = "error",
1616
}
17-
18-
export enum ExceptionPriority {
19-
MINOR = "minor",
20-
IMPORTANT = "important",
21-
CRITICAL = "critical",
22-
}

src/transport/events.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CatchType, ExceptionPriority } from "./enums";
1+
import { CatchType } from "./enums";
22
import { TraceoRequest } from "./http";
33
import { Trace } from "./trace";
44
import { Environment } from "./types";
@@ -29,18 +29,14 @@ export interface TraceoEvent {
2929
traces: Trace[];
3030
requestData?: TraceoRequest;
3131
catchType?: CatchType;
32-
options?: {
33-
priority?: ExceptionPriority;
34-
tag?: string;
35-
};
3632
env?: Environment;
3733
version?: string;
3834
platform: Platform;
3935
}
4036

4137
export interface TraceoReleaseEvent {
4238
version?: string;
43-
env: Environment;
39+
env?: Environment;
4440
os: Platform;
4541
}
4642

0 commit comments

Comments
 (0)