44} from "@exceptionless/core" ;
55
66import { NodeConfiguration } from "./configuration/NodeConfiguration.js" ;
7+ import { NodeGlobalHandlerPlugin } from "./plugins/NodeGlobalHandlerPlugin.js" ;
8+ import { NodeLifeCyclePlugin } from "./plugins/NodeLifeCyclePlugin.js" ;
9+ import { NodeWrapFunctions } from "./plugins/NodeWrapFunctions.js" ;
710import { NodeEnvironmentInfoCollector } from "./services/NodeEnvironmentInfoCollector.js" ;
811import { NodeErrorParser } from "./services/NodeErrorParser.js" ;
912import { NodeRequestInfoCollector } from "./services/NodeRequestInfoCollector.js" ;
@@ -15,92 +18,19 @@ export class NodeExceptionlessClient extends ExceptionlessClient {
1518 }
1619
1720 public async startup ( configurationOrApiKey ?: ( config : NodeConfiguration ) => void | string ) : Promise < void > {
18- if ( configurationOrApiKey ) {
19- this . config . services . environmentInfoCollector = new NodeEnvironmentInfoCollector ( ) ;
20- this . config . services . errorParser = new NodeErrorParser ( ) ;
21- this . config . services . requestInfoCollector = new NodeRequestInfoCollector ( ) ;
22- this . config . services . submissionClient = new NodeFetchSubmissionClient ( this . config ) ;
21+ const config = this . config ;
2322
24- // TODO: Register platform specific plugins.
23+ if ( configurationOrApiKey ) {
24+ config . services . environmentInfoCollector = new NodeEnvironmentInfoCollector ( ) ;
25+ config . services . errorParser = new NodeErrorParser ( ) ;
26+ config . services . requestInfoCollector = new NodeRequestInfoCollector ( ) ;
27+ config . services . submissionClient = new NodeFetchSubmissionClient ( config ) ;
28+
29+ config . addPlugin ( new NodeGlobalHandlerPlugin ( ) ) ;
30+ config . addPlugin ( new NodeLifeCyclePlugin ( ) ) ;
31+ config . addPlugin ( new NodeWrapFunctions ( ) ) ;
2532 }
2633
2734 await super . startup ( configurationOrApiKey ) ;
2835 }
2936}
30- /*
31-
32-
33- import {
34- addListener,
35- on
36- } from "process";
37-
38- addListener("uncaughtException", (error: Error) => {
39- //ExceptionlessClient.default.submitUnhandledException(error, "uncaughtException");
40- });
41-
42- // TODO: Handle submission https://stackoverflow.com/questions/40574218/how-to-perform-an-async-operation-on-exit
43-
44- on("exit", (code: number) => {
45- /**
46- * exit codes: https://nodejs.org/api/process.html#process_event_exit
47- * From now on, only synchronous code may run. As soon as this method
48- * ends, the application inevitably will exit.
49- */
50- /*
51- function getExitCodeReason(exitCode: number): string {
52- if (exitCode === 1) {
53- return "Uncaught Fatal Exception";
54- }
55-
56- if (exitCode === 3) {
57- return "Internal JavaScript Parse Error";
58- }
59-
60- if (exitCode === 4) {
61- return "Internal JavaScript Evaluation Failure";
62- }
63-
64- if (exitCode === 5) {
65- return "Fatal Exception";
66- }
67-
68- if (exitCode === 6) {
69- return "Non-function Internal Exception Handler ";
70- }
71-
72- if (exitCode === 7) {
73- return "Internal Exception Handler Run-Time Failure";
74- }
75-
76- if (exitCode === 8) {
77- return "Uncaught Exception";
78- }
79-
80- if (exitCode === 9) {
81- return "Invalid Argument";
82- }
83-
84- if (exitCode === 10) {
85- return "Internal JavaScript Run-Time Failure";
86- }
87-
88- if (exitCode === 12) {
89- return "Invalid Debug Argument";
90- }
91-
92- return null;
93- }
94-
95- const message = getExitCodeReason(code);
96-
97- if (message !== null) {
98- Exceptionless.submitLog("exit", message, "Error");
99- }
100-
101- Exceptionless.config.queue.process();
102- // Application will now exit.
103- });
104-
105- //(Error as any).stackTraceLimit = Infinity;
106- */
0 commit comments