@genn-inc/cluebase-frontend-sdk 0.0.6 → 0.0.8
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/_generated/correlation-attribute-keys.d.ts +3 -0
- package/dist/_generated/correlation-attribute-keys.js +34 -0
- package/dist/_generated/diagnostic-codes.d.ts +4 -0
- package/dist/_generated/diagnostic-codes.js +48 -0
- package/dist/_generated/drop-reasons.d.ts +2 -0
- package/dist/_generated/drop-reasons.js +25 -0
- package/dist/_generated/ingest-routes.d.ts +5 -0
- package/dist/_generated/ingest-routes.js +12 -0
- package/dist/context/trace.js +2 -4
- package/dist/exporter/batch.d.ts +23 -26
- package/dist/exporter/batch.js +247 -289
- package/dist/exporter/browser-outbox-records.d.ts +7 -24
- package/dist/exporter/browser-outbox-records.js +6 -94
- package/dist/exporter/browser-outbox.d.ts +23 -28
- package/dist/exporter/browser-outbox.js +99 -211
- package/dist/exporter/client.d.ts +24 -34
- package/dist/exporter/client.js +105 -318
- package/dist/exporter/delivery-pipeline.d.ts +71 -0
- package/dist/exporter/delivery-pipeline.js +196 -0
- package/dist/exporter/delivery-response-contract.d.ts +1 -81
- package/dist/exporter/delivery-response-contract.js +0 -168
- package/dist/exporter/delivery-response.d.ts +7 -4
- package/dist/exporter/delivery-response.js +59 -133
- package/dist/exporter/diagnostics.d.ts +2 -1
- package/dist/exporter/diagnostics.js +1 -25
- package/dist/exporter/event-id.d.ts +1 -0
- package/dist/exporter/event-id.js +3 -0
- package/dist/exporter/observation-source-event-exporter.d.ts +1 -1
- package/dist/exporter/observation-source-event-exporter.js +2 -2
- package/dist/exporter/sdk-core-delivery.d.ts +225 -0
- package/dist/exporter/sdk-core-delivery.js +97 -0
- package/dist/exporter/sdk-core-wasm.d.ts +7 -1
- package/dist/exporter/sdk-core-wasm.js +24 -3
- package/dist/exporter/source-event.d.ts +2 -0
- package/dist/exporter/source-event.js +17 -0
- package/dist/exporter/span-to-source-signal.d.ts +1 -1
- package/dist/exporter/span-to-source-signal.js +20 -140
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -3
- package/dist/instrumentation/network.d.ts +1 -1
- package/dist/instrumentation/network.js +17 -0
- package/dist/provider/_version.d.ts +1 -1
- package/dist/provider/_version.js +1 -1
- package/dist/provider/config.js +16 -3
- package/dist/provider/constants.js +0 -1
- package/dist/provider/lifecycle-event-dedup.d.ts +7 -0
- package/dist/provider/lifecycle-event-dedup.js +31 -0
- package/dist/provider/sdk-event-pipeline.d.ts +1 -3
- package/dist/provider/sdk-event-pipeline.js +0 -15
- package/dist/provider/sdk-otel-pipeline.d.ts +2 -1
- package/dist/provider/sdk-otel-pipeline.js +2 -11
- package/dist/provider/sdk-runtime-surfaces.d.ts +3 -2
- package/dist/provider/sdk-runtime-surfaces.js +7 -6
- package/dist/provider/sdk.js +88 -54
- package/dist/provider/types.d.ts +12 -19
- package/dist/wasm/pkg-web/cluebase_sdk_core_wasm.d.ts +12 -9
- package/dist/wasm/pkg-web/cluebase_sdk_core_wasm.js +117 -29
- package/dist/wasm/pkg-web/cluebase_sdk_core_wasm_bg.wasm +0 -0
- package/dist/wasm/pkg-web/cluebase_sdk_core_wasm_bg.wasm.d.ts +8 -9
- package/package.json +1 -1
- package/dist/provider/usage-governor.d.ts +0 -7
- package/dist/provider/usage-governor.js +0 -114
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
/** 伏せる処理を通しても残す、相関のための属性名。 */
|
|
2
2
|
export declare const CLUEBASE_CORRELATION_ATTRIBUTE_KEYS: ReadonlySet<string>;
|
|
3
|
+
export declare const CLUEBASE_KEYS_NO_CUSTOMER_VALUE_REACHES: ReadonlySet<string>;
|
|
4
|
+
export declare const CLUEBASE_KEYS_HASHED_WHEN_PERSONAL_INFORMATION_SHAPED: ReadonlySet<string>;
|
|
5
|
+
export declare const CLUEBASE_VALUE_FORMATS_THAT_KEEP_THE_EXEMPTION_TRUE: Readonly<Record<string, readonly string[]>>;
|
|
@@ -35,3 +35,37 @@ export const CLUEBASE_CORRELATION_ATTRIBUTE_KEYS = new Set([
|
|
|
35
35
|
"mcp.client.version",
|
|
36
36
|
"mcp.session.id",
|
|
37
37
|
]);
|
|
38
|
+
export const CLUEBASE_KEYS_NO_CUSTOMER_VALUE_REACHES = new Set([
|
|
39
|
+
"cluebase.span_id",
|
|
40
|
+
"gen_ai.agent.parent_step_id",
|
|
41
|
+
"gen_ai.agent.run_id",
|
|
42
|
+
]);
|
|
43
|
+
export const CLUEBASE_KEYS_HASHED_WHEN_PERSONAL_INFORMATION_SHAPED = new Set([
|
|
44
|
+
"cluebase.actor.anonymous_id",
|
|
45
|
+
"cluebase.actor.user_id",
|
|
46
|
+
"cluebase.action.id",
|
|
47
|
+
"cluebase.action_id",
|
|
48
|
+
"cluebase.interaction.id",
|
|
49
|
+
"cluebase.interaction_id",
|
|
50
|
+
"cluebase.organization.id",
|
|
51
|
+
"cluebase.organization_id",
|
|
52
|
+
"cluebase.origin_frontend_interaction.id",
|
|
53
|
+
"cluebase.request.id",
|
|
54
|
+
"cluebase.request_id",
|
|
55
|
+
"cluebase.session.id",
|
|
56
|
+
"cluebase.session_id",
|
|
57
|
+
"cluebase.subject.organization_id",
|
|
58
|
+
"cluebase.tab.id",
|
|
59
|
+
"cluebase.tab_id",
|
|
60
|
+
"http.request.header.x-cluebase-action-id",
|
|
61
|
+
"http.request.header.x_cluebase_action_id",
|
|
62
|
+
"enduser.id",
|
|
63
|
+
"mcp.session.id",
|
|
64
|
+
]);
|
|
65
|
+
export const CLUEBASE_VALUE_FORMATS_THAT_KEEP_THE_EXEMPTION_TRUE = {
|
|
66
|
+
"gen_ai.agent.run_id": [
|
|
67
|
+
"^[0-9a-f]{32}$",
|
|
68
|
+
"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
|
|
69
|
+
"^run_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
|
|
70
|
+
]
|
|
71
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type DiagnosticCode = "batch_split" | "consent_persistence_failed" | "consent_purge" | "consent_purge_failed" | "consent_state_unavailable" | "delivered_directive_unreadable" | "duplicate_drop_details_unavailable" | "durable_outbox_unavailable" | "event_build_failed" | "event_lost" | "event_oversize" | "intentional_drop" | "invalid_response" | "legacy_bridge_capacity_reached" | "legacy_pre_revocation_event_blocked" | "legacy_writer_detected" | "non_canonical_success_status" | "outbox_key_collision" | "outbox_record_corrupt" | "protocol_redirect" | "queue_overflow" | "retry_exhausted" | "retry_scheduled" | "shutdown_failure" | "terminal_rejection" | "unknown_status";
|
|
2
|
+
export declare const DIAGNOSTIC_CODES: readonly DiagnosticCode[];
|
|
3
|
+
export type HostReportableDiagnosticCode = "consent_persistence_failed" | "consent_purge_failed" | "consent_state_unavailable" | "durable_outbox_unavailable" | "event_build_failed" | "legacy_bridge_capacity_reached" | "legacy_pre_revocation_event_blocked" | "legacy_writer_detected" | "outbox_key_collision" | "outbox_record_corrupt" | "shutdown_failure";
|
|
4
|
+
export declare const HOST_REPORTABLE_DIAGNOSTIC_CODES: readonly HostReportableDiagnosticCode[];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// 自動生成です。**手で編集しないでください。**
|
|
2
|
+
//
|
|
3
|
+
// 正本: packages/cluebase-backend-contract/src/delivery/sdk-diagnostic-codes.v1.json
|
|
4
|
+
// 出し直す: node scripts/generate-shared-contract-tables.mjs
|
|
5
|
+
//
|
|
6
|
+
// 正本を直したらこの file も一緒に commit してください。CI が
|
|
7
|
+
// `node scripts/generate-shared-contract-tables.mjs --check` で照合し、ずれていれば落とします。
|
|
8
|
+
export const DIAGNOSTIC_CODES = [
|
|
9
|
+
"batch_split",
|
|
10
|
+
"consent_persistence_failed",
|
|
11
|
+
"consent_purge",
|
|
12
|
+
"consent_purge_failed",
|
|
13
|
+
"consent_state_unavailable",
|
|
14
|
+
"delivered_directive_unreadable",
|
|
15
|
+
"duplicate_drop_details_unavailable",
|
|
16
|
+
"durable_outbox_unavailable",
|
|
17
|
+
"event_build_failed",
|
|
18
|
+
"event_lost",
|
|
19
|
+
"event_oversize",
|
|
20
|
+
"intentional_drop",
|
|
21
|
+
"invalid_response",
|
|
22
|
+
"legacy_bridge_capacity_reached",
|
|
23
|
+
"legacy_pre_revocation_event_blocked",
|
|
24
|
+
"legacy_writer_detected",
|
|
25
|
+
"non_canonical_success_status",
|
|
26
|
+
"outbox_key_collision",
|
|
27
|
+
"outbox_record_corrupt",
|
|
28
|
+
"protocol_redirect",
|
|
29
|
+
"queue_overflow",
|
|
30
|
+
"retry_exhausted",
|
|
31
|
+
"retry_scheduled",
|
|
32
|
+
"shutdown_failure",
|
|
33
|
+
"terminal_rejection",
|
|
34
|
+
"unknown_status",
|
|
35
|
+
];
|
|
36
|
+
export const HOST_REPORTABLE_DIAGNOSTIC_CODES = [
|
|
37
|
+
"consent_persistence_failed",
|
|
38
|
+
"consent_purge_failed",
|
|
39
|
+
"consent_state_unavailable",
|
|
40
|
+
"durable_outbox_unavailable",
|
|
41
|
+
"event_build_failed",
|
|
42
|
+
"legacy_bridge_capacity_reached",
|
|
43
|
+
"legacy_pre_revocation_event_blocked",
|
|
44
|
+
"legacy_writer_detected",
|
|
45
|
+
"outbox_key_collision",
|
|
46
|
+
"outbox_record_corrupt",
|
|
47
|
+
"shutdown_failure",
|
|
48
|
+
];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const DROP_REASONS: readonly ["event_schema_invalid", "event_too_large", "fact_admission_filtered", "ingest_control", "privacy_blocked", "privacy_gate_rejected_field", "privacy_policy_rejected", "source_signal_transform_failed", "unreadable_occurred_at", "unsupported_span"];
|
|
2
|
+
export declare const DROP_REASONS_EXCLUDED_BY_DESIGN: ReadonlySet<string>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// 自動生成です。**手で編集しないでください。**
|
|
2
|
+
//
|
|
3
|
+
// 正本: packages/cluebase-backend-contract/src/delivery/delivery-response-vectors.v1.json
|
|
4
|
+
// 出し直す: node scripts/generate-shared-contract-tables.mjs
|
|
5
|
+
//
|
|
6
|
+
// 正本を直したらこの file も一緒に commit してください。CI が
|
|
7
|
+
// `node scripts/generate-shared-contract-tables.mjs --check` で照合し、ずれていれば落とします。
|
|
8
|
+
export const DROP_REASONS = [
|
|
9
|
+
"event_schema_invalid",
|
|
10
|
+
"event_too_large",
|
|
11
|
+
"fact_admission_filtered",
|
|
12
|
+
"ingest_control",
|
|
13
|
+
"privacy_blocked",
|
|
14
|
+
"privacy_gate_rejected_field",
|
|
15
|
+
"privacy_policy_rejected",
|
|
16
|
+
"source_signal_transform_failed",
|
|
17
|
+
"unreadable_occurred_at",
|
|
18
|
+
"unsupported_span",
|
|
19
|
+
];
|
|
20
|
+
export const DROP_REASONS_EXCLUDED_BY_DESIGN = new Set([
|
|
21
|
+
"fact_admission_filtered",
|
|
22
|
+
"privacy_blocked",
|
|
23
|
+
"privacy_gate_rejected_field",
|
|
24
|
+
"privacy_policy_rejected",
|
|
25
|
+
]);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** 取り込みの受け口の綴り。送信先の設定を伸ばせる形かどうかはこれで決まります。 */
|
|
2
|
+
export declare const CLUEBASE_API_V1_PREFIX: "/api/v1";
|
|
3
|
+
export declare const CANONICAL_BACKEND_INGEST_PATH: "/api/v1/ingest/backend";
|
|
4
|
+
export declare const CANONICAL_BROWSER_INGEST_PATH: "/api/v1/ingest/browser";
|
|
5
|
+
export declare const CANONICAL_BROWSER_TOKEN_PATH: "/api/v1/ingest/browser-tokens";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// 自動生成です。**手で編集しないでください。**
|
|
2
|
+
//
|
|
3
|
+
// 正本: packages/cluebase-shared/src/ingest/routes.ts
|
|
4
|
+
// 出し直す: node scripts/generate-shared-contract-tables.mjs
|
|
5
|
+
//
|
|
6
|
+
// 正本を直したらこの file も一緒に commit してください。CI が
|
|
7
|
+
// `node scripts/generate-shared-contract-tables.mjs --check` で照合し、ずれていれば落とします。
|
|
8
|
+
/** 取り込みの受け口の綴り。送信先の設定を伸ばせる形かどうかはこれで決まります。 */
|
|
9
|
+
export const CLUEBASE_API_V1_PREFIX = "/api/v1";
|
|
10
|
+
export const CANONICAL_BACKEND_INGEST_PATH = "/api/v1/ingest/backend";
|
|
11
|
+
export const CANONICAL_BROWSER_INGEST_PATH = "/api/v1/ingest/browser";
|
|
12
|
+
export const CANONICAL_BROWSER_TOKEN_PATH = "/api/v1/ingest/browser-tokens";
|
package/dist/context/trace.js
CHANGED
|
@@ -207,12 +207,10 @@ export class TraceManager {
|
|
|
207
207
|
requestSpanId: generateRequestSpanId(),
|
|
208
208
|
actionId: active?.actionId ?? null,
|
|
209
209
|
interactionId: generateInteractionId(),
|
|
210
|
-
interactionInitiator: trigger?.interactionInitiator ??
|
|
211
|
-
active?.interactionInitiator ??
|
|
212
|
-
"background",
|
|
210
|
+
interactionInitiator: trigger?.interactionInitiator ?? active?.interactionInitiator ?? null,
|
|
213
211
|
interactionStartEventKind: trigger?.interactionStartEventKind ??
|
|
214
212
|
active?.interactionStartEventKind ??
|
|
215
|
-
|
|
213
|
+
null,
|
|
216
214
|
originFrontendInteractionId: active?.interactionId ?? null,
|
|
217
215
|
};
|
|
218
216
|
}
|
package/dist/exporter/batch.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { InternalMetricsStore } from "../internal/metrics.js";
|
|
2
|
-
import type { CluebaseConsentState
|
|
3
|
-
import { type CollectionPermit } from "./browser-outbox.js";
|
|
2
|
+
import type { CluebaseConsentState } from "../provider/types.js";
|
|
4
3
|
import type { IngestClient } from "./client.js";
|
|
5
4
|
import { DiagnosticStore, type DiagnosticsSnapshot } from "./diagnostics.js";
|
|
5
|
+
import type { CollectionPermit } from "./sdk-core-delivery.js";
|
|
6
6
|
import type { BrowserSourceEvent } from "./source-event.js";
|
|
7
|
-
export type BatchIngestClient = Pick<IngestClient, "
|
|
7
|
+
export type BatchIngestClient = Pick<IngestClient, "perform" | "abortAttempt" | "ensureDeliveryToken" | "hasUsableBrowserToken" | "createBatchEnvelopeMetadata" | "measurePayloadBytes" | "stringifyPayload" | "diagnosticCanonicalPayload">;
|
|
8
8
|
export type BatchTransportOptions = {
|
|
9
9
|
enabled: boolean;
|
|
10
10
|
flushIntervalMs: number;
|
|
@@ -16,9 +16,13 @@ export type BatchTransportOptions = {
|
|
|
16
16
|
queueMaxBytes?: number;
|
|
17
17
|
queueMaxItems?: number;
|
|
18
18
|
projectKey?: string;
|
|
19
|
+
endpoint: string;
|
|
20
|
+
sdkVersion: string;
|
|
21
|
+
sourceSchemaVersion: string;
|
|
22
|
+
sdkRequest: string;
|
|
23
|
+
requestTimeoutMs?: number;
|
|
19
24
|
initialConsent?: CluebaseConsentState;
|
|
20
25
|
diagnostics?: DiagnosticStore;
|
|
21
|
-
onGovernorFeedback?: (feedback: IngestUsageGovernorFeedback) => void;
|
|
22
26
|
};
|
|
23
27
|
export type FlushDeadline = {
|
|
24
28
|
readonly signal: AbortSignal;
|
|
@@ -26,6 +30,7 @@ export type FlushDeadline = {
|
|
|
26
30
|
};
|
|
27
31
|
export declare class BatchTransport {
|
|
28
32
|
private readonly outbox;
|
|
33
|
+
private readonly pipeline;
|
|
29
34
|
private readonly client;
|
|
30
35
|
private readonly enabled;
|
|
31
36
|
private readonly flushIntervalMs;
|
|
@@ -34,24 +39,19 @@ export declare class BatchTransport {
|
|
|
34
39
|
private readonly maxSize;
|
|
35
40
|
private readonly metrics;
|
|
36
41
|
private readonly diagnostics;
|
|
37
|
-
private readonly onGovernorFeedback;
|
|
38
42
|
private idleHandle;
|
|
39
43
|
private flushing;
|
|
40
44
|
private flushAgainAfterCurrent;
|
|
41
|
-
private activeSendController;
|
|
42
|
-
private closeDeadlineController;
|
|
43
|
-
private closeDeadlineTimer;
|
|
44
45
|
private closeDeadlineAt;
|
|
45
|
-
private
|
|
46
|
-
private
|
|
47
|
-
private
|
|
48
|
-
private flushDeadlineAt;
|
|
46
|
+
private clearedAt;
|
|
47
|
+
private disposed;
|
|
48
|
+
private closeDeadlineTimer;
|
|
49
49
|
private lifecycle;
|
|
50
50
|
private closeHadTerminalDisposition;
|
|
51
|
+
private restored;
|
|
52
|
+
private tokenRefusedForGood;
|
|
51
53
|
private activeFlushPromise;
|
|
52
54
|
private enqueueTail;
|
|
53
|
-
private readonly seenEventIds;
|
|
54
|
-
private static readonly DEDUP_CAPACITY;
|
|
55
55
|
constructor(options: BatchTransportOptions);
|
|
56
56
|
getDiagnostics(): DiagnosticsSnapshot;
|
|
57
57
|
start(): void;
|
|
@@ -61,24 +61,21 @@ export declare class BatchTransport {
|
|
|
61
61
|
capturePermit(): CollectionPermit;
|
|
62
62
|
setConsent(consent: CluebaseConsentState): void;
|
|
63
63
|
enqueue(event: BrowserSourceEvent, permit?: CollectionPermit): void;
|
|
64
|
-
|
|
65
|
-
beginFlushDeadline(): FlushDeadline | null;
|
|
66
|
-
endFlushDeadline(deadline: FlushDeadline | null | undefined): void;
|
|
67
|
-
flush(deadline?: FlushDeadline | null): Promise<void>;
|
|
64
|
+
flush(): Promise<void>;
|
|
68
65
|
private runFlushUntilIdle;
|
|
69
|
-
beginClose():
|
|
66
|
+
beginClose(): void;
|
|
70
67
|
close(): Promise<void>;
|
|
71
|
-
private runFlushCycle;
|
|
72
|
-
private sendBatchWhilePermitted;
|
|
73
|
-
private applyDeliveryResult;
|
|
74
|
-
private applyFailedDelivery;
|
|
75
|
-
private applySuccessfulDelivery;
|
|
76
68
|
flushOnUnload(): void;
|
|
77
69
|
clear(): void;
|
|
70
|
+
private runFlushCycle;
|
|
71
|
+
private serializeBatch;
|
|
72
|
+
private applyObservation;
|
|
73
|
+
private adoptStoredRecords;
|
|
74
|
+
private ensureDeliveryToken;
|
|
75
|
+
private envelopeOverheadBytes;
|
|
76
|
+
private scheduleFlushDeadline;
|
|
78
77
|
private abortActiveSendForConsent;
|
|
79
78
|
private recordPendingBatchCount;
|
|
80
79
|
private clearCloseDeadline;
|
|
81
|
-
private currentDeadline;
|
|
82
80
|
private queueOutboxMutation;
|
|
83
|
-
private shouldRetainFailedBatch;
|
|
84
81
|
}
|