Skip to content

Commit 536bb84

Browse files
Abhi591rohitesh-wingify
authored andcommitted
feat: proxy URL
1 parent a6ad7ba commit 536bb84

16 files changed

Lines changed: 148 additions & 75 deletions

File tree

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ 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.16.0] - 2026-01-15
9+
10+
- Added support for redirecting all network calls through a custom proxy URL. This feature allows users to route all SDK network requests (settings, tracking, etc.) through their own proxy server.
11+
12+
```java
13+
VWOInitOptions vwoInitOptions = new VWOInitOptions();
14+
15+
vwoInitOptions.setSdkKey("32-alpha-numeric-sdk-key");
16+
vwoInitOptions.setAccountId(123456);
17+
vwoInitOptions.setProxyUrl("http://custom.proxy.com");
18+
19+
// set aliasing flag in vwoInitOptions
20+
vwoInitOptions.setIsAliasingEnabled(true);
21+
VWO instance = VWO.init(vwoInitOptions);
22+
```
23+
824
## [1.15.0] - 2025-12-08
925
### Added
1026

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ To customize the SDK further, additional parameters can be passed to the `init()
9191
| `setLogger` | Toggle log levels for more insights or for debugging purposes. You can also customize your own transport in order to have better control over log messages. | No | Object | See [Logger](#logger) section |
9292
| `setIntegrations` | Callback function for integrating with third-party analytics services. | No | Function | See [Integrations](#integrations) section |
9393
| `setIsAliasingEnabled` | Enable user aliasing functionality. Requires gateway service to be configured. | No | Boolean | see [UserAliasing](#UserAliasing) section |
94+
| `setProxyUrl` | Custom proxy URL for redirecting all SDK network requests (settings, tracking, etc.) through your own proxy server. | No | String | see [Proxy](#proxy) section |
9495

9596
Refer to the [official VWO documentation](https://developers.vwo.com/v2/docs/fme-java-install) for additional parameter details.
9697

@@ -206,6 +207,20 @@ vwoInitOptions.setPollInterval(60000); // Set the poll interval to 60 seconds
206207
VWO vwoInstance = VWO.init(vwoInitOptions);
207208
```
208209

210+
### Proxy
211+
212+
The `setProxyUrl` parameter allows you to redirect all SDK network calls through a custom proxy URL. This feature enables you to route all SDK network requests (settings, tracking, etc.) through your own proxy server, providing better control over network traffic and security.
213+
214+
```java
215+
VWOInitOptions vwoInitOptions = new VWOInitOptions();
216+
217+
vwoInitOptions.setSdkKey("32-alpha-numeric-sdk-key");
218+
vwoInitOptions.setAccountId(123456);
219+
vwoInitOptions.setProxyUrl("http://custom.proxy.com");
220+
221+
VWO instance = VWO.init(vwoInitOptions);
222+
```
223+
209224
### Gateway
210225

211226
The VWO FME Gateway Service is an optional but powerful component that enhances VWO's Feature Management and Experimentation (FME) SDKs. It acts as a critical intermediary for pre-segmentation capabilities based on user location and user agent (UA). By deploying this service within your infrastructure, you benefit from minimal latency and strengthened security for all FME operations.

pom.xml

Lines changed: 1 addition & 1 deletion
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.15.0</version>
22+
<version>1.16.0</version>
2323
<packaging>jar</packaging>
2424

2525
<name>VWO FME Java SDK</name>

src/main/java/com/vwo/ServiceContainer.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,16 @@ public Settings getSettings() {
117117
}
118118

