@rpcbase/server 0.483.0 → 0.484.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/index.js
CHANGED
|
@@ -566,18 +566,12 @@ const type_utils_toString = ObjProto.toString;
|
|
|
566
566
|
const isArray = nativeIsArray || function(obj) {
|
|
567
567
|
return "[object Array]" === type_utils_toString.call(obj);
|
|
568
568
|
};
|
|
569
|
+
const isObject = (x) => x === Object(x) && !isArray(x);
|
|
569
570
|
const isUndefined = (x) => void 0 === x;
|
|
570
571
|
const isString = (x) => "[object String]" == type_utils_toString.call(x);
|
|
571
572
|
const isEmptyString = (x) => isString(x) && 0 === x.trim().length;
|
|
572
573
|
const isNumber = (x) => "[object Number]" == type_utils_toString.call(x);
|
|
573
574
|
const isPlainError = (x) => x instanceof Error;
|
|
574
|
-
function isInstanceOf(candidate, base) {
|
|
575
|
-
try {
|
|
576
|
-
return candidate instanceof base;
|
|
577
|
-
} catch {
|
|
578
|
-
return false;
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
575
|
function isPrimitive(value) {
|
|
582
576
|
return null === value || "object" != typeof value;
|
|
583
577
|
}
|
|
@@ -590,6 +584,13 @@ function isEvent(candidate) {
|
|
|
590
584
|
function isPlainObject(candidate) {
|
|
591
585
|
return isBuiltin(candidate, "Object");
|
|
592
586
|
}
|
|
587
|
+
function isInstanceOf(candidate, base) {
|
|
588
|
+
try {
|
|
589
|
+
return candidate instanceof base;
|
|
590
|
+
} catch {
|
|
591
|
+
return false;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
593
594
|
function clampToRange(value, min, max, logger, fallbackValue) {
|
|
594
595
|
if (min > max) {
|
|
595
596
|
logger.warn("min cannot be greater than max.");
|
|
@@ -2050,6 +2051,9 @@ class ErrorTracking {
|
|
|
2050
2051
|
});
|
|
2051
2052
|
this.startAutocaptureIfEnabled();
|
|
2052
2053
|
}
|
|
2054
|
+
static isPreviouslyCapturedError(x) {
|
|
2055
|
+
return isObject(x) && "__posthog_previously_captured_error" in x && true === x.__posthog_previously_captured_error;
|
|
2056
|
+
}
|
|
2053
2057
|
static async buildEventMessage(error, hint, distinctId, additionalProperties) {
|
|
2054
2058
|
const properties = {
|
|
2055
2059
|
...additionalProperties
|
|
@@ -2074,14 +2078,16 @@ class ErrorTracking {
|
|
|
2074
2078
|
}
|
|
2075
2079
|
onException(exception, hint) {
|
|
2076
2080
|
this.client.addPendingPromise((async () => {
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
exception
|
|
2083
|
-
|
|
2084
|
-
|
|
2081
|
+
if (!ErrorTracking.isPreviouslyCapturedError(exception)) {
|
|
2082
|
+
const eventMessage = await ErrorTracking.buildEventMessage(exception, hint);
|
|
2083
|
+
const exceptionProperties = eventMessage.properties;
|
|
2084
|
+
const exceptionType = exceptionProperties?.$exception_list[0]?.type ?? "Exception";
|
|
2085
|
+
const isRateLimited = this._rateLimiter.consumeRateLimit(exceptionType);
|
|
2086
|
+
if (isRateLimited) return void this._logger.info("Skipping exception capture because of client rate limiting.", {
|
|
2087
|
+
exception: exceptionType
|
|
2088
|
+
});
|
|
2089
|
+
return this.client.capture(eventMessage);
|
|
2090
|
+
}
|
|
2085
2091
|
})());
|
|
2086
2092
|
}
|
|
2087
2093
|
async onFatalError(exception) {
|
|
@@ -2096,7 +2102,7 @@ class ErrorTracking {
|
|
|
2096
2102
|
this._rateLimiter.stop();
|
|
2097
2103
|
}
|
|
2098
2104
|
}
|
|
2099
|
-
const version = "5.
|
|
2105
|
+
const version = "5.20.0";
|
|
2100
2106
|
const FeatureFlagError = {
|
|
2101
2107
|
ERRORS_WHILE_COMPUTING: "errors_while_computing_flags",
|
|
2102
2108
|
FLAG_MISSING: "flag_missing",
|
|
@@ -3125,17 +3131,24 @@ class PostHogBackendClient extends PostHogCoreStateless {
|
|
|
3125
3131
|
allGroupProperties
|
|
3126
3132
|
};
|
|
3127
3133
|
}
|
|
3128
|
-
captureException(error, distinctId, additionalProperties) {
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3134
|
+
captureException(error, distinctId, additionalProperties, uuid) {
|
|
3135
|
+
if (!ErrorTracking.isPreviouslyCapturedError(error)) {
|
|
3136
|
+
const syntheticException = new Error("PostHog syntheticException");
|
|
3137
|
+
this.addPendingPromise(ErrorTracking.buildEventMessage(error, {
|
|
3138
|
+
syntheticException
|
|
3139
|
+
}, distinctId, additionalProperties).then((msg) => this.capture({
|
|
3140
|
+
...msg,
|
|
3141
|
+
uuid
|
|
3142
|
+
})));
|
|
3143
|
+
}
|
|
3133
3144
|
}
|
|
3134
3145
|
async captureExceptionImmediate(error, distinctId, additionalProperties) {
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3146
|
+
if (!ErrorTracking.isPreviouslyCapturedError(error)) {
|
|
3147
|
+
const syntheticException = new Error("PostHog syntheticException");
|
|
3148
|
+
this.addPendingPromise(ErrorTracking.buildEventMessage(error, {
|
|
3149
|
+
syntheticException
|
|
3150
|
+
}, distinctId, additionalProperties).then((msg) => this.captureImmediate(msg)));
|
|
3151
|
+
}
|
|
3139
3152
|
}
|
|
3140
3153
|
async prepareEventMessage(props) {
|
|
3141
3154
|
const { distinctId, event, properties, groups, sendFeatureFlags, timestamp, disableGeoip, uuid } = props;
|
|
@@ -3249,6 +3262,7 @@ function setupExpressErrorHandler(_posthog, app) {
|
|
|
3249
3262
|
}
|
|
3250
3263
|
function posthogErrorHandler(posthog) {
|
|
3251
3264
|
return (error, req, res, next) => {
|
|
3265
|
+
if (ErrorTracking.isPreviouslyCapturedError(error)) return void next(error);
|
|
3252
3266
|
const sessionId = req.headers["x-posthog-session-id"];
|
|
3253
3267
|
const distinctId = req.headers["x-posthog-distinct-id"];
|
|
3254
3268
|
const syntheticException = new Error("Synthetic exception");
|
package/dist/rts/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Server as HttpServer } from 'node:http';
|
|
2
2
|
import { RequestHandler } from 'express';
|
|
3
|
-
import { AppAbility } from '../../../db/acl/
|
|
3
|
+
import { AppAbility } from '../../../db/src/acl/index.ts';
|
|
4
4
|
import { WebSocket } from 'ws';
|
|
5
5
|
type SocketMeta = {
|
|
6
6
|
tenantId: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Ctx } from '../../../../../api/src';
|
|
2
2
|
import { IRBUploadChunk, IRBUploadSession, LoadModelCtx } from '../../../../../db/src';
|
|
3
|
-
import { AppAbility } from '../../../../../db/acl/
|
|
3
|
+
import { AppAbility } from '../../../../../db/src/acl/index.ts';
|
|
4
4
|
import { Model } from '../../../../../vite/node_modules/mongoose';
|
|
5
5
|
export type SessionUser = {
|
|
6
6
|
id?: string;
|