Skip to content

Commit ebfe85c

Browse files
authored
Fix/insight-stream: update insight and stream (#4)
* fix/insight: update insight and stream
1 parent 8496f02 commit ebfe85c

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,17 +179,17 @@ public JsonElement serialize(FlagEvent flagEvent, Type type, JsonSerializationCo
179179
JsonArray array1 = new JsonArray();
180180
for (FlagEventVariation variation : flagEvent.userVariations) {
181181
JsonObject var = new JsonObject();
182-
var.addProperty("featureFlagKeyName", variation.getFeatureFlagKeyName());
182+
var.addProperty("featureFlagKey", variation.getFeatureFlagKeyName());
183183
var.addProperty("sendToExperiment", variation.getVariation().isSendToExperiment());
184184
var.addProperty("timestamp", Instant.now().toEpochMilli());
185185
JsonObject v = new JsonObject();
186-
v.addProperty("localId", variation.getVariation().getIndex());
187-
v.addProperty("variationValue", variation.getVariation().getValue());
186+
v.addProperty("id", variation.getVariation().getIndex());
187+
v.addProperty("value", variation.getVariation().getValue());
188188
v.addProperty("reason", variation.getVariation().getReason());
189189
var.add("variation", v);
190190
array1.add(var);
191191
}
192-
json.add("userVariations", array1);
192+
json.add("variations", array1);
193193
return json;
194194
}
195195
}
@@ -217,7 +217,7 @@ public JsonElement serialize(MetricEvent metricEvent, Type type, JsonSerializati
217217
private static JsonObject serializeUser(FBUser user) {
218218
JsonObject json = new JsonObject();
219219
JsonObject json1 = new JsonObject();
220-
json1.addProperty("userName", user.getUserName());
220+
json1.addProperty("name", user.getUserName());
221221
json1.addProperty("keyId", user.getKey());
222222
JsonArray array = new JsonArray();
223223
for (Map.Entry<String, String> keyItem : user.getCustom().entrySet()) {

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ private Boolean processDateAsync(final DataModel.Data data) {
215215
return opOK;
216216
}
217217

218-
private final class DefaultWebSocketListener extends StreamingWebSocketListener {
218+
final class DefaultWebSocketListener extends StreamingWebSocketListener {
219219
// this callback method may throw a JsonParseException
220220
// if received data is invalid
221221
@Override
@@ -293,8 +293,9 @@ public final void onFailure(@NotNull WebSocket webSocket, @NotNull Throwable t,
293293
boolean isReconn;
294294
String errorType;
295295
Class<? extends Throwable> tClass = t.getClass();
296-
// runtime exception restart except JsonParseException
296+
String message = String.format("%s : %s", tClass.getTypeName(), t.getMessage());
297297
if (t instanceof RuntimeException) {
298+
// runtime exception restart except JsonParseException
298299
isReconn = tClass != JsonParseException.class;
299300
errorType = isReconn ? Status.RUNTIME_ERROR : Status.DATA_INVALID_ERROR;
300301
} else {
@@ -303,12 +304,12 @@ public final void onFailure(@NotNull WebSocket webSocket, @NotNull Throwable t,
303304
errorType = Status.WEBSOCKET_ERROR;
304305
} else if (t instanceof IOException) {
305306
errorType = Status.NETWORK_ERROR;
306-
forceToUseMaxRetryDelay = true;
307307
} else {
308308
errorType = Status.UNKNOWN_ERROR;
309+
forceToUseMaxRetryDelay = true;
309310
}
310311
}
311-
Status.ErrorInfo errorInfo = Status.ErrorInfo.of(errorType, t.getMessage());
312+
Status.ErrorInfo errorInfo = Status.ErrorInfo.of(errorType, message);
312313
if (isReconn) {
313314
logger.warn("FFC JAVA SDK: streaming webSocket will reconnect because of {}", t.getMessage());
314315
updater.updateStatus(Status.StateType.INTERRUPTED, errorInfo);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
public abstract class Utils {
3636

3737
public static Iterable<Map.Entry<String, String>> defaultHeaders(String envSecret) {
38-
return ImmutableMap.of("envSecret", envSecret,
38+
return ImmutableMap.of("Authorization", envSecret,
3939
"User-Agent", "fb-java-server-sdk",
4040
"Content-Type", "application/json")
4141
.entrySet();

src/main/java/co/featbit/server/exterior/BasicConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public final class BasicConfig {
99

1010
private static final String DEFAULT_STREAMING_PATH = "/streaming";
1111

12-
private static final String DEFAULT_EVENT_PATH = "/api/public/track";
12+
private static final String DEFAULT_EVENT_PATH = "/api/public/insight/track";
1313

1414
private final String envSecret;
1515
private final boolean offline;

0 commit comments

Comments
 (0)