forked from segmentio/analytics-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSegmentAnalyticsAutoConfiguration.java
More file actions
29 lines (25 loc) · 1.1 KB
/
SegmentAnalyticsAutoConfiguration.java
File metadata and controls
29 lines (25 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.segment.analytics.autoconfigure;
import com.segment.analytics.Analytics;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* Spring Boot autoconfiguration class for Segment Analytics.
*
* @author Christopher Smith
*/
@Configuration
@EnableConfigurationProperties(SegmentProperties.class)
@ConditionalOnProperty("segment.analytics.writeKey")
public class SegmentAnalyticsAutoConfiguration {
@Autowired private SegmentProperties properties;
@Bean
public Analytics segmentAnalytics(ObjectProvider<SegmentAnalyticsCustomizer> customizerProvider) {
Analytics.Builder builder = Analytics.builder(properties.getWriteKey());
customizerProvider.orderedStream().forEach((customizer) -> customizer.customize(builder));
return builder.build();
}
}