Skip to content

Commit 9de17ae

Browse files
Abhi591rohitesh-wingify
authored andcommitted
added: enhanced logging and fix for error reading pom.xml
1 parent 3d670da commit 9de17ae

File tree

12 files changed

+528
-159
lines changed

12 files changed

+528
-159
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.11.0] - 2025-08-16
9+
10+
### Added
11+
- Added support for sending error logs to VWO server for better debugging.
12+
13+
### Fixed
14+
- Fixed an issue where SDK version was not being read correctly from pom.xml file.
15+
816
## [1.10.0] - 2025-08-04
917

1018
### Added

pom.xml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ limitations under the License. -->
1919

2020
<groupId>com.vwo.sdk</groupId>
2121
<artifactId>vwo-fme-java-sdk</artifactId>
22-
<version>1.10.0</version>
22+
<version>1.11.0</version>
2323
<packaging>jar</packaging>
2424

2525
<name>VWO FME Java SDK</name>
@@ -60,12 +60,14 @@ limitations under the License. -->
6060
<id>release</id>
6161
<distributionManagement>
6262
<snapshotRepository>
63-
<id>ossrh</id>
64-
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
63+
<id>central</id>
64+
<!-- url>https://oss.sonatype.org/content/repositories/snapshots</url -->
65+
<!-- url>https://central.sonatype.com/api/v1/publisher/upload</url -->
6566
</snapshotRepository>
6667
<repository>
67-
<id>ossrh</id>
68-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
68+
<id>central</id>
69+
<!-- url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url -->
70+
<!-- url>https://central.sonatype.com/api/v1/publisher/upload</url -->
6971
</repository>
7072
</distributionManagement>
7173
<build>
@@ -122,7 +124,7 @@ limitations under the License. -->
122124
</execution>
123125
</executions>
124126
</plugin>
125-
<plugin>
127+
<!-- plugin>
126128
<groupId>org.sonatype.plugins</groupId>
127129
<artifactId>nexus-staging-maven-plugin</artifactId>
128130
<version>1.6.13</version>
@@ -132,22 +134,31 @@ limitations under the License. -->
132134
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
133135
<autoReleaseAfterClose>true</autoReleaseAfterClose>
134136
</configuration>
137+
</plugin -->
138+
<plugin>
139+
<groupId>org.sonatype.central</groupId>
140+
<artifactId>central-publishing-maven-plugin</artifactId>
141+
<version>0.8.0</version>
142+
<extensions>true</extensions>
143+
<configuration>
144+
<publishingServerId>central</publishingServerId>
145+
</configuration>
135146
</plugin>
136147
</plugins>
137148
</build>
138149
</profile>
139150
</profiles>
140151

141-
<distributionManagement>
152+
<!-- distributionManagement>
142153
<snapshotRepository>
143-
<id>ossrh</id>
144-
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
154+
<id>central</id>
155+
<url>https://central.sonatype.com/api/v1/publisher/upload</url>
145156
</snapshotRepository>
146157
<repository>
147-
<id>ossrh</id>
148-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
158+
<id>central</id>
159+
<url>https://central.sonatype.com/api/v1/publisher/upload</url>
149160
</repository>
150-
</distributionManagement>
161+
</distributionManagement -->
151162

152163
<build>
153164
<plugins>

