package com.quantgroup.asset.distribution.config.sentry;

import cn.quantgroup.tech.util.TechEnvironment;
import io.sentry.Sentry;
import io.sentry.spring.SentryServletContextInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerExceptionResolver;

import javax.annotation.PostConstruct;

@Configuration
public class SentryConfig {

    @Bean
    public HandlerExceptionResolver sentryExceptionResolver() {
        return new CustomSentryExceptionResolver();
    }

    @Bean
    public SentryServletContextInitializer sentryServletContextInitializer() {
        return new io.sentry.spring.SentryServletContextInitializer();
    }

    @PostConstruct
    public void initSentry() {
        // if (TechEnvironment.isPro()) {
        // }
        Sentry.init("http://a2d2ecc94b1d421cac7c2ea2abe2f34a:d1ea101bb7d046888e6e8150da152dad@sentry.quantgroups.com/77");
    }
}