@genn-inc/cluebase-frontend-sdk 0.0.1

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.
Files changed (140) hide show
  1. package/README.md +222 -0
  2. package/dist/_generated/correlation-attribute-keys.d.ts +2 -0
  3. package/dist/_generated/correlation-attribute-keys.js +33 -0
  4. package/dist/_generated/identity-pii-policy.d.ts +38 -0
  5. package/dist/_generated/identity-pii-policy.js +103 -0
  6. package/dist/_generated/ingest-privacy-tables.d.ts +120 -0
  7. package/dist/_generated/ingest-privacy-tables.js +890 -0
  8. package/dist/_generated/otel-resource-keys.d.ts +21 -0
  9. package/dist/_generated/otel-resource-keys.js +72 -0
  10. package/dist/_generated/otel-span-conversion.d.ts +48 -0
  11. package/dist/_generated/otel-span-conversion.js +69 -0
  12. package/dist/_generated/parameter-snapshot-leaf.d.ts +11 -0
  13. package/dist/_generated/parameter-snapshot-leaf.js +37 -0
  14. package/dist/_generated/sdk-runtime-policy.d.ts +7 -0
  15. package/dist/_generated/sdk-runtime-policy.js +14 -0
  16. package/dist/_generated/usage-governor-tables.d.ts +15 -0
  17. package/dist/_generated/usage-governor-tables.js +44 -0
  18. package/dist/context/browser-storage.d.ts +15 -0
  19. package/dist/context/browser-storage.js +38 -0
  20. package/dist/context/environment.d.ts +37 -0
  21. package/dist/context/environment.js +229 -0
  22. package/dist/context/identity.d.ts +16 -0
  23. package/dist/context/identity.js +139 -0
  24. package/dist/context/organization.d.ts +16 -0
  25. package/dist/context/organization.js +60 -0
  26. package/dist/context/session.d.ts +28 -0
  27. package/dist/context/session.js +130 -0
  28. package/dist/context/tab.d.ts +22 -0
  29. package/dist/context/tab.js +117 -0
  30. package/dist/context/trace.d.ts +76 -0
  31. package/dist/context/trace.js +163 -0
  32. package/dist/exporter/batch.d.ts +94 -0
  33. package/dist/exporter/batch.js +485 -0
  34. package/dist/exporter/browser-outbox-records.d.ts +159 -0
  35. package/dist/exporter/browser-outbox-records.js +341 -0
  36. package/dist/exporter/browser-outbox.d.ts +112 -0
  37. package/dist/exporter/browser-outbox.js +876 -0
  38. package/dist/exporter/client.d.ts +92 -0
  39. package/dist/exporter/client.js +541 -0
  40. package/dist/exporter/delivery-response-contract.d.ts +103 -0
  41. package/dist/exporter/delivery-response-contract.js +147 -0
  42. package/dist/exporter/delivery-response.d.ts +37 -0
  43. package/dist/exporter/delivery-response.js +151 -0
  44. package/dist/exporter/diagnostics.d.ts +42 -0
  45. package/dist/exporter/diagnostics.js +148 -0
  46. package/dist/exporter/event-id.d.ts +10 -0
  47. package/dist/exporter/event-id.js +75 -0
  48. package/dist/exporter/frontend-resource.d.ts +20 -0
  49. package/dist/exporter/frontend-resource.js +52 -0
  50. package/dist/exporter/local-minimization.d.ts +29 -0
  51. package/dist/exporter/local-minimization.js +87 -0
  52. package/dist/exporter/observation-source-event-exporter.d.ts +69 -0
  53. package/dist/exporter/observation-source-event-exporter.js +154 -0
  54. package/dist/exporter/parameter-snapshot.d.ts +14 -0
  55. package/dist/exporter/parameter-snapshot.js +215 -0
  56. package/dist/exporter/path-template.d.ts +1 -0
  57. package/dist/exporter/path-template.js +67 -0
  58. package/dist/exporter/raw-event-to-source-signal.d.ts +12 -0
  59. package/dist/exporter/raw-event-to-source-signal.js +297 -0
  60. package/dist/exporter/retry.d.ts +8 -0
  61. package/dist/exporter/retry.js +8 -0
  62. package/dist/exporter/sanitize.d.ts +30 -0
  63. package/dist/exporter/sanitize.js +177 -0
  64. package/dist/exporter/schema-evidence.d.ts +20 -0
  65. package/dist/exporter/schema-evidence.js +232 -0
  66. package/dist/exporter/source-event.d.ts +99 -0
  67. package/dist/exporter/source-event.js +13 -0
  68. package/dist/exporter/span-to-source-signal.d.ts +8 -0
  69. package/dist/exporter/span-to-source-signal.js +174 -0
  70. package/dist/exporter/text-fingerprint.d.ts +9 -0
  71. package/dist/exporter/text-fingerprint.js +16 -0
  72. package/dist/index.d.ts +25 -0
  73. package/dist/index.js +158 -0
  74. package/dist/instrumentation/action.d.ts +2 -0
  75. package/dist/instrumentation/action.js +171 -0
  76. package/dist/instrumentation/cluebase-authored-attributes.d.ts +4 -0
  77. package/dist/instrumentation/cluebase-authored-attributes.js +32 -0
  78. package/dist/instrumentation/common.d.ts +73 -0
  79. package/dist/instrumentation/common.js +90 -0
  80. package/dist/instrumentation/dom.d.ts +63 -0
  81. package/dist/instrumentation/dom.js +640 -0
  82. package/dist/instrumentation/drag.d.ts +2 -0
  83. package/dist/instrumentation/drag.js +82 -0
  84. package/dist/instrumentation/error.d.ts +2 -0
  85. package/dist/instrumentation/error.js +318 -0
  86. package/dist/instrumentation/form.d.ts +2 -0
  87. package/dist/instrumentation/form.js +132 -0
  88. package/dist/instrumentation/input.d.ts +2 -0
  89. package/dist/instrumentation/input.js +180 -0
  90. package/dist/instrumentation/location.d.ts +11 -0
  91. package/dist/instrumentation/location.js +69 -0
  92. package/dist/instrumentation/naming-evidence.d.ts +20 -0
  93. package/dist/instrumentation/naming-evidence.js +11 -0
  94. package/dist/instrumentation/navigation.d.ts +2 -0
  95. package/dist/instrumentation/navigation.js +144 -0
  96. package/dist/instrumentation/network-request.d.ts +103 -0
  97. package/dist/instrumentation/network-request.js +285 -0
  98. package/dist/instrumentation/network-span-attributes.d.ts +25 -0
  99. package/dist/instrumentation/network-span-attributes.js +153 -0
  100. package/dist/instrumentation/network.d.ts +16 -0
  101. package/dist/instrumentation/network.js +502 -0
  102. package/dist/instrumentation/page.d.ts +2 -0
  103. package/dist/instrumentation/page.js +56 -0
  104. package/dist/instrumentation/performance.d.ts +2 -0
  105. package/dist/instrumentation/performance.js +365 -0
  106. package/dist/integrations/next-router.d.ts +16 -0
  107. package/dist/integrations/next-router.js +18 -0
  108. package/dist/integrations/react-router.d.ts +7 -0
  109. package/dist/integrations/react-router.js +61 -0
  110. package/dist/internal/internal-log.d.ts +23 -0
  111. package/dist/internal/internal-log.js +47 -0
  112. package/dist/internal/metrics.d.ts +10 -0
  113. package/dist/internal/metrics.js +50 -0
  114. package/dist/provider/_version.d.ts +1 -0
  115. package/dist/provider/_version.js +3 -0
  116. package/dist/provider/config.d.ts +12 -0
  117. package/dist/provider/config.js +177 -0
  118. package/dist/provider/constants.d.ts +62 -0
  119. package/dist/provider/constants.js +118 -0
  120. package/dist/provider/contracts.d.ts +51 -0
  121. package/dist/provider/contracts.js +46 -0
  122. package/dist/provider/privacy-policy-store.d.ts +20 -0
  123. package/dist/provider/privacy-policy-store.js +56 -0
  124. package/dist/provider/sampling.d.ts +2 -0
  125. package/dist/provider/sampling.js +17 -0
  126. package/dist/provider/sdk-event-pipeline.d.ts +60 -0
  127. package/dist/provider/sdk-event-pipeline.js +478 -0
  128. package/dist/provider/sdk-input-normalization.d.ts +7 -0
  129. package/dist/provider/sdk-input-normalization.js +113 -0
  130. package/dist/provider/sdk-otel-pipeline.d.ts +14 -0
  131. package/dist/provider/sdk-otel-pipeline.js +148 -0
  132. package/dist/provider/sdk-runtime-surfaces.d.ts +49 -0
  133. package/dist/provider/sdk-runtime-surfaces.js +216 -0
  134. package/dist/provider/sdk.d.ts +2 -0
  135. package/dist/provider/sdk.js +614 -0
  136. package/dist/provider/types.d.ts +323 -0
  137. package/dist/provider/types.js +1 -0
  138. package/dist/provider/usage-governor.d.ts +7 -0
  139. package/dist/provider/usage-governor.js +116 -0
  140. package/package.json +59 -0
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Shared instrumentation helpers used across multiple capture modules
3
+ * (network, performance, navigation, etc.).
4
+ *
5
+ * The most important contract here is URL sanitization for any payload
6
+ * that may carry the user's current browsing URL. The page URL must never
7
+ * be emitted with query string intact, because OAuth callback /
8
+ * password-reset / magic-link flows place secret tokens in the query
9
+ * string. Any instrumentation module that needs a "page URL" field on
10
+ * its outgoing event payload MUST go through `currentPageUrl()` here.
11
+ *
12
+ * Previously `instrumentation/performance.ts` emitted
13
+ * `pageUrl: window.location.href` directly while
14
+ * `instrumentation/network.ts` had its own internal stripping helper.
15
+ * This module unifies the behavior so all callers share a single
16
+ * implementation and a single test surface.
17
+ */
18
+ /**
19
+ * Resolves `value` to a URL, falling back to the current document
20
+ * location for relative URLs. Returns `null` if neither parsing succeeds.
21
+ */
22
+ export const resolveUrlAgainstCurrentLocation = (value) => {
23
+ try {
24
+ return new URL(value);
25
+ }
26
+ catch { }
27
+ const currentHref = typeof globalThis.location?.href === "string" &&
28
+ globalThis.location.href.length > 0
29
+ ? globalThis.location.href
30
+ : null;
31
+ if (!currentHref) {
32
+ return null;
33
+ }
34
+ try {
35
+ return new URL(value, currentHref);
36
+ }
37
+ catch {
38
+ return null;
39
+ }
40
+ };
41
+ /**
42
+ * Strips the query string and hash from the given URL, returning
43
+ * `origin + pathname` only. Falls back to a `split("?")` form if URL
44
+ * parsing fails so callers never receive a query-bearing string.
45
+ *
46
+ * The query string is the primary leak surface for OAuth callbacks
47
+ * (`?code=...&state=...`) and password reset links (`?token=...`).
48
+ */
49
+ export const stripQueryFromUrl = (url) => {
50
+ try {
51
+ const resolvedUrl = resolveUrlAgainstCurrentLocation(url);
52
+ if (!resolvedUrl) {
53
+ return url.split("?")[0] ?? url;
54
+ }
55
+ return `${resolvedUrl.origin}${resolvedUrl.pathname}`;
56
+ }
57
+ catch {
58
+ return url.split("?")[0] ?? url;
59
+ }
60
+ };
61
+ /**
62
+ * Returns the current page URL with all query parameters and hash
63
+ * fragments stripped. Returns `null` if `globalThis.location` is not
64
+ * available (e.g., non-browser environments).
65
+ *
66
+ * THIS IS THE ONLY APPROVED WAY TO POPULATE A `pageUrl` FIELD ON ANY
67
+ * INSTRUMENTATION EVENT PAYLOAD. Do not use `window.location.href`
68
+ * directly.
69
+ */
70
+ export const currentPageUrl = () => {
71
+ const href = globalThis.location?.href;
72
+ return href ? stripQueryFromUrl(href) : null;
73
+ };
74
+ /**
75
+ * Single sentinel marker used by Cluebase-owned History API wrappers. OTel-owned
76
+ * navigation instrumentation may patch history independently and must remain
77
+ * the primary navigation source.
78
+ */
79
+ export const HISTORY_WRAPPED_MARKER = "__cluebaseHistoryWrapped";
80
+ export const isHistoryAlreadyCluebaseWrapped = (historyApi) => {
81
+ const push = historyApi.pushState;
82
+ const replace = historyApi.replaceState;
83
+ return Boolean(push[HISTORY_WRAPPED_MARKER] || replace[HISTORY_WRAPPED_MARKER]);
84
+ };
85
+ /**
86
+ * 画面操作 1 種類を指す安定キー。意味層は操作の identity 単位で行動名を付けるため、
87
+ * 通信経路 (method / path) を持たない画面操作にも同じ粒度の識別子が要る。
88
+ * 画面と操作対象の安定キーの組で「どの画面のどの操作か」を表す。
89
+ */
90
+ export const buildPrimaryActionKey = (screenKey, targetStableKey) => screenKey && targetStableKey ? `${screenKey}#${targetStableKey}` : null;
@@ -0,0 +1,63 @@
1
+ export declare const buildDomPath: (element: Element) => string;
2
+ export declare const getTextPreview: (element: Element) => string | null;
3
+ export declare const getElementClassList: (element: Element) => string[] | null;
4
+ export declare const getElementRole: (element: Element) => string | null;
5
+ export declare const getElementPlaceholder: (element: Element) => string | null;
6
+ export declare const getElementAriaLabel: (element: Element) => string | null;
7
+ export declare const getElementSectionHeading: (element: Element) => string | null;
8
+ /** どの段が名前を決めたか。伏せられていても残る**機械が決めた値**です。 */
9
+ export type AccessibleNameSource = "aria_labelledby" | "aria_label" | "native_label" | "content" | "title";
10
+ export type AccessibleName = {
11
+ name: string;
12
+ source: AccessibleNameSource;
13
+ };
14
+ /**
15
+ * 要素の名前を **1 本**に決めます。
16
+ *
17
+ * 順序は W3C の名前算出 (Accessible Name Computation) に従います。
18
+ * `aria-labelledby` → `aria-label` → 対応ラベル / `alt` → 要素内の文言 → `title`。
19
+ * **自前の優先順を作ってはいけません。** 顧客の画面を読み上げる道具が名乗る名前と
20
+ * 食い違う名前を保管すると、行動の名付けが「利用者が見ている名前」から離れます。
21
+ *
22
+ * 生の候補を並べて持たないのも同じ理由です。どれを採るかを後段でもう一度決めると、
23
+ * 決め方が 2 つになります。
24
+ */
25
+ export declare const getAccessibleName: (element: Element) => AccessibleName | null;
26
+ export declare const getElementLabel: (element: Element) => string | null;
27
+ /**
28
+ * 押された要素の**祖先の並び**。`main > form[role=search] > button` の形で返します。
29
+ *
30
+ * 綴りは**機械が決めた値だけ**で作ります (要素の種類と役割)。顧客が書いた文言を
31
+ * 混ぜないので、文言を伏せた状態でも「画面のどのまとまりの中の操作か」が残ります。
32
+ */
33
+ export declare const getAncestorChain: (element: Element) => string | null;
34
+ /** 画面の題。頁が何の画面かを表す、顧客が書いた文言です。 */
35
+ export declare const getDocumentTitle: (element: Element) => string | null;
36
+ /**
37
+ * 押した後に行く先。`href` を持つ要素はその値を返します。
38
+ *
39
+ * 問い合わせ文字列は落とします。**そこに載るのは利用者ごとに違う値**で、
40
+ * 名前に入れると行動の型が利用者の数だけ増えます。
41
+ */
42
+ export declare const getNavigationHref: (element: Element) => string | null;
43
+ export declare const resolveClickDisplayTarget: (element: Element) => Element;
44
+ export declare const shouldCaptureClickTarget: (element: Element) => boolean;
45
+ export type StableKeyQuality = "official" | "compat" | "structural";
46
+ export type StableKeyDescriptor = {
47
+ stableKey: string;
48
+ stableKeyQuality: StableKeyQuality;
49
+ formKey: string | null;
50
+ };
51
+ export type InteractionScopeDescriptor = {
52
+ interactionScopeKind: "form" | "dialog" | "fieldset";
53
+ interactionScopeKey: string;
54
+ };
55
+ export declare const getFormKey: (element: Element) => string | null;
56
+ export declare const resolveStableKeyDescriptor: (element: Element) => StableKeyDescriptor;
57
+ export declare const getStableKey: (element: Element) => string;
58
+ export declare const resolveInteractionScopeDescriptor: (element: Element) => InteractionScopeDescriptor | null;
59
+ export declare const extractFieldName: (element: Element) => string | null;
60
+ export declare const extractFieldType: (element: Element) => string | null;
61
+ export declare const findParentFormId: (element: Element) => string | null;
62
+ export declare const isEditableElement: (element: Element) => boolean;
63
+ export declare const getElementValue: (element: Element) => unknown;