Open2

20210625-My Updates: Sentry, Vue

otokunaga2otokunaga2

Sentry

アプリケーションモニタリングとエラートラッキングができるプラットフォームSentryを知った。
goとJavaScriptのSDKが豊富な印象だが、それ以外の言語もサポートしている。
Goでログをモニタリングするためには以下のようなコードを書けばよい。→とても手軽。

package main

import (
	"log"
	"time"
	"os"
	"fmt"
	"github.com/getsentry/sentry-go"
	"github.com/joho/godotenv"
)

func main() {
	err := godotenv.Load(fmt.Sprintf("./%s.env", os.Getenv("GO_ENV")))
        if err != nil {
               // .env読めなかった場合の処理
		log.Fatal("error caused when read .env", err)
        }
	dsn := os.Getenv("DSN")
	log.Print("Here",dsn)
	err2 := sentry.Init(sentry.ClientOptions{
		Dsn: dsn,
	})
	if err2 != nil {
		log.Fatalf("sentry.Init: %s", err2)
	}
	// Flush buffered events before the program terminates.
	defer sentry.Flush(2 * time.Second)

	sentry.CaptureMessage("It works!")
}

Vue

New York timesの提供しているAPIを利用して、Vueで記事を表示するサンプル
最初にいじるプログラムとしてはコンパクトなので良い気がする。 [1]
New York timesのAPIは公式サイトから発行する必要あり[2]:
https://github.com/sitepoint-editors/vuejs-news

Vue-element-admin

il18nに対応しているVue製のライブラリ。
多機能であり、権限設定によるページの表示・非表示なども実装できる。
https://github.com/PanJiaChen/vue-element-admin
また以下のサイトは、Vue-element-adminを利用したシンプルな例を提供している。
https://github.com/PanJiaChen/vue-admin-template

Reference

脚注
  1. APIキーをフロント側で保持しているので、そのまま公開したりしないように注意が必要 ↩︎

  2. https://developer.nytimes.com/ にてAPIキーが発行できる。New York Times社はAPIをいくつか提供しているので、用途に沿って登録するようになっている。 ↩︎