From 5395f830cff763dffa25be0f57175f17ece2000d Mon Sep 17 00:00:00 2001 From: Jason Long Date: Wed, 19 Jun 2024 19:10:12 -0700 Subject: [PATCH] [platform] Remove logrocket and fullstory We have posthog now Change-Id: I4d766dc0fe8e6fd0ace80135c96bcb2ddf24fb29 GitOrigin-RevId: 65d6dc98423ca4d94dc1c041ff1fbb3318a1f73f --- platform/wab/package.json | 1 - platform/wab/src/wab/client/api.ts | 3 - .../wab/src/wab/client/components/Shell.tsx | 88 ------------------- .../wab/client/frame-ctx/top-frame-ctx.tsx | 9 -- platform/wab/src/wab/client/tracking.ts | 2 - platform/wab/src/wab/devflags.ts | 1 - platform/wab/tools/studio-html-plugin.ts | 8 -- platform/wab/yarn.lock | 5 -- 8 files changed, 117 deletions(-) diff --git a/platform/wab/package.json b/platform/wab/package.json index 3e8ddcfed0e..485b17f1ba0 100644 --- a/platform/wab/package.json +++ b/platform/wab/package.json @@ -380,7 +380,6 @@ "lodash": "^4.17.21", "lodash-es": "^4.17.21", "loglevel": "^1.6.8", - "logrocket": "^1.0.9", "lusca": "^1.6.1", "memoize-one": "^6.0.0", "mime": "^2.4.6", diff --git a/platform/wab/src/wab/client/api.ts b/platform/wab/src/wab/client/api.ts index 1edee42ebf9..1e8c12e6a9e 100644 --- a/platform/wab/src/wab/client/api.ts +++ b/platform/wab/src/wab/client/api.ts @@ -37,7 +37,6 @@ import * as Sentry from "@sentry/browser"; import { proxy, ProxyMarked } from "comlink"; import $ from "jquery"; import L, { pick } from "lodash"; -import LogRocket from "logrocket"; import io, { Socket } from "socket.io-client"; const fullApiPath = (url: /*TWZ*/ string) => `/api/v1/${L.trimStart(url, "/")}`; @@ -154,7 +153,6 @@ export class Api extends SharedApi { Sentry.configureScope((scope) => { scope.setUser({}); }); - LogRocket.startNewSession(); } async req( @@ -657,7 +655,6 @@ export function setUser(user: ApiUser) { Sentry.configureScope((scope) => { scope.setUser({ id, ...traits }); }); - LogRocket.identify(id, traits); } export function invalidationKey(method: string, ...args: any[]) { diff --git a/platform/wab/src/wab/client/components/Shell.tsx b/platform/wab/src/wab/client/components/Shell.tsx index 2303a17782c..953cc548542 100644 --- a/platform/wab/src/wab/client/components/Shell.tsx +++ b/platform/wab/src/wab/client/components/Shell.tsx @@ -17,8 +17,6 @@ import { CustomError, hackyCast, isLiteralObject, - mkUuid, - stampObjectUuid, swallow, tuple, withoutFalsy, @@ -31,7 +29,6 @@ import { UserError } from "@/wab/shared/UserError"; import * as Sentry from "@sentry/browser"; import * as Integrations from "@sentry/integrations"; import { createBrowserHistory } from "history"; -import LogRocket from "logrocket"; import { onReactionError } from "mobx"; import posthog from "posthog-js"; import * as React from "react"; @@ -118,27 +115,6 @@ export function main() { applyDevFlagOverrides(DEVFLAGS, initClientFlags(DEVFLAGS)); - if (DEVFLAGS.useLogrocket) { - hackyCast(window).useLogrocket = true; - type Payload = { body?: string }; - const sanitizer = function (payload: T): T { - if (payload.body && payload.body.length > 999) { - payload.body = JSON.stringify({ - length: payload.body.length, - snip: `${payload.body.slice(0, 500)}..${payload.body.slice(-400)}`, - }); - } - return payload; - }; - LogRocket.init("dl8waw/plasmic", { - mergeIframes: true, - network: { - requestSanitizer: sanitizer, - responseSanitizer: sanitizer, - }, - }); - } - if (DeploymentFlags.DEPLOYENV === "production") { if (DEVFLAGS.posthog) { posthog.init("phc_eaI1hFsPRIZkmwrXaSGRNDh4H9J3xdh1j9rgNy27NgP"); @@ -224,70 +200,6 @@ export function main() { event.tags.tier = getMaximumTier(userTiers); } - // - // Record FullStory session ID. - // Adapted from https://gist.github.com/patrick-fs/8066c2a0c97aec6cca6d355a55a52506 - // via https://github.com/getsentry/sentry-fullstory/issues/30 - // - - const _fs = hackyCast(window[hackyCast(window)._fs_namespace]); - // getCurrentSessionURL isn't available until after the FullStory script is fully bootstrapped. - // If an error occurs before getCurrentSessionURL is ready, make a note in Sentry and move on. - // More on getCurrentSessionURL here: https://help.fullstory.com/develop-js/getcurrentsessionurl - event.extra.fullstory = - typeof _fs !== "function" - ? "FullStory is not installed" - : typeof _fs.getCurrentSessionURL === "function" - ? _fs.getCurrentSessionURL(true) - : "current session URL API not ready"; - - // - // Record LogRocket session ID (including timestamp). - // - - const logRocketSession = LogRocket.sessionURL; - if (logRocketSession) { - event.extra.LogRocket = logRocketSession; - } - - if (hint) { - // - // Tag the error with a UUID. This is usually read later by - // handleError which reports it in analytics.track(). - // - - const uuid = hint.originalException - ? stampObjectUuid(hint.originalException) - : mkUuid(); - if (!event.tags) { - event.tags = {}; - } - event.tags.plasmicErrorUuid = uuid; - - // This originally tracks the Sentry ID to FS, but we are already - // calling analytics.track() in handleError(). But that doesn't - // have the Sentry event_id, which we have only here in - // beforeSend. We might want to merge the two somehow and ensure - // analytics.track() has the Sentry event_id (or even some - // kind of unique Segment event ID?). - const error = hint.originalException; - if ( - 0 / 1 && - typeof _fs === "function" && - error && - error instanceof Error - ) { - // FS.event is immediately ready even if FullStory isn't fully bootstrapped - _fs.event("Application error", { - name: error.name, - message: error.message, - fileName: hackyCast(error).fileName, - sentryEventId: hint.event_id, - sentryUrl: `https://sentry.io/organizations/${sentryOrgId}/issues/?project=${sentryProjId}&query=${hint.event_id}`, - }); - } - } - return event; }, }); diff --git a/platform/wab/src/wab/client/frame-ctx/top-frame-ctx.tsx b/platform/wab/src/wab/client/frame-ctx/top-frame-ctx.tsx index a367709ce5a..b361b37ead4 100644 --- a/platform/wab/src/wab/client/frame-ctx/top-frame-ctx.tsx +++ b/platform/wab/src/wab/client/frame-ctx/top-frame-ctx.tsx @@ -106,15 +106,6 @@ export function TopFrameCtxProvider({ topFrameApi.registerLocationListener(locationListener) ); }, - - toJSON() { - // When we do console.log(studioCtx) in the inner frame, fullstory - // tries to jsonify studioCtx, converting all descendant objects - // into json to record in fullstory, eventually calling api.toJSON(). - // So we add that method here to prevent comlink from trying to call a - // non-existent function on our API object. - return "API"; - }, } as TopFrameFullApi; Comlink.expose(topFrameCtxApi, { ...hostFrameEndpoint, diff --git a/platform/wab/src/wab/client/tracking.ts b/platform/wab/src/wab/client/tracking.ts index 4f286204bc5..00d64c783fe 100644 --- a/platform/wab/src/wab/client/tracking.ts +++ b/platform/wab/src/wab/client/tracking.ts @@ -1,5 +1,4 @@ import L from "lodash"; -import LogRocket from "logrocket"; import { useEffect } from "react"; const reservedProps = [ @@ -40,7 +39,6 @@ export function trackEvent(eventName: string, eventData?: any) { } } analytics.track(eventName, eventData); - LogRocket.track(eventName); } export function useTracking() { diff --git a/platform/wab/src/wab/devflags.ts b/platform/wab/src/wab/devflags.ts index c203b8de851..3a7bc01184b 100644 --- a/platform/wab/src/wab/devflags.ts +++ b/platform/wab/src/wab/devflags.ts @@ -552,7 +552,6 @@ const DEFAULT_DEVFLAGS = { uncatchErrors: false, // Prefers loading state over expression fallback useLoadingState: false, - useLogrocket: false, showHiddenHostLessComponents: false, ccStubs: false, workspaces: false, diff --git a/platform/wab/tools/studio-html-plugin.ts b/platform/wab/tools/studio-html-plugin.ts index 7bec5725790..45117f1c16d 100644 --- a/platform/wab/tools/studio-html-plugin.ts +++ b/platform/wab/tools/studio-html-plugin.ts @@ -51,14 +51,6 @@ export class StudioHtmlPlugin implements RspackPluginInstance { `` // Replaced in studio.js ); - // Specify that this iframe is the outermost root of the FullStory recording. - root - .querySelector("head") - .insertAdjacentHTML( - "afterbegin", - `` - ); - // Allow our instrumentation to run when the host URL uses HTTP root .querySelector("head") diff --git a/platform/wab/yarn.lock b/platform/wab/yarn.lock index d9b4fbcc3d0..3384601b890 100644 --- a/platform/wab/yarn.lock +++ b/platform/wab/yarn.lock @@ -18305,11 +18305,6 @@ loglevel@^1.6.8: resolved "https://registry.yarnpkg.com/loglevel/-/loglevel-1.7.1.tgz#005fde2f5e6e47068f935ff28573e125ef72f197" integrity sha512-Hesni4s5UkWkwCGJMQGAh71PaLUmKFM60dHvq0zi/vDhhrzuk+4GgNbTXJ12YYQJn6ZKBDNIjYcuQGKudvqrIw== -logrocket@^1.0.9: - version "1.0.14" - resolved "https://registry.yarnpkg.com/logrocket/-/logrocket-1.0.14.tgz#afe61a6b993691a706154e83fe2c05e8174a650d" - integrity sha512-notwwiIiXOmWSKQDsW8UrFJPu81u9rd6YaIFBmx6uF0XtXXwNQ+Mvteh5WHdABWcQ2nN4I7QkQrCAocYDx7OVg== - loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.2.0, loose-envify@^1.3.1, loose-envify@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"