@upshiftfinance/sdk 0.0.0-stage → 0.2.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.
Files changed (344) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +408 -2
  3. package/lib/abis/AddressResolver.d.ts +28 -0
  4. package/lib/abis/AddressResolver.js +23 -0
  5. package/lib/abis/ChainlinkV3.d.ts +87 -0
  6. package/lib/abis/ChainlinkV3.js +117 -0
  7. package/lib/abis/ERC20.d.ts +168 -0
  8. package/lib/abis/ERC20.js +226 -0
  9. package/lib/abis/ERC20_Bytes32.d.ts +139 -0
  10. package/lib/abis/ERC20_Bytes32.js +196 -0
  11. package/lib/abis/ERC4626.d.ts +364 -0
  12. package/lib/abis/ERC4626.js +507 -0
  13. package/lib/abis/ERC721.d.ts +231 -0
  14. package/lib/abis/ERC721.js +321 -0
  15. package/lib/abis/FeeOracle.d.ts +120 -0
  16. package/lib/abis/FeeOracle.js +162 -0
  17. package/lib/abis/LendingPool.d.ts +1393 -0
  18. package/lib/abis/LendingPool.js +1807 -0
  19. package/lib/abis/LendingPoolV2.d.ts +1413 -0
  20. package/lib/abis/LendingPoolV2.js +1833 -0
  21. package/lib/abis/LendingPoolV3.d.ts +1677 -0
  22. package/lib/abis/LendingPoolV3.js +1160 -0
  23. package/lib/abis/Loan.d.ts +837 -0
  24. package/lib/abis/Loan.js +1080 -0
  25. package/lib/abis/MultiAssetNativeDepositWrapper.d.ts +137 -0
  26. package/lib/abis/MultiAssetNativeDepositWrapper.js +125 -0
  27. package/lib/abis/Multicall3.d.ts +30 -0
  28. package/lib/abis/Multicall3.js +97 -0
  29. package/lib/abis/OFT.d.ts +116 -0
  30. package/lib/abis/OFT.js +85 -0
  31. package/lib/abis/PoolAdapter.d.ts +36 -0
  32. package/lib/abis/PoolAdapter.js +51 -0
  33. package/lib/abis/RewardDistributor.d.ts +267 -0
  34. package/lib/abis/RewardDistributor.js +352 -0
  35. package/lib/abis/RwaRedeemSubaccount.d.ts +747 -0
  36. package/lib/abis/RwaRedeemSubaccount.js +548 -0
  37. package/lib/abis/SmartAccount.d.ts +17 -0
  38. package/lib/abis/SmartAccount.js +19 -0
  39. package/lib/abis/SwapRouter.d.ts +953 -0
  40. package/lib/abis/SwapRouter.js +1228 -0
  41. package/lib/abis/TextResolver.d.ts +16 -0
  42. package/lib/abis/TextResolver.js +16 -0
  43. package/lib/abis/TokenizedVaultV2.d.ts +1364 -0
  44. package/lib/abis/TokenizedVaultV2.js +1041 -0
  45. package/lib/abis/TokenizedVaultV2DepositWithPermit.d.ts +1456 -0
  46. package/lib/abis/TokenizedVaultV2DepositWithPermit.js +1878 -0
  47. package/lib/abis/TokenizedVaultV2Receipt.d.ts +1568 -0
  48. package/lib/abis/TokenizedVaultV2Receipt.js +1061 -0
  49. package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.d.ts +454 -0
  50. package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.js +327 -0
  51. package/lib/abis/TokenizedVaultV2WhitelistedAllocation.d.ts +1466 -0
  52. package/lib/abis/TokenizedVaultV2WhitelistedAllocation.js +1092 -0
  53. package/lib/abis/TokenizedVaultV2WhitelistedAssets.d.ts +274 -0
  54. package/lib/abis/TokenizedVaultV2WhitelistedAssets.js +167 -0
  55. package/lib/abis/UniversalResolverResolve.d.ts +69 -0
  56. package/lib/abis/UniversalResolverResolve.js +35 -0
  57. package/lib/abis/UniversalSignatureValidator.d.ts +17 -0
  58. package/lib/abis/UniversalSignatureValidator.js +30 -0
  59. package/lib/abis/WrapperAdapter.d.ts +71 -0
  60. package/lib/abis/WrapperAdapter.js +77 -0
  61. package/lib/abis/index.d.ts +34 -0
  62. package/lib/abis/index.js +51 -0
  63. package/lib/adapters/evm/getters.d.ts +19 -0
  64. package/lib/adapters/evm/getters.js +249 -0
  65. package/lib/adapters/evm/index.d.ts +539 -0
  66. package/lib/adapters/evm/index.js +656 -0
  67. package/lib/adapters/evm/utils.d.ts +8 -0
  68. package/lib/adapters/evm/utils.js +51 -0
  69. package/lib/adapters/solana/confirm.d.ts +88 -0
  70. package/lib/adapters/solana/confirm.js +291 -0
  71. package/lib/adapters/solana/constants.d.ts +42 -0
  72. package/lib/adapters/solana/constants.js +59 -0
  73. package/lib/adapters/solana/getters.d.ts +42 -0
  74. package/lib/adapters/solana/getters.js +275 -0
  75. package/lib/adapters/solana/idl/vault-idl.d.ts +700 -0
  76. package/lib/adapters/solana/idl/vault-idl.js +2101 -0
  77. package/lib/adapters/solana/idl/withdrawal-queue-idl.d.ts +795 -0
  78. package/lib/adapters/solana/idl/withdrawal-queue-idl.js +1864 -0
  79. package/lib/adapters/solana/index.d.ts +372 -0
  80. package/lib/adapters/solana/index.js +459 -0
  81. package/lib/adapters/solana/pricing.d.ts +184 -0
  82. package/lib/adapters/solana/pricing.js +239 -0
  83. package/lib/adapters/solana/queue-hints.d.ts +29 -0
  84. package/lib/adapters/solana/queue-hints.js +59 -0
  85. package/lib/adapters/solana/queue.actions.d.ts +97 -0
  86. package/lib/adapters/solana/queue.actions.js +468 -0
  87. package/lib/adapters/solana/token-reads.d.ts +108 -0
  88. package/lib/adapters/solana/token-reads.js +145 -0
  89. package/lib/adapters/solana/types.d.ts +325 -0
  90. package/lib/adapters/solana/types.js +3 -0
  91. package/lib/adapters/solana/utils.d.ts +229 -0
  92. package/lib/adapters/solana/utils.js +773 -0
  93. package/lib/adapters/solana/vault.actions.d.ts +140 -0
  94. package/lib/adapters/solana/vault.actions.js +657 -0
  95. package/lib/adapters/solana/withdrawal-queue.d.ts +125 -0
  96. package/lib/adapters/solana/withdrawal-queue.js +301 -0
  97. package/lib/adapters/stellar/actions.d.ts +41 -0
  98. package/lib/adapters/stellar/actions.js +126 -0
  99. package/lib/adapters/stellar/constants.d.ts +43 -0
  100. package/lib/adapters/stellar/constants.js +53 -0
  101. package/lib/adapters/stellar/getters.d.ts +68 -0
  102. package/lib/adapters/stellar/getters.js +290 -0
  103. package/lib/adapters/stellar/index.d.ts +126 -0
  104. package/lib/adapters/stellar/index.js +187 -0
  105. package/lib/adapters/stellar/invocation.d.ts +55 -0
  106. package/lib/adapters/stellar/invocation.js +92 -0
  107. package/lib/adapters/stellar/soroban.d.ts +131 -0
  108. package/lib/adapters/stellar/soroban.js +617 -0
  109. package/lib/adapters/stellar/submit.d.ts +42 -0
  110. package/lib/adapters/stellar/submit.js +195 -0
  111. package/lib/adapters/stellar/types.d.ts +57 -0
  112. package/lib/adapters/stellar/types.js +6 -0
  113. package/lib/adapters/stellar/utils.d.ts +24 -0
  114. package/lib/adapters/stellar/utils.js +34 -0
  115. package/lib/adapters/sui/client.d.ts +83 -0
  116. package/lib/adapters/sui/client.js +216 -0
  117. package/lib/adapters/sui/constants.d.ts +33 -0
  118. package/lib/adapters/sui/constants.js +31 -0
  119. package/lib/adapters/sui/index.d.ts +57 -0
  120. package/lib/adapters/sui/index.js +100 -0
  121. package/lib/adapters/sui/targets.d.ts +171 -0
  122. package/lib/adapters/sui/targets.js +225 -0
  123. package/lib/adapters/sui/utils.d.ts +8 -0
  124. package/lib/adapters/sui/utils.js +17 -0
  125. package/lib/core/analytics/app-name.d.ts +27 -0
  126. package/lib/core/analytics/app-name.js +48 -0
  127. package/lib/core/analytics/chain-name.d.ts +9 -0
  128. package/lib/core/analytics/chain-name.js +34 -0
  129. package/lib/core/analytics/constants.d.ts +15 -0
  130. package/lib/core/analytics/constants.js +28 -0
  131. package/lib/core/analytics/env.d.ts +46 -0
  132. package/lib/core/analytics/env.js +147 -0
  133. package/lib/core/analytics/index.d.ts +39 -0
  134. package/lib/core/analytics/index.js +83 -0
  135. package/lib/core/analytics/instrumentation.d.ts +29 -0
  136. package/lib/core/analytics/instrumentation.js +292 -0
  137. package/lib/core/analytics/method-taxonomy.d.ts +19 -0
  138. package/lib/core/analytics/method-taxonomy.js +156 -0
  139. package/lib/core/analytics/metrics.d.ts +48 -0
  140. package/lib/core/analytics/metrics.js +142 -0
  141. package/lib/core/analytics/sanitize.d.ts +57 -0
  142. package/lib/core/analytics/sanitize.js +272 -0
  143. package/lib/core/analytics/sentry-runtime.d.ts +15 -0
  144. package/lib/core/analytics/sentry-runtime.js +131 -0
  145. package/lib/core/analytics/sentry.d.ts +100 -0
  146. package/lib/core/analytics/sentry.js +696 -0
  147. package/lib/core/analytics/types.d.ts +55 -0
  148. package/lib/core/analytics/types.js +3 -0
  149. package/lib/core/analytics/user-identity.d.ts +55 -0
  150. package/lib/core/analytics/user-identity.js +218 -0
  151. package/lib/core/analytics/version.d.ts +6 -0
  152. package/lib/core/analytics/version.js +10 -0
  153. package/lib/core/attribution.d.ts +159 -0
  154. package/lib/core/attribution.js +194 -0
  155. package/lib/core/auth/index.d.ts +1 -0
  156. package/lib/core/auth/index.js +18 -0
  157. package/lib/core/auth/verify.d.ts +2 -0
  158. package/lib/core/auth/verify.js +35 -0
  159. package/lib/core/base.class.d.ts +193 -0
  160. package/lib/core/base.class.js +163 -0
  161. package/lib/core/cache.d.ts +9 -0
  162. package/lib/core/cache.js +31 -0
  163. package/lib/core/constants/adapters.d.ts +103 -0
  164. package/lib/core/constants/adapters.js +180 -0
  165. package/lib/core/constants/core.d.ts +162 -0
  166. package/lib/core/constants/core.js +281 -0
  167. package/lib/core/constants/swap-router.d.ts +180 -0
  168. package/lib/core/constants/swap-router.js +203 -0
  169. package/lib/core/constants/vaults.d.ts +93 -0
  170. package/lib/core/constants/vaults.js +277 -0
  171. package/lib/core/constants/web3.d.ts +106 -0
  172. package/lib/core/constants/web3.js +251 -0
  173. package/lib/core/errors/index.d.ts +177 -0
  174. package/lib/core/errors/index.js +257 -0
  175. package/lib/core/fetcher.d.ts +237 -0
  176. package/lib/core/fetcher.js +1103 -0
  177. package/lib/core/helpers/adapters.d.ts +13 -0
  178. package/lib/core/helpers/adapters.js +39 -0
  179. package/lib/core/helpers/chain-address.d.ts +13 -0
  180. package/lib/core/helpers/chain-address.js +47 -0
  181. package/lib/core/helpers/chain-error.d.ts +207 -0
  182. package/lib/core/helpers/chain-error.js +697 -0
  183. package/lib/core/helpers/chain-support.d.ts +98 -0
  184. package/lib/core/helpers/chain-support.js +139 -0
  185. package/lib/core/helpers/concurrency.d.ts +51 -0
  186. package/lib/core/helpers/concurrency.js +79 -0
  187. package/lib/core/helpers/core.d.ts +92 -0
  188. package/lib/core/helpers/core.js +368 -0
  189. package/lib/core/helpers/explorer-link.d.ts +16 -0
  190. package/lib/core/helpers/explorer-link.js +26 -0
  191. package/lib/core/helpers/multicall.d.ts +68 -0
  192. package/lib/core/helpers/multicall.js +103 -0
  193. package/lib/core/helpers/revert-decode.d.ts +248 -0
  194. package/lib/core/helpers/revert-decode.js +515 -0
  195. package/lib/core/helpers/signer.d.ts +61 -0
  196. package/lib/core/helpers/signer.js +184 -0
  197. package/lib/core/helpers/swap-router.d.ts +269 -0
  198. package/lib/core/helpers/swap-router.js +542 -0
  199. package/lib/core/helpers/vault-version.d.ts +24 -0
  200. package/lib/core/helpers/vault-version.js +83 -0
  201. package/lib/core/helpers/vaults.d.ts +89 -0
  202. package/lib/core/helpers/vaults.js +241 -0
  203. package/lib/core/helpers/web3.d.ts +366 -0
  204. package/lib/core/helpers/web3.js +1034 -0
  205. package/lib/core/index.d.ts +23 -0
  206. package/lib/core/index.js +40 -0
  207. package/lib/core/logger/curator-alert.d.ts +217 -0
  208. package/lib/core/logger/curator-alert.js +276 -0
  209. package/lib/core/logger/index.d.ts +99 -0
  210. package/lib/core/logger/index.js +163 -0
  211. package/lib/core/logger/slack.d.ts +49 -0
  212. package/lib/core/logger/slack.js +111 -0
  213. package/lib/core/vault-metadata.d.ts +12 -0
  214. package/lib/core/vault-metadata.js +42 -0
  215. package/lib/core/version-check.d.ts +58 -0
  216. package/lib/core/version-check.js +182 -0
  217. package/lib/evm/index.d.ts +2 -0
  218. package/lib/evm/index.js +19 -0
  219. package/lib/evm/methods/crossChainVault.d.ts +132 -0
  220. package/lib/evm/methods/crossChainVault.js +857 -0
  221. package/lib/evm/methods/crossChainVaultRegistry.d.ts +92 -0
  222. package/lib/evm/methods/crossChainVaultRegistry.js +239 -0
  223. package/lib/evm/methods/index.d.ts +2 -0
  224. package/lib/evm/methods/index.js +19 -0
  225. package/lib/evm/types/crossChain.d.ts +363 -0
  226. package/lib/evm/types/crossChain.js +20 -0
  227. package/lib/evm/types/index.d.ts +1 -0
  228. package/lib/evm/types/index.js +18 -0
  229. package/lib/index.d.ts +30 -0
  230. package/lib/index.js +52 -0
  231. package/lib/main.d.ts +596 -0
  232. package/lib/main.js +681 -0
  233. package/lib/modules/api/fetcher.d.ts +108 -0
  234. package/lib/modules/api/fetcher.js +187 -0
  235. package/lib/modules/api/index.d.ts +1 -0
  236. package/lib/modules/api/index.js +6 -0
  237. package/lib/modules/api/main.d.ts +587 -0
  238. package/lib/modules/api/main.js +911 -0
  239. package/lib/modules/sub-accounts/fetcher.d.ts +53 -0
  240. package/lib/modules/sub-accounts/fetcher.js +96 -0
  241. package/lib/modules/sub-accounts/index.d.ts +2 -0
  242. package/lib/modules/sub-accounts/index.js +19 -0
  243. package/lib/modules/sub-accounts/main.d.ts +249 -0
  244. package/lib/modules/sub-accounts/main.js +211 -0
  245. package/lib/modules/sub-accounts/utils.d.ts +106 -0
  246. package/lib/modules/sub-accounts/utils.js +112 -0
  247. package/lib/modules/vaults/adapter.helpers.d.ts +84 -0
  248. package/lib/modules/vaults/adapter.helpers.js +202 -0
  249. package/lib/modules/vaults/fetcher.d.ts +147 -0
  250. package/lib/modules/vaults/fetcher.js +357 -0
  251. package/lib/modules/vaults/getters.d.ts +1060 -0
  252. package/lib/modules/vaults/getters.js +4079 -0
  253. package/lib/modules/vaults/index.d.ts +20 -0
  254. package/lib/modules/vaults/index.js +44 -0
  255. package/lib/modules/vaults/main.d.ts +607 -0
  256. package/lib/modules/vaults/main.js +1687 -0
  257. package/lib/modules/vaults/prefetch.d.ts +65 -0
  258. package/lib/modules/vaults/prefetch.js +120 -0
  259. package/lib/modules/vaults/read.actions.d.ts +406 -0
  260. package/lib/modules/vaults/read.actions.js +891 -0
  261. package/lib/modules/vaults/types.d.ts +149 -0
  262. package/lib/modules/vaults/types.js +3 -0
  263. package/lib/modules/vaults/utils/call-data-decoder.d.ts +61 -0
  264. package/lib/modules/vaults/utils/call-data-decoder.js +194 -0
  265. package/lib/modules/vaults/utils/date-utils.d.ts +50 -0
  266. package/lib/modules/vaults/utils/date-utils.js +84 -0
  267. package/lib/modules/vaults/utils.d.ts +153 -0
  268. package/lib/modules/vaults/utils.js +818 -0
  269. package/lib/modules/vaults/write.actions.d.ts +812 -0
  270. package/lib/modules/vaults/write.actions.js +2377 -0
  271. package/lib/polyfills.d.ts +1 -0
  272. package/lib/polyfills.js +12 -0
  273. package/lib/sdk.d.ts +30173 -0
  274. package/lib/services/coingecko/fetcher.d.ts +15 -0
  275. package/lib/services/coingecko/fetcher.js +67 -0
  276. package/lib/services/coingecko/index.d.ts +2 -0
  277. package/lib/services/coingecko/index.js +19 -0
  278. package/lib/services/coingecko/utils.d.ts +1 -0
  279. package/lib/services/coingecko/utils.js +24 -0
  280. package/lib/services/debank/fetcher.d.ts +126 -0
  281. package/lib/services/debank/fetcher.js +47 -0
  282. package/lib/services/debank/index.d.ts +2 -0
  283. package/lib/services/debank/index.js +19 -0
  284. package/lib/services/debank/utils.d.ts +50 -0
  285. package/lib/services/debank/utils.js +325 -0
  286. package/lib/services/layerzero/deposits.d.ts +55 -0
  287. package/lib/services/layerzero/deposits.js +174 -0
  288. package/lib/services/layerzero/redeems.d.ts +20 -0
  289. package/lib/services/layerzero/redeems.js +92 -0
  290. package/lib/services/layerzero/utils.d.ts +9 -0
  291. package/lib/services/layerzero/utils.js +22 -0
  292. package/lib/services/octavfi/fetcher.d.ts +33 -0
  293. package/lib/services/octavfi/fetcher.js +39 -0
  294. package/lib/services/octavfi/index.d.ts +3 -0
  295. package/lib/services/octavfi/index.js +20 -0
  296. package/lib/services/octavfi/types.d.ts +34 -0
  297. package/lib/services/octavfi/types.js +3 -0
  298. package/lib/services/octavfi/utils.d.ts +16 -0
  299. package/lib/services/octavfi/utils.js +244 -0
  300. package/lib/services/subgraph/fetcher.d.ts +2 -0
  301. package/lib/services/subgraph/fetcher.js +66 -0
  302. package/lib/services/subgraph/index.d.ts +2 -0
  303. package/lib/services/subgraph/index.js +19 -0
  304. package/lib/services/subgraph/schema.d.ts +48 -0
  305. package/lib/services/subgraph/schema.js +87 -0
  306. package/lib/services/subgraph/vaults.d.ts +83 -0
  307. package/lib/services/subgraph/vaults.js +1282 -0
  308. package/lib/services/swap-quotes/index.d.ts +105 -0
  309. package/lib/services/swap-quotes/index.js +77 -0
  310. package/lib/services/swap-quotes/paraswap.d.ts +51 -0
  311. package/lib/services/swap-quotes/paraswap.js +138 -0
  312. package/lib/services/untangled/fetcher.d.ts +40 -0
  313. package/lib/services/untangled/fetcher.js +110 -0
  314. package/lib/services/untangled/index.d.ts +3 -0
  315. package/lib/services/untangled/index.js +20 -0
  316. package/lib/services/untangled/types.d.ts +83 -0
  317. package/lib/services/untangled/types.js +10 -0
  318. package/lib/services/untangled/utils.d.ts +91 -0
  319. package/lib/services/untangled/utils.js +339 -0
  320. package/lib/types/api.d.ts +498 -0
  321. package/lib/types/api.js +3 -0
  322. package/lib/types/index.d.ts +12 -0
  323. package/lib/types/index.js +28 -0
  324. package/lib/types/points.d.ts +28 -0
  325. package/lib/types/points.js +3 -0
  326. package/lib/types/pools.d.ts +144 -0
  327. package/lib/types/pools.js +3 -0
  328. package/lib/types/staking.d.ts +28 -0
  329. package/lib/types/staking.js +3 -0
  330. package/lib/types/sub-accounts.d.ts +150 -0
  331. package/lib/types/sub-accounts.js +3 -0
  332. package/lib/types/subgraph.d.ts +84 -0
  333. package/lib/types/subgraph.js +3 -0
  334. package/lib/types/typed-contract.d.ts +102 -0
  335. package/lib/types/typed-contract.js +3 -0
  336. package/lib/types/user.d.ts +1 -0
  337. package/lib/types/user.js +3 -0
  338. package/lib/types/vaults.d.ts +886 -0
  339. package/lib/types/vaults.js +30 -0
  340. package/lib/types/web3.d.ts +100 -0
  341. package/lib/types/web3.js +14 -0
  342. package/lib/types/webserver.d.ts +730 -0
  343. package/lib/types/webserver.js +3 -0
  344. package/package.json +79 -3
@@ -0,0 +1,292 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withMethodTracking = withMethodTracking;
4
+ exports.withSyncMethodTracking = withSyncMethodTracking;
5
+ exports.instrumentClass = instrumentClass;
6
+ const chain_name_1 = require("./chain-name");
7
+ const method_taxonomy_1 = require("./method-taxonomy");
8
+ const sanitize_1 = require("./sanitize");
9
+ const sentry_runtime_1 = require("./sentry-runtime");
10
+ const sentry_1 = require("./sentry");
11
+ /**
12
+ * Higher-order function to wrap SDK methods with performance tracking.
13
+ * Tracks method calls, timing, chain usage, and errors.
14
+ *
15
+ * @param methodName - Name of the method being wrapped
16
+ * @param method - The original async method
17
+ * @param getChainId - Function to get current chain ID
18
+ * @returns Wrapped method with tracking
19
+ */
20
+ function withMethodTracking(methodName, method, getChainId) {
21
+ return async function trackedMethod(...args) {
22
+ if (!(0, sentry_1.isAnalyticsEnabled)()) {
23
+ return method(...args);
24
+ }
25
+ // Resolve the SDK before the sanitize/shape/category work — when
26
+ // @sentry/node fails to resolve, every call would otherwise pay the
27
+ // hot-path cost only to discard the result below.
28
+ const sdk = (0, sentry_runtime_1.getSentrySDK)();
29
+ if (!sdk) {
30
+ return method(...args);
31
+ }
32
+ const startTime = performance.now();
33
+ const chainId = getChainId?.();
34
+ const category = (0, method_taxonomy_1.getMethodCategory)(methodName);
35
+ const sanitizedArgs = (0, sanitize_1.sanitizeArgs)(args);
36
+ const argShape = (0, sanitize_1.computeArgShape)(args);
37
+ // Flipped the moment the wrapped method is invoked inside the span. The
38
+ // outer catch uses it to tell "Sentry's startSpan itself blew up before
39
+ // our method ran" (safe to fall back to a direct call) from "our method
40
+ // ran and threw" (must NOT be re-run — for a write method that would be
41
+ // a second broadcast of the same transaction).
42
+ let methodInvoked = false;
43
+ try {
44
+ // Use Sentry's startSpan for performance tracking (v8 API)
45
+ return await sdk.startSpan({
46
+ op: 'sdk.method',
47
+ name: methodName,
48
+ attributes: {
49
+ // Scope tags only reach the root span in Sentry's span dataset;
50
+ // child spans need the identity copied on as attributes or they
51
+ // cannot be filtered by app or partner.
52
+ ...(0, sentry_1.getSpanAttributes)(),
53
+ chainId: chainId?.toString() || 'unknown',
54
+ 'sdk.chain': (0, chain_name_1.chainIdToTagValue)(chainId),
55
+ 'sdk.category': category,
56
+ // Joined to a string because Sentry span attributes are scalar.
57
+ 'sdk.argShape': argShape.join('|'),
58
+ ...sanitizedArgs,
59
+ },
60
+ }, async (span) => {
61
+ try {
62
+ methodInvoked = true;
63
+ const result = await method(...args);
64
+ const duration = performance.now() - startTime;
65
+ // Record success metrics
66
+ span?.setAttribute('duration', Math.round(duration));
67
+ span?.setAttribute('success', true);
68
+ // Track method call
69
+ trackMethodCall(methodName, {
70
+ method: methodName,
71
+ category,
72
+ chainId,
73
+ duration,
74
+ success: true,
75
+ }, { ...sanitizedArgs, argShape: argShape.join('|') });
76
+ span?.setStatus({ code: 1 }); // OK status
77
+ return result;
78
+ }
79
+ catch (error) {
80
+ const duration = performance.now() - startTime;
81
+ const errorType = error instanceof Error ? error.name : 'UnknownError';
82
+ // Record error metrics
83
+ span?.setAttribute('duration', Math.round(duration));
84
+ span?.setAttribute('success', false);
85
+ span?.setAttribute('error', error instanceof Error ? error.message : String(error));
86
+ // Track failed method call
87
+ trackMethodCall(methodName, {
88
+ method: methodName,
89
+ category,
90
+ chainId,
91
+ duration,
92
+ success: false,
93
+ errorType,
94
+ }, { ...sanitizedArgs, argShape: argShape.join('|') });
95
+ span?.setStatus({ code: 2, message: errorType }); // Error status
96
+ throw error;
97
+ }
98
+ });
99
+ }
100
+ catch (error) {
101
+ // If Sentry.startSpan fails BEFORE the method ran, fall back to a
102
+ // direct call so analytics never breaks SDK functionality. Once the
103
+ // method has been invoked, any error — even one whose message happens
104
+ // to mention "Sentry" — is the method's own and is re-thrown untouched.
105
+ if (!methodInvoked &&
106
+ error instanceof Error &&
107
+ error.message?.includes('Sentry')) {
108
+ return method(...args);
109
+ }
110
+ // Re-throw the original method error
111
+ throw error;
112
+ }
113
+ };
114
+ }
115
+ /**
116
+ * Track individual method calls as breadcrumbs and measurements.
117
+ */
118
+ function trackMethodCall(methodName, metrics, args) {
119
+ try {
120
+ const sdk = (0, sentry_runtime_1.getSentrySDK)();
121
+ if (!sdk)
122
+ return;
123
+ // Add breadcrumb for method call
124
+ sdk.addBreadcrumb({
125
+ category: 'sdk.method',
126
+ message: methodName,
127
+ level: metrics.success ? 'info' : 'error',
128
+ data: {
129
+ chainId: metrics.chainId,
130
+ category: metrics.category,
131
+ duration: Math.round(metrics.duration),
132
+ errorType: metrics.errorType,
133
+ ...args,
134
+ },
135
+ });
136
+ // Set measurement for method duration
137
+ sdk.setMeasurement('sdk.method.duration', metrics.duration, 'millisecond');
138
+ // Counters: SUM(invocation) → total calls; SUM(error)/SUM(invocation) → error rate.
139
+ sdk.setMeasurement('sdk.method.invocation', 1, 'none');
140
+ sdk.setMeasurement('sdk.method.error', metrics.success ? 0 : 1, 'none');
141
+ // Only sticky-tag the last method name — useful for attributing errors that fire
142
+ // outside an active SDK span. sdk.category and sdk.chain are already recorded as
143
+ // span attributes on each call, so mutating the global scope with them here would
144
+ // just contaminate subsequent unrelated events with stale values.
145
+ sdk.setTag('sdk.last_method', methodName);
146
+ }
147
+ catch {
148
+ // Silently fail - analytics should never break SDK
149
+ }
150
+ }
151
+ /**
152
+ * Check if a function is async (returns a Promise).
153
+ */
154
+ function isAsyncMethod(fn) {
155
+ // Check if constructor name indicates async
156
+ if (fn.constructor.name === 'AsyncFunction') {
157
+ return true;
158
+ }
159
+ // Check if function body suggests async
160
+ const fnString = fn.toString();
161
+ return fnString.includes('__awaiter') || fnString.startsWith('async');
162
+ }
163
+ /**
164
+ * Higher-order function to wrap synchronous SDK methods with tracking.
165
+ * Uses breadcrumbs for tracking since spans require async context.
166
+ *
167
+ * @param methodName - Name of the method being wrapped
168
+ * @param method - The original sync method
169
+ * @param getChainId - Function to get current chain ID
170
+ * @returns Wrapped method with tracking
171
+ */
172
+ function withSyncMethodTracking(methodName, method, getChainId) {
173
+ return function trackedSyncMethod(...args) {
174
+ if (!(0, sentry_1.isAnalyticsEnabled)()) {
175
+ return method(...args);
176
+ }
177
+ // Same hot-path short-circuit as the async path.
178
+ const sdk = (0, sentry_runtime_1.getSentrySDK)();
179
+ if (!sdk) {
180
+ return method(...args);
181
+ }
182
+ const startTime = performance.now();
183
+ const chainId = getChainId?.();
184
+ const category = (0, method_taxonomy_1.getMethodCategory)(methodName);
185
+ const sanitizedArgs = (0, sanitize_1.sanitizeArgs)(args);
186
+ const argShape = (0, sanitize_1.computeArgShape)(args);
187
+ try {
188
+ const result = method(...args);
189
+ const duration = performance.now() - startTime;
190
+ // Track successful sync method call via breadcrumb
191
+ trackSyncMethodCall(methodName, {
192
+ method: methodName,
193
+ category,
194
+ chainId,
195
+ duration,
196
+ success: true,
197
+ }, { ...sanitizedArgs, argShape: argShape.join('|') });
198
+ return result;
199
+ }
200
+ catch (error) {
201
+ const duration = performance.now() - startTime;
202
+ const errorType = error instanceof Error ? error.name : 'UnknownError';
203
+ // Track failed sync method call
204
+ trackSyncMethodCall(methodName, {
205
+ method: methodName,
206
+ category,
207
+ chainId,
208
+ duration,
209
+ success: false,
210
+ errorType,
211
+ }, { ...sanitizedArgs, argShape: argShape.join('|') });
212
+ throw error;
213
+ }
214
+ };
215
+ }
216
+ /**
217
+ * Track synchronous method calls as breadcrumbs.
218
+ */
219
+ function trackSyncMethodCall(methodName, metrics, args) {
220
+ try {
221
+ const sdk = (0, sentry_runtime_1.getSentrySDK)();
222
+ if (!sdk)
223
+ return;
224
+ // Add breadcrumb for sync method call
225
+ sdk.addBreadcrumb({
226
+ category: 'sdk.sync_method',
227
+ message: methodName,
228
+ level: metrics.success ? 'info' : 'error',
229
+ data: {
230
+ chainId: metrics.chainId,
231
+ category: metrics.category,
232
+ duration: Math.round(metrics.duration),
233
+ errorType: metrics.errorType,
234
+ ...args,
235
+ },
236
+ });
237
+ // Measurements omitted: sync methods have no span of their own, so setMeasurement
238
+ // would attach to whatever parent transaction happens to be active on the scope,
239
+ // overwriting its counters. The breadcrumb above already captures success/failure.
240
+ // `sdk.category` and `sdk.chain` stay off the global scope: concurrent sync
241
+ // calls would race on them and stamp stale values onto unrelated events (the
242
+ // breadcrumb above carries both per call). `sdk.last_chainId` stays because
243
+ // `isMutedChainEvent` in sentry.ts reads it to drop muted-chain events.
244
+ sdk.setTag('sdk.last_sync_method', methodName);
245
+ if (metrics.chainId !== undefined) {
246
+ sdk.setTag('sdk.last_chainId', metrics.chainId.toString());
247
+ }
248
+ }
249
+ catch {
250
+ // Silently fail - analytics should never break SDK
251
+ }
252
+ }
253
+ /**
254
+ * Instrument all methods on a class instance with tracking.
255
+ * This auto-wraps all public methods (both async and sync) without boilerplate.
256
+ *
257
+ * @param instance - The class instance to instrument
258
+ * @param getChainId - Function to get current chain ID
259
+ * @returns The same instance with instrumented methods
260
+ */
261
+ function instrumentClass(instance, getChainId) {
262
+ try {
263
+ const proto = Object.getPrototypeOf(instance);
264
+ const methodNames = Object.getOwnPropertyNames(proto).filter((name) => {
265
+ // Skip constructor and private methods
266
+ if (name === 'constructor' || name.startsWith('_'))
267
+ return false;
268
+ const descriptor = Object.getOwnPropertyDescriptor(proto, name);
269
+ return typeof descriptor?.value === 'function';
270
+ });
271
+ for (const methodName of methodNames) {
272
+ const original = instance[methodName];
273
+ if (typeof original === 'function') {
274
+ if (isAsyncMethod(original)) {
275
+ // Wrap async methods with span-based tracking
276
+ instance[methodName] =
277
+ withMethodTracking(methodName, original.bind(instance), getChainId);
278
+ }
279
+ else {
280
+ // Wrap sync methods with breadcrumb-based tracking
281
+ instance[methodName] =
282
+ withSyncMethodTracking(methodName, original.bind(instance), getChainId);
283
+ }
284
+ }
285
+ }
286
+ }
287
+ catch {
288
+ // Silently fail - analytics should never break SDK
289
+ }
290
+ return instance;
291
+ }
292
+ //# sourceMappingURL=instrumentation.js.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Canonical category for an SDK public method, used as the `sdk.category`
3
+ * Sentry tag so the partner-usage dashboard can roll calls up into
4
+ * `read.*` / `write.*` / `network` / `bridge` buckets.
5
+ */
6
+ export type MethodCategory = 'read.vault' | 'read.position' | 'read.redemption' | 'read.price' | 'read.points' | 'read.subaccount' | 'read.staking' | 'read.layerzero' | 'read.solana' | 'read.stellar' | 'read.sui' | 'read.evm' | 'write.deposit' | 'write.redeem' | 'write.approve' | 'write.points' | 'write.stellar' | 'network' | 'bridge' | 'unknown';
7
+ /**
8
+ * Map of public SDK method names to their {@link MethodCategory}.
9
+ *
10
+ * Keys are unqualified because `instrumentClass` walks the prototype and
11
+ * surfaces them that way; the same name on multiple adapters (e.g.
12
+ * `vaultDeposit` on EVM, Solana, Stellar) shares the same category.
13
+ */
14
+ export declare const METHOD_CATEGORIES: Readonly<Record<string, MethodCategory>>;
15
+ /**
16
+ * Look up the category for a method name, defaulting to `'unknown'` for
17
+ * methods not yet added to {@link METHOD_CATEGORIES}.
18
+ */
19
+ export declare function getMethodCategory(methodName: string): MethodCategory;
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.METHOD_CATEGORIES = void 0;
4
+ exports.getMethodCategory = getMethodCategory;
5
+ /**
6
+ * Map of public SDK method names to their {@link MethodCategory}.
7
+ *
8
+ * Keys are unqualified because `instrumentClass` walks the prototype and
9
+ * surfaces them that way; the same name on multiple adapters (e.g.
10
+ * `vaultDeposit` on EVM, Solana, Stellar) shares the same category.
11
+ */
12
+ exports.METHOD_CATEGORIES = {
13
+ getVault: 'read.vault',
14
+ getVaults: 'read.vault',
15
+ getTotalDeposited: 'read.vault',
16
+ getVaultLoans: 'read.vault',
17
+ getVaultSubaccountLoans: 'read.vault',
18
+ getVaultAllocations: 'read.vault',
19
+ getVaultApy: 'read.vault',
20
+ getVaultAnnualizedApy: 'read.vault',
21
+ getVaultTvl: 'read.vault',
22
+ getVaultHistoricalTimeseries: 'read.vault',
23
+ getVaultSummary: 'read.vault',
24
+ getVaultPnl: 'read.vault',
25
+ getVaultUnrealizedPnlHistory: 'read.vault',
26
+ getLatestUnrealizedPnl: 'read.vault',
27
+ getDashboardLoans: 'read.vault',
28
+ getDiscountFactors: 'read.vault',
29
+ getCollateralExcessOrDeficit: 'read.vault',
30
+ simulateCollateral: 'read.vault',
31
+ getRevertReason: 'read.vault',
32
+ getOtcPositions: 'read.vault',
33
+ getOtcMarginRequirements: 'read.vault',
34
+ getCuratorVaultSubaccounts: 'read.vault',
35
+ getCuratorVaultWhitelist: 'read.vault',
36
+ getTimelockRequests: 'read.vault',
37
+ getVaultPerformanceFees: 'read.vault',
38
+ getVaultOracleClassification: 'read.vault',
39
+ // Transparency dashboard (one per card/tab)
40
+ getVaultPositionSnapshot: 'read.vault',
41
+ getVaultBackingSeries: 'read.vault',
42
+ getVaultSmoothedApy: 'read.vault',
43
+ getVaultHistoricalAllocations: 'read.vault',
44
+ getVaultFeeConfig: 'read.vault',
45
+ getVaultGovernanceRoles: 'read.vault',
46
+ getVaultGovernancePermissions: 'read.vault',
47
+ getVaultGovernanceTimelocks: 'read.vault',
48
+ getVaultGovernanceAuditLog: 'read.vault',
49
+ getVaultBorrowerHealthFactor: 'read.vault',
50
+ getYieldLastRealizedOn: 'read.vault',
51
+ getVaultActivity: 'read.vault',
52
+ getSwapRouterDepositResult: 'read.vault',
53
+ getSwapRouterWhitelistedTokens: 'read.vault',
54
+ getSwapRouterEligibleVaults: 'read.vault',
55
+ getOriginInfo: 'read.vault',
56
+ getDepositRoute: 'read.vault',
57
+ getVaultPositions: 'read.position',
58
+ getVaultUserHistory: 'read.position',
59
+ getUserHistory: 'read.position',
60
+ getVaultUserTransfers: 'read.position',
61
+ getUserTransfers: 'read.position',
62
+ getVaultUserLifetimePnl: 'read.position',
63
+ getVaultAvailableRedemptions: 'read.redemption',
64
+ getVaultRedemptionHistory: 'read.redemption',
65
+ getVaultPendingRedemptions: 'read.redemption',
66
+ getVaultWithdrawals: 'read.redemption',
67
+ getWithdrawalRequestsWithStatus: 'read.redemption',
68
+ previewRedemption: 'read.redemption',
69
+ previewRwaRedemption: 'read.redemption',
70
+ getBurnableAmountByReceiver: 'read.redemption',
71
+ getRequirementByDate: 'read.redemption',
72
+ getScheduledTransactionsByDate: 'read.redemption',
73
+ getPrice: 'read.price',
74
+ getUserPoints: 'read.points',
75
+ fetchPointsLeaderboard: 'read.points',
76
+ getAllSubaccounts: 'read.subaccount',
77
+ getSubaccountHealthFactor: 'read.subaccount',
78
+ getSubaccountLoans: 'read.subaccount',
79
+ getSubaccountCefiPositions: 'read.subaccount',
80
+ getSubaccountOtcPositions: 'read.subaccount',
81
+ getSubaccountSummary: 'read.subaccount',
82
+ getSubaccountTransactions: 'read.subaccount',
83
+ getSubaccountLoanByAddress: 'read.subaccount',
84
+ getSubaccountDebank: 'read.subaccount',
85
+ getStakingPositions: 'read.staking',
86
+ getVaultStakingPositions: 'read.staking',
87
+ getLayerZeroDeposits: 'read.layerzero',
88
+ getLayerZeroRedeems: 'read.layerzero',
89
+ getVaultState: 'read.solana',
90
+ getVaultStateReadOnly: 'read.solana',
91
+ getToken: 'read.solana',
92
+ getTokenSymbol: 'read.solana',
93
+ fetchUserTokenBalance: 'read.solana',
94
+ fetchUserShareBalance: 'read.solana',
95
+ fetchUserShareBalanceRaw: 'read.solana',
96
+ // Both are offline resolvers (no RPC) — classified so the partner dashboard
97
+ // sees program-targeting calls instead of dropping them into 'unknown'.
98
+ getProgram: 'read.solana',
99
+ getProgramId: 'read.solana',
100
+ setWalletProvider: 'network',
101
+ // submitTransaction broadcasts a signed Soroban tx — it mutates on-chain
102
+ // state and belongs in the write bucket even though Stellar adapter call
103
+ // shape mirrors the read helpers (returns a hash, takes signed XDR).
104
+ submitTransaction: 'write.stellar',
105
+ getUserPosition: 'read.stellar',
106
+ // convertToShares is a read-only Soroban simulation despite its mutative-
107
+ // sounding name — runs through queryContract, no broadcast.
108
+ convertToShares: 'read.stellar',
109
+ // Offline helpers on the public adapter surface, classified under the
110
+ // chain's read bucket like getProgram/getProgramId above rather than
111
+ // leaking into 'unknown'.
112
+ isStellarAddress: 'read.stellar',
113
+ getExplorerLink: 'read.stellar',
114
+ isSuiAddress: 'read.sui',
115
+ isSuiVault: 'read.sui',
116
+ vaultAllowance: 'read.evm',
117
+ sendersWhitelistAddress: 'read.evm',
118
+ isWhitelisted: 'read.evm',
119
+ getDeposited: 'read.evm',
120
+ getRemainingAllocations: 'read.evm',
121
+ previewDeposit: 'read.vault',
122
+ previewRedeem: 'read.redemption',
123
+ allowance: 'read.evm',
124
+ balanceOf: 'read.evm',
125
+ maxDeposit: 'read.vault',
126
+ getIdleLiquidity: 'read.vault',
127
+ lagDuration: 'read.vault',
128
+ getWithdrawalEpoch: 'read.vault',
129
+ vaultDeposit: 'write.deposit',
130
+ depositNative: 'write.deposit',
131
+ swapAndDeposit: 'write.deposit',
132
+ depositViaSwapRouter: 'write.deposit',
133
+ depositNativeViaSwapRouter: 'write.deposit',
134
+ swapRouterDeposit: 'write.deposit',
135
+ vaultRedeem: 'write.redeem',
136
+ claimWithdrawal: 'write.redeem',
137
+ vaultRequestRedeem: 'write.redeem',
138
+ // Solana withdrawal queue: cancelling a request is part of the redeem flow.
139
+ vaultCancelRedeemRequest: 'write.redeem',
140
+ rwaRedeemAsset: 'write.redeem',
141
+ vaultApprove: 'write.approve',
142
+ approve: 'write.approve',
143
+ registerUserForPoints: 'write.points',
144
+ switchNetwork: 'network',
145
+ updateWallet: 'network',
146
+ clearWallet: 'network',
147
+ setSigner: 'network',
148
+ };
149
+ /**
150
+ * Look up the category for a method name, defaulting to `'unknown'` for
151
+ * methods not yet added to {@link METHOD_CATEGORIES}.
152
+ */
153
+ function getMethodCategory(methodName) {
154
+ return exports.METHOD_CATEGORIES[methodName] ?? 'unknown';
155
+ }
156
+ //# sourceMappingURL=method-taxonomy.js.map
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Track API response times and status.
3
+ *
4
+ * @param endpoint - The API endpoint called
5
+ * @param method - HTTP method used
6
+ * @param startTime - Start timestamp from performance.now()
7
+ * @param status - HTTP response status code (0 for network errors)
8
+ * @param server - Server identifier (production, staging, etc.)
9
+ */
10
+ export declare function trackApiCall(endpoint: string, method: string, startTime: number, status: number, server: string): void;
11
+ /**
12
+ * Track chain/network switches for usage distribution analysis.
13
+ *
14
+ * @param chainId - The chain ID being switched to
15
+ */
16
+ export declare function trackNetworkSwitch(chainId: number): void;
17
+ /**
18
+ * Track the outcome of an API-key verification check (e.g. `verifyUpshiftKey`).
19
+ * Records success/failure as a breadcrumb and a low-cardinality tag so
20
+ * verification failures are visible in the dashboard without leaking the key
21
+ * itself — callers must never pass the raw key value.
22
+ *
23
+ * @param keyType - Which key was verified (e.g. `'upshift'`)
24
+ * @param success - Whether the key was accepted
25
+ */
26
+ export declare function trackKeyVerification(keyType: string, success: boolean): void;
27
+ declare let cacheStats: {
28
+ hits: number;
29
+ misses: number;
30
+ sets: number;
31
+ };
32
+ /**
33
+ * Cache statistics snapshot. The SDK never recorded cache hits, misses, or
34
+ * sets, so every field is always `0`.
35
+ *
36
+ * @deprecated Always returns zeros. Kept only for API compatibility and will
37
+ * be removed in the next major release; there is no replacement.
38
+ */
39
+ export declare function getCacheStats(): typeof cacheStats;
40
+ /**
41
+ * Reset the cache statistics snapshot to zeros. The SDK never records any, so
42
+ * this has no observable effect.
43
+ *
44
+ * @deprecated Has no effect. Kept only for API compatibility and will be
45
+ * removed in the next major release; there is no replacement.
46
+ */
47
+ export declare function resetCacheStats(): void;
48
+ export {};
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.trackApiCall = trackApiCall;
4
+ exports.trackNetworkSwitch = trackNetworkSwitch;
5
+ exports.trackKeyVerification = trackKeyVerification;
6
+ exports.getCacheStats = getCacheStats;
7
+ exports.resetCacheStats = resetCacheStats;
8
+ const chain_name_1 = require("./chain-name");
9
+ const sentry_runtime_1 = require("./sentry-runtime");
10
+ const sentry_1 = require("./sentry");
11
+ /**
12
+ * Track API response times and status.
13
+ *
14
+ * @param endpoint - The API endpoint called
15
+ * @param method - HTTP method used
16
+ * @param startTime - Start timestamp from performance.now()
17
+ * @param status - HTTP response status code (0 for network errors)
18
+ * @param server - Server identifier (production, staging, etc.)
19
+ */
20
+ function trackApiCall(endpoint, method, startTime, status, server) {
21
+ if (!(0, sentry_1.isAnalyticsEnabled)())
22
+ return;
23
+ try {
24
+ const sdk = (0, sentry_runtime_1.getSentrySDK)();
25
+ if (!sdk)
26
+ return;
27
+ const duration = performance.now() - startTime;
28
+ // Normalize endpoint for aggregation (replace dynamic segments)
29
+ const normalizedEndpoint = normalizeEndpoint(endpoint);
30
+ // Add breadcrumb
31
+ sdk.addBreadcrumb({
32
+ category: 'api',
33
+ message: `${method} ${normalizedEndpoint}`,
34
+ level: status >= 400 || status === 0 ? 'error' : 'info',
35
+ data: {
36
+ endpoint: normalizedEndpoint,
37
+ method,
38
+ duration: Math.round(duration),
39
+ status,
40
+ server,
41
+ },
42
+ });
43
+ sdk.setMeasurement('api.duration', duration, 'millisecond');
44
+ }
45
+ catch {
46
+ // Silently fail - analytics should never break SDK
47
+ }
48
+ }
49
+ /**
50
+ * Track chain/network switches for usage distribution analysis.
51
+ *
52
+ * @param chainId - The chain ID being switched to
53
+ */
54
+ function trackNetworkSwitch(chainId) {
55
+ if (!(0, sentry_1.isAnalyticsEnabled)())
56
+ return;
57
+ try {
58
+ const sdk = (0, sentry_runtime_1.getSentrySDK)();
59
+ if (!sdk)
60
+ return;
61
+ const chainLabel = (0, chain_name_1.chainIdToTagValue)(chainId);
62
+ sdk.addBreadcrumb({
63
+ category: 'network',
64
+ message: `Switched to chain ${chainId} (${chainLabel})`,
65
+ level: 'info',
66
+ data: { chainId, chain: chainLabel },
67
+ });
68
+ sdk.setTag('sdk.chain', chainLabel);
69
+ }
70
+ catch {
71
+ // Silently fail - analytics should never break SDK
72
+ }
73
+ }
74
+ /**
75
+ * Track the outcome of an API-key verification check (e.g. `verifyUpshiftKey`).
76
+ * Records success/failure as a breadcrumb and a low-cardinality tag so
77
+ * verification failures are visible in the dashboard without leaking the key
78
+ * itself — callers must never pass the raw key value.
79
+ *
80
+ * @param keyType - Which key was verified (e.g. `'upshift'`)
81
+ * @param success - Whether the key was accepted
82
+ */
83
+ function trackKeyVerification(keyType, success) {
84
+ if (!(0, sentry_1.isAnalyticsEnabled)())
85
+ return;
86
+ try {
87
+ const sdk = (0, sentry_runtime_1.getSentrySDK)();
88
+ if (!sdk)
89
+ return;
90
+ sdk.addBreadcrumb({
91
+ category: 'auth.verify',
92
+ message: `${keyType} key verification ${success ? 'succeeded' : 'failed'}`,
93
+ level: success ? 'info' : 'warning',
94
+ data: { keyType, success },
95
+ });
96
+ sdk.setTag('auth.last_verified_key_type', keyType);
97
+ sdk.setTag('auth.last_verification_result', success ? 'success' : 'failure');
98
+ }
99
+ catch {
100
+ // Silently fail - analytics should never break SDK
101
+ }
102
+ }
103
+ /**
104
+ * Normalize endpoint URLs for aggregation.
105
+ * Replaces dynamic segments (addresses, IDs) with placeholders.
106
+ *
107
+ * @param endpoint - Raw endpoint URL
108
+ * @returns Normalized endpoint pattern
109
+ */
110
+ function normalizeEndpoint(endpoint) {
111
+ return (endpoint
112
+ // Replace Ethereum addresses (0x + 40 hex chars)
113
+ .replace(/0x[a-fA-F0-9]{40}/g, ':address')
114
+ // Replace chain IDs (5+ digit numbers)
115
+ .replace(/\/\d{5,}/g, '/:chainId')
116
+ // Replace UUIDs
117
+ .replace(/[a-f0-9-]{36}/gi, ':uuid')
118
+ // Replace numeric IDs in paths
119
+ .replace(/\/\d+(?=\/|$)/g, '/:id'));
120
+ }
121
+ let cacheStats = { hits: 0, misses: 0, sets: 0 };
122
+ /**
123
+ * Cache statistics snapshot. The SDK never recorded cache hits, misses, or
124
+ * sets, so every field is always `0`.
125
+ *
126
+ * @deprecated Always returns zeros. Kept only for API compatibility and will
127
+ * be removed in the next major release; there is no replacement.
128
+ */
129
+ function getCacheStats() {
130
+ return { ...cacheStats };
131
+ }
132
+ /**
133
+ * Reset the cache statistics snapshot to zeros. The SDK never records any, so
134
+ * this has no observable effect.
135
+ *
136
+ * @deprecated Has no effect. Kept only for API compatibility and will be
137
+ * removed in the next major release; there is no replacement.
138
+ */
139
+ function resetCacheStats() {
140
+ cacheStats = { hits: 0, misses: 0, sets: 0 };
141
+ }
142
+ //# sourceMappingURL=metrics.js.map