File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
analytics-spring-boot-starter/src/main/java/com/segment/analytics/autoconfigure Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 11package com .segment .analytics .autoconfigure ;
22
33import com .segment .analytics .Analytics ;
4+ import org .springframework .beans .factory .ObjectProvider ;
45import org .springframework .beans .factory .annotation .Autowired ;
56import org .springframework .boot .autoconfigure .condition .ConditionalOnProperty ;
67import org .springframework .boot .context .properties .EnableConfigurationProperties ;
@@ -20,7 +21,9 @@ public class SegmentAnalyticsAutoConfiguration {
2021 @ Autowired private SegmentProperties properties ;
2122
2223 @ Bean
23- public Analytics segmentAnalytics () {
24- return Analytics .builder (properties .getWriteKey ()).build ();
24+ public Analytics segmentAnalytics (ObjectProvider <SegmentAnalyticsCustomizer > customizerProvider ) {
25+ Analytics .Builder builder = Analytics .builder (properties .getWriteKey ());
26+ customizerProvider .orderedStream ().forEach ((customizer ) -> customizer .customize (builder ));
27+ return builder .build ();
2528 }
2629}
Original file line number Diff line number Diff line change 1+ package com .segment .analytics .autoconfigure ;
2+
3+ import com .segment .analytics .Analytics ;
4+
5+ /**
6+ * Callback interface that can be used to customize a {@link com.segment.analytics.Analytics.Builder
7+ * Analytics.Builder}.
8+ *
9+ * @author Koen Punt
10+ */
11+ @ FunctionalInterface
12+ public interface SegmentAnalyticsCustomizer {
13+
14+ /**
15+ * Callback to customize a {@link com.segment.analytics.Analytics.Builder Analytics.Builder}
16+ * instance.
17+ *
18+ * @param analyticsBuilder the analytics builder to customize
19+ */
20+ void customize (Analytics .Builder analyticsBuilder );
21+ }
You can’t perform that action at this time.
0 commit comments