Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto capture console logs #78

Closed
wants to merge 9 commits into from
Closed

Conversation

RyanCommits
Copy link
Contributor

@RyanCommits RyanCommits commented Oct 10, 2023

Issue: https://fullstory.atlassian.net/browse/MOCA-8076

Add methods enableConsole and disableConsole to FullStory API that will extend React Native's console API. Messages will be passed to FS.log.

Console capture defaults to enabled, and follows the FS default log level of info if the customer hasn't configured it already.

Example session: https://app.staging.fullstory.com/ui/KWH/session/6727898337050624:5966357937455104/devtools/console

Added enable and disable API.

Added safeStringify from web side, minus DOM node handling since that's not defined in RN.

@RyanCommits
Copy link
Contributor Author

Updated jest dev dependencies and snapshots to resolve npm errors.

src/index.ts Outdated Show resolved Hide resolved
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment about configuration

src/index.ts Outdated Show resolved Hide resolved
@RyanCommits
Copy link
Contributor Author

After discussion - we discovered new requirements: https://docs.google.com/document/d/1QAGpjrC96ePbY_-SugOYK9zFSaqh1HnkXh6CP5MrRp8

@RyanCommits RyanCommits marked this pull request as ready for review January 4, 2024 15:58
Copy link

@jurassix jurassix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall seems fine. Added my nit feedback to a stacked pr: #83

Two open issues:

  • do we need to expose the safeStringify or can we use an OSS solution? Longer term if we want to maintain this functinality it seems best to do as a separate lib.
  • It's unclear why we default to enable and not let the FSTA settings determine the initial state.

Assert = 5, // Clamps to Error on Android
}

const consoleLevelMap = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

web supports assert here as well.

expect(oldConsoleError).toEqual(console.error);
});

it('disableConsole does not overwrite third party overwrites', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Comment on lines +159 to +162
// default ON
consoleWatcher.enable();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is confusing, web-capture doesn't default to ON. We default to disabled and only enable when there is a flags.ConsoleWatcher set to true on the PageResponse. The only exception is the FS.log API which adds logs.

// @ts-expect-error
const isTurboModuleEnabled = global.__turboModuleProxy != null;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like you need to define a module for the global scope instead of just ignoring the TS errors.

This should work.

declare global {
  let __turboModuleProxy: boolean;
}

const isTurboModuleEnabled = __turboModuleProxy != null;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added this to my pr feedback branch.

Comment on lines 46 to 47
// A naive version of ConsoleWatcher on web.
// See https://github.com/cowpaths/mn/blob/865353f374b687e481d3b230e7eec8e1d7be2eb4/projects/fullstory/packages/recording/src/consolewatcher.ts

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a public repo correct? doesn't seem that useful to ref our private repo

@@ -0,0 +1,174 @@
import { safeStringify } from '../logging/safeStringify';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is a public repo seems like we could add a third-party dep for this instead of managing this directly.

@wiz-inc-e194d921e3-fullstorydev
Copy link

wiz-inc-e194d921e3-fullstorydev bot commented May 1, 2024

Wiz Scan Summary

IaC Misconfigurations 0C 0H 0M 0L 0I
Vulnerabilities 0C 0H 1M 0L 0I
Sensitive Data 0C 0H 0M 0L 0I
Total 0C 0H 1M 0L 0I
Secrets 0🔑

@RyanCommits RyanCommits force-pushed the ryanwang/capture-console-logs branch from 23dcb27 to ac6011c Compare May 1, 2024 15:14
@RyanCommits
Copy link
Contributor Author

Closing this for now since we'll need to discuss console scrubbing on the native side

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants