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 2
2
3
3
import com .segment .analytics .Analytics ;
4
4
import org .springframework .beans .factory .annotation .Autowired ;
5
+ import org .springframework .beans .factory .ObjectProvider ;
5
6
import org .springframework .boot .autoconfigure .condition .ConditionalOnProperty ;
6
7
import org .springframework .boot .context .properties .EnableConfigurationProperties ;
7
8
import org .springframework .context .annotation .Bean ;
@@ -20,7 +21,9 @@ public class SegmentAnalyticsAutoConfiguration {
20
21
@ Autowired private SegmentProperties properties ;
21
22
22
23
@ 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 ();
25
28
}
26
29
}
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
7
+ * {@link com.segment.analytics.Analytics.Builder Analytics.Builder}.
8
+ *
9
+ * @author Koen Punt
10
+ */
11
+ @ FunctionalInterface
12
+ public interface SegmentAnalyticsCustomizer {
13
+
14
+ /**
15
+ * Callback to customize a
16
+ * {@link com.segment.analytics.Analytics.Builder Analytics.Builder} instance.
17
+ * @param analyticsBuilder the analytics builder to customize
18
+ */
19
+ void customize (Analytics .Builder analyticsBuilder );
20
+
21
+ }
You can’t perform that action at this time.
0 commit comments