npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

loupe-typescript

v1.2.1

Published

Loupe Agent for Web clients

Downloads

53

Readme

loupe-typescript

loupe-typescript is a Loupe Agent for web browser applications.

The agent will hook into the window.onerror event to automatically log any uncaught JavaScript errors.

Use of the agent needs to be combined with a server component to correlate the actions your user performs client side with the corresponding server side processing, giving you a better insight into end to end functionality. See the project readme for more details.

Installation

You can install the module via npm:

API

  • critical(category: string, caption: string, description: string, parameters?: any[] | null, exception?: any | null, details?: any | null, methodSourceInfo?: * MethodSourceInfo | null) - write a categorized Crticial message to Loupe.

  • error(category: string, caption: string, description: string, parameters?: any[] | null, exception?: any | null, details?: any | null, methodSourceInfo?: * MethodSourceInfo | null) - write a categorized Error message to Loupe.

  • information(category: string, caption: string, description: string, parameters?: any[] | null, exception?: any | null, details?: any | null, methodSourceInfo?: MethodSourceInfo | null) - write a categorized Information message to Loupe.

  • warning(category: string, caption: string, description: string, parameters?: any[] | null, exception?: any | null, details?: any | null, methodSourceInfo?: * MethodSourceInfo | null) - write a categorized Warning message to Loupe.

  • verbose(category: string, caption: string, description: string, parameters?: any[] | null, exception?: any | null, details?: any | null, methodSourceInfo?:MethodSourceInfo | null) - write a categorized Verbose message to Loupe.

  • write(severity: LogMessageSeverity, category: string, caption: string, description: string, parameters?: any[] | null, exception?: any | null, details?: any |null, methodSourceInfo?: MethodSourceInfo | null) - write a categorized message to Loupe.

  • setSessionId(value: string) - set the client session id.

  • setCORSOrigin(value: string | null) - set the target endpoint for log message. If not set, the current host is used with the default log point of /Loupe/Log.

  • setAuthorizationHeader(header: Header) - sets the Authorization header to send when logging to Loupe.

  • clientSessionHeader() - gets the Header used as the agent session id.

  • resetMessageInterval(interval: number) - resets the interval used to batch up and send messages. This interval starts at 10 milliseconds and increases if there are failures to send; messages are stored in the browser local storage and resent in order when communication is restored.

  • addSendMessageCommandToEventQueue() - immediately send any queued messages.

The critical, error, information, warning and verbose methods are all convenience wrappers over the critical method. For these, the parameters are:

  • category - The application subsystem or logging category that the log message is associated with, which supports a dot-delimited hierarchy (eg the logger name).
  • caption - A simple single-line message caption. (Will not be processed for formatting).
  • description - Additional multi-line descriptive message (or may be null) which can be a format string followed by corresponding args.
  • parameters - Optional. A variable number of arguments referenced by the formatted description string (or no arguments to skip formatting).
  • exception - Optional. The error details. This can be a string detailing the exception, an Exception object, or a JavaScript Error object.
  • details - Optional. A JSON object, or string version of, with additional details to be logged and shown in the details in Loupe Desktop and Loupe Server. This is useful for passing context information or state information that could be useful for diagnostics.
  • methodSourceInfo - Optional. Details of the file, method, line and column number. This allows source information to be passed without the performance overhead of working out the current file and line (eg by examining the stack, which may well be different with compressed source, especially if source maps are not being used).

Examples

The first step to using Loupe is to create an instance of the agent, passing in the window and document objects:

Next, set an id for the client session. The id can be any unique number, but we recommend a guid:

If your server project is hosted on a different domain or port, then you'll need to set the target:

Next, start logging:

The description supports C# style string formatting parameters, which should be passed as an array in parameters. For example:

For errors and additional details you can use:

The additional details parameter cab be either a string or a JSON object.

To addition source information you can use the MethodSourceInfo:

For me examples, see the sample project.

Dependencies

  • stacktrace-js for stack trace handling for uncaught window errors.
  • platform for obtaining platform details fo the client

License

This module is licensed under ...