Skip to content

Commit 012fb05

Browse files
authored
feat: add DisableEvents property in FBConfig (#23)
1 parent 080bea2 commit 012fb05

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ if (inited) {
172172
`startWaitTime`: how long the constructor will block awaiting a successful data sync. Setting this to a zero or negative
173173
duration will not block and cause the constructor to return immediately.
174174

175-
`offline`: Set whether SDK is offline. when set to true no connection to your feature management platform anymore
175+
`offline`: Set whether SDK is offline. when set to **true** no connection to your feature management platform anymore
176+
177+
`disableEvents`: Set whether disable to send events. when set to **true** no sending any events to your feature management platform
176178

177179
Here is an example of creating a client with default configurations:
178180

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>co.featbit</groupId>
88
<artifactId>featbit-java-sdk</artifactId>
9-
<version>1.4.2</version>
9+
<version>1.4.3</version>
1010

1111
<name>featbit/featbit-java-sdk</name>
1212

src/main/java/co/featbit/server/FBConfig.java

+21-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class FBConfig {
1818

1919
private boolean offline;
2020
private Duration startWaitTime;
21+
private boolean disableEvents;
2122

2223
private String streamingURL;
2324

@@ -59,10 +60,15 @@ public String getEventURL() {
5960
return eventURL;
6061
}
6162

63+
public boolean isDisableEvents() {
64+
return disableEvents;
65+
}
66+
6267
public FBConfig(Builder builder) {
6368
this.offline = builder.offline;
6469
this.streamingURL = builder.streamingURL;
6570
this.eventURL = builder.eventURL;
71+
this.disableEvents = builder.disableEvents;
6672
this.startWaitTime = builder.startWaitTime == null ? DEFAULT_START_WAIT_TIME : builder.startWaitTime;
6773
if (builder.offline) {
6874
Loggers.CLIENT.info("FB JAVA SDK: SDK is in offline mode");
@@ -72,7 +78,7 @@ public FBConfig(Builder builder) {
7278
this.dataSynchronizerFactory =
7379
builder.dataSynchronizerFactory == null ? Factory.dataSynchronizerFactory() : builder.dataSynchronizerFactory;
7480
this.insightProcessorFactory =
75-
builder.insightProcessorFactory == null ? Factory.insightProcessorFactory() : builder.insightProcessorFactory;
81+
builder.insightProcessorFactory == null ? (this.disableEvents ? Factory.externalEventTrack() : Factory.insightProcessorFactory()) : builder.insightProcessorFactory;
7682
}
7783
this.dataStorageFactory =
7884
builder.dataStorageFactory == null ? Factory.inMemoryDataStorageFactory() : builder.dataStorageFactory;
@@ -88,6 +94,7 @@ public FBConfig(Builder builder) {
8894
* .eventURL("your event URI")
8995
* .startWaitTime(Duration.ZERO)
9096
* .offline(false)
97+
* .disableEvents(false)
9198
* .build()
9299
* </code></pre>
93100
*/
@@ -99,6 +106,8 @@ public static class Builder {
99106
private InsightProcessorFactory insightProcessorFactory;
100107
private Duration startWaitTime;
101108
private boolean offline = false;
109+
private boolean disableEvents = false;
110+
102111

103112
private String streamingURL;
104113

@@ -206,6 +215,17 @@ public Builder eventURL(String eventURL) {
206215
return this;
207216
}
208217

218+
/**
219+
* Set whether disable to send events
220+
*
221+
* @param disableEvents
222+
* @return the builder
223+
*/
224+
public Builder disableEvents(boolean disableEvents) {
225+
this.disableEvents = disableEvents;
226+
return this;
227+
}
228+
209229
/**
210230
* Builds the configured {@link FBConfig}
211231
*

0 commit comments

Comments
 (0)