1.2.1 ā€¢ Published 3 years ago

smart-issue-tracker-sdk v1.2.1

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
3 years ago

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

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago