@segment/actions-shared 1.97.0 → 1.98.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engage/utils/AggregateError.d.ts +14 -0
- package/dist/engage/utils/AggregateError.js +26 -0
- package/dist/engage/utils/AggregateError.js.map +1 -0
- package/dist/engage/utils/EngageActionPerformer.d.ts +42 -0
- package/dist/engage/utils/EngageActionPerformer.js +148 -0
- package/dist/engage/utils/EngageActionPerformer.js.map +1 -0
- package/dist/engage/utils/EngageLogger.d.ts +18 -0
- package/dist/engage/utils/EngageLogger.js +52 -0
- package/dist/engage/utils/EngageLogger.js.map +1 -0
- package/dist/engage/utils/EngageStats.d.ts +18 -0
- package/dist/engage/utils/EngageStats.js +95 -0
- package/dist/engage/utils/EngageStats.js.map +1 -0
- package/dist/engage/utils/IntegrationErrorWrapper.d.ts +12 -0
- package/dist/engage/utils/IntegrationErrorWrapper.js +31 -0
- package/dist/engage/utils/IntegrationErrorWrapper.js.map +1 -0
- package/dist/engage/utils/MessageSendPerformer.d.ts +65 -0
- package/dist/engage/utils/MessageSendPerformer.js +211 -0
- package/dist/engage/utils/MessageSendPerformer.js.map +1 -0
- package/dist/engage/utils/Profile.d.ts +6 -0
- package/dist/engage/utils/Profile.js +3 -0
- package/dist/engage/utils/Profile.js.map +1 -0
- package/dist/engage/utils/ResponseError.d.ts +25 -0
- package/dist/engage/utils/ResponseError.js +22 -0
- package/dist/engage/utils/ResponseError.js.map +1 -0
- package/dist/engage/utils/getProfileApiEndpoint.d.ts +2 -0
- package/dist/engage/utils/getProfileApiEndpoint.js +10 -0
- package/dist/engage/utils/getProfileApiEndpoint.js.map +1 -0
- package/dist/engage/utils/index.d.ts +14 -0
- package/dist/engage/utils/index.js +27 -0
- package/dist/engage/utils/index.js.map +1 -0
- package/dist/engage/utils/isDestinationActionService.d.ts +1 -0
- package/dist/engage/utils/isDestinationActionService.js +8 -0
- package/dist/engage/utils/isDestinationActionService.js.map +1 -0
- package/dist/engage/utils/isRetryableError.d.ts +2 -0
- package/dist/engage/utils/isRetryableError.js +33 -0
- package/dist/engage/utils/isRetryableError.js.map +1 -0
- package/dist/engage/utils/operationTracking/GenericMethodDecorator.d.ts +1 -0
- package/dist/engage/utils/operationTracking/GenericMethodDecorator.js +3 -0
- package/dist/engage/utils/operationTracking/GenericMethodDecorator.js.map +1 -0
- package/dist/engage/utils/operationTracking/OperationDecorator.d.ts +46 -0
- package/dist/engage/utils/operationTracking/OperationDecorator.js +46 -0
- package/dist/engage/utils/operationTracking/OperationDecorator.js.map +1 -0
- package/dist/engage/utils/operationTracking/OperationDuration.d.ts +12 -0
- package/dist/engage/utils/operationTracking/OperationDuration.js +23 -0
- package/dist/engage/utils/operationTracking/OperationDuration.js.map +1 -0
- package/dist/engage/utils/operationTracking/OperationErrorHandler.d.ts +12 -0
- package/dist/engage/utils/operationTracking/OperationErrorHandler.js +35 -0
- package/dist/engage/utils/operationTracking/OperationErrorHandler.js.map +1 -0
- package/dist/engage/utils/operationTracking/OperationFinallyHooks.d.ts +14 -0
- package/dist/engage/utils/operationTracking/OperationFinallyHooks.js +31 -0
- package/dist/engage/utils/operationTracking/OperationFinallyHooks.js.map +1 -0
- package/dist/engage/utils/operationTracking/OperationLogger.d.ts +31 -0
- package/dist/engage/utils/operationTracking/OperationLogger.js +104 -0
- package/dist/engage/utils/operationTracking/OperationLogger.js.map +1 -0
- package/dist/engage/utils/operationTracking/OperationStats.d.ts +39 -0
- package/dist/engage/utils/operationTracking/OperationStats.js +130 -0
- package/dist/engage/utils/operationTracking/OperationStats.js.map +1 -0
- package/dist/engage/utils/operationTracking/OperationTree.d.ts +23 -0
- package/dist/engage/utils/operationTracking/OperationTree.js +49 -0
- package/dist/engage/utils/operationTracking/OperationTree.js.map +1 -0
- package/dist/engage/utils/operationTracking/TrackedError.d.ts +6 -0
- package/dist/engage/utils/operationTracking/TrackedError.js +3 -0
- package/dist/engage/utils/operationTracking/TrackedError.js.map +1 -0
- package/dist/engage/utils/operationTracking/index.d.ts +10 -0
- package/dist/engage/utils/operationTracking/index.js +23 -0
- package/dist/engage/utils/operationTracking/index.js.map +1 -0
- package/dist/engage/utils/operationTracking/wrapTryCatchFinallyPromisable.d.ts +21 -0
- package/dist/engage/utils/operationTracking/wrapTryCatchFinallyPromisable.js +99 -0
- package/dist/engage/utils/operationTracking/wrapTryCatchFinallyPromisable.js.map +1 -0
- package/dist/engage/utils/testUtils.d.ts +6 -0
- package/dist/engage/utils/testUtils.js +27 -0
- package/dist/engage/utils/testUtils.js.map +1 -0
- package/dist/engage/utils/track.d.ts +52 -0
- package/dist/engage/utils/track.js +9 -0
- package/dist/engage/utils/track.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationErrorHandler.js","sourceRoot":"","sources":["../../../../src/engage/utils/operationTracking/OperationErrorHandler.ts"],"names":[],"mappings":";;;AAaA,MAAa,qBAAqB;IAChC,MAAM,CAAC,sBAAsB,CAAC,IAAkC;QAC9D,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,GAAiC;QAC9C,MAAM,KAAK,GAAG,GAAG,CAAC,aAAa,CAAA;QAG/B,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CACnB,GAAG,CAAC,KAAK,EACT,GAAG,EAAE;YAEH,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;YAClC,OAAO,GAAG,CAAC,KAAqB,CAAA;QAClC,CAAC,EACD,GAAG,CACJ,CAAA;IACH,CAAC;IAED,MAAM,CAAC,IAAI,CACT,aAAsB,EACtB,UAA+C,EAC/C,GAAc;QAEd,MAAM,OAAO,GAAG,UAAU,CAAC,aAAa,CAAiB,CAAA;QAEzD,IAAI,OAAO,IAAI,aAAa,KAAK,OAAO;YAAE,OAAO,CAAC,eAAe,GAAG,aAAa,CAAA;QAEjF,MAAM,YAAY,GAAG,OAAO,CAAA;QAC5B,IAAI,CAAC,YAAY;YAAE,OAAM;QAEzB,IAAI,CAAC,GAAG;YAAE,OAAM;QAGhB,IAAI,CAAC,YAAY,CAAC,cAAc;YAAE,YAAY,CAAC,cAAc,GAAG,GAAG,CAAA;QAGnE,MAAM,kBAAkB,GAAG,MAAM,CAAC,wBAAwB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAA;QAC1F,IAAI,kBAAkB,EAAE,UAAU,EAAE;YAElC,kBAAkB,CAAC,UAAU,GAAG,KAAK,CAAA;YACrC,MAAM,CAAC,cAAc,CAAC,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,CAAC,CAAA;SAC1E;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AA/CD,sDA+CC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TryCatchFinallyContext, TryCatchFinallyHook } from './wrapTryCatchFinallyPromisable';
|
|
2
|
+
export declare type OperationFinallyHooksContext<TContext extends TryCatchFinallyContext = TryCatchFinallyContext> = TContext & {
|
|
3
|
+
onFinally: (() => void)[];
|
|
4
|
+
decoratorArgs?: {
|
|
5
|
+
onTry?: (ctx: TContext) => void;
|
|
6
|
+
onFinally?: (ctx: TContext) => void;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export declare class OperationFinallyHooks {
|
|
10
|
+
static getTryCatchFinallyHook(_ctx: OperationFinallyHooksContext): TryCatchFinallyHook<OperationFinallyHooksContext>;
|
|
11
|
+
static getPriority(): number;
|
|
12
|
+
static onTry<TContext extends TryCatchFinallyContext>(ctx: OperationFinallyHooksContext<TContext>): void;
|
|
13
|
+
static onFinally<TContext extends TryCatchFinallyContext>(ctx: OperationFinallyHooksContext<TContext>): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperationFinallyHooks = void 0;
|
|
4
|
+
class OperationFinallyHooks {
|
|
5
|
+
static getTryCatchFinallyHook(_ctx) {
|
|
6
|
+
return this;
|
|
7
|
+
}
|
|
8
|
+
static getPriority() {
|
|
9
|
+
return 100;
|
|
10
|
+
}
|
|
11
|
+
static onTry(ctx) {
|
|
12
|
+
ctx.onFinally = [];
|
|
13
|
+
ctx.decoratorArgs?.onTry?.(ctx);
|
|
14
|
+
}
|
|
15
|
+
static onFinally(ctx) {
|
|
16
|
+
for (const hook of ctx.onFinally) {
|
|
17
|
+
try {
|
|
18
|
+
hook();
|
|
19
|
+
}
|
|
20
|
+
catch (e) {
|
|
21
|
+
const error = e;
|
|
22
|
+
const loggerCtx = ctx;
|
|
23
|
+
if (loggerCtx.logs)
|
|
24
|
+
loggerCtx.logs.push(`Error in onFinally hook: ${error?.message || error.toString()}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
ctx.decoratorArgs?.onFinally?.(ctx);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.OperationFinallyHooks = OperationFinallyHooks;
|
|
31
|
+
//# sourceMappingURL=OperationFinallyHooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationFinallyHooks.js","sourceRoot":"","sources":["../../../../src/engage/utils/operationTracking/OperationFinallyHooks.ts"],"names":[],"mappings":";;;AAeA,MAAa,qBAAqB;IAChC,MAAM,CAAC,sBAAsB,CAAC,IAAkC;QAC9D,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,CAAC,WAAW;QAChB,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,MAAM,CAAC,KAAK,CAA0C,GAA2C;QAC/F,GAAG,CAAC,SAAS,GAAG,EAAE,CAAA;QAClB,GAAG,CAAC,aAAa,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAA;IACjC,CAAC;IAED,MAAM,CAAC,SAAS,CAA0C,GAA2C;QACnG,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,SAAS,EAAE;YAChC,IAAI;gBACF,IAAI,EAAE,CAAA;aACP;YAAC,OAAO,CAAC,EAAE;gBACV,MAAM,KAAK,GAAG,CAAU,CAAA;gBAExB,MAAM,SAAS,GAAG,GAAsC,CAAA;gBACxD,IAAI,SAAS,CAAC,IAAI;oBAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,4BAA4B,KAAK,EAAE,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;aAC1G;SACF;QACD,GAAG,CAAC,aAAa,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,CAAA;IACrC,CAAC;CACF;AA1BD,sDA0BC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TryCatchFinallyContext, TryCatchFinallyHook } from './wrapTryCatchFinallyPromisable';
|
|
2
|
+
import { TrackedError } from './TrackedError';
|
|
3
|
+
import { OperationDecoratorContext } from './OperationDecorator';
|
|
4
|
+
export declare type OperationLoggerContext<TContext extends TryCatchFinallyContext = TryCatchFinallyContext> = TContext & {
|
|
5
|
+
logs: string[];
|
|
6
|
+
logMetadata?: Record<string, unknown>;
|
|
7
|
+
decoratorArgs?: OperationLoggerDecoratorArgs;
|
|
8
|
+
sharedContext: OperationLoggerSharedContext;
|
|
9
|
+
};
|
|
10
|
+
export interface OperationLoggerSharedContext {
|
|
11
|
+
logs: string[];
|
|
12
|
+
logMetadata?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export interface OperationLoggerDecoratorArgs {
|
|
15
|
+
shouldLog?: (ctx: OperationLoggerContext) => boolean | void;
|
|
16
|
+
}
|
|
17
|
+
export declare abstract class OperationLogger implements TryCatchFinallyHook<OperationLoggerContext> {
|
|
18
|
+
static getTryCatchFinallyHook(_ctx: OperationLoggerContext): TryCatchFinallyHook<OperationLoggerContext>;
|
|
19
|
+
abstract logInfo(msg: string, metadata?: object): void;
|
|
20
|
+
abstract logError(msg: string, metadata?: object): void;
|
|
21
|
+
onTry(ctx: OperationLoggerContext): () => void;
|
|
22
|
+
onFinally(ctx: OperationLoggerContext): () => void;
|
|
23
|
+
stageLog(ctx: OperationLoggerContext): () => void;
|
|
24
|
+
shouldLogDefault(_ctx: OperationLoggerContext): boolean;
|
|
25
|
+
getOperationLogMessages(ctx: OperationLoggerContext): string[];
|
|
26
|
+
getOperationTryMessage(ctx: OperationLoggerContext): string;
|
|
27
|
+
getOperationName<TContext extends OperationDecoratorContext>(ctx: TContext, fullPath?: boolean, separator?: string): string;
|
|
28
|
+
getOperationCompletedMessage(ctx: OperationLoggerContext): string;
|
|
29
|
+
getOperationErrorDetails(error: TrackedError, ctx: OperationLoggerContext): string[];
|
|
30
|
+
getErrorMessage(error: unknown, _ctx?: OperationLoggerContext): string;
|
|
31
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperationLogger = void 0;
|
|
4
|
+
const OperationTree_1 = require("./OperationTree");
|
|
5
|
+
const OperationDecorator_1 = require("./OperationDecorator");
|
|
6
|
+
class OperationLogger {
|
|
7
|
+
static getTryCatchFinallyHook(_ctx) {
|
|
8
|
+
throw new Error('OperationLogger.getTryCatchFinallyHook is abstract and must be implemented by derived class');
|
|
9
|
+
}
|
|
10
|
+
onTry(ctx) {
|
|
11
|
+
return this.stageLog(ctx);
|
|
12
|
+
}
|
|
13
|
+
onFinally(ctx) {
|
|
14
|
+
return this.stageLog(ctx);
|
|
15
|
+
}
|
|
16
|
+
stageLog(ctx) {
|
|
17
|
+
if (!ctx.sharedContext.logs)
|
|
18
|
+
ctx.sharedContext.logs = [];
|
|
19
|
+
if (!ctx.logs)
|
|
20
|
+
ctx.logs = [];
|
|
21
|
+
const stageLogMessages = this.getOperationLogMessages(ctx);
|
|
22
|
+
if (stageLogMessages)
|
|
23
|
+
ctx.logs.push(...stageLogMessages);
|
|
24
|
+
return () => {
|
|
25
|
+
let shouldLog = ctx.decoratorArgs?.shouldLog?.(ctx);
|
|
26
|
+
if (shouldLog === undefined)
|
|
27
|
+
shouldLog = this.shouldLogDefault(ctx);
|
|
28
|
+
if (shouldLog) {
|
|
29
|
+
const fullLogMessage = (ctx.logs || [])
|
|
30
|
+
.concat(...(ctx.sharedContext.logs || []))
|
|
31
|
+
.filter((t) => t)
|
|
32
|
+
.join('. ');
|
|
33
|
+
const logDetails = ctx.logMetadata || ctx.sharedContext.logMetadata
|
|
34
|
+
? { ...ctx.sharedContext.logMetadata, ...ctx.logMetadata }
|
|
35
|
+
: undefined;
|
|
36
|
+
if (ctx.error)
|
|
37
|
+
this.logError(fullLogMessage, { error: ctx.error, ...logDetails });
|
|
38
|
+
else
|
|
39
|
+
this.logInfo(fullLogMessage, logDetails);
|
|
40
|
+
}
|
|
41
|
+
ctx.logs.length = 0;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
shouldLogDefault(_ctx) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
getOperationLogMessages(ctx) {
|
|
48
|
+
const res = [];
|
|
49
|
+
switch (ctx.stage) {
|
|
50
|
+
case 'try':
|
|
51
|
+
res.push(this.getOperationTryMessage(ctx));
|
|
52
|
+
break;
|
|
53
|
+
case 'finally':
|
|
54
|
+
res.push(this.getOperationCompletedMessage(ctx));
|
|
55
|
+
if (ctx.error) {
|
|
56
|
+
const error = ctx.error;
|
|
57
|
+
res.push(...(this.getOperationErrorDetails(error, ctx) || []));
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
default:
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
return res;
|
|
64
|
+
}
|
|
65
|
+
getOperationTryMessage(ctx) {
|
|
66
|
+
return `${this.getOperationName(ctx)} starting...`;
|
|
67
|
+
}
|
|
68
|
+
getOperationName(ctx, fullPath = true, separator = ' > ') {
|
|
69
|
+
if (!fullPath)
|
|
70
|
+
return OperationDecorator_1.OperationDecorator.getOperationName(ctx) || '(anonymous)';
|
|
71
|
+
const fullOperationName = OperationTree_1.OperationTree.getOperationsStack(ctx)
|
|
72
|
+
.map((op) => this.getOperationName(op, false))
|
|
73
|
+
.join(separator);
|
|
74
|
+
return fullOperationName;
|
|
75
|
+
}
|
|
76
|
+
getOperationCompletedMessage(ctx) {
|
|
77
|
+
const hasError = !!ctx.error;
|
|
78
|
+
const fullOperationName = this.getOperationName(ctx);
|
|
79
|
+
const duration = ctx.duration;
|
|
80
|
+
if (duration !== undefined)
|
|
81
|
+
return `${fullOperationName} ${hasError ? 'failed' : 'succeeded'} after ${duration} ms`;
|
|
82
|
+
else
|
|
83
|
+
return `${fullOperationName} ${hasError ? 'failed' : 'succeeded'}`;
|
|
84
|
+
}
|
|
85
|
+
getOperationErrorDetails(error, ctx) {
|
|
86
|
+
const errorContext = error.trackedContext;
|
|
87
|
+
const logMessages = [];
|
|
88
|
+
logMessages.push(this.getErrorMessage(error, ctx));
|
|
89
|
+
if (errorContext == ctx && error.underlyingError) {
|
|
90
|
+
logMessages.push(`Underlying error: ${this.getErrorMessage(error.underlyingError, ctx)}`);
|
|
91
|
+
}
|
|
92
|
+
return logMessages;
|
|
93
|
+
}
|
|
94
|
+
getErrorMessage(error, _ctx) {
|
|
95
|
+
if (error instanceof Error) {
|
|
96
|
+
const trError = error;
|
|
97
|
+
const errorClass = trError?.constructor?.name;
|
|
98
|
+
return `${errorClass || '[undefined]'}: ${trError.message}`;
|
|
99
|
+
}
|
|
100
|
+
return error?.toString?.() || 'unknown error';
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.OperationLogger = OperationLogger;
|
|
104
|
+
//# sourceMappingURL=OperationLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationLogger.js","sourceRoot":"","sources":["../../../../src/engage/utils/operationTracking/OperationLogger.ts"],"names":[],"mappings":";;;AAGA,mDAA+C;AAC/C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AE,GAAG,CAAC,EAAE,CAAC,CAAA;SAC1F;QACD,OAAO,WAAW,CAAA;IACpB,CAAC;IAQD,eAAe,CAAC,KAAc,EAAE,IAA6B;QAC3D,IAAI,KAAK,YAAY,KAAK,EAAE;YAC1B,MAAM,OAAO,GAAG,KAAqB,CAAA;YACrC,MAAM,UAAU,GAAG,OAAO,EAAE,WAAW,EAAE,IAAI,CAAA;YAC7C,OAAO,GAAG,UAAU,IAAI,aAAa,KAAK,OAAO,CAAC,OAAO,EAAE,CAAA;SAC5D;QAED,OAAQ,KAAe,EAAE,QAAQ,EAAE,EAAE,IAAI,eAAe,CAAA;IAC1D,CAAC;CACF;AAtJD,0CAsJC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TrackedError } from './TrackedError';
|
|
2
|
+
import { TryCatchFinallyContext, TryCatchFinallyHook } from './wrapTryCatchFinallyPromisable';
|
|
3
|
+
export declare type OperationStatsContext<TContext extends TryCatchFinallyContext = TryCatchFinallyContext> = TContext & {
|
|
4
|
+
tags: string[];
|
|
5
|
+
sharedContext: {
|
|
6
|
+
tags: string[];
|
|
7
|
+
};
|
|
8
|
+
decoratorArgs?: {
|
|
9
|
+
shouldStats?: (args: OperationStatsEventArgs) => boolean | void;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare abstract class OperationStats<TContext extends OperationStatsContext = OperationStatsContext> implements TryCatchFinallyHook<TContext> {
|
|
13
|
+
static getTryCatchFinallyHook(_ctx: OperationStatsContext): TryCatchFinallyHook<OperationStatsContext>;
|
|
14
|
+
abstract stats(args: StatsArgs): void;
|
|
15
|
+
getMetricName(ctx: OperationStatsContext): string | undefined;
|
|
16
|
+
onTry(ctx: OperationStatsContext): () => void;
|
|
17
|
+
mergeTags(...tagSets: (string[] | undefined)[]): string[];
|
|
18
|
+
statsOperationEvent(args: OperationStatsEventArgs): void;
|
|
19
|
+
onCatch(ctx: OperationStatsContext): void;
|
|
20
|
+
onFinally(ctx: OperationStatsContext): () => void;
|
|
21
|
+
getHistogramMetric(ctx: OperationStatsContext): string | undefined;
|
|
22
|
+
extractTagsFromError(error: TrackedError, ctx: OperationStatsContext): string[];
|
|
23
|
+
getErrorOperationNameTag(error: TrackedError, ctx: OperationStatsContext): string | undefined;
|
|
24
|
+
getOperationNameTag(ctx: OperationStatsContext): string | undefined;
|
|
25
|
+
}
|
|
26
|
+
export declare type StatsMethod = 'incr' | 'histogram' | 'set';
|
|
27
|
+
export declare type StatsArgs = {
|
|
28
|
+
method?: StatsMethod;
|
|
29
|
+
metric: string;
|
|
30
|
+
value?: number;
|
|
31
|
+
tags?: string[];
|
|
32
|
+
};
|
|
33
|
+
export declare type OperationStatsEvent = OperationStatsContext['stage'] | 'duration';
|
|
34
|
+
export interface OperationStatsEventArgs {
|
|
35
|
+
event: OperationStatsEvent;
|
|
36
|
+
context: OperationStatsContext;
|
|
37
|
+
stats: StatsArgs;
|
|
38
|
+
shouldStats: boolean;
|
|
39
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperationStats = void 0;
|
|
4
|
+
const OperationDuration_1 = require("./OperationDuration");
|
|
5
|
+
const OperationDecorator_1 = require("./OperationDecorator");
|
|
6
|
+
class OperationStats {
|
|
7
|
+
static getTryCatchFinallyHook(_ctx) {
|
|
8
|
+
throw new Error('OperationStats.getTryCatchFinallyHook is abstract and must be implemented by derived class');
|
|
9
|
+
}
|
|
10
|
+
getMetricName(ctx) {
|
|
11
|
+
const opName = OperationDecorator_1.OperationDecorator.getOperationName(ctx);
|
|
12
|
+
if (!opName)
|
|
13
|
+
return undefined;
|
|
14
|
+
switch (ctx.stage) {
|
|
15
|
+
case 'try':
|
|
16
|
+
return `${opName}.try`;
|
|
17
|
+
case 'catch':
|
|
18
|
+
return `${opName}.catch`;
|
|
19
|
+
case 'finally':
|
|
20
|
+
default:
|
|
21
|
+
return `${opName}`;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
onTry(ctx) {
|
|
25
|
+
ctx.tags = [];
|
|
26
|
+
if (!ctx.sharedContext.tags)
|
|
27
|
+
ctx.sharedContext.tags = [];
|
|
28
|
+
return () => {
|
|
29
|
+
const metricName = this.getMetricName(ctx);
|
|
30
|
+
if (metricName)
|
|
31
|
+
this.statsOperationEvent({
|
|
32
|
+
context: ctx,
|
|
33
|
+
event: 'try',
|
|
34
|
+
shouldStats: false,
|
|
35
|
+
stats: {
|
|
36
|
+
metric: metricName,
|
|
37
|
+
method: 'incr',
|
|
38
|
+
value: 1,
|
|
39
|
+
tags: this.mergeTags(ctx.sharedContext.tags, ctx.tags)
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
mergeTags(...tagSets) {
|
|
45
|
+
const res = [];
|
|
46
|
+
for (const tags of tagSets) {
|
|
47
|
+
if (tags)
|
|
48
|
+
res.push(...tags);
|
|
49
|
+
}
|
|
50
|
+
return res.filter((t) => t);
|
|
51
|
+
}
|
|
52
|
+
statsOperationEvent(args) {
|
|
53
|
+
if (args.context.decoratorArgs?.shouldStats) {
|
|
54
|
+
const shouldStats = args.context.decoratorArgs.shouldStats(args);
|
|
55
|
+
if (shouldStats !== undefined)
|
|
56
|
+
args.shouldStats = shouldStats;
|
|
57
|
+
}
|
|
58
|
+
if (args.shouldStats && args.stats) {
|
|
59
|
+
this.stats(args.stats);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
onCatch(ctx) {
|
|
63
|
+
const metricName = this.getMetricName(ctx);
|
|
64
|
+
if (metricName)
|
|
65
|
+
this.statsOperationEvent({
|
|
66
|
+
context: ctx,
|
|
67
|
+
event: ctx.stage,
|
|
68
|
+
shouldStats: false,
|
|
69
|
+
stats: {
|
|
70
|
+
metric: metricName,
|
|
71
|
+
method: 'incr',
|
|
72
|
+
value: 1,
|
|
73
|
+
tags: this.mergeTags(ctx.sharedContext.tags, ctx.tags)
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
onFinally(ctx) {
|
|
78
|
+
const finallyTags = [];
|
|
79
|
+
if (ctx.stage == 'finally')
|
|
80
|
+
finallyTags.push(`error:${ctx.error ? 'true' : 'false'}`);
|
|
81
|
+
if (ctx.error) {
|
|
82
|
+
const error = ctx.error;
|
|
83
|
+
finallyTags.push(...(this.extractTagsFromError(error, ctx) || []));
|
|
84
|
+
}
|
|
85
|
+
ctx.tags.push(...finallyTags);
|
|
86
|
+
return () => {
|
|
87
|
+
const finallyTags = this.mergeTags(ctx.sharedContext.tags, ctx.tags);
|
|
88
|
+
const metricName = this.getMetricName(ctx);
|
|
89
|
+
if (metricName)
|
|
90
|
+
this.statsOperationEvent({
|
|
91
|
+
context: ctx,
|
|
92
|
+
event: 'finally',
|
|
93
|
+
shouldStats: true,
|
|
94
|
+
stats: { metric: metricName, method: 'incr', value: 1, tags: [...finallyTags] }
|
|
95
|
+
});
|
|
96
|
+
const duration = OperationDuration_1.OperationDuration.getDuration(ctx);
|
|
97
|
+
const histogramMetric = this.getHistogramMetric(ctx);
|
|
98
|
+
if (duration !== undefined && histogramMetric)
|
|
99
|
+
this.statsOperationEvent({
|
|
100
|
+
context: ctx,
|
|
101
|
+
event: 'duration',
|
|
102
|
+
shouldStats: true,
|
|
103
|
+
stats: { metric: histogramMetric, method: 'histogram', value: duration, tags: [...finallyTags] }
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
getHistogramMetric(ctx) {
|
|
108
|
+
const opName = OperationDecorator_1.OperationDecorator.getOperationName(ctx);
|
|
109
|
+
if (!opName)
|
|
110
|
+
return undefined;
|
|
111
|
+
return `${opName}.duration`;
|
|
112
|
+
}
|
|
113
|
+
extractTagsFromError(error, ctx) {
|
|
114
|
+
const res = [];
|
|
115
|
+
const errorOperation = this.getErrorOperationNameTag(error, ctx);
|
|
116
|
+
if (errorOperation)
|
|
117
|
+
res.push(`error_operation:${errorOperation}`);
|
|
118
|
+
res.push(`error_class:${error?.constructor?.name || typeof error}`);
|
|
119
|
+
return res;
|
|
120
|
+
}
|
|
121
|
+
getErrorOperationNameTag(error, ctx) {
|
|
122
|
+
const errorContext = error.trackedContext;
|
|
123
|
+
return errorContext ? this.getOperationNameTag(errorContext) : this.getOperationNameTag(ctx);
|
|
124
|
+
}
|
|
125
|
+
getOperationNameTag(ctx) {
|
|
126
|
+
return OperationDecorator_1.OperationDecorator.getOperationName(ctx);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.OperationStats = OperationStats;
|
|
130
|
+
//# sourceMappingURL=OperationStats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationStats.js","sourceRoot":"","sources":["../../../../src/engage/utils/operationTracking/OperationStats.ts"],"names":[],"mappings":";;;AAAA,2DAAuD;AAEvD,6DAAyD;AA0BzD,MAAsB,cAAc;IAGlC,MAAM,CAAC,sBAAsB,CAAC,IAA2B;QACvD,MAAM,IAAI,KAAK,CAAC,4FAA4F,CAAC,CAAA;IAC/G,CAAC;IAGD,aAAa,CAAC,GAA0B;QACtC,MAAM,MAAM,GAAG,uCAAkB,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAA;QACvD,IAAI,CAAC,MAAM;YAAE,OAAO,SAAS,CAAA;QAE7B,QAAQ,GAAG,CAAC,KAAK,EAAE;YACjB,KAAK,KAAK;gBACR,OAAO,GAAG,MAAM,MAAM,CAAA;YACxB,KAAK,OAAO;gBACV,OAAO,GAAG,MAAM,QAAQ,CAAA;YAC1B,KAAK,SAAS,CAAC;YACf;gBACE,OAAO,GAAG,MAAM,EAAE,CAAA;SACrB;IACH,CAAC;IAED,KAAK,CAAC,GAA0B;QAC9B,GAAG,CAAC,IAAI,GAAG,EAAE,CAAA;QACb,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI;YAAE,GAAG,CAAC,aAAa,CAAC,IAAI,GAAG,EAAE,CAA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0B;QACtE,MAAM,YAAY,GAAG,KAAK,CAAC,cAAuC,CAAA;QAClE,OAAO,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAA;IAC9F,CAAC;IAOD,mBAAmB,CAAC,GAA0B;QAC5C,OAAO,uCAAkB,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAA;IACjD,CAAC;CACF;AAnJD,wCAmJC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ContextFromHookProviders, FuncFromHookProviders, OperationHookProvider } from './OperationDecorator';
|
|
2
|
+
import { TryCatchFinallyHook, TryCatchFinallyContext } from './wrapTryCatchFinallyPromisable';
|
|
3
|
+
declare type OperationTreeContext<TParentContext extends TryCatchFinallyContext = TryCatchFinallyContext> = TParentContext & {
|
|
4
|
+
parent?: OperationTreeContext<TParentContext>;
|
|
5
|
+
sharedContext: {};
|
|
6
|
+
};
|
|
7
|
+
export declare class OperationTree {
|
|
8
|
+
static getTryCatchFinallyHook(_ctx: OperationTreeContext): TryCatchFinallyHook<OperationTreeContext>;
|
|
9
|
+
static getPriority(): number;
|
|
10
|
+
static onTry(ctx: OperationTreeContext): void;
|
|
11
|
+
static onFinally(ctx: OperationTreeContext): () => void;
|
|
12
|
+
static getCurrentOperationFromTrackedClassInstance<TClassInstance>(classInstance: TClassInstance): OperationTreeContext<TryCatchFinallyContext<(this: any, ...args: any[]) => any>>;
|
|
13
|
+
static getCurrentOperationFromContext(ctx: OperationTreeContext): OperationTreeContext<TryCatchFinallyContext<(this: any, ...args: any[]) => any>>;
|
|
14
|
+
protected static setCurrentOperationToContext(ctx: OperationTreeContext, newCurrentOperation: OperationTreeContext | undefined): void;
|
|
15
|
+
static getOperationsStack<TContext extends OperationTreeContext>(ctx: TContext): TContext[];
|
|
16
|
+
static getDecoratorUtils(): {
|
|
17
|
+
getCurrentOperation(classInstance: any): OperationTreeContext | undefined;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export declare type CanGetCurrentOperation<TOperationHookProviders extends OperationHookProvider[]> = {
|
|
21
|
+
getCurrentOperation(classInstance: ThisParameterType<FuncFromHookProviders<TOperationHookProviders>>): ContextFromHookProviders<TOperationHookProviders> | undefined;
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperationTree = void 0;
|
|
4
|
+
class OperationTree {
|
|
5
|
+
static getTryCatchFinallyHook(_ctx) {
|
|
6
|
+
return this;
|
|
7
|
+
}
|
|
8
|
+
static getPriority() {
|
|
9
|
+
return -1;
|
|
10
|
+
}
|
|
11
|
+
static onTry(ctx) {
|
|
12
|
+
const parent = this.getCurrentOperationFromContext(ctx);
|
|
13
|
+
ctx.sharedContext = parent?.sharedContext || {};
|
|
14
|
+
ctx.parent = parent;
|
|
15
|
+
this.setCurrentOperationToContext(ctx, ctx);
|
|
16
|
+
}
|
|
17
|
+
static onFinally(ctx) {
|
|
18
|
+
return () => {
|
|
19
|
+
this.setCurrentOperationToContext(ctx, ctx.parent);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
static getCurrentOperationFromTrackedClassInstance(classInstance) {
|
|
23
|
+
return classInstance?.currentOperation;
|
|
24
|
+
}
|
|
25
|
+
static getCurrentOperationFromContext(ctx) {
|
|
26
|
+
return ctx.funcThis.currentOperation;
|
|
27
|
+
}
|
|
28
|
+
static setCurrentOperationToContext(ctx, newCurrentOperation) {
|
|
29
|
+
ctx.funcThis.currentOperation = newCurrentOperation;
|
|
30
|
+
}
|
|
31
|
+
static getOperationsStack(ctx) {
|
|
32
|
+
const stack = [];
|
|
33
|
+
let current = ctx;
|
|
34
|
+
while (current) {
|
|
35
|
+
stack.unshift(current);
|
|
36
|
+
current = current.parent;
|
|
37
|
+
}
|
|
38
|
+
return stack;
|
|
39
|
+
}
|
|
40
|
+
static getDecoratorUtils() {
|
|
41
|
+
return {
|
|
42
|
+
getCurrentOperation(classInstance) {
|
|
43
|
+
return classInstance?.currentOperation;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.OperationTree = OperationTree;
|
|
49
|
+
//# sourceMappingURL=OperationTree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OperationTree.js","sourceRoot":"","sources":["../../../../src/engage/utils/operationTracking/OperationTree.ts"],"names":[],"mappings":";;;AAWA,MAAa,aAAa;IACxB,MAAM,CAAC,sBAAsB,CAAC,IAA0B;QAEtD,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,CAAC,WAAW;QAChB,OAAO,CAAC,CAAC,CAAA;IACX,CAAC;IACD,MAAM,CAAC,KAAK,CAAC,GAAyB;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC,8BAA8B,CAAC,GAAG,CAAC,CAAA;QACvD,GAAG,CAAC,aAAa,GAAG,MAAM,EAAE,aAAa,IAAI,EAAE,CAAA;QAC/C,GAAG,CAAC,MAAM,GAAG,MAAM,CAAA;QACnB,IAAI,CAAC,4BAA4B,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IAC7C,CAAC;IACD,MAAM,CAAC,SAAS,CAAC,GAAyB;QACxC,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,4BAA4B,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;QACpD,CAAC,CAAA;IACH,CAAC;IACD,MAAM,CAAC,2CAA2C,CAAiB,aAA6B;QAE9F,OAAQ,aAAqB,EAAE,gBAAwC,CAAA;IACzE,CAAC;IACD,MAAM,CAAC,8BAA8B,CAAC,GAAyB;QAC7D,OAAO,GAAG,CAAC,QAAQ,CAAC,gBAAwC,CAAA;IAC9D,CAAC;IACS,MAAM,CAAC,4BAA4B,CAC3C,GAAyB,EACzB,mBAAqD;QAErD,GAAG,CAAC,QAAQ,CAAC,gBAAgB,GAAG,mBAAmB,CAAA;IACrD,CAAC;IAED,MAAM,CAAC,kBAAkB,CAAwC,GAAa;QAC5E,MAAM,KAAK,GAAe,EAAE,CAAA;QAC5B,IAAI,OAAO,GAAG,GAAG,CAAA;QACjB,OAAO,OAAO,EAAE;YACd,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;YAEtB,OAAO,GAAG,OAAO,CAAC,MAAkB,CAAA;SACrC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAED,MAAM,CAAC,iBAAiB;QACtB,OAAO;YAEL,mBAAmB,CAAC,aAAkB;gBACpC,OAAO,aAAa,EAAE,gBAAgB,CAAA;YACxC,CAAC;SACF,CAAA;IACH,CAAC;CACF;AApDD,sCAoDC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TryCatchFinallyContext } from './wrapTryCatchFinallyPromisable';
|
|
2
|
+
export interface TrackedError<TContext extends TryCatchFinallyContext = TryCatchFinallyContext> extends Error {
|
|
3
|
+
underlyingError?: unknown;
|
|
4
|
+
trackedContext?: TContext;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TrackedError.js","sourceRoot":"","sources":["../../../../src/engage/utils/operationTracking/TrackedError.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './wrapTryCatchFinallyPromisable';
|
|
2
|
+
export * from './OperationDecorator';
|
|
3
|
+
export * from './GenericMethodDecorator';
|
|
4
|
+
export * from './OperationTree';
|
|
5
|
+
export * from './OperationFinallyHooks';
|
|
6
|
+
export * from './OperationLogger';
|
|
7
|
+
export * from './OperationDuration';
|
|
8
|
+
export * from './OperationStats';
|
|
9
|
+
export * from './OperationErrorHandler';
|
|
10
|
+
export * from './TrackedError';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./wrapTryCatchFinallyPromisable"), exports);
|
|
14
|
+
__exportStar(require("./OperationDecorator"), exports);
|
|
15
|
+
__exportStar(require("./GenericMethodDecorator"), exports);
|
|
16
|
+
__exportStar(require("./OperationTree"), exports);
|
|
17
|
+
__exportStar(require("./OperationFinallyHooks"), exports);
|
|
18
|
+
__exportStar(require("./OperationLogger"), exports);
|
|
19
|
+
__exportStar(require("./OperationDuration"), exports);
|
|
20
|
+
__exportStar(require("./OperationStats"), exports);
|
|
21
|
+
__exportStar(require("./OperationErrorHandler"), exports);
|
|
22
|
+
__exportStar(require("./TrackedError"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/engage/utils/operationTracking/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kEAA+C;AAC/C,uDAAoC;AACpC,2DAAwC;AACxC,kDAA+B;AAC/B,0DAAuC;AACvC,oDAAiC;AACjC,sDAAmC;AACnC,mDAAgC;AAChC,0DAAuC;AACvC,iDAA8B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface TryCatchFinallyContext<TFunc extends (this: any, ...args: any[]) => any = (this: any, ...args: any[]) => any> {
|
|
2
|
+
func: TFunc;
|
|
3
|
+
funcArgs: Parameters<TFunc>;
|
|
4
|
+
funcThis: ThisParameterType<TFunc>;
|
|
5
|
+
result?: ReturnType<TFunc> | Awaited<ReturnType<TFunc>>;
|
|
6
|
+
error?: unknown;
|
|
7
|
+
stage: 'try' | 'success' | 'catch' | 'finally';
|
|
8
|
+
}
|
|
9
|
+
export interface TryCatchFinallyHook<TContext extends TryCatchFinallyContext<any> = TryCatchFinallyContext<(...args: any[]) => any>> {
|
|
10
|
+
onTry?(ctx: TContext): void | (() => void);
|
|
11
|
+
onSuccess?(ctx: TContext): void | (() => void);
|
|
12
|
+
onCatch?(ctx: TContext): void | (() => void);
|
|
13
|
+
onFinally?(ctx: TContext): void | (() => void);
|
|
14
|
+
getPriority?(ctx: TContext): number | void;
|
|
15
|
+
}
|
|
16
|
+
export declare type FuncFromTryCatchFinallyContext<TWrapContext extends TryCatchFinallyContext<any>> = TWrapContext extends TryCatchFinallyContext<infer TFunc> ? TFunc : never;
|
|
17
|
+
export declare const DefaultHookPriority = 0;
|
|
18
|
+
export declare function wrapTryCatchFinallyPromisable<TFunc extends (...args: any[]) => any, TContext extends TryCatchFinallyContext<TFunc> = TryCatchFinallyContext<TFunc>, THooks extends TryCatchFinallyHook<TContext>[] = TryCatchFinallyHook<TContext>[]>(func: TFunc, getHooks: (ctx: TContext) => THooks, onHookError?: (e: unknown) => unknown | undefined): TFunc;
|
|
19
|
+
export declare type Awaited<T> = T extends null | undefined ? T : T extends object & {
|
|
20
|
+
then(onfulfilled: infer F, ...args: infer _): any;
|
|
21
|
+
} ? F extends (value: infer V, ...args: infer _) => any ? Awaited<V> : never : T;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.wrapTryCatchFinallyPromisable = exports.DefaultHookPriority = void 0;
|
|
4
|
+
exports.DefaultHookPriority = 0;
|
|
5
|
+
function wrapTryCatchFinallyPromisable(func, getHooks, onHookError) {
|
|
6
|
+
function forEachHook(hooks, inContext, doThis) {
|
|
7
|
+
const prioritizedHooks = Object.values(hooks).sort((h1, h2) => {
|
|
8
|
+
const p1 = h1.getPriority ? h1.getPriority(inContext) : exports.DefaultHookPriority;
|
|
9
|
+
const p2 = h2.getPriority ? h2.getPriority(inContext) : exports.DefaultHookPriority;
|
|
10
|
+
return (p1 === undefined ? exports.DefaultHookPriority : p1) - (p2 === undefined ? exports.DefaultHookPriority : p2);
|
|
11
|
+
});
|
|
12
|
+
const postCallbacks = [];
|
|
13
|
+
for (const hook of prioritizedHooks) {
|
|
14
|
+
try {
|
|
15
|
+
const callback = doThis(hook);
|
|
16
|
+
if (callback instanceof Function)
|
|
17
|
+
postCallbacks.push(callback);
|
|
18
|
+
}
|
|
19
|
+
catch (hookError) {
|
|
20
|
+
let errorToThrow = hookError;
|
|
21
|
+
if (onHookError)
|
|
22
|
+
errorToThrow = onHookError(errorToThrow);
|
|
23
|
+
if (errorToThrow)
|
|
24
|
+
throw errorToThrow;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
for (const callback of postCallbacks.reverse()) {
|
|
28
|
+
try {
|
|
29
|
+
callback();
|
|
30
|
+
}
|
|
31
|
+
catch (callbackError) {
|
|
32
|
+
let errorToThrow = callbackError;
|
|
33
|
+
if (onHookError)
|
|
34
|
+
errorToThrow = onHookError(errorToThrow);
|
|
35
|
+
if (errorToThrow)
|
|
36
|
+
throw errorToThrow;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return function (...funcArgs) {
|
|
41
|
+
const ctx = {
|
|
42
|
+
funcArgs: funcArgs,
|
|
43
|
+
funcThis: this,
|
|
44
|
+
func,
|
|
45
|
+
stage: 'try'
|
|
46
|
+
};
|
|
47
|
+
let isPromise = false;
|
|
48
|
+
const hooks = getHooks(ctx);
|
|
49
|
+
try {
|
|
50
|
+
forEachHook(hooks, ctx, (hook) => hook.onTry?.(ctx));
|
|
51
|
+
const funcResMayBePromise = func.apply(this, funcArgs);
|
|
52
|
+
isPromise = isValuePromise(funcResMayBePromise);
|
|
53
|
+
if (isPromise) {
|
|
54
|
+
const wrappedPromise = (async () => {
|
|
55
|
+
try {
|
|
56
|
+
ctx.result = await funcResMayBePromise;
|
|
57
|
+
ctx.stage = 'success';
|
|
58
|
+
forEachHook(hooks, ctx, (hook) => hook.onSuccess?.(ctx));
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
ctx.stage = 'catch';
|
|
62
|
+
ctx.error = error;
|
|
63
|
+
forEachHook(hooks, ctx, (hook) => hook.onCatch?.(ctx));
|
|
64
|
+
if (ctx.error)
|
|
65
|
+
throw ctx.error;
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
ctx.stage = 'finally';
|
|
69
|
+
forEachHook(hooks, ctx, (hook) => hook.onFinally?.(ctx));
|
|
70
|
+
}
|
|
71
|
+
return ctx.result;
|
|
72
|
+
})();
|
|
73
|
+
return wrappedPromise;
|
|
74
|
+
}
|
|
75
|
+
ctx.result = funcResMayBePromise;
|
|
76
|
+
ctx.stage = 'success';
|
|
77
|
+
forEachHook(hooks, ctx, (hook) => hook.onSuccess?.(ctx));
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
ctx.stage = 'catch';
|
|
81
|
+
ctx.error = error;
|
|
82
|
+
forEachHook(hooks, ctx, (hook) => hook.onCatch?.(ctx));
|
|
83
|
+
if (ctx.error)
|
|
84
|
+
throw ctx.error;
|
|
85
|
+
}
|
|
86
|
+
finally {
|
|
87
|
+
if (!isPromise) {
|
|
88
|
+
ctx.stage = 'finally';
|
|
89
|
+
forEachHook(hooks, ctx, (hook) => hook.onFinally?.(ctx));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return ctx.result;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
exports.wrapTryCatchFinallyPromisable = wrapTryCatchFinallyPromisable;
|
|
96
|
+
function isValuePromise(obj) {
|
|
97
|
+
return obj instanceof Object && 'then' in obj && typeof obj.then === 'function';
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=wrapTryCatchFinallyPromisable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapTryCatchFinallyPromisable.js","sourceRoot":"","sources":["../../../../src/engage/utils/operationTracking/wrapTryCatchFinallyPromisable.ts"],"names":[],"mappings":";;;AA+Ba,QAAA,mBAAmB,GAAG,CAAC,CAAA;AASpC,SAAgB,6BAA6B,CAI3C,IAAW,EAAE,QAAmC,EAAE,WAAiD;IAEnG,SAAS,WAAW,CAAC,KAAa,EAAE,SAAmB,EAAE,MAA2C;QAClG,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;YAC5D,MAAM,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,2BAAmB,CAAA;YAC3E,MAAM,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,2BAAmB,CAAA;YAC3E,OAAO,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,2BAAmB,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,2BAAmB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;QACtG,CAAC,CAAC,CAAA;QAEF,MAAM,aAAa,GAAmB,EAAE,CAAA;QACxC,KAAK,MAAM,IAAI,IAAI,gBAAgB,EAAE;YACnC,IAAI;gBACF,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;gBAC7B,IAAI,QAAQ,YAAY,QAAQ;oBAAE,aAAa,CAAC,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