New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ybug-react

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ybug-react

Wrapper to make ybug.io scripts easily usable in React project

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
298
decreased by-15.82%
Maintainers
1
Weekly downloads
 
Created
Source

Ybug-react

A simple wrapper of ybug.io widget to easily integrate with React applications.

Install

npm install --save ybug-react

Usage

Simply wrap your app within the provided YbugProvider component

<YbugProvider ybugId="my-ybug-id" >
    <MyApp>
</YbugProvider>

Then in the rest of the app lifecycle, you can interact with the ybug instance by using the useYbugApi hook

Examples

Autofilling the Ybug forms with user infos

import {useYbugApi} from 'ybug-react';

function useUserConnection(props: {userId: string}) {
    const YbugContext = useYbugApi();
    const {data} = useUserDataFetching(props.userId);

    const currentUser = data?.user;
    React.useEffect(() => {
        if (currentUser && YbugContext.Ybug) {
            YbugContext.init({
                feedback: {
                    // Autofill feedback forms with user email and name
                    email: currentUser.contact?.email ?? "",
                    name: currentUser.full_name ?? "",
                },
                // Make ybug use the user language
                language_override: currentUser.language,
                // Add custom user infos
                user: {
                    email: currentUser.contact?.email ?? "",
                    ...
                },
            });
        }
    }, [currentUser, YbugContext])
}

Programatically trigger ybug report pop-up

import * as React from "react";
import { useYbugApi } from "~/config/ybug/YbugContext";

function ErrorPage() {
  const YbugContext = useYbugApi();
  const YbugApi = YbugContext?.Ybug;

  const openYbugReport = () => {
    if (YbugApi) {
      YbugApi.open("feedback");
    }
  };

  return (
    <div>
        <span>
            An error happened. Please contact our team
        </span>
        <button onClick={actions.openYbugReport}>
            Tell us more
        </button>
    </div>
  );
}

export { ErrorPage };

Demo

Edit ybug-react-usage-demo

For more info visit https://ybug.io

Keywords

FAQs

Package last updated on 13 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc