https://github.com/wingify/vwo-java-sdk
[DEPRECATED] VWO Java SDK for server-side A/B Testing
https://github.com/wingify/vwo-java-sdk
ab-testing java java-sdk murmurhash3 server-side server-side-rendering vwo
Last synced: 4 days ago
JSON representation
[DEPRECATED] VWO Java SDK for server-side A/B Testing
- Host: GitHub
- URL: https://github.com/wingify/vwo-java-sdk
- Owner: wingify
- License: apache-2.0
- Created: 2019-07-30T11:46:15.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2025-03-25T14:07:02.000Z (about 1 month ago)
- Last Synced: 2025-04-04T16:12:35.786Z (26 days ago)
- Topics: ab-testing, java, java-sdk, murmurhash3, server-side, server-side-rendering, vwo
- Language: Java
- Homepage: https://developers.vwo.com/docs/fullstack-overview
- Size: 4.83 MB
- Stars: 9
- Watchers: 18
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# ⚠️ [DEPRECATED] VWO JAVA SDK
**⚠️ This project is no longer actively developed. ⚠️**
**✅ We are only fixing critical bugs and security issues.**
**❌ No new features, enhancements, or non-critical updates will be added.**
#### Switch to *VWO Feature Management & Experimentation(FME)* – The Better Alternative! 🚀
VWO’s FME product empowers teams to seamlessly test, release, optimize, and roll back features across their entire tech stack while minimizing risk and maximizing business impact.
* Check out FME developer documentation [here](https://developers.vwo.com/v2/docs/fme-overview).
* Check [this](https://developers.vwo.com/v2/docs/sdks-release-info ) for the list of all FME-supported SDKs.**💡 Need Help?**
For migration assistance or any questions, contact us at [[email protected]]([email protected])------
[](https://github.com/wingify/vwo-java-sdk/actions?query=workflow%3ACI)
[](https://codecov.io/gh/wingify/vwo-java-sdk)
[](http://www.apache.org/licenses/LICENSE-2.0)This open source library allows you to A/B Test your Website at server-side.
## Requirements
The Java SDK supports:
* Open JDK 8, 9, 11, 12, 13, 15, 17
* Oracle JDK 8, 9, 11, 12, 13, 15, 17Our [Build](https://github.com/wingify/vwo-java-sdk/actions) is successful on these Java Versions - `8, 11, 12, 13, 15, 17`
## SDK Installation
Install dependencies using `mvn install`
Add below Maven dependency in your project.
```java
com.vwo.sdk
vwo-java-sdk
LATEST```
## Documentation
Refer [Official VWO Documentation](https://developers.vwo.com/docs/fullstack-overview)
## Basic Usage
**GET SETTINGS FILE**
Each VWO SDK client corresponds to the settingsFIle representing the current state of the campaign settings, that is, a list of server-side running campaign settings.
Setting File is a pre-requisite for initiating the VWO CLIENT INSTANCE.```java
String settingsFile = VWO.getSettingsFile(accountId, sdkKey));
```**INSTANTIATION**
SDK provides a method to instantiate a VWO client as an instance. The method accepts an object to configure the VWO client.
The mandatory parameter for instantiating the SDK is settingsFile.```java
import com.vwo.VWO;VWO vwoInstance = VWO.launch(settingsFile).build();
```**Activate API**
```java
String variationName = vwoClientInstance.activate(campaignKey, userId, options);if (variationName.equals("Control")) {
// Write code for handling 'Control'
} else if (variationName.equals("Variation-1")) {
// CODE: write code for Variation-1
} else {
// CODE: When user does not become part of campaign.
}
```**Track API**
```java
// For CUSTOM goal type
boolean isSuccessful = vwoClientInstance.track(campaignKey, userId, goalIdentifier, options);// For REVENUE goal type
boolean isSuccessful = vwoClientInstance.track(campaignKey, userId, goalIdentifier, options);
```**Feature Enabled API**
```java
Boolean isEnabled = vwoClientInstance.isFeatureEnabled(campaignKey, userId, options);if (isEnabled) {
// Write code for handling feature enabled
} else {
// CODE: User is not qualified for the campaign. Would be due to configuring campaign's percent-traffic less than 100% while creating or updating a FullStack campaign.
}
```**Get Variable Value API**
```java
Object value = vwoClientInstance.getFeatureVariableValue(campaignKey, variableKey, userId, options);
```**Push API**
```java
boolean isSuccessful = vwoClientInstance.push(customDimensionKey, customDimensionValue, userId);
```The VWO client class needs to be instantiated as an instance that exposes various API methods like activate, getVariation and track.
**USER STORAGE SERVICE**
```java
String settingsFile = VWO.getSettingsFile(accountId, sdkKey);Storage.User userStorage = return new Storage.User() {
@Override
public Map get(String userId, String campaignName) {
for (Map savedCampaign: campaignStorageArray) {
if (savedCampaign.get("userId").equals(userId) && savedCampaign.get("campaignKey").equals(campaignName)) {
return savedCampaign;
}
}
return null;
}@Override
public void set(Map map){
campaignStorageArray.add(map);
}
};VWO vwo = VWO.launch(settingsFile).withUserStorage(userStorage).build();
```**LOGGER**
JAVA SDK utilizes a logging facade, SL4J (https://www.slf4j.org/) as the logging api layer. If no binding is found on the class path,
then you will see the following logs```
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
You can get the SDK to log by providing a concrete implementation for SLF4J.
```What it means is that at runtime, the logging `implementation` (or the logger binding) is missing , so slf4j simply use a "NOP" implementation, which does nothing.
If you need to output JAVA SDK logs, there are different approaches for the same.SIMPLE IMPLEMENTATION
If there are no implementation in your project , you may provide a simple implementation that does not require any configuration at all.
Add following code to you pom.xml,```java
org.slf4j
slf4j-simple
1.6.4```
Now you see logging output on STDOUT with INFO level. This simple logger will default show any INFO level message or higher.
In order to see DEBUG messages, you would need to pass -Dorg.slf4j.simpleLogger.defaultLogLevel=debug or simplelogger.properties file on the classpath
See http://www.slf4j.org/api/org/slf4j/impl/SimpleLogger.html for detailsCONCRETE IMPLEMENTATION
sl4j supports various logging framework. Refer here ->https://www.slf4j.org/manual.html
We have provided our example with Logback
If you have logback in your class path, to get console logs add following Appender and Logger in logback for formatted logs.```java
%cyan(VWO-SDK) [%date] %highlight([%level]) %cyan([%logger{10} %file:%line]) %msg%n
DEBUG
```
```java
new VWOLogger(VWO.Enums.LOGGER_LEVEL.DEBUG.value()) {
@Override
public void trace(String message, Object... params) {
LOGGER.trace(message, params);
}@Override
public void debug(String message, Object... params) {
LOGGER.debug(message, params);
}@Override
public void info(String message, Object... params) {
LOGGER.info(message, params);
}@Override
public void warn(String message, Object... params) {
LOGGER.warn(message, params);
}@Override
public void error(String message, Object... params) {
LOGGER.error(message, params);
}
};
```For more appenders, refer [this](https://logback.qos.ch/manual/appenders.html).
## Third-party Resources and Credits
Refer [third-party-attributions.txt](https://github.com/wingify/vwo-java-sdk/blob/master/third-party-attributions.txt)
## Authors
* Core Contributor & Maintainer - [pntgupta](https://github.com/pntgupta)
* Main Contributor - [sakshimahendruvk](https://github.com/sakshimahendruvk)
* Repo health maintainer - [softvar](https://github.com/softvar)## Changelog
Refer [CHANGELOG.md](https://github.com/wingify/vwo-java-sdk/blob/master/CHANGELOG.md)
## Contributing
Please go through our [contributing guidelines](https://github.com/wingify/vwo-java-sdk/blob/master/CONTRIBUTING.md)
## Code of Conduct
[Code of Conduct](https://github.com/wingify/vwo-java-sdk/blob/master/CODE_OF_CONDUCT.md)
## License
[Apache License, Version 2.0](https://github.com/wingify/vwo-java-sdk/blob/master/LICENSE)
Copyright 2019-2022 Wingify Software Pvt. Ltd.