@zuplo/cli 7.15.0 → 7.15.3
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/LICENSE.third-party.txt +236 -0
- package/LICENSE.txt +5 -78
- package/README.md +18 -3
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +2 -0
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/package.json +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwks/remote.js +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +2 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/package.json +1 -1
- package/node_modules/@posthog/core/dist/featureFlagLocalEvaluation.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/featureFlagLocalEvaluation.js +17 -2
- package/node_modules/@posthog/core/dist/featureFlagLocalEvaluation.mjs +17 -2
- package/node_modules/@posthog/core/dist/logs/index.d.ts +18 -1
- package/node_modules/@posthog/core/dist/logs/index.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/logs/index.js +22 -3
- package/node_modules/@posthog/core/dist/logs/index.mjs +22 -3
- package/node_modules/@posthog/core/dist/metrics/index.d.ts +9 -0
- package/node_modules/@posthog/core/dist/metrics/index.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/metrics/index.js +13 -0
- package/node_modules/@posthog/core/dist/metrics/index.mjs +13 -0
- package/node_modules/@posthog/core/dist/privacy.d.ts +6 -1
- package/node_modules/@posthog/core/dist/privacy.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/privacy.js +69 -10
- package/node_modules/@posthog/core/dist/privacy.mjs +65 -9
- package/node_modules/@posthog/core/dist/traces/span.d.ts +6 -0
- package/node_modules/@posthog/core/dist/traces/span.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/traces/span.js +18 -0
- package/node_modules/@posthog/core/dist/traces/span.mjs +18 -0
- package/node_modules/@posthog/core/package.json +2 -2
- package/node_modules/@posthog/core/src/featureFlagLocalEvaluation.ts +23 -2
- package/node_modules/@posthog/core/src/logs/index.spec.ts +119 -0
- package/node_modules/@posthog/core/src/logs/index.ts +57 -3
- package/node_modules/@posthog/core/src/metrics/index.spec.ts +70 -0
- package/node_modules/@posthog/core/src/metrics/index.ts +30 -0
- package/node_modules/@posthog/core/src/privacy.ts +100 -18
- package/node_modules/@posthog/core/src/traces/span.spec.ts +15 -1
- package/node_modules/@posthog/core/src/traces/span.ts +23 -0
- package/node_modules/@posthog/types/dist/posthog-config.d.ts +4 -0
- package/node_modules/@posthog/types/dist/posthog-config.d.ts.map +1 -1
- package/node_modules/@posthog/types/dist/traces.d.ts +10 -0
- package/node_modules/@posthog/types/dist/traces.d.ts.map +1 -1
- package/node_modules/@posthog/types/package.json +1 -1
- package/node_modules/@posthog/types/src/posthog-config.ts +4 -0
- package/node_modules/@posthog/types/src/traces.ts +12 -0
- package/node_modules/@zuplo/core/LICENSE.third-party.txt +622 -0
- package/node_modules/@zuplo/core/LICENSE.txt +5 -78
- package/node_modules/@zuplo/core/README.md +7 -0
- package/node_modules/@zuplo/core/constants.minified.js +7 -20
- package/node_modules/@zuplo/core/customer.cli.minified.js +243 -256
- package/node_modules/@zuplo/core/index.minified.js +248 -261
- package/node_modules/@zuplo/core/package.json +4 -2
- package/node_modules/@zuplo/core/zeno.js +7 -20
- package/node_modules/@zuplo/graphql/LICENSE.third-party.txt +29 -0
- package/node_modules/@zuplo/graphql/LICENSE.txt +5 -78
- package/node_modules/@zuplo/graphql/README.md +7 -0
- package/node_modules/@zuplo/graphql/out/esm/index.js +7 -20
- package/node_modules/@zuplo/graphql/out/esm/index.js.map +1 -1
- package/node_modules/@zuplo/graphql/package.json +3 -2
- package/node_modules/@zuplo/openapi-tools/LICENSE.txt +7 -0
- package/node_modules/@zuplo/openapi-tools/README.md +7 -0
- package/node_modules/@zuplo/openapi-tools/package.json +3 -2
- package/node_modules/@zuplo/otel/LICENSE.third-party.txt +243 -0
- package/node_modules/@zuplo/otel/LICENSE.txt +5 -78
- package/node_modules/@zuplo/otel/README.md +33 -0
- package/node_modules/@zuplo/otel/out/esm/chunk-6YAK7LGJ.js +13 -0
- package/node_modules/@zuplo/otel/out/esm/chunk-6YAK7LGJ.js.map +1 -0
- package/node_modules/@zuplo/otel/out/esm/index.js +8 -21
- package/node_modules/@zuplo/otel/out/types/index.d.ts +41 -0
- package/node_modules/@zuplo/otel/package.json +3 -2
- package/node_modules/@zuplo/runtime/LICENSE.third-party.txt +511 -0
- package/node_modules/@zuplo/runtime/LICENSE.txt +5 -78
- package/node_modules/@zuplo/runtime/README.md +7 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-5JGLAPFA.js +13 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-5JGLAPFA.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/{chunk-SX6JF7A6.js → chunk-AJ3MMWJS.js} +9 -22
- package/node_modules/@zuplo/runtime/out/esm/chunk-AJ3MMWJS.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-BH4DKEES.js +13 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-BH4DKEES.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-G42UYZ6V.js +24 -0
- package/node_modules/@zuplo/runtime/out/esm/{chunk-M4IZPJP6.js.map → chunk-G42UYZ6V.js.map} +1 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-OE2WMJXK.js +431 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-OE2WMJXK.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-R6UNMRUU.js +13 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-R6UNMRUU.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/{chunk-GWGCD6Z7.js → chunk-T2WKOG7J.js} +9 -22
- package/node_modules/@zuplo/runtime/out/esm/chunk-T2WKOG7J.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/{chunk-HTXNM72E.js → chunk-TOJD4RET.js} +9 -22
- package/node_modules/@zuplo/runtime/out/esm/chunk-TOJD4RET.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-VXPFMOL5.js +13 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-VXPFMOL5.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/index.js +8 -21
- package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/esm/internal/index.js +8 -21
- package/node_modules/@zuplo/runtime/out/esm/mcp/messages/index.js +8 -21
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +11 -39
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +8 -21
- package/node_modules/@zuplo/runtime/out/esm/mocks/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/esm/sdks/aws/index.js +8 -21
- package/node_modules/@zuplo/runtime/out/esm/sdks/aws/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/types/index.d.ts +248 -6
- package/node_modules/@zuplo/runtime/out/types/internal/index.d.ts +101 -0
- package/node_modules/@zuplo/runtime/out/types/mcp-gateway/index.d.ts +127 -0
- package/node_modules/@zuplo/runtime/package.json +3 -2
- package/node_modules/express-rate-limit/dist/index.cjs +33 -4
- package/node_modules/express-rate-limit/dist/index.mjs +33 -4
- package/node_modules/express-rate-limit/package.json +1 -1
- package/package.json +12 -11
- package/node_modules/@zuplo/otel/out/esm/chunk-PVCAT62X.js +0 -26
- package/node_modules/@zuplo/otel/out/esm/chunk-PVCAT62X.js.map +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-A3QGJZO7.js +0 -26
- package/node_modules/@zuplo/runtime/out/esm/chunk-A3QGJZO7.js.map +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-F4G3YEN2.js +0 -429
- package/node_modules/@zuplo/runtime/out/esm/chunk-F4G3YEN2.js.map +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-GWGCD6Z7.js.map +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-HTXNM72E.js.map +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-M4IZPJP6.js +0 -37
- package/node_modules/@zuplo/runtime/out/esm/chunk-SX6JF7A6.js.map +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-TYV53J3B.js +0 -26
- package/node_modules/@zuplo/runtime/out/esm/chunk-TYV53J3B.js.map +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-UKQQD2JN.js +0 -26
- package/node_modules/@zuplo/runtime/out/esm/chunk-UKQQD2JN.js.map +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-VP5Q3DEN.js +0 -26
- package/node_modules/@zuplo/runtime/out/esm/chunk-VP5Q3DEN.js.map +0 -1
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-M4IZPJP6.js.LEGAL.txt → chunk-G42UYZ6V.js.LEGAL.txt} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-F4G3YEN2.js.LEGAL.txt → chunk-OE2WMJXK.js.LEGAL.txt} +0 -0
|
@@ -5,7 +5,7 @@ import { FlushTimer } from "../utils/flush-timer.mjs";
|
|
|
5
5
|
import { RetryAfterWindow } from "../utils/retry-after.mjs";
|
|
6
6
|
import { MAX_FLUSH_BACKOFF_MS, NO_JITTER, backoffDelayMs, drawJitter } from "../utils/backoff.mjs";
|
|
7
7
|
class PostHogLogs {
|
|
8
|
-
constructor(_instance, _config, _logger, _getContext, _onReady, _waitForStoragePersist = ()=>Promise.resolve(), _scopeName){
|
|
8
|
+
constructor(_instance, _config, _logger, _getContext, _onReady, _waitForStoragePersist = ()=>Promise.resolve(), _scopeName, _isConsentWithdrawn = ()=>false){
|
|
9
9
|
this._instance = _instance;
|
|
10
10
|
this._config = _config;
|
|
11
11
|
this._logger = _logger;
|
|
@@ -13,10 +13,12 @@ class PostHogLogs {
|
|
|
13
13
|
this._onReady = _onReady;
|
|
14
14
|
this._waitForStoragePersist = _waitForStoragePersist;
|
|
15
15
|
this._scopeName = _scopeName;
|
|
16
|
+
this._isConsentWithdrawn = _isConsentWithdrawn;
|
|
16
17
|
this._flushTimer = new FlushTimer(()=>this._flushInBackground());
|
|
17
18
|
this._flushPromise = null;
|
|
18
19
|
this._evictedSinceAdvance = 0;
|
|
19
20
|
this._queueGeneration = 0;
|
|
21
|
+
this._backgroundFlushPromise = null;
|
|
20
22
|
this._retryAfter = new RetryAfterWindow();
|
|
21
23
|
this._consecutiveFlushFailures = 0;
|
|
22
24
|
this._flushJitter = NO_JITTER;
|
|
@@ -34,6 +36,9 @@ class PostHogLogs {
|
|
|
34
36
|
this._queueGeneration++;
|
|
35
37
|
this._instance.setPersistedProperty(PostHogPersistedProperty.LogsQueue, []);
|
|
36
38
|
}
|
|
39
|
+
get throttled() {
|
|
40
|
+
return this._retryAfter.isOpen();
|
|
41
|
+
}
|
|
37
42
|
reset() {
|
|
38
43
|
this._flushTimer.clear();
|
|
39
44
|
this._intervalWindowStart = 0;
|
|
@@ -116,11 +121,13 @@ class PostHogLogs {
|
|
|
116
121
|
}
|
|
117
122
|
async _flushInner() {
|
|
118
123
|
this._flushTimer.clear();
|
|
124
|
+
if (this._discardQueueIfConsentWithdrawn()) return;
|
|
119
125
|
let queue = this._instance.getPersistedProperty(PostHogPersistedProperty.LogsQueue) ?? [];
|
|
120
126
|
if (0 === queue.length) return;
|
|
121
127
|
const originalQueueLength = queue.length;
|
|
122
128
|
let sentCount = 0;
|
|
123
129
|
while(queue.length > 0 && sentCount < originalQueueLength){
|
|
130
|
+
if (this._discardQueueIfConsentWithdrawn()) return;
|
|
124
131
|
const generation = this._queueGeneration;
|
|
125
132
|
this._evictedSinceAdvance = 0;
|
|
126
133
|
const batchSize = Math.min(queue.length, this._maxBatchRecordsPerPost);
|
|
@@ -145,6 +152,11 @@ class PostHogLogs {
|
|
|
145
152
|
if ('fatal' === outcome.kind) throw outcome.error;
|
|
146
153
|
}
|
|
147
154
|
}
|
|
155
|
+
_discardQueueIfConsentWithdrawn() {
|
|
156
|
+
if (!this._isConsentWithdrawn()) return false;
|
|
157
|
+
if (this._hasQueuedRecords()) this.clearQueue();
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
148
160
|
async _persistQueueAdvance(consumed) {
|
|
149
161
|
const evicted = this._evictedSinceAdvance;
|
|
150
162
|
const drop = Math.max(0, consumed - evicted);
|
|
@@ -191,8 +203,9 @@ class PostHogLogs {
|
|
|
191
203
|
flushPromise.catch(()=>{});
|
|
192
204
|
});
|
|
193
205
|
}
|
|
194
|
-
|
|
195
|
-
this.
|
|
206
|
+
flushInBackground() {
|
|
207
|
+
if (this._backgroundFlushPromise) return this._backgroundFlushPromise;
|
|
208
|
+
const promise = this.flush().then(()=>{
|
|
196
209
|
this._consecutiveFlushFailures = 0;
|
|
197
210
|
this._flushJitter = NO_JITTER;
|
|
198
211
|
}, (err)=>{
|
|
@@ -200,8 +213,14 @@ class PostHogLogs {
|
|
|
200
213
|
this._flushJitter = drawJitter();
|
|
201
214
|
this._logger.error('PostHog logs flush failed:', err);
|
|
202
215
|
}).finally(()=>{
|
|
216
|
+
if (this._backgroundFlushPromise === promise) this._backgroundFlushPromise = null;
|
|
203
217
|
if (!this._instance.isDisabled && this._hasQueuedRecords()) this._flushTimer.armNoEarlierThan(this._nextFlushDelay());
|
|
204
218
|
});
|
|
219
|
+
this._backgroundFlushPromise = promise;
|
|
220
|
+
return promise;
|
|
221
|
+
}
|
|
222
|
+
_flushInBackground() {
|
|
223
|
+
this.flushInBackground();
|
|
205
224
|
}
|
|
206
225
|
}
|
|
207
226
|
export { PostHogLogs };
|
|
@@ -26,6 +26,7 @@ export declare class PostHogMetrics {
|
|
|
26
26
|
private _series;
|
|
27
27
|
private readonly _flushTimer;
|
|
28
28
|
private _flushPromise;
|
|
29
|
+
private _queuedFlush;
|
|
29
30
|
private _seriesCapWarned;
|
|
30
31
|
private _typeByName;
|
|
31
32
|
private _typeCollisionWarned;
|
|
@@ -42,6 +43,14 @@ export declare class PostHogMetrics {
|
|
|
42
43
|
histogram(name: string, value: number, options?: HistogramOptions): void;
|
|
43
44
|
/** Sends everything aggregated so far without waiting for the flush interval. */
|
|
44
45
|
flush(): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* A flush for callers that ask once per unit of work (a served request, say) rather than once per window.
|
|
48
|
+
* Callers share one queued flush, so at most one send is in flight and one waits behind it however often
|
|
49
|
+
* this is called, and every sample captured before the call is in one of them. While a failed send is
|
|
50
|
+
* backing off it starts nothing and the retry timer owns the next send.
|
|
51
|
+
*/
|
|
52
|
+
flushCoalesced(): Promise<void>;
|
|
53
|
+
private _isBackingOff;
|
|
45
54
|
/**
|
|
46
55
|
* Synchronously snapshots the current window into an OTLP payload and
|
|
47
56
|
* resets it, bypassing the flush serializer entirely — for unload-time
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metrics/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAOhB,kBAAkB,EAEnB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAetC,OAAO,KAAK,EAAE,WAAW,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAA;AAqCxE;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,cAAc;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/metrics/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EAOhB,kBAAkB,EAEnB,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,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AI,OAAO,CAAC,IAAI,CAAC,CAe9B;IAED,OAAO,CAAC,aAAa;IAIrB;;;;;;OAMG;IACH,WAAW,IAAI,kBAAkB,GAAG,IAAI,CAOvC;IAED,2FAA2F;IAC3F,KAAK,IAAI,IAAI,CAWZ;IAED,wDAAwD;IACxD,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,QAAQ;IAwFhB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAY3B;;;OAGG;IACH,OAAO,CAAC,eAAe;IAcvB;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAwCxB,OAAO,CAAC,qBAAqB;IAgB7B,OAAO,CAAC,KAAK;IAoBb,OAAO,CAAC,cAAc;IAyBtB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,eAAe;YAYT,QAAQ;IAsDtB,OAAO,CAAC,aAAa;IASrB;;;OAGG;IACH,OAAO,CAAC,aAAa;IA6DrB,oFAAoF;IACpF,OAAO,CAAC,gBAAgB;CAoCzB;AAoDD,OAAO,EAAE,uBAAuB,EAAE,8BAA8B,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AACnH,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAC/C,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,4BAA4B,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -53,6 +53,7 @@ class PostHogMetrics {
|
|
|
53
53
|
this._logger.error('Metrics flush failed:', e);
|
|
54
54
|
}));
|
|
55
55
|
this._flushPromise = null;
|
|
56
|
+
this._queuedFlush = null;
|
|
56
57
|
this._seriesCapWarned = false;
|
|
57
58
|
this._typeByName = new Map();
|
|
58
59
|
this._typeCollisionWarned = new Set();
|
|
@@ -104,6 +105,17 @@ class PostHogMetrics {
|
|
|
104
105
|
this._flushPromise = p;
|
|
105
106
|
return p;
|
|
106
107
|
}
|
|
108
|
+
flushCoalesced() {
|
|
109
|
+
if (this._isBackingOff()) return this._flushPromise ?? Promise.resolve();
|
|
110
|
+
if (!this._queuedFlush) this._queuedFlush = (this._flushPromise ?? Promise.resolve()).catch(()=>{}).then(()=>{
|
|
111
|
+
this._queuedFlush = null;
|
|
112
|
+
return this._isBackingOff() ? void 0 : this.flush();
|
|
113
|
+
});
|
|
114
|
+
return this._queuedFlush;
|
|
115
|
+
}
|
|
116
|
+
_isBackingOff() {
|
|
117
|
+
return this._consecutiveFlushFailures > 0 || this._retryAfter.remainingMs() > 0;
|
|
118
|
+
}
|
|
107
119
|
drainWindow() {
|
|
108
120
|
if (0 === this._series.size) return null;
|
|
109
121
|
const window = this._series;
|
|
@@ -117,6 +129,7 @@ class PostHogMetrics {
|
|
|
117
129
|
this._flushJitter = backoff_js_namespaceObject.NO_JITTER;
|
|
118
130
|
this._flushTimer.clear();
|
|
119
131
|
this._flushPromise = null;
|
|
132
|
+
this._queuedFlush = null;
|
|
120
133
|
this._startWindow();
|
|
121
134
|
this._boundsByHistogram = new Map();
|
|
122
135
|
this._boundsCapWarned = false;
|
|
@@ -16,6 +16,7 @@ class PostHogMetrics {
|
|
|
16
16
|
this._logger.error('Metrics flush failed:', e);
|
|
17
17
|
}));
|
|
18
18
|
this._flushPromise = null;
|
|
19
|
+
this._queuedFlush = null;
|
|
19
20
|
this._seriesCapWarned = false;
|
|
20
21
|
this._typeByName = new Map();
|
|
21
22
|
this._typeCollisionWarned = new Set();
|
|
@@ -67,6 +68,17 @@ class PostHogMetrics {
|
|
|
67
68
|
this._flushPromise = p;
|
|
68
69
|
return p;
|
|
69
70
|
}
|
|
71
|
+
flushCoalesced() {
|
|
72
|
+
if (this._isBackingOff()) return this._flushPromise ?? Promise.resolve();
|
|
73
|
+
if (!this._queuedFlush) this._queuedFlush = (this._flushPromise ?? Promise.resolve()).catch(()=>{}).then(()=>{
|
|
74
|
+
this._queuedFlush = null;
|
|
75
|
+
return this._isBackingOff() ? void 0 : this.flush();
|
|
76
|
+
});
|
|
77
|
+
return this._queuedFlush;
|
|
78
|
+
}
|
|
79
|
+
_isBackingOff() {
|
|
80
|
+
return this._consecutiveFlushFailures > 0 || this._retryAfter.remainingMs() > 0;
|
|
81
|
+
}
|
|
70
82
|
drainWindow() {
|
|
71
83
|
if (0 === this._series.size) return null;
|
|
72
84
|
const window = this._series;
|
|
@@ -80,6 +92,7 @@ class PostHogMetrics {
|
|
|
80
92
|
this._flushJitter = NO_JITTER;
|
|
81
93
|
this._flushTimer.clear();
|
|
82
94
|
this._flushPromise = null;
|
|
95
|
+
this._queuedFlush = null;
|
|
83
96
|
this._startWindow();
|
|
84
97
|
this._boundsByHistogram = new Map();
|
|
85
98
|
this._boundsCapWarned = false;
|
|
@@ -2,6 +2,8 @@ export interface TextSanitizationOptions {
|
|
|
2
2
|
maxStringLength: number;
|
|
3
3
|
truncationSuffix: string;
|
|
4
4
|
}
|
|
5
|
+
/** Whether a key names a credential, so its value is captured as `[redacted]` whatever it holds. */
|
|
6
|
+
export declare function shouldRedactKey(key: string): boolean;
|
|
5
7
|
/**
|
|
6
8
|
* Sanitizes agent-narrated free text (`$mcp_intent`, the `send_feedback`
|
|
7
9
|
* fields): structured PII on top of the passes every captured string gets.
|
|
@@ -29,7 +31,10 @@ export declare function sanitizeCapturedValue(value: unknown, options: TextSanit
|
|
|
29
31
|
/**
|
|
30
32
|
* {@link sanitizeCapturedValue} with the intent-grade string pass
|
|
31
33
|
* ({@link sanitizeFreeText}) on every string leaf, so nested agent-narrated
|
|
32
|
-
* values get structured-PII redaction in the load-bearing order too.
|
|
34
|
+
* values get structured-PII redaction in the load-bearing order too. Keys and
|
|
35
|
+
* numbers are read as free text as well, since a value sent as JSON text carries
|
|
36
|
+
* them: a number that holds an identifier becomes `[redacted]`, so the text
|
|
37
|
+
* stays valid JSON.
|
|
33
38
|
*/
|
|
34
39
|
export declare function sanitizeFreeTextValue(value: unknown, options: TextSanitizationOptions): unknown;
|
|
35
40
|
//# sourceMappingURL=privacy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"privacy.d.ts","sourceRoot":"","sources":["../src/privacy.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,uBAAuB;IACtC,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB,EAAE,MAAM,CAAA;CACzB;
|
|
1
|
+
{"version":3,"file":"privacy.d.ts","sourceRoot":"","sources":["../src/privacy.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,uBAAuB;IACtC,eAAe,EAAE,MAAM,CAAA;IACvB,gBAAgB,EAAE,MAAM,CAAA;CACzB;AAsHD,oGAAoG;AACpG,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAEpD;AAgbD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,GAAG,MAAM,CAKxF;AA6HD;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAU/C;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAK/F;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAK/F"}
|
|
@@ -55,7 +55,7 @@ const EMAIL_PATTERN = /[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,2
|
|
|
55
55
|
const IPV4_PATTERN = /\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g;
|
|
56
56
|
const IPV6_PATTERN = /(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g;
|
|
57
57
|
const US_SSN_PATTERN = /\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g;
|
|
58
|
-
const
|
|
58
|
+
const CARD_SEPARATORS = ' ./-';
|
|
59
59
|
const DIGIT_GROUP_PATTERN = /\d+/g;
|
|
60
60
|
const PHONE_NANP_PATTERN = /(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g;
|
|
61
61
|
const PHONE_INTL_PATTERN = /(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;
|
|
@@ -295,6 +295,40 @@ function passesLuhn(digits) {
|
|
|
295
295
|
}
|
|
296
296
|
return sum % 10 === 0;
|
|
297
297
|
}
|
|
298
|
+
function isDigitAt(text, index) {
|
|
299
|
+
const code = text.charCodeAt(index);
|
|
300
|
+
return code >= 48 && code <= 57;
|
|
301
|
+
}
|
|
302
|
+
function isWordAt(text, index) {
|
|
303
|
+
const code = text.charCodeAt(index);
|
|
304
|
+
return isDigitAt(text, index) || 95 === code || code >= 65 && code <= 90 || code >= 97 && code <= 122;
|
|
305
|
+
}
|
|
306
|
+
function digitsEnd(text, index) {
|
|
307
|
+
let end = index;
|
|
308
|
+
while(isDigitAt(text, end))end++;
|
|
309
|
+
return end;
|
|
310
|
+
}
|
|
311
|
+
function findCardCandidate(text, from) {
|
|
312
|
+
for(let start = from; start < text.length; start++){
|
|
313
|
+
if (!isDigitAt(text, start) || isWordAt(text, start - 1)) continue;
|
|
314
|
+
let digits = 0;
|
|
315
|
+
let end = -1;
|
|
316
|
+
let groupStart = start;
|
|
317
|
+
for(;;){
|
|
318
|
+
const groupEnd = digitsEnd(text, groupStart);
|
|
319
|
+
digits += groupEnd - groupStart;
|
|
320
|
+
if (digits >= 13 && !isWordAt(text, groupEnd)) end = groupEnd;
|
|
321
|
+
groupStart = groupEnd + 1;
|
|
322
|
+
if (!CARD_SEPARATORS.includes(text.charAt(groupEnd)) || !isDigitAt(text, groupStart)) break;
|
|
323
|
+
}
|
|
324
|
+
if (end >= 0) return [
|
|
325
|
+
start,
|
|
326
|
+
end
|
|
327
|
+
];
|
|
328
|
+
start = groupStart - 1;
|
|
329
|
+
}
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
298
332
|
function redactCardInMatch(match) {
|
|
299
333
|
const groups = [];
|
|
300
334
|
for(let m = DIGIT_GROUP_PATTERN.exec(match); null !== m; m = DIGIT_GROUP_PATTERN.exec(match))groups.push({
|
|
@@ -321,48 +355,73 @@ function redactCardInMatch(match) {
|
|
|
321
355
|
}
|
|
322
356
|
return output + match.slice(cursor);
|
|
323
357
|
}
|
|
358
|
+
function redactCards(text) {
|
|
359
|
+
let output = '';
|
|
360
|
+
let cursor = 0;
|
|
361
|
+
for(let run = findCardCandidate(text, 0); null !== run; run = findCardCandidate(text, run[1])){
|
|
362
|
+
output += text.slice(cursor, run[0]) + redactCardInMatch(text.slice(run[0], run[1]));
|
|
363
|
+
cursor = run[1];
|
|
364
|
+
}
|
|
365
|
+
return output + text.slice(cursor);
|
|
366
|
+
}
|
|
324
367
|
function redactPii(value) {
|
|
325
368
|
let result = value.replace(UNICODE_SPACE_PATTERN, ' ');
|
|
326
369
|
result = result.replace(EMAIL_PATTERN, REDACTED_VALUE);
|
|
327
370
|
result = result.replace(IPV4_PATTERN, REDACTED_VALUE);
|
|
328
371
|
result = result.replace(IPV6_PATTERN, `$1${REDACTED_VALUE}`);
|
|
329
|
-
result = result
|
|
372
|
+
result = redactCards(result);
|
|
330
373
|
result = result.replace(US_SSN_PATTERN, REDACTED_VALUE);
|
|
331
374
|
result = result.replace(PHONE_NANP_PATTERN, `$1${REDACTED_VALUE}`);
|
|
332
375
|
result = result.replace(PHONE_INTL_PATTERN, `$1${REDACTED_VALUE}`);
|
|
333
376
|
return result;
|
|
334
377
|
}
|
|
335
378
|
function sanitizeCapturedValue(value, options) {
|
|
336
|
-
return sanitizeValueWith(value,
|
|
379
|
+
return sanitizeValueWith(value, {
|
|
380
|
+
text: (stringValue)=>sanitizeString(stringValue, options),
|
|
381
|
+
readsKeysAndNumbers: false
|
|
382
|
+
});
|
|
337
383
|
}
|
|
338
384
|
function sanitizeFreeTextValue(value, options) {
|
|
339
|
-
return sanitizeValueWith(value,
|
|
385
|
+
return sanitizeValueWith(value, {
|
|
386
|
+
text: (stringValue)=>sanitizeFreeText(stringValue, options),
|
|
387
|
+
readsKeysAndNumbers: true
|
|
388
|
+
});
|
|
340
389
|
}
|
|
341
|
-
function sanitizeValueWith(value,
|
|
390
|
+
function sanitizeValueWith(value, sanitizer) {
|
|
342
391
|
if (null == value) return value;
|
|
343
|
-
if ('string' == typeof value) return
|
|
344
|
-
if (
|
|
392
|
+
if ('string' == typeof value) return sanitizer.text(value);
|
|
393
|
+
if ('number' == typeof value && sanitizer.readsKeysAndNumbers) {
|
|
394
|
+
const text = String(value);
|
|
395
|
+
return sanitizer.text(text) === text ? value : REDACTED_VALUE;
|
|
396
|
+
}
|
|
397
|
+
if (Array.isArray(value)) return value.map((item)=>sanitizeValueWith(item, sanitizer));
|
|
345
398
|
if (value instanceof Date) return value;
|
|
346
399
|
if ('object' != typeof value) return value;
|
|
347
400
|
const result = {};
|
|
348
|
-
for (const [key, nestedValue] of Object.entries(value))
|
|
401
|
+
for (const [key, nestedValue] of Object.entries(value)){
|
|
402
|
+
const capturedKey = sanitizer.readsKeysAndNumbers ? sanitizer.text(key) : key;
|
|
403
|
+
result[capturedKey] = shouldRedactKey(key) ? REDACTED_VALUE : sanitizeValueWith(nestedValue, sanitizer);
|
|
404
|
+
}
|
|
349
405
|
return result;
|
|
350
406
|
}
|
|
351
407
|
__webpack_require__.d(__webpack_exports__, {
|
|
352
408
|
redactPii: ()=>redactPii,
|
|
353
409
|
sanitizeCapturedValue: ()=>sanitizeCapturedValue,
|
|
354
410
|
sanitizeFreeText: ()=>sanitizeFreeText,
|
|
355
|
-
sanitizeFreeTextValue: ()=>sanitizeFreeTextValue
|
|
411
|
+
sanitizeFreeTextValue: ()=>sanitizeFreeTextValue,
|
|
412
|
+
shouldRedactKey: ()=>shouldRedactKey
|
|
356
413
|
});
|
|
357
414
|
exports.redactPii = __webpack_exports__.redactPii;
|
|
358
415
|
exports.sanitizeCapturedValue = __webpack_exports__.sanitizeCapturedValue;
|
|
359
416
|
exports.sanitizeFreeText = __webpack_exports__.sanitizeFreeText;
|
|
360
417
|
exports.sanitizeFreeTextValue = __webpack_exports__.sanitizeFreeTextValue;
|
|
418
|
+
exports.shouldRedactKey = __webpack_exports__.shouldRedactKey;
|
|
361
419
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
362
420
|
"redactPii",
|
|
363
421
|
"sanitizeCapturedValue",
|
|
364
422
|
"sanitizeFreeText",
|
|
365
|
-
"sanitizeFreeTextValue"
|
|
423
|
+
"sanitizeFreeTextValue",
|
|
424
|
+
"shouldRedactKey"
|
|
366
425
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
367
426
|
Object.defineProperty(exports, '__esModule', {
|
|
368
427
|
value: true
|
|
@@ -26,7 +26,7 @@ const EMAIL_PATTERN = /[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,2
|
|
|
26
26
|
const IPV4_PATTERN = /\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g;
|
|
27
27
|
const IPV6_PATTERN = /(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g;
|
|
28
28
|
const US_SSN_PATTERN = /\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g;
|
|
29
|
-
const
|
|
29
|
+
const CARD_SEPARATORS = ' ./-';
|
|
30
30
|
const DIGIT_GROUP_PATTERN = /\d+/g;
|
|
31
31
|
const PHONE_NANP_PATTERN = /(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g;
|
|
32
32
|
const PHONE_INTL_PATTERN = /(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;
|
|
@@ -266,6 +266,40 @@ function passesLuhn(digits) {
|
|
|
266
266
|
}
|
|
267
267
|
return sum % 10 === 0;
|
|
268
268
|
}
|
|
269
|
+
function isDigitAt(text, index) {
|
|
270
|
+
const code = text.charCodeAt(index);
|
|
271
|
+
return code >= 48 && code <= 57;
|
|
272
|
+
}
|
|
273
|
+
function isWordAt(text, index) {
|
|
274
|
+
const code = text.charCodeAt(index);
|
|
275
|
+
return isDigitAt(text, index) || 95 === code || code >= 65 && code <= 90 || code >= 97 && code <= 122;
|
|
276
|
+
}
|
|
277
|
+
function digitsEnd(text, index) {
|
|
278
|
+
let end = index;
|
|
279
|
+
while(isDigitAt(text, end))end++;
|
|
280
|
+
return end;
|
|
281
|
+
}
|
|
282
|
+
function findCardCandidate(text, from) {
|
|
283
|
+
for(let start = from; start < text.length; start++){
|
|
284
|
+
if (!isDigitAt(text, start) || isWordAt(text, start - 1)) continue;
|
|
285
|
+
let digits = 0;
|
|
286
|
+
let end = -1;
|
|
287
|
+
let groupStart = start;
|
|
288
|
+
for(;;){
|
|
289
|
+
const groupEnd = digitsEnd(text, groupStart);
|
|
290
|
+
digits += groupEnd - groupStart;
|
|
291
|
+
if (digits >= 13 && !isWordAt(text, groupEnd)) end = groupEnd;
|
|
292
|
+
groupStart = groupEnd + 1;
|
|
293
|
+
if (!CARD_SEPARATORS.includes(text.charAt(groupEnd)) || !isDigitAt(text, groupStart)) break;
|
|
294
|
+
}
|
|
295
|
+
if (end >= 0) return [
|
|
296
|
+
start,
|
|
297
|
+
end
|
|
298
|
+
];
|
|
299
|
+
start = groupStart - 1;
|
|
300
|
+
}
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
269
303
|
function redactCardInMatch(match) {
|
|
270
304
|
const groups = [];
|
|
271
305
|
for(let m = DIGIT_GROUP_PATTERN.exec(match); null !== m; m = DIGIT_GROUP_PATTERN.exec(match))groups.push({
|
|
@@ -292,31 +326,53 @@ function redactCardInMatch(match) {
|
|
|
292
326
|
}
|
|
293
327
|
return output + match.slice(cursor);
|
|
294
328
|
}
|
|
329
|
+
function redactCards(text) {
|
|
330
|
+
let output = '';
|
|
331
|
+
let cursor = 0;
|
|
332
|
+
for(let run = findCardCandidate(text, 0); null !== run; run = findCardCandidate(text, run[1])){
|
|
333
|
+
output += text.slice(cursor, run[0]) + redactCardInMatch(text.slice(run[0], run[1]));
|
|
334
|
+
cursor = run[1];
|
|
335
|
+
}
|
|
336
|
+
return output + text.slice(cursor);
|
|
337
|
+
}
|
|
295
338
|
function redactPii(value) {
|
|
296
339
|
let result = value.replace(UNICODE_SPACE_PATTERN, ' ');
|
|
297
340
|
result = result.replace(EMAIL_PATTERN, REDACTED_VALUE);
|
|
298
341
|
result = result.replace(IPV4_PATTERN, REDACTED_VALUE);
|
|
299
342
|
result = result.replace(IPV6_PATTERN, `$1${REDACTED_VALUE}`);
|
|
300
|
-
result = result
|
|
343
|
+
result = redactCards(result);
|
|
301
344
|
result = result.replace(US_SSN_PATTERN, REDACTED_VALUE);
|
|
302
345
|
result = result.replace(PHONE_NANP_PATTERN, `$1${REDACTED_VALUE}`);
|
|
303
346
|
result = result.replace(PHONE_INTL_PATTERN, `$1${REDACTED_VALUE}`);
|
|
304
347
|
return result;
|
|
305
348
|
}
|
|
306
349
|
function sanitizeCapturedValue(value, options) {
|
|
307
|
-
return sanitizeValueWith(value,
|
|
350
|
+
return sanitizeValueWith(value, {
|
|
351
|
+
text: (stringValue)=>sanitizeString(stringValue, options),
|
|
352
|
+
readsKeysAndNumbers: false
|
|
353
|
+
});
|
|
308
354
|
}
|
|
309
355
|
function sanitizeFreeTextValue(value, options) {
|
|
310
|
-
return sanitizeValueWith(value,
|
|
356
|
+
return sanitizeValueWith(value, {
|
|
357
|
+
text: (stringValue)=>sanitizeFreeText(stringValue, options),
|
|
358
|
+
readsKeysAndNumbers: true
|
|
359
|
+
});
|
|
311
360
|
}
|
|
312
|
-
function sanitizeValueWith(value,
|
|
361
|
+
function sanitizeValueWith(value, sanitizer) {
|
|
313
362
|
if (null == value) return value;
|
|
314
|
-
if ('string' == typeof value) return
|
|
315
|
-
if (
|
|
363
|
+
if ('string' == typeof value) return sanitizer.text(value);
|
|
364
|
+
if ('number' == typeof value && sanitizer.readsKeysAndNumbers) {
|
|
365
|
+
const text = String(value);
|
|
366
|
+
return sanitizer.text(text) === text ? value : REDACTED_VALUE;
|
|
367
|
+
}
|
|
368
|
+
if (Array.isArray(value)) return value.map((item)=>sanitizeValueWith(item, sanitizer));
|
|
316
369
|
if (value instanceof Date) return value;
|
|
317
370
|
if ('object' != typeof value) return value;
|
|
318
371
|
const result = {};
|
|
319
|
-
for (const [key, nestedValue] of Object.entries(value))
|
|
372
|
+
for (const [key, nestedValue] of Object.entries(value)){
|
|
373
|
+
const capturedKey = sanitizer.readsKeysAndNumbers ? sanitizer.text(key) : key;
|
|
374
|
+
result[capturedKey] = shouldRedactKey(key) ? REDACTED_VALUE : sanitizeValueWith(nestedValue, sanitizer);
|
|
375
|
+
}
|
|
320
376
|
return result;
|
|
321
377
|
}
|
|
322
|
-
export { redactPii, sanitizeCapturedValue, sanitizeFreeText, sanitizeFreeTextValue };
|
|
378
|
+
export { redactPii, sanitizeCapturedValue, sanitizeFreeText, sanitizeFreeTextValue, shouldRedactKey };
|
|
@@ -88,6 +88,8 @@ export declare class PostHogSpan implements Span {
|
|
|
88
88
|
recordException(error: unknown): this;
|
|
89
89
|
updateName(name: string): this;
|
|
90
90
|
traceparent(): string | null;
|
|
91
|
+
get traceId(): string;
|
|
92
|
+
get spanId(): string;
|
|
91
93
|
tracestate(): string | null;
|
|
92
94
|
/** Context a child span inherits when this handle is its parent. */
|
|
93
95
|
childContext(): {
|
|
@@ -130,6 +132,8 @@ export declare class NoopSpan implements Span {
|
|
|
130
132
|
recordException(): this;
|
|
131
133
|
updateName(): this;
|
|
132
134
|
traceparent(): string | null;
|
|
135
|
+
get traceId(): string | null;
|
|
136
|
+
get spanId(): string | null;
|
|
133
137
|
tracestate(): string | null;
|
|
134
138
|
end(): void;
|
|
135
139
|
}
|
|
@@ -146,6 +150,8 @@ export declare class PassThroughSpan extends NoopSpan {
|
|
|
146
150
|
private readonly _tracestate?;
|
|
147
151
|
constructor(_traceparent: string, _tracestate?: string | undefined);
|
|
148
152
|
traceparent(): string;
|
|
153
|
+
get traceId(): string | null;
|
|
154
|
+
get spanId(): string | null;
|
|
149
155
|
tracestate(): string | null;
|
|
150
156
|
}
|
|
151
157
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"span.d.ts","sourceRoot":"","sources":["../../src/traces/span.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,kBAAkB,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACvH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAmB,UAAU,EAAE,MAAM,SAAS,CAAA;AAmB9E;;;GAGG;AACH,wBAAgB,YAAY,IAAI,MAAM,GAAG,SAAS,CAGjD;AAED,8FAA8F;AAC9F,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAA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;;GASG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,cAAc,EAAE,kBAAkB,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,CAAC,GAAG,CAAC,CAE7G;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAqB/F"}
|
|
@@ -176,6 +176,12 @@ class PostHogSpan {
|
|
|
176
176
|
traceparent() {
|
|
177
177
|
return (0, external_traceparent_js_namespaceObject.formatTraceparent)(this._traceId, this._spanId, this._traceFlags);
|
|
178
178
|
}
|
|
179
|
+
get traceId() {
|
|
180
|
+
return this._traceId;
|
|
181
|
+
}
|
|
182
|
+
get spanId() {
|
|
183
|
+
return this._spanId;
|
|
184
|
+
}
|
|
179
185
|
tracestate() {
|
|
180
186
|
return this._traceState ?? null;
|
|
181
187
|
}
|
|
@@ -315,6 +321,12 @@ class NoopSpan {
|
|
|
315
321
|
traceparent() {
|
|
316
322
|
return null;
|
|
317
323
|
}
|
|
324
|
+
get traceId() {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
get spanId() {
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
318
330
|
tracestate() {
|
|
319
331
|
return null;
|
|
320
332
|
}
|
|
@@ -328,6 +340,12 @@ class PassThroughSpan extends NoopSpan {
|
|
|
328
340
|
traceparent() {
|
|
329
341
|
return this._traceparent;
|
|
330
342
|
}
|
|
343
|
+
get traceId() {
|
|
344
|
+
return this._traceparent.split('-')[1] ?? null;
|
|
345
|
+
}
|
|
346
|
+
get spanId() {
|
|
347
|
+
return this._traceparent.split('-')[2] ?? null;
|
|
348
|
+
}
|
|
331
349
|
tracestate() {
|
|
332
350
|
return this._tracestate ?? null;
|
|
333
351
|
}
|
|
@@ -133,6 +133,12 @@ class PostHogSpan {
|
|
|
133
133
|
traceparent() {
|
|
134
134
|
return formatTraceparent(this._traceId, this._spanId, this._traceFlags);
|
|
135
135
|
}
|
|
136
|
+
get traceId() {
|
|
137
|
+
return this._traceId;
|
|
138
|
+
}
|
|
139
|
+
get spanId() {
|
|
140
|
+
return this._spanId;
|
|
141
|
+
}
|
|
136
142
|
tracestate() {
|
|
137
143
|
return this._traceState ?? null;
|
|
138
144
|
}
|
|
@@ -272,6 +278,12 @@ class NoopSpan {
|
|
|
272
278
|
traceparent() {
|
|
273
279
|
return null;
|
|
274
280
|
}
|
|
281
|
+
get traceId() {
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
get spanId() {
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
275
287
|
tracestate() {
|
|
276
288
|
return null;
|
|
277
289
|
}
|
|
@@ -285,6 +297,12 @@ class PassThroughSpan extends NoopSpan {
|
|
|
285
297
|
traceparent() {
|
|
286
298
|
return this._traceparent;
|
|
287
299
|
}
|
|
300
|
+
get traceId() {
|
|
301
|
+
return this._traceparent.split('-')[1] ?? null;
|
|
302
|
+
}
|
|
303
|
+
get spanId() {
|
|
304
|
+
return this._traceparent.split('-')[2] ?? null;
|
|
305
|
+
}
|
|
288
306
|
tracestate() {
|
|
289
307
|
return this._tracestate ?? null;
|
|
290
308
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.67.1",
|
|
4
4
|
"bugs": {
|
|
5
5
|
"url": "https://github.com/PostHog/posthog-js/issues"
|
|
6
6
|
},
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@posthog/types": "^1.
|
|
75
|
+
"@posthog/types": "^1.423.0"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@rslib/core": "0.23.2",
|
|
@@ -478,13 +478,34 @@ export function relativeDateParseForFeatureFlagMatching(value: string): Date | n
|
|
|
478
478
|
if (interval === 'h') parsedDt.setUTCHours(parsedDt.getUTCHours() - number)
|
|
479
479
|
else if (interval === 'd') parsedDt.setUTCDate(parsedDt.getUTCDate() - number)
|
|
480
480
|
else if (interval === 'w') parsedDt.setUTCDate(parsedDt.getUTCDate() - number * 7)
|
|
481
|
-
else if (interval === 'm')
|
|
482
|
-
else if (interval === 'y')
|
|
481
|
+
else if (interval === 'm') subtractUTCMonths(parsedDt, number)
|
|
482
|
+
else if (interval === 'y') subtractUTCYears(parsedDt, number)
|
|
483
483
|
else return null
|
|
484
484
|
|
|
485
485
|
return parsedDt
|
|
486
486
|
}
|
|
487
487
|
|
|
488
|
+
// The SDK spec subtracts months one at a time and clamps the day after every step, so
|
|
489
|
+
// March 31 minus one month is February 28 and minus two months is January 28.
|
|
490
|
+
function subtractUTCMonths(date: Date, months: number): void {
|
|
491
|
+
const year = date.getUTCFullYear()
|
|
492
|
+
const month = date.getUTCMonth()
|
|
493
|
+
let day = date.getUTCDate()
|
|
494
|
+
// Every month has at least 28 days, so nothing can clamp further after that.
|
|
495
|
+
for (let step = 1; step <= months && day > 28; step++) {
|
|
496
|
+
const lastDayOfMonth = new Date(Date.UTC(year, month - step + 1, 0)).getUTCDate()
|
|
497
|
+
day = Math.min(day, lastDayOfMonth)
|
|
498
|
+
}
|
|
499
|
+
date.setUTCFullYear(year, month - months, day)
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function subtractUTCYears(date: Date, years: number): void {
|
|
503
|
+
const month = date.getUTCMonth()
|
|
504
|
+
// The year before a leap year is never a leap year, so February 29 clamps on the first step.
|
|
505
|
+
const day = years > 0 && month === 1 && date.getUTCDate() === 29 ? 28 : date.getUTCDate()
|
|
506
|
+
date.setUTCFullYear(date.getUTCFullYear() - years, month, day)
|
|
507
|
+
}
|
|
508
|
+
|
|
488
509
|
function parseDateFilter(value: FeatureFlagPropertyValue): Date {
|
|
489
510
|
if (typeof value === 'boolean') {
|
|
490
511
|
throw new InconclusiveMatchError('Date operations cannot be performed on boolean values')
|