2.0.22 • Published 9 months ago

@railtownai/react v2.0.22

Weekly downloads
-
License
-
Repository
github
Last release
9 months ago

Railtown AI for React apps

Railtown AI root cause analysis for React apps.

Getting Started

  1. Sign up for a free account at railtown.ai.
  2. Copy your Railtown API Token from the Project Configuration page
  3. Install the package: npm install --save @railtownai/react or yarn add @railtownai/react
  4. Follow the instructions below to integrate Railtown AI into your React app(s)

Installation

// main.tsx or index.tsx
import React from "react";
import * as RailtownAI from "@railtownai/react";

RailtownAI.install({
  token: YOUR_RAILTOWN_TOKEN,
  userProperties: {
    ignoreErrors: ["Error Message", /Exact Error Message/],
  },
});

function App() {
  return (
    <>
      <h1>Hello Railtown AI!</h1>
      <RailtownAI.ErrorBoundary fallback={<div>This is a fallback to the error</div>}>
        <SomeErroneousComponent />
      </RailtownAI.ErrorBoundary>
    </>
  );
}

const container = document.getElementById("app");
const root = ReactDOM.createRoot(container);
root.render(<App />);

Usage with useLogger()

// UserList.tsx
import React from "react";
import { useLogger } from "@railtownai/react";

const UserList = (props) => {
  const logger = useLogger();
  const [users, setUsers] = React.useState([]);

  useEffect(() => {
    (async () => {
      try {
        const response = await fetch("https://jsonplaceholder.typicode.com/users");
        const users = await response.json();
        setUsers(users);
      } catch (error) {
        logger.error(error);
      }
    })();
  }, []);

  return (
    <>
      <ul>
        {users.map((user) => (
          <li key={user.id}>{user.name}</li>
        ))}
      </ul>
    </>
  );
};
export { UserList };
2.0.22

9 months ago

2.0.20

12 months ago

2.0.21

12 months ago

2.0.19

1 year ago

2.0.17

1 year ago

2.0.16

2 years ago

2.0.15-r3

2 years ago

2.0.15-r2

2 years ago

2.0.15-r1

2 years ago

2.0.15

2 years ago