@rpcbase/client 0.236.0 → 0.238.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/client",
3
- "version": "0.236.0",
3
+ "version": "0.238.0",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "scripts": {
@@ -25,9 +25,9 @@
25
25
  },
26
26
  "peerDependencies": {},
27
27
  "dependencies": {
28
- "@sentry/react": "9.5.0",
28
+ "@sentry/react": "9.9.0",
29
29
  "@sentry/tracing": "7.120.3",
30
- "axios": "1.7.9"
30
+ "axios": "1.8.4"
31
31
  },
32
32
  "devDependencies": {}
33
33
  }
@@ -0,0 +1,46 @@
1
+ const CLEANUP_WAIT_DELAY = 1000
2
+
3
+ // Function to clean UTM params while preserving others
4
+ export const cleanupURL = () => {
5
+ if (import.meta.env.SSR) {
6
+ return
7
+ }
8
+
9
+ const runCleanup = () => {
10
+ // Add a small delay before running cleanupURL
11
+ setTimeout(() => {
12
+ const url = new URL(window.location.href)
13
+ const params = new URLSearchParams(url.search)
14
+
15
+ // Get all current query parameter keys
16
+ const paramKeys = Array.from(params.keys())
17
+
18
+ // Remove any parameter starting with 'utm_'
19
+ paramKeys.forEach((key) => {
20
+ if (key.startsWith("utm_")) {
21
+ params.delete(key)
22
+ }
23
+ })
24
+
25
+ // Build the new URL: keep pathname and append remaining query params (if any)
26
+ const cleanUrl =
27
+ url.pathname +
28
+ (params.toString() ? "?" + params.toString() : "") +
29
+ url.hash
30
+
31
+ // Update the browser URL without reloading
32
+ window.history.replaceState({}, document.title, cleanUrl)
33
+ }, CLEANUP_WAIT_DELAY)
34
+ }
35
+
36
+ // If DOM is already loaded, schedule the cleanup
37
+ if (
38
+ document.readyState === "complete" ||
39
+ document.readyState === "interactive"
40
+ ) {
41
+ runCleanup()
42
+ } else {
43
+ // Otherwise wait for the DOM content to be loaded
44
+ document.addEventListener("DOMContentLoaded", runCleanup, { once: true })
45
+ }
46
+ }
package/src/initClient.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { initApiClient } from "./apiClient"
2
+ import {cleanupURL} from "./cleanupURL"
2
3
 
3
4
  /* eslint-disable @typescript-eslint/no-explicit-any */
4
5
  const showErrorOverlay = (err: { title: string, message: string, reason: string, plugin: string }) => {
@@ -28,5 +29,7 @@ const handleServerErrors = () => {
28
29
  export const initClient = () => {
29
30
  initApiClient()
30
31
 
32
+ cleanupURL()
33
+
31
34
  handleServerErrors()
32
35
  }