Skip to content

A flexible sdk to track any kind of errors and create automatic issue if found new

License

Notifications You must be signed in to change notification settings

ludorival/smart-issue-tracker-sdk

Repository files navigation

Welcome to smart-issue-tracker-sdk 👋

Version Documentation Maintenance License: BSD--3--Clause

A simple, flexible, light sdk to track any kind of occurrences and create automatic issue if found new.

Demo

Take a look to the demo 👉👉 HERE 👈👈

There are many ways to use this sdk:

  • Use it as a webhook for your data collection in order to create issue for new alerts. For example, from ElasticSearch alert action.
  • Use it to search similar issues from a text input
  • etc.

Install

yarn add -D smart-issue-tracker-sdk

Usage

import { trackIssues } from 'smart-issue-tracker-sdk'
// --- your issue client
class MyIssueClient {
  constructor() {
    this.store = []
  }
  async createIssue(issue) {
    // here you can create the issue related to an untracked error
    const savedIssue = {
      ...issue,
      id: this.store.length.toString(),
      url: 'http://issue-client/newIdIssue',
      body: `Found ${issue.newOccurrences.length} occurences of "${issue.title}"`,
    }
    this.store.push(savedIssue)
    return this.store[this.store.length - 1]
  }
  async updateIssue(error) {
    // here you can update the issue for example add a new comment for new occurences
    const comments = [
      ...error.comments,
      `Found new ${error.newOccurrences.length} occurences of ${error.title}`,
    ]
    return { ...error, comments }
  }
  async fetchIssues() {
    return this.store
  }
}
// Your custom comparator
const compareOccurrence = (a, b) => a.message.localeCompare(b.message)
// use it
const errors = [
  { message: 'Error when create the checkout', timestamp: 1 },
  { message: 'Error When Create The Checkout', timestamp: 2 },
  { message: 'Null Pointer Exception on payment page', timestamp: 3 },
  { message: 'cannot call login on undefined', timestamp: 4 },
  { message: 'Null Pointer Exception on payment page', timestamp: 5 },
]
trackIssues(errors, {
  issueClient: new MyIssueClient(),
  hooks: {
    getIdentifier: (occurrence) => occurrence.timestamp, // to avoid adding same occurrence
    compareOccurrence,
  },
}).then((trackedErrors) => console.log(trackedErrors))
// should return
// - "Error when create the checkout" (occurrences : 2)
// - "Null Pointer Exception on payment page" (occurrences : 2)
// - "cannot call login on undefined" (occurences : 1)

Usage in Typescript

Take a look to the typescript version

Author

👤 Ludovic Dorival

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2021 Ludovic Dorival.
This project is BSD--3--Clause licensed.

Contributing

We welcome community contributions and pull requests. See CONTRIBUTING.md for information on how to set up a development environment and submit code.

This README was generated with ❤️ by readme-md-generator

About

A flexible sdk to track any kind of errors and create automatic issue if found new

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •