From 878955647ceea0fab9e3dd4fc752d8f5dacc436a Mon Sep 17 00:00:00 2001 From: yuli-ferna Date: Tue, 9 Jul 2024 15:17:37 -0400 Subject: [PATCH 1/4] Fix --- apps/connect/package-lock.json | 12 +++++------- apps/connect/package.json | 3 ++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/connect/package-lock.json b/apps/connect/package-lock.json index 30567749d..96019dbca 100644 --- a/apps/connect/package-lock.json +++ b/apps/connect/package-lock.json @@ -29,7 +29,8 @@ "mixpanel-browser": "^2.49.0", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-router-dom": "^6.24.0" + "react-router-dom": "^6.24.0", + "zone.js": "^0.14.7" }, "devDependencies": { "@types/dompurify": "^3.0.5", @@ -28369,12 +28370,9 @@ } }, "node_modules/zone.js": { - "version": "0.14.4", - "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.14.4.tgz", - "integrity": "sha512-NtTUvIlNELez7Q1DzKVIFZBzNb646boQMgpATo9z3Ftuu/gWvzxCW7jdjcUDoRGxRikrhVHB/zLXh1hxeJawvw==", - "dependencies": { - "tslib": "^2.3.0" - } + "version": "0.14.7", + "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.14.7.tgz", + "integrity": "sha512-0w6DGkX2BPuiK/NLf+4A8FLE43QwBfuqz2dVgi/40Rj1WmqUskCqj329O/pwrqFJLG5X8wkeG2RhIAro441xtg==" }, "node_modules/zustand": { "version": "4.5.2", diff --git a/apps/connect/package.json b/apps/connect/package.json index 775733b0d..c21b5dcac 100644 --- a/apps/connect/package.json +++ b/apps/connect/package.json @@ -36,7 +36,8 @@ "mixpanel-browser": "^2.49.0", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-router-dom": "^6.24.0" + "react-router-dom": "^6.24.0", + "zone.js": "^0.14.7" }, "devDependencies": { "@types/dompurify": "^3.0.5", From 31cf2fe055dfc722e3b540837cfcf48946ae5cfc Mon Sep 17 00:00:00 2001 From: yuli-ferna Date: Wed, 10 Jul 2024 11:41:35 -0400 Subject: [PATCH 2/4] Remove opentelemetry --- apps/connect/package-lock.json | 215 +----------------------- apps/connect/package.json | 11 +- apps/connect/src/main.tsx | 3 - apps/connect/src/providers/telemetry.ts | 151 ++++------------- 4 files changed, 32 insertions(+), 348 deletions(-) diff --git a/apps/connect/package-lock.json b/apps/connect/package-lock.json index 96019dbca..fdbc49a4a 100644 --- a/apps/connect/package-lock.json +++ b/apps/connect/package-lock.json @@ -13,24 +13,15 @@ "@emotion/styled": "^11.11.0", "@mui/icons-material": "^5.14.11", "@mui/material": "^5.12.1", - "@opentelemetry/api": "^1.8.0", - "@opentelemetry/auto-instrumentations-web": "^0.38.0", - "@opentelemetry/context-zone": "^1.23.0", "@opentelemetry/core": "^1.23.0", "@opentelemetry/exporter-trace-otlp-http": "^0.50.0", - "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/instrumentation-user-interaction": "^0.37.0", - "@opentelemetry/otlp-transformer": "^0.50.0", - "@opentelemetry/resources": "^1.23.0", - "@opentelemetry/sdk-trace-web": "^1.23.0", "@tanstack/react-query": "^5.14.2", "@wormhole-foundation/wormhole-connect": "^0.3.16", "dompurify": "^3.0.6", "mixpanel-browser": "^2.49.0", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-router-dom": "^6.24.0", - "zone.js": "^0.14.7" + "react-router-dom": "^6.24.0" }, "devDependencies": { "@types/dompurify": "^3.0.5", @@ -7966,49 +7957,6 @@ "node": ">=14" } }, - "node_modules/@opentelemetry/auto-instrumentations-web": { - "version": "0.38.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/auto-instrumentations-web/-/auto-instrumentations-web-0.38.0.tgz", - "integrity": "sha512-KDPaQNy360ALbHUF7fkkBenvtCOIYZ8wJzpyza88+Dhrz9abgQtALLDx5mMtpaCZVL5Iqfer2L4WuzhsGqlTHQ==", - "dependencies": { - "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/instrumentation-document-load": "^0.37.0", - "@opentelemetry/instrumentation-fetch": "^0.50.0", - "@opentelemetry/instrumentation-user-interaction": "^0.37.0", - "@opentelemetry/instrumentation-xml-http-request": "^0.50.0" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": "^1.3.0", - "zone.js": "^0.11.4 || ^0.13.0 || ^0.14.0" - } - }, - "node_modules/@opentelemetry/context-zone": { - "version": "1.23.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/context-zone/-/context-zone-1.23.0.tgz", - "integrity": "sha512-7piNTrpH+gZNMDDOHIJXCSwp0Xslh3R96HWH5HwXw+4PykR4+jVoXvd6jziQxudX9rFAfu2B64A10DHs4ZWrfA==", - "dependencies": { - "@opentelemetry/context-zone-peer-dep": "1.23.0", - "zone.js": "^0.11.0 || ^0.13.0 || ^0.14.0" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/@opentelemetry/context-zone-peer-dep": { - "version": "1.23.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/context-zone-peer-dep/-/context-zone-peer-dep-1.23.0.tgz", - "integrity": "sha512-3ia5w2y3CGHIhMSggttliGbeRBWclIyMMXdfRCcit1NHg1ocieA9qYxyUEetbOvPrQpoti3O3k+5eyQUv7r8nw==", - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": ">=1.0.0 <1.9.0", - "zone.js": "^0.10.2 || ^0.11.0 || ^0.13.0 || ^0.14.0" - } - }, "node_modules/@opentelemetry/core": { "version": "1.23.0", "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.23.0.tgz", @@ -8041,94 +7989,6 @@ "@opentelemetry/api": "^1.0.0" } }, - "node_modules/@opentelemetry/instrumentation": { - "version": "0.50.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation/-/instrumentation-0.50.0.tgz", - "integrity": "sha512-bhGhbJiZKpuu7wTaSak4hyZcFPlnDeuSF/2vglze8B4w2LubcSbbOnkVTzTs5SXtzh4Xz8eRjaNnAm+u2GYufQ==", - "dependencies": { - "@opentelemetry/api-logs": "0.50.0", - "@types/shimmer": "^1.0.2", - "import-in-the-middle": "1.7.1", - "require-in-the-middle": "^7.1.1", - "semver": "^7.5.2", - "shimmer": "^1.2.1" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": "^1.3.0" - } - }, - "node_modules/@opentelemetry/instrumentation-document-load": { - "version": "0.37.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-document-load/-/instrumentation-document-load-0.37.0.tgz", - "integrity": "sha512-tmxx8k2gjUwbAEhnvxACEeYTHRwkrcvU3ABkmoH5NKtd5aWSiY6Pni2hCtccLqj0Hk4/jwv51+lLiA6moji6ZQ==", - "dependencies": { - "@opentelemetry/core": "^1.8.0", - "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/sdk-trace-base": "^1.0.0", - "@opentelemetry/sdk-trace-web": "^1.15.0", - "@opentelemetry/semantic-conventions": "^1.22.0" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": "^1.3.0" - } - }, - "node_modules/@opentelemetry/instrumentation-fetch": { - "version": "0.50.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-fetch/-/instrumentation-fetch-0.50.0.tgz", - "integrity": "sha512-CayteluGJbrfDvzEFQ0EWqLFkNAcO9H7nfDHptZjtonBpJRWF170XZoMkJVC2bxp0lIVwyuw6WlnGVRSNwEtKA==", - "dependencies": { - "@opentelemetry/core": "1.23.0", - "@opentelemetry/instrumentation": "0.50.0", - "@opentelemetry/sdk-trace-web": "1.23.0", - "@opentelemetry/semantic-conventions": "1.23.0" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": "^1.0.0" - } - }, - "node_modules/@opentelemetry/instrumentation-user-interaction": { - "version": "0.37.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-user-interaction/-/instrumentation-user-interaction-0.37.0.tgz", - "integrity": "sha512-MVJXRmg7WKtGLlq5PwsP2NKLZZ6TbhKsR0CMcEbeAoWC9QPigKDR7nyVw3bWhfTnD2GAUpAWO9PA8Q/19hYuUw==", - "dependencies": { - "@opentelemetry/core": "^1.8.0", - "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/sdk-trace-web": "^1.8.0" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": "^1.3.0", - "zone.js": "^0.11.4 || ^0.13.0 || ^0.14.0" - } - }, - "node_modules/@opentelemetry/instrumentation-xml-http-request": { - "version": "0.50.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/instrumentation-xml-http-request/-/instrumentation-xml-http-request-0.50.0.tgz", - "integrity": "sha512-o9z6SDQByqc3GvmUcy6Npt/SAIrv2Pk0Hm0Hl54B3Ny8WUrTsrlt6MULx8d+EjuifE4uVo8op8DekmvKJ1FHoQ==", - "dependencies": { - "@opentelemetry/core": "1.23.0", - "@opentelemetry/instrumentation": "0.50.0", - "@opentelemetry/sdk-trace-web": "1.23.0", - "@opentelemetry/semantic-conventions": "1.23.0" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": "^1.0.0" - } - }, "node_modules/@opentelemetry/otlp-exporter-base": { "version": "0.50.0", "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-exporter-base/-/otlp-exporter-base-0.50.0.tgz", @@ -8225,22 +8085,6 @@ "@opentelemetry/api": ">=1.0.0 <1.9.0" } }, - "node_modules/@opentelemetry/sdk-trace-web": { - "version": "1.23.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-web/-/sdk-trace-web-1.23.0.tgz", - "integrity": "sha512-tx9N3hIkd6k567BeujBnpXYdhu3ptYVk0ZkhdcjyQ3I8ZDJ+/JkVtaVNLAuf8hp1buTqNDmxSipALMxEmK2fnw==", - "dependencies": { - "@opentelemetry/core": "1.23.0", - "@opentelemetry/sdk-trace-base": "1.23.0", - "@opentelemetry/semantic-conventions": "1.23.0" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": ">=1.0.0 <1.9.0" - } - }, "node_modules/@opentelemetry/semantic-conventions": { "version": "1.23.0", "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.23.0.tgz", @@ -12029,11 +11873,6 @@ "integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==", "dev": true }, - "node_modules/@types/shimmer": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@types/shimmer/-/shimmer-1.0.5.tgz", - "integrity": "sha512-9Hp0ObzwwO57DpLFF0InUjUm/II8GmKAvzbefxQTihCb7KI6yc9yzf0nLc4mVdby5N4DRCgQM2wCup9KTieeww==" - }, "node_modules/@types/trusted-types": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", @@ -16920,14 +16759,6 @@ "node": ">=0.4.0" } }, - "node_modules/acorn-import-assertions": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz", - "integrity": "sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==", - "peerDependencies": { - "acorn": "^8" - } - }, "node_modules/acorn-jsx": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", @@ -18342,11 +18173,6 @@ "consola": "^3.2.3" } }, - "node_modules/cjs-module-lexer": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.3.tgz", - "integrity": "sha512-0TNiGstbQmCFwt4akjjBg5pLRTSyj/PkWQ1ZoO2zntmg9yLqSRxwEa4iCfQLGjqhiqBfOJa7W/E8wfGrTDmlZQ==" - }, "node_modules/classnames": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.5.1.tgz", @@ -21705,17 +21531,6 @@ "node": ">=4" } }, - "node_modules/import-in-the-middle": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/import-in-the-middle/-/import-in-the-middle-1.7.1.tgz", - "integrity": "sha512-1LrZPDtW+atAxH42S6288qyDFNQ2YCty+2mxEPRtfazH6Z5QwkaBSTS2ods7hnVJioF6rkRfNoA6A/MstpFXLg==", - "dependencies": { - "acorn": "^8.8.2", - "acorn-import-assertions": "^1.9.0", - "cjs-module-lexer": "^1.2.2", - "module-details-from-path": "^1.0.3" - } - }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -23521,11 +23336,6 @@ "ufo": "^1.3.2" } }, - "node_modules/module-details-from-path": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/module-details-from-path/-/module-details-from-path-1.0.3.tgz", - "integrity": "sha512-ySViT69/76t8VhE1xXHK6Ch4NcDd26gx0MzKXLO+F7NOtnqH68d9zF94nT8ZWSxXh8ELOERsnJO/sWt1xZYw5A==" - }, "node_modules/moment": { "version": "2.30.1", "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", @@ -25494,19 +25304,6 @@ "node": ">=0.10.0" } }, - "node_modules/require-in-the-middle": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/require-in-the-middle/-/require-in-the-middle-7.3.0.tgz", - "integrity": "sha512-nQFEv9gRw6SJAwWD2LrL0NmQvAcO7FBwJbwmr2ttPAacfy0xuiOjE5zt+zM4xDyuyvUaxBi/9gb2SoCyNEVJcw==", - "dependencies": { - "debug": "^4.1.1", - "module-details-from-path": "^1.0.3", - "resolve": "^1.22.1" - }, - "engines": { - "node": ">=8.6.0" - } - }, "node_modules/require-main-filename": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", @@ -26183,11 +25980,6 @@ "node": ">=4" } }, - "node_modules/shimmer": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.2.1.tgz", - "integrity": "sha512-sQTKC1Re/rM6XyFM6fIAGHRPVGvyXfgzIDvzoq608vM+jeyVD0Tu1E6Np0Kc2zAIFWIj963V2800iF/9LPieQw==" - }, "node_modules/shx": { "version": "0.3.4", "resolved": "https://registry.npmjs.org/shx/-/shx-0.3.4.tgz", @@ -28369,11 +28161,6 @@ "zen-observable": "0.8.15" } }, - "node_modules/zone.js": { - "version": "0.14.7", - "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.14.7.tgz", - "integrity": "sha512-0w6DGkX2BPuiK/NLf+4A8FLE43QwBfuqz2dVgi/40Rj1WmqUskCqj329O/pwrqFJLG5X8wkeG2RhIAro441xtg==" - }, "node_modules/zustand": { "version": "4.5.2", "resolved": "https://registry.npmjs.org/zustand/-/zustand-4.5.2.tgz", diff --git a/apps/connect/package.json b/apps/connect/package.json index c21b5dcac..475fcb70a 100644 --- a/apps/connect/package.json +++ b/apps/connect/package.json @@ -20,24 +20,15 @@ "@emotion/styled": "^11.11.0", "@mui/icons-material": "^5.14.11", "@mui/material": "^5.12.1", - "@opentelemetry/api": "^1.8.0", - "@opentelemetry/auto-instrumentations-web": "^0.38.0", - "@opentelemetry/context-zone": "^1.23.0", "@opentelemetry/core": "^1.23.0", "@opentelemetry/exporter-trace-otlp-http": "^0.50.0", - "@opentelemetry/instrumentation": "^0.50.0", - "@opentelemetry/instrumentation-user-interaction": "^0.37.0", - "@opentelemetry/otlp-transformer": "^0.50.0", - "@opentelemetry/resources": "^1.23.0", - "@opentelemetry/sdk-trace-web": "^1.23.0", "@tanstack/react-query": "^5.14.2", "@wormhole-foundation/wormhole-connect": "^0.3.16", "dompurify": "^3.0.6", "mixpanel-browser": "^2.49.0", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-router-dom": "^6.24.0", - "zone.js": "^0.14.7" + "react-router-dom": "^6.24.0" }, "devDependencies": { "@types/dompurify": "^3.0.5", diff --git a/apps/connect/src/main.tsx b/apps/connect/src/main.tsx index e65abcf48..2b88d0221 100644 --- a/apps/connect/src/main.tsx +++ b/apps/connect/src/main.tsx @@ -6,7 +6,6 @@ import { QueryClientProvider, QueryClient } from "@tanstack/react-query"; import theme from "./theme/portal.ts"; import Background from "./components/atoms/Background.tsx"; import App from "./App.tsx"; -import { OpenTelemetryContext, tracer } from "./providers/telemetry.ts"; import { HashRouter } from "react-router-dom"; if (redirects && redirects?.source?.length > 0) { @@ -22,14 +21,12 @@ ReactDOM.createRoot(document.getElementById("root")!).render( - - diff --git a/apps/connect/src/providers/telemetry.ts b/apps/connect/src/providers/telemetry.ts index 8a142ec23..8a6b036fc 100644 --- a/apps/connect/src/providers/telemetry.ts +++ b/apps/connect/src/providers/telemetry.ts @@ -1,41 +1,11 @@ -import { Tracer, Span, Attributes, Context } from "@opentelemetry/api"; -import { ZoneContextManager } from "@opentelemetry/context-zone"; -import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http"; -import { Resource } from "@opentelemetry/resources"; -import { - SimpleSpanProcessor, - WebTracerProvider, - ReadableSpan, - TracerConfig, - Span as SpanSdk, -} from "@opentelemetry/sdk-trace-web"; -import mixpanel, { Dict } from "mixpanel-browser"; -import { OTLPExporterError } from "@opentelemetry/otlp-exporter-base"; -import { createContext, useContext } from "react"; -export type OpenTelemetryContextType = { - tracer: Tracer; -}; - -export type OpenTelemetryProviderProps = { - children: JSX.Element; -}; - -export const OpenTelemetryContext = - createContext(null); - -class MixpanelSpanProcessor extends SimpleSpanProcessor { - onStart(span: SpanSdk, context: Context): void { - super.onStart(span, context); - } -} - -interface MixpanelSpan { - event: string; - properties: Dict | undefined; -} +import mixpanel from "mixpanel-browser"; -const APP_NAME = - import.meta.env.VITE_APP_NAME || "portal-bridge/wormhole-connect"; +mixpanel.init("fdaf35ef8f838559e248a71c80ff1626", { + ignore_dnt: true, + ip: false, + debug: true, + +}); let sessionId = localStorage.getItem("session.id"); if (!sessionId) { @@ -43,97 +13,42 @@ if (!sessionId) { localStorage.setItem("session.id", JSON.stringify(newSessionId)); sessionId = newSessionId; } -const tracerProvider = new WebTracerProvider({ - resource: new Resource({ - ["service.name"]: APP_NAME, - ["session.id"]: sessionId, - }), -}); -const TRACER = `tracer://${APP_NAME}`; - -export const tracer = tracerProvider.getTracer(TRACER); -mixpanel.init("fdaf35ef8f838559e248a71c80ff1626", { - ignore_dnt: true, - ip: false, - debug: true, -}); // TODO remove $device_id - -class MixpanelExporter extends OTLPTraceExporter { - convertMixpanel(spans: ReadableSpan[]): MixpanelSpan[] { - const mixpanelSpan = spans.map((span) => { - return { - event: span.name, - properties: { - time: span.startTime[0], - ...span.attributes, - }, - }; - }); - return mixpanelSpan; - } - send( - objects: ReadableSpan[], - onSuccess: () => void, - onError: (error: OTLPExporterError) => void - ): void { - const mixpanelSpan = this.convertMixpanel(objects); - console.log("MixpanelExporter send", mixpanelSpan); - try { - mixpanel.identify(localStorage.getItem("session.id") || ""); - mixpanelSpan.forEach( - (span: { event: string; properties: Dict | undefined }) => { - mixpanel.track(span.event, span.properties); - } - ); - onSuccess(); - } catch (error) { - onError(error as OTLPExporterError); - } +/* eslint-disable @typescript-eslint/no-explicit-any */ +const sendEvent = (e: any) => { + try { + mixpanel.identify(localStorage.getItem("session.id") || ""); // TODO fix errAnonDistinctIdAssignedAlready error https://docs.mixpanel.com/docs/tracking-methods/id-management/identifying-users + mixpanel.track(e.event, e.properties); + } catch (error) { + console.error(error); } -} - -const providerConfig: TracerConfig = { - resource: new Resource({ - "service.name": "portal-bridge", - }), }; - -const provider = new WebTracerProvider(providerConfig); - -// we will use ConsoleSpanExporter to check the generated spans in dev console -//provider.addSpanProcessor(new MixpanelSpanProcessor(new ConsoleSpanExporter())); -provider.addSpanProcessor(new MixpanelSpanProcessor(new MixpanelExporter())); -provider.register({ - contextManager: new ZoneContextManager(), -}); - -let span: Span; let lastChain: string; -// Send the event to the opentelemetry /* eslint-disable @typescript-eslint/no-explicit-any */ export const eventHandler = (e: any) => { // Ignore the load event if (e.type === "load") return; // Start the trace when the event is load - span = provider.getTracer(TRACER).startSpan(e.type); - + let span = { event: e.type, properties: e.details }; // Wallet connect information if (e.type === "wallet.connect") { const side = e.details.side; - span.setAttributes({ + span = { + ...span, + properties: { [`wallet-${side}`]: e.details.wallet, [`chain-${side}`]: e.details.chain, - }); + }, + }; const chain = `${e.details.chain}-${side}`; if (lastChain !== chain) { - span?.end(); + sendEvent(span) } lastChain = chain; } else { // Convert WormholeConnectEvent to Attributes - const attributes: Attributes = {}; + const attributes: { [key: string]: string } = {}; attributes["fromChain"] = e.details.fromChain; attributes["toChain"] = e.details.toChain; @@ -192,18 +107,12 @@ export const eventHandler = (e: any) => { } // Transfer event information - span.setAttributes(attributes); - span?.end(); + span = { + ...span, + properties: { + ...attributes, + }, + }; + sendEvent(span) } -}; - -// Custom hook to use the OpenTelemetry context -export const useOpenTelemetry = () => { - const context = useContext(OpenTelemetryContext); - if (context === null) { - throw new Error( - "useOpenTelemetry must be used within a OpenTelemetryProvider" - ); - } - return context; -}; +}; \ No newline at end of file From 7e30bb00681dc8cc147a403b5ceaf20838c4b0bd Mon Sep 17 00:00:00 2001 From: yuli-ferna Date: Wed, 10 Jul 2024 13:23:53 -0400 Subject: [PATCH 3/4] fix prettier --- apps/connect/src/main.tsx | 12 ++++++------ apps/connect/src/providers/telemetry.ts | 11 +++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/apps/connect/src/main.tsx b/apps/connect/src/main.tsx index 2b88d0221..c8c7d1bab 100644 --- a/apps/connect/src/main.tsx +++ b/apps/connect/src/main.tsx @@ -21,12 +21,12 @@ ReactDOM.createRoot(document.getElementById("root")!).render( - - - - - - + + + + + + diff --git a/apps/connect/src/providers/telemetry.ts b/apps/connect/src/providers/telemetry.ts index 8a6b036fc..3f11c178b 100644 --- a/apps/connect/src/providers/telemetry.ts +++ b/apps/connect/src/providers/telemetry.ts @@ -4,7 +4,6 @@ mixpanel.init("fdaf35ef8f838559e248a71c80ff1626", { ignore_dnt: true, ip: false, debug: true, - }); let sessionId = localStorage.getItem("session.id"); @@ -37,13 +36,13 @@ export const eventHandler = (e: any) => { span = { ...span, properties: { - [`wallet-${side}`]: e.details.wallet, - [`chain-${side}`]: e.details.chain, + [`wallet-${side}`]: e.details.wallet, + [`chain-${side}`]: e.details.chain, }, }; const chain = `${e.details.chain}-${side}`; if (lastChain !== chain) { - sendEvent(span) + sendEvent(span); } lastChain = chain; } else { @@ -113,6 +112,6 @@ export const eventHandler = (e: any) => { ...attributes, }, }; - sendEvent(span) + sendEvent(span); } -}; \ No newline at end of file +}; From 039a1692c35c5efe7e2b91e07f3fa9b1782ed36d Mon Sep 17 00:00:00 2001 From: yuli-ferna Date: Wed, 10 Jul 2024 16:13:11 -0400 Subject: [PATCH 4/4] remove open telemetry p2 --- apps/connect/package-lock.json | 157 --------------------------------- apps/connect/package.json | 2 - 2 files changed, 159 deletions(-) diff --git a/apps/connect/package-lock.json b/apps/connect/package-lock.json index fdbc49a4a..909485815 100644 --- a/apps/connect/package-lock.json +++ b/apps/connect/package-lock.json @@ -13,8 +13,6 @@ "@emotion/styled": "^11.11.0", "@mui/icons-material": "^5.14.11", "@mui/material": "^5.12.1", - "@opentelemetry/core": "^1.23.0", - "@opentelemetry/exporter-trace-otlp-http": "^0.50.0", "@tanstack/react-query": "^5.14.2", "@wormhole-foundation/wormhole-connect": "^0.3.16", "dompurify": "^3.0.6", @@ -7938,161 +7936,6 @@ "base-x": "^4.0.0" } }, - "node_modules/@opentelemetry/api": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.8.0.tgz", - "integrity": "sha512-I/s6F7yKUDdtMsoBWXJe8Qz40Tui5vsuKCWJEWVL+5q9sSWRzzx6v2KeNsOBEwd94j0eWkpWCH4yB6rZg9Mf0w==", - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/@opentelemetry/api-logs": { - "version": "0.50.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.50.0.tgz", - "integrity": "sha512-JdZuKrhOYggqOpUljAq4WWNi5nB10PmgoF0y2CvedLGXd0kSawb/UBnWT8gg1ND3bHCNHStAIVT0ELlxJJRqrA==", - "dependencies": { - "@opentelemetry/api": "^1.0.0" - }, - "engines": { - "node": ">=14" - } - }, - "node_modules/@opentelemetry/core": { - "version": "1.23.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.23.0.tgz", - "integrity": "sha512-hdQ/a9TMzMQF/BO8Cz1juA43/L5YGtCSiKoOHmrTEf7VMDAZgy8ucpWx3eQTnQ3gBloRcWtzvcrMZABC3PTSKQ==", - "dependencies": { - "@opentelemetry/semantic-conventions": "1.23.0" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": ">=1.0.0 <1.9.0" - } - }, - "node_modules/@opentelemetry/exporter-trace-otlp-http": { - "version": "0.50.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/exporter-trace-otlp-http/-/exporter-trace-otlp-http-0.50.0.tgz", - "integrity": "sha512-L7OtIMT7MsFqkmhbQlPBGRXt7152VN5esHpQEJYIBFedOEo3Da+yHpu5ojMZtPzpIvSpB5Xr5lnJUjJCbkttCA==", - "dependencies": { - "@opentelemetry/core": "1.23.0", - "@opentelemetry/otlp-exporter-base": "0.50.0", - "@opentelemetry/otlp-transformer": "0.50.0", - "@opentelemetry/resources": "1.23.0", - "@opentelemetry/sdk-trace-base": "1.23.0" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": "^1.0.0" - } - }, - "node_modules/@opentelemetry/otlp-exporter-base": { - "version": "0.50.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-exporter-base/-/otlp-exporter-base-0.50.0.tgz", - "integrity": "sha512-JUmjmrCmE1/fc4LjCQMqLfudgSl5OpUkzx7iA94b4jgeODM7zWxUoVXL7/CT7fWf47Cn+pmKjMvTCSESqZZ3mA==", - "dependencies": { - "@opentelemetry/core": "1.23.0" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": "^1.0.0" - } - }, - "node_modules/@opentelemetry/otlp-transformer": { - "version": "0.50.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/otlp-transformer/-/otlp-transformer-0.50.0.tgz", - "integrity": "sha512-s0sl1Yfqd5q1Kjrf6DqXPWzErL+XHhrXOfejh4Vc/SMTNqC902xDsC8JQxbjuramWt/+hibfguIvi7Ns8VLolA==", - "dependencies": { - "@opentelemetry/api-logs": "0.50.0", - "@opentelemetry/core": "1.23.0", - "@opentelemetry/resources": "1.23.0", - "@opentelemetry/sdk-logs": "0.50.0", - "@opentelemetry/sdk-metrics": "1.23.0", - "@opentelemetry/sdk-trace-base": "1.23.0" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": ">=1.3.0 <1.9.0" - } - }, - "node_modules/@opentelemetry/resources": { - "version": "1.23.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.23.0.tgz", - "integrity": "sha512-iPRLfVfcEQynYGo7e4Di+ti+YQTAY0h5mQEUJcHlU9JOqpb4x965O6PZ+wMcwYVY63G96KtdS86YCM1BF1vQZg==", - "dependencies": { - "@opentelemetry/core": "1.23.0", - "@opentelemetry/semantic-conventions": "1.23.0" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": ">=1.0.0 <1.9.0" - } - }, - "node_modules/@opentelemetry/sdk-logs": { - "version": "0.50.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.50.0.tgz", - "integrity": "sha512-PeUEupBB29p9nlPNqXoa1PUWNLsZnxG0DCDj3sHqzae+8y76B/A5hvZjg03ulWdnvBLYpnJslqzylG9E0IL87g==", - "dependencies": { - "@opentelemetry/core": "1.23.0", - "@opentelemetry/resources": "1.23.0" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": ">=1.4.0 <1.9.0", - "@opentelemetry/api-logs": ">=0.39.1" - } - }, - "node_modules/@opentelemetry/sdk-metrics": { - "version": "1.23.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-1.23.0.tgz", - "integrity": "sha512-4OkvW6+wST4h6LFG23rXSTf6nmTf201h9dzq7bE0z5R9ESEVLERZz6WXwE7PSgg1gdjlaznm1jLJf8GttypFDg==", - "dependencies": { - "@opentelemetry/core": "1.23.0", - "@opentelemetry/resources": "1.23.0", - "lodash.merge": "^4.6.2" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": ">=1.3.0 <1.9.0" - } - }, - "node_modules/@opentelemetry/sdk-trace-base": { - "version": "1.23.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-1.23.0.tgz", - "integrity": "sha512-PzBmZM8hBomUqvCddF/5Olyyviayka44O5nDWq673np3ctnvwMOvNrsUORZjKja1zJbwEuD9niAGbnVrz3jwRQ==", - "dependencies": { - "@opentelemetry/core": "1.23.0", - "@opentelemetry/resources": "1.23.0", - "@opentelemetry/semantic-conventions": "1.23.0" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": ">=1.0.0 <1.9.0" - } - }, - "node_modules/@opentelemetry/semantic-conventions": { - "version": "1.23.0", - "resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.23.0.tgz", - "integrity": "sha512-MiqFvfOzfR31t8cc74CTP1OZfz7MbqpAnLCra8NqQoaHJX6ncIRTdYOQYBDQ2uFISDq0WY8Y9dDTWvsgzzBYRg==", - "engines": { - "node": ">=14" - } - }, "node_modules/@osmonauts/helpers": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/@osmonauts/helpers/-/helpers-0.6.0.tgz", diff --git a/apps/connect/package.json b/apps/connect/package.json index 475fcb70a..350736828 100644 --- a/apps/connect/package.json +++ b/apps/connect/package.json @@ -20,8 +20,6 @@ "@emotion/styled": "^11.11.0", "@mui/icons-material": "^5.14.11", "@mui/material": "^5.12.1", - "@opentelemetry/core": "^1.23.0", - "@opentelemetry/exporter-trace-otlp-http": "^0.50.0", "@tanstack/react-query": "^5.14.2", "@wormhole-foundation/wormhole-connect": "^0.3.16", "dompurify": "^3.0.6",