119119
/**
120-
* Returns the base URL for the API requests
120+
* Returns the endpoint with the collection prefix
121+
* @param endpoint The endpoint to return
122+
* @return The endpoint with the collection prefix
121123
*/
122-
public String getBaseUrl() {
123-
String baseUrl = this.settingsManager.hostname;
124-
125-
if (this.settingsManager.isGatewayServiceProvided) {
126-
return baseUrl;
127-
}
128-
129-
if (this.settings.getCollectionPrefix() != null && !this.settings.getCollectionPrefix().isEmpty()) {
130-
return baseUrl + "/" + this.settings.getCollectionPrefix();
124+
public String getEndpointWithCollectionPrefix(String endpoint) {
125+
if (this.settingsManager.collectionPrefix != null && !this.settingsManager.collectionPrefix.isEmpty()) {
126+
return "/" + this.settingsManager.collectionPrefix + "/" + endpoint;
131127
}
132128

133-
return baseUrl;
129+
return endpoint;
134130
}
135131

136132
/**

src/main/java/com/vwo/VWO.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,17 @@ private static VWO setInstance(VWOInitOptions options) {
6666

6767
public static VWO init(VWOInitOptions options) {
6868
if (options == null || options.getSdkKey() == null || options.getSdkKey().isEmpty()) {
69-
String message = LogMessageUtil.buildMessage(LoggerService.errorMessages.get("INVALID_SDK_KEY_IN_OPTIONS"), null);
69+
String message = "[ERROR]: VWO-SDK Please provide the sdkKey in the options and should be a of type string";
7070
System.err.println(message);
7171
}
7272

7373
if (options == null || options.getAccountId() == null || options.getAccountId().toString().isEmpty()) {
74-
String message = LogMessageUtil.buildMessage(LoggerService.errorMessages.get("INVALID_ACCOUNT_ID_IN_OPTIONS"), null);
74+
String message = "[ERROR]: VWO-SDK Please provide VWO account ID in the options and should be a of type string|number";
7575
System.err.println(message);
7676
}
7777

78-
if (options.getIsAliasingEnabled() && (options.getGatewayService() == null || options.getGatewayService().isEmpty())) {
79-
String message = LogMessageUtil.buildMessage(LoggerService.errorMessages.get("INVALID_GATEWAY_SERVICE_WHEN_ALIASING_ENABLED"), null);
78+
if (options == null ||options.getIsAliasingEnabled() && (options.getGatewayService() == null || options.getGatewayService().isEmpty())) {
79+
String message = "[ERROR]: VWO-SDK Please provide a valid gateway service url in the options when aliasing is enabled";
8080
System.err.println(message);
8181
}
8282
//start timer

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,8 @@ public VWOBuilder initBatching() {
426426
this.options.getBatchEventData().getFlushCallback(),
427427
this.options.getAccountId(),
428428
this.options.getSdkKey(),
429-
loggerService
429+
loggerService,
430+
settingFileManager
430431
);
431432

432433
this.batchEventQueue = batchEventQueue; // Link to the vwoClient

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ public VWOClient(String settings, VWOBuilder vwoBuilder) {
6060
}
6161
this.settings = settings;
6262
this.processedSettings = objectMapper.readValue(settings, Settings.class);
63-
if (vwoBuilder.getBatchEventQueue() != null) {
64-
vwoBuilder.getBatchEventQueue().setSettings(this.processedSettings);
65-
}
6663
if (!DataTypeUtil.isNull(this.processedSettings.getCollectionPrefix()) && !this.processedSettings.getCollectionPrefix().isEmpty()) {
6764
this.vwoBuilder.getSettingsManager().collectionPrefix = this.processedSettings.getCollectionPrefix();
6865
}
@@ -365,8 +362,19 @@ public String updateSettings() {
365362
/**
366363
* This method is used to update the settings with provided settings string
367364
* @param settings New settings to be updated
365+
* @return String value containing the updated settings
368366
*/
369367
public String updateSettings(String settings) {
368+
return this.updateSettings(settings, false);
369+
}
370+
371+
/**
372+
* This method is used to update the settings with provided settings string and isViaWebhook flag
373+
* @param settings New settings to be updated
374+
* @param isViaWebhook Boolean value to indicate if the settings are being fetched via webhook
375+
* @return String value containing the updated settings
376+
*/
377+
private String updateSettings(String settings, Boolean isViaWebhook) {
370378
String apiName = "updateSettings";
371379
try {
372380
vwoBuilder.getLoggerService().log(LogLevelEnum.DEBUG, "API_CALLED", new HashMap<String, Object>() {{
@@ -388,14 +396,14 @@ public String updateSettings(String settings) {
388396
this.updateSettingsOnVWOClient(settings);
389397
vwoBuilder.getLoggerService().log(LogLevelEnum.INFO, "SETTINGS_UPDATED", new HashMap<String, Object>() {{
390398
put("apiName", apiName);
391-
put("isViaWebhook", "false");
399+
put("isViaWebhook", isViaWebhook.toString());
392400
}});
393401
return settings;
394402
} catch (Exception exception) {
395403
vwoBuilder.getLoggerService().log(LogLevelEnum.ERROR, "UPDATING_CLIENT_INSTANCE_FAILED_WHEN_WEBHOOK_TRIGGERED", new HashMap<String, Object>() {{
396404
put("apiName", apiName);
397405
put("err", exception.getMessage());
398-
put("isViaWebhook", "false");
406+
put("isViaWebhook", isViaWebhook.toString());
399407
put("an", ApiEnum.UPDATE_SETTINGS.getValue());
400408
}});
401409
return null;
@@ -411,7 +419,7 @@ public String updateSettings(Boolean isViaWebhook) {
411419
try {
412420
// Fetch the new settings from the server
413421
this.settings = this.vwoBuilder.getSettingsManager().fetchSettings(isViaWebhook);
414-
return this.updateSettings(this.settings);
422+
return this.updateSettings(this.settings, isViaWebhook);
415423
} catch (Exception exception) {
416424
vwoBuilder.getLoggerService().log(LogLevelEnum.ERROR, "UPDATING_CLIENT_INSTANCE_FAILED_WHEN_WEBHOOK_TRIGGERED", new HashMap<String, Object>() {{
417425
put("apiName", apiName);

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.15.0";
31+
public static final String SDK_VERSION = "1.16.0";
3232
public static final long SETTINGS_EXPIRY = 10000000;
3333
public static final long SETTINGS_TIMEOUT = 50000;
3434

src/main/java/com/vwo/models/user/VWOInitOptions.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public class VWOInitOptions {
4343
private Boolean isUsageStatsDisabled = false;
4444
private Map<String, Object> _vwo_meta = new HashMap<>();
4545
private Boolean isAliasingEnabled = false;
46+
private String proxyUrl = "";
4647

4748
public Map<String, Object> getVwoMetaData() {
4849
return _vwo_meta;
@@ -155,4 +156,12 @@ public Boolean getIsAliasingEnabled() {
155156
public void setIsAliasingEnabled(Boolean isAliasingEnabled) {
156157
this.isAliasingEnabled = isAliasingEnabled;
157158
}
159+
160+
public String getProxyUrl() {
161+
return proxyUrl;
162+
}
163+
164+
public void setProxyUrl(String proxyUrl) {
165+
this.proxyUrl = proxyUrl;
166+
}
158167
}

src/main/java/com/vwo/packages/segmentation_evaluator/core/SegmentationManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void setContextualData(ServiceContainer serviceContainer, Feature feature
6868
}
6969

7070
// If gateway service is required and the base URL is not the default one, fetch the data from the gateway service
71-
if (feature.getIsGatewayServiceRequired() && !serviceContainer.getBaseUrl().contains(Constants.HOST_NAME) && (context.getVwo() == null)) {
71+
if (feature.getIsGatewayServiceRequired() && serviceContainer.getSettingsManager().isGatewayServiceProvided && (context.getVwo() == null)) {
7272
Map<String, String> queryParams = new HashMap<>();
7373
if ( (context.getUserAgent() == null || context.getUserAgent().isEmpty() ) && (context.getIpAddress() == null || context.getIpAddress().isEmpty())) {
7474
return;

0 commit comments

Comments
 (0)