src/main/java/com/vwo/VWOBuilder.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ public String fetchSettings(Boolean forceFetch) {
125125
LoggerService.log(LogLevelEnum.ERROR, "SETTINGS_FETCH_ERROR", new HashMap<String, String>() {
126126
{
127127
put("err", e.toString());
128+
put("accountId", options.getAccountId().toString());
129+
put("sdkKey", options.getSdkKey());
128130
}
129131
});
130132
// Clear the flag to indicate that the fetch operation is complete
@@ -277,12 +279,14 @@ private void checkAndPoll() {
277279
JsonNode latestSettingJsonNode = VWOClient.objectMapper.readTree(latestSettings);
278280
JsonNode originalSettingsJsonNode = VWOClient.objectMapper.readTree(originalSettings);
279281
if (!latestSettingJsonNode.equals(originalSettingsJsonNode)) {
280-
originalSettings = latestSettings;
281282
LoggerService.log(LogLevelEnum.INFO, "POLLING_SET_SETTINGS", null);
282283
// Update VWOClient settings
283284
if (vwoClient != null) {
284-
vwoClient.updateSettings(originalSettings);
285-
updatePollIntervalAndCheckAndPoll(latestSettings, false);
285+
String updatedSettings = vwoClient.updateSettings(latestSettings);
286+
if (updatedSettings != null) {
287+
originalSettings = latestSettings;
288+
updatePollIntervalAndCheckAndPoll(originalSettings, false);
289+
}
286290
}
287291
} else {
288292
LoggerService.log(LogLevelEnum.INFO, "POLLING_NO_CHANGE_IN_SETTINGS", null);

src/main/java/com/vwo/VWOClient.java

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import com.vwo.services.LoggerService;
3131
import com.vwo.services.UrlService;
3232
import com.vwo.utils.DataTypeUtil;
33-
import com.vwo.utils.SDKMetaUtil;
3433
import com.vwo.utils.SettingsUtil;
3534
import com.vwo.services.BatchEventQueue;
3635
import com.vwo.services.SettingsManager;
@@ -60,8 +59,6 @@ public VWOClient(String settings, VWOInitOptions options) {
6059
SettingsUtil.processSettings(this.processedSettings);
6160
// init url version with collection prefix
6261
UrlService.init(this.processedSettings.getCollectionPrefix());
63-
// init SDKMetaUtil and set sdkVersion
64-
SDKMetaUtil.init();
6562
LoggerService.log(LogLevelEnum.INFO, "CLIENT_INITIALIZED", null);
6663
} catch (Exception exception) {
6764
LoggerService.log(LogLevelEnum.ERROR, "exception occurred while parsing settings " + exception.getMessage());
@@ -101,8 +98,7 @@ public GetFlag getFlag(String featureKey, VWOContext context) {
10198
throw new IllegalArgumentException("Feature Key is required");
10299
}
103100

104-
if (this.processedSettings == null || !new SettingsSchema().isSettingsValid(this.processedSettings)) {
105-
LoggerService.log(LogLevelEnum.ERROR, "SETTINGS_SCHEMA_INVALID", null);
101+
if (!validateSettings(this.processedSettings)) {
106102
getFlag.setIsEnabled(false);
107103
return getFlag;
108104
}
@@ -111,7 +107,7 @@ public GetFlag getFlag(String featureKey, VWOContext context) {
111107
} catch (Exception exception) {
112108
LoggerService.log(LogLevelEnum.ERROR, "API_THROW_ERROR", new HashMap<String, String>() {{
113109
put("apiName", "getFlag");
114-
put("err", exception.toString());
110+
put("err", exception.getMessage());
115111
}});
116112
getFlag.setIsEnabled(false);
117113
return getFlag;
@@ -147,8 +143,7 @@ private Map<String, Boolean> track(String eventName, VWOContext context, Map<Str
147143
throw new IllegalArgumentException("User ID is required");
148144
}
149145

150-
if (this.processedSettings == null || !new SettingsSchema().isSettingsValid(this.processedSettings)) {
151-
LoggerService.log(LogLevelEnum.ERROR, "SETTINGS_SCHEMA_INVALID", null);
146+
if (!validateSettings(this.processedSettings)) {
152147
resultMap.put(eventName, false);
153148
return resultMap;
154149
}
@@ -163,7 +158,7 @@ private Map<String, Boolean> track(String eventName, VWOContext context, Map<Str
163158
} catch (Exception exception) {
164159
LoggerService.log(LogLevelEnum.ERROR, "API_THROW_ERROR", new HashMap<String, String>() {{
165160
put("apiName", apiName);
166-
put("err", exception.toString());
161+
put("err", exception.getMessage());
167162
}});
168163
resultMap.put(eventName, false);
169164
return resultMap;
@@ -228,16 +223,15 @@ public void setAttribute(Map<String, Object> attributeMap, VWOContext context) {
228223
throw new IllegalArgumentException("User ID is required");
229224
}
230225

231-
if (this.processedSettings == null || !new SettingsSchema().isSettingsValid(this.processedSettings)) {
232-
LoggerService.log(LogLevelEnum.ERROR, "SETTINGS_SCHEMA_INVALID", null);
226+
if (!validateSettings(this.processedSettings)) {
233227
return;
234228
}
235229

236230
SetAttributeAPI.setAttribute(this.processedSettings, attributeMap, context);
237231
} catch (Exception exception) {
238232
LoggerService.log(LogLevelEnum.ERROR, "API_THROW_ERROR", new HashMap<String, String>() {{
239233
put("apiName", apiName);
240-
put("err", exception.toString());
234+
put("err", exception.getMessage());
241235
}});
242236
}
243237
}
@@ -287,15 +281,16 @@ private void updateSettingsOnVWOClient(String newSettings) {
287281
throw new IllegalArgumentException("Settings cannot be empty");
288282
}
289283
// Read the new settings and update the processedSettings
290-
this.processedSettings = objectMapper.readValue(newSettings, Settings.class);
291-
284+
Settings newProcessedSettings = objectMapper.readValue(newSettings, Settings.class);
292285
// Check if the new settings are valid
293-
boolean settingsValid = new SettingsSchema().isSettingsValid(this.processedSettings);
294-
if (settingsValid) {
286+
SettingsSchema validationResult = new SettingsSchema().validateSettings(newProcessedSettings);
287+
if (validationResult.isValid()) {
288+
this.processedSettings = newProcessedSettings;
289+
settings = newSettings;
295290
// Process the new settings and update the client instance
296291
SettingsUtil.processSettings(this.processedSettings);
297292
} else {
298-
throw new IllegalStateException("Settings schema is invalid");
293+
throw new IllegalStateException("Settings schema is invalid: " + validationResult.getErrorsAsString());
299294
}
300295
} catch (Exception exception) {
301296
throw new IllegalStateException(exception.getMessage());
@@ -314,6 +309,7 @@ public String updateSettings() {
314309
* @param settings New settings to be updated
315310
*/
316311
public String updateSettings(String settings) {
312+
Boolean isViaWebhook = false;
317313
String apiName = "updateSettings";
318314
try {
319315
LoggerService.log(LogLevelEnum.DEBUG, "API_CALLED", new HashMap<String, String>() {{
@@ -322,7 +318,8 @@ public String updateSettings(String settings) {
322318

323319
String settingsToUpdate = settings;
324320
if (settings == null || settings.isEmpty()) {
325-
settingsToUpdate = this.updateSettings(true);
321+
isViaWebhook = true;
322+
settingsToUpdate = this.updateSettings(isViaWebhook);
326323
}
327324
// Update the settings on the VWOClient instance
328325
this.updateSettingsOnVWOClient(settingsToUpdate);
@@ -331,9 +328,11 @@ public String updateSettings(String settings) {
331328
}});
332329
return settingsToUpdate;
333330
} catch (Exception exception) {
331+
Boolean finalIsViaWebhook = isViaWebhook;
334332
LoggerService.log(LogLevelEnum.ERROR, "SETTINGS_FETCH_FAILED", new HashMap<String, String>() {{
335333
put("apiName", apiName);
336-
put("err", exception.toString());
334+
put("err", exception.getMessage());
335+
put("isViaWebhook", finalIsViaWebhook.toString());
337336
}});
338337
return null;
339338
}
@@ -353,9 +352,48 @@ public String updateSettings(Boolean isViaWebhook) {
353352
LoggerService.log(LogLevelEnum.ERROR, "SETTINGS_FETCH_FAILED", new HashMap<String, String>() {{
354353
put("apiName", apiName);
355354
put("isViaWebhook", isViaWebhook.toString());
356-
put("err", exception.toString());
355+
put("err", exception.getMessage());
357356
}});
358357
return null;
359358
}
360359
}
361-
}
360+
361+
362+
/**
363+
* This method is used to validate the settings
364+
* @param settings Settings to be validated
365+
* @return Boolean value indicating if the settings are valid
366+
*/
367+
private Boolean validateSettings(Settings processedSettings) {
368+
try {
369+
if (processedSettings == null) {
370+
LoggerService.log(LogLevelEnum.ERROR, "SETTINGS_SCHEMA_INVALID", new HashMap<String, String>() {{
371+
put("errors", "Settings object is null");
372+
put("accountId", options.getAccountId().toString());
373+
put("sdkKey", options.getSdkKey());
374+
put("settings", "null");
375+
}});
376+
return false;
377+
}
378+
SettingsSchema validationResult = new SettingsSchema().validateSettings(processedSettings);
379+
if (!validationResult.isValid()) {
380+
LoggerService.log(LogLevelEnum.ERROR, "SETTINGS_SCHEMA_INVALID", new HashMap<String, String>() {{
381+
put("errors", validationResult.getErrorsAsString());
382+
put("accountId", options.getAccountId().toString());
383+
put("sdkKey", options.getSdkKey());
384+
put("settings", settings);
385+
}});
386+
return false;
387+
}
388+
return true;
389+
} catch (Exception exception) {
390+
LoggerService.log(LogLevelEnum.ERROR, "SETTINGS_SCHEMA_INVALID", new HashMap<String, String>() {{
391+
put("errors", exception.getMessage());
392+
put("accountId", options.getAccountId().toString());
393+
put("sdkKey", options.getSdkKey());
394+
put("settings", settings);
395+
}});
396+
return false;
397+
}
398+
}
399+
}

src/main/java/com/vwo/constants/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class Constants {
2828
public static final int DEFAULT_REQUEST_TIME_INTERVAL = 600; // 10 * 60(secs) = 600 secs i.e. 10 minutes
2929
public static final int DEFAULT_EVENTS_PER_REQUEST = 100;
3030
public static final String SDK_NAME = "vwo-fme-java-sdk";
31-
public static final String SDK_VERSION = "1.10.0";
31+
public static final String SDK_VERSION = "1.11.0";
3232
public static final long SETTINGS_EXPIRY = 10000000;
3333
public static final long SETTINGS_TIMEOUT = 50000;
3434

0 commit comments

Comments
 (0)