Files
Stirling-PDF/src/main/java/stirling/software/SPDF/config/PostHogConfig.java
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
977 B
Java
Raw Normal View History

2024-10-14 22:34:41 +01:00
package stirling.software.SPDF.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.posthog.java.PostHog;
import jakarta.annotation.PreDestroy;
2025-01-30 15:13:42 +00:00
import lombok.extern.slf4j.Slf4j;
2024-10-14 22:34:41 +01:00
@Configuration
2025-01-30 15:13:42 +00:00
@Slf4j
2024-10-14 22:34:41 +01:00
public class PostHogConfig {
@Value("${posthog.api.key}")
private String posthogApiKey;
@Value("${posthog.host}")
private String posthogHost;
private PostHog postHogClient;
@Bean
public PostHog postHogClient() {
2025-01-30 15:13:42 +00:00
postHogClient =
new PostHog.Builder(posthogApiKey)
.host(posthogHost)
.logger(new PostHogLoggerImpl())
.build();
2024-10-14 22:34:41 +01:00
return postHogClient;
}
@PreDestroy
public void shutdownPostHog() {
if (postHogClient != null) {
postHogClient.shutdown();
}
}
}