Giter Club home page Giter Club logo

logs-js's Introduction

JavaScript client for Apex Logs with support for Node.js, Deno, and the browser.

Installation

npm install --save apex-logs

Node

Here's an example of usage in Node or the browser using the apex-logs NPM package:

const { Client } = require('apex-logs')

const client = new Client({
  url: '<ENDPOINT>',
  authToken: '<TOKEN>'
})

async function run() {
  const { projects } = await client.getProjects()
  console.log(projects)
  
  const { alerts } = await client.getAlerts({ projectId: 'production' })
  console.log(alerts)
}

run()

Deno

Here's an example of usage in Deno:

import { Client } from 'https://deno.land/x/apex_logs/client.ts'

const client = new Client({
  url: '<ENDPOINT>',
  authToken: '<TOKEN>'
})

const { projects } = await client.getProjects()
console.log(projects)

const { alerts } = await client.getAlerts({ projectId: 'ping_production' })
console.log(alerts)

Resources

To learn more about Apex Logs visit the documentation, and to contribute to this client visit the github.com/apex/rpc project which is used to generate this client.

logs-js's People

Contributors

tj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

seanpm2001

logs-js's Issues

Adding option "snapshot" to an event

Heya 👋,

Working with the JS client on both the server and client and loving it so far.

Would it be possible to add some sort of "snapshot" field to to the event type which isn't indexed/searchable?

Essentially it would be nice to catch a snapshot of an HTTP request when it fails, or the response from a USB device etc... currently I am adding this data to the fields key and it does work, however it really muddies the fields column on the right hand side.

400 when using client

Hi, I can manually curl my api endpoint...

http POST https://logs-xxxxxx-xx.a.run.app/add_events authorization:"Bearer xxxxx" events:='[{"message":"ioooooo","fields":{"lollai":"assai"},"level":"info"}]' project_id="test"

...but I can't get the client to work:

const { Client } = require('apex-logs')

const client = new Client({
  url: 'https://logs-xxxxx-xxxx.a.run.app/',
  authToken: '----'
})

async function run() {
  while (true) {
    await client.addEvents([{message: "hello"}], 'test')
    await new Promise((resolve, reject) => setTimeout(resolve, 1000))
  }
}

run().catch((err) => {
  console.error(err)
  throw err
})
internal/process/promises.js:213
        triggerUncaughtException(err, true /* fromPromise */);
        ^

ClientError: Failed to parse malformed JSON body
    at /.../logs/node_modules/apex-logs/dist/client.js:49:23
    at Generator.next (<anonymous>)
    at fulfilled (/.../logs/node_modules/apex-logs/dist/client.js:5:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  status: 400,
  type: 'bad_request'

Cannot copy id to clipboard

When I click on id and choose "Copy to clipboard" I get "undefined" copied instead of id value.

It does work for all the other fields. For id it shows "Copied to clipboard" toast but doesn't copy the value.

Should we migrate away?

We love apex and want to stick with it but have been running up against issues. I've outlined them below, please let me know if you think Apex is the right solution for us at the moment or if it makes sense for us to migrate away from it.

Background
Our product is a browser extension that executes on web pages we don't control. Consequently, we log relatively large payloads to get a better idea of what was happening in the browser when the log was issued.

Problems we've faced
We initially saw exceptions thrown when our message strings exceeded the limit in structured data mode (#4 - thanks for your help with that). We created a new project in plain-text mode, and now the apex web interfaces freezes often. We often have to refresh the page to several times before a query produces data. We were also billed for $488 in charges last month for "BigQuery Analysis" (see screenshot below). This doesn't seem expected.

Conclusion
Given our use case, is it possible to run apex at low cost and with good performance?

Thanks in advance!

======================================================

BigQuery Analysis

Insertions fail when key too long

Hey there, seeing this error quite frequently:

Clustering encountered a key Msg_0_CLOUD_QUERY_TABLE.message that is 2115 
bytes long, which is more than the maximum allowed length of 1024 bytes.

I have an example request that's failing, but it's long and contains some potentially sensitive information that I don't trust myself to remove so I can send it privately.

Thanks!

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.