Giter Site home page Giter Site logo

treblle / treblle-node Goto Github PK

View Code? Open in Web Editor NEW
36.0 8.0 3.0 61 KB

The official Treblle SDK for NodeJS/ExpressJS/NestJS. Seamlessly integrate Treblle to manage communication with your dashboard, send errors, and secure sensitive data.

Home Page: https://www.treblle.com/

License: MIT License

JavaScript 100.00%
nodejs api api-monitoring api-observability backend developer-tool express expressjs-api logging nodejs-expressjs

treblle-node's Issues

NestJS - When accessing a blacklistPaths path it throws error if there is a global filter

Expected result

When I use the blacklist key and a global filter, it does not throw any errors.

Description

When I try to access the path of the blacklist, I get the following error:

Error: Cannot set headers after they are sent to the client

This is my code:

// main.ts

const httpAdapterHost = app.get(HttpAdapterHost)
app.useGlobalFilters(new AllErrorsFilter(httpAdapterHost))

const constants = app.get(ConstantsService)
const expressInstance = app.getHttpAdapter().getInstance()

useNestTreblle(expressInstance, {
  apiKey: constants.TREBLLE_API_KEY,
  projectId: constants.TREBLLE_PROJECT_ID,
  blacklistPaths: ['v1/health']
})

But when I remove the global filter, the blacklist does work.

Info Version
Node v20.11.1
@nestjs/core v10.3.8
treblle v1.4.3
OS macOS 14.5

Hi Team, getting this issue while trying to integrate my node api with Treblle. Need help

This is a simple Typescript API but, Treblle is failing to handle the request.

[error] Sending data to Treblle failed (it's possibly a network error) TypeError: function () {
let value = container[varName]

  log(`will be read from the environment using "${accessor.name}" accessor`)

  if (typeof value === 'undefined') {
    if (typeof defValue === 'undefined' && isRequired) {
      log('was not found in the environment, but is required to be set')
      // Var is not set, nor is a default. Throw an error
      raiseError(undefined, 'is a required variable, but it was not set')
    } else if (typeof defValue !== 'undefined') {
      log(`was not found in the environment, parsing default value "${defValue}" instead`)
      value = defValue
    } else {
      log('was not found in the environment, but is not required. returning undefined')
      // return undefined since variable is not required and
      // there's no default value provided
      return undefined
    }
  }

  if (isRequired) {
    log('verifying variable value is not an empty string')
    // Need to verify that required variables aren't just whitespace
    if (value.trim().length === 0) {
      raiseError(undefined, 'is a required variable, but its value was empty')
    }
  }

  if (isBase64) {
    log('verifying variable is a valid base64 string')
    if (!value.match(base64Regex)) {
      raiseError(value, 'should be a valid base64 string if using convertFromBase64')
    }
    log('converting from base64 to utf8 string')
    value = Buffer.from(value, 'base64').toString()
  }

  const args = [value].concat(Array.prototype.slice.call(arguments))

  try {
    log(`passing value "${value}" to "${accessor.name}" accessor`)

    const result = accessor.apply(
      accessor,
      args
    )

    log(`parsed successfully, returning ${result}`)
    return result
  } catch (error) {
    raiseError(value, error.message)
  }
} is not a legal HTTP header value

"Sending data to Treblle failed"

i followed the dashboard's instructions to implement treblle in my api but on every call i get this error message in the console
[error] Sending data to Treblle failed - status: Forbidden (403) { message: 'Forbidden' }

Here is how i implemented treblle

const app = express();

app.use(json());

app.use(cors());
app.use(urlencoded({ extended: true }));

useTreblle(app, {
  apiKey: process.env.TREBLLE_API_KEY,
  projectId: process.env.TREBLLE_PROJECT_ID,
});

and here are my dependencies

  "dependencies": {
    "@types/node-cron": "^3.0.1",
    "axios": "^0.27.2",
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "csv-parser": "^3.0.0",
    "date-fns": "^2.28.0",
    "express": "^4.17.1",
    "express-async-errors": "^3.1.1",
    "express-validator": "^6.13.0",
    "jsonwebtoken": "^8.5.1",
    "mongoose": "^6.0.14",
    "multer": "^1.4.3",
    "node-cron": "^3.0.0",
    "nodemailer": "^6.7.4",
    "treblle": "^1.2.0"
  }

my first thought was that i've setup my envs wrong but they seem to be correct, how can i fix it?

integration with next js api routes

Hey there, is there anyway of implementing useTreblle for nextjs api routes? It's quite coupled to be used with express but is there a way to make it in middleware's fashion of some sorts?

Thank you for the amazing library

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.