Code Monkey home page Code Monkey logo

target-java-sdk's Introduction

Adobe Target Java SDK

The Adobe Target Java SDK uses the [Target View Delivery API] to retrieve and deliver personalized experiences using best practices. Furthermore, the Java SDK helps manage integrations with Experience Cloud solutions like Visitor API and Adobe Analytics.

Getting started

Prerequisites

  • Java 8+
  • Maven or Gradle

Installation

To get started with Target Java SDK, just add it as a dependency in gradle as:

implementation 'com.adobe.target:target-java-sdk:2.5.1'

or maven as:

<dependency>
    <groupId>com.adobe.target</groupId>
    <artifactId>target-java-sdk</artifactId>
    <version>2.5.1</version>
</dependency>

Super Simple to Use

Please take a look at our documentation to learn how to use the Java SDK.

Samples

The Adobe Target Java SDK Samples can be found here.

Development

Check out our Contribution guidelines as well as Code of Conduct prior to contributing to Target Java SDK development.

  1. To build the project: ./gradlew build
  2. To install java-sdk locally: ./gradle install

Delivery API Client generation

The SDK depends on Target Open API. It uses Open API and the Open API generator to generate the low level HTTP client.

To be able to use Target Open API for code generation, we are leveraging Git subtree.

To refresh the local target-openapi subtree, use the command:

git subtree pull --prefix openapi [email protected]:adobe/target-openapi.git main --squash

The openapi-generator config is located in the codegeneration directory, but there is no need to invoke it directly. To regenerate the openapi models use the command: ./gradlew codegen spotlessApply

target-java-sdk's People

Contributors

anshchauhan avatar artur-ciocanu avatar babin920 avatar dcottingham avatar donwalling avatar eric-fichtel-adobe avatar ericfichtel avatar filmaj avatar gregggreg avatar hisham-hassan avatar jasonwaters avatar mptap avatar sakshamtaneja21 avatar shandilya3 avatar xdex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

target-java-sdk's Issues

Running the SDK behind a proxy times out and throws a NullPointerException

Expected Behaviour

We need to be able to use the SDK on a server that is running behind a proxy.
We could not find any documentation that specifies how a proxy could be configured for the Target HTTP client.

Actual Behaviour

Running the SDK behind a proxy times out and throws a NullPointerException. Running the same code on a server with direct internet connection works well.

Steps to Reproduce

Run the SDK on any PC that is behind a corporate firewall and that requires a proxy configuration to allow external internet calls.

Platform and Version

Java 1.8
Adobe Target SDK 1.0.1

Sample Code that illustrates the problem

Running this line behind in a network that requires a proxy would timeout and throw a null pointer exception.

TargetDeliveryResponse targetDeliveryResponse = targetClient.getOffers(targetDeliveryRequest);

Logs taken while reproducing problem

Exception in thread "main" com.adobe.target.edge.client.service.TargetRequestException
	at com.adobe.target.edge.client.DefaultTargetClient.getOffers(DefaultTargetClient.java:46)
	at TargetSDKTest.main(TargetSDKTest.java:48)
Caused by: java.lang.NullPointerException
	at com.adobe.target.edge.client.http.TargetMetrics.lambda$begin$0(TargetMetrics.java:36)
	at kong.unirest.apache.ApacheClient.request(ApacheClient.java:132)
	at kong.unirest.BaseRequest.asObject(BaseRequest.java:230)
	at com.adobe.target.edge.client.http.DefaultTargetHttpClient.execute(DefaultTargetHttpClient.java:69)
	at com.adobe.target.edge.client.http.TargetHttpClientLoggingDecorator.execute(TargetHttpClientLoggingDecorator.java:34)
	at com.adobe.target.edge.client.service.DefaultTargetService.executeRequest(DefaultTargetService.java:59)
	at com.adobe.target.edge.client.DefaultTargetClient.getOffers(DefaultTargetClient.java:43)
	... 1 more

Possible Fix

The code can be enhanced to enable the customers to set their proxy when needed. this could be achieved by making the following changes:

1- Create a new ClientProxyConfig class to hold the proxy details.

package com.adobe.target.edge.client;

public class ClientProxyConfig {
	private String address;
	private String port;
	private String userName;
	private String password;
	private boolean authProxy = false; 
	
	public ClientProxyConfig(String proxyAddress, String proxyPort) {
		this.address = proxyAddress;
		this.port = proxyPort;
	}
	
	public ClientProxyConfig(String address, String port, String userName, String password) {
		this.address = address;
		this.port = port;
		this.userName = userName;
		this.password = password;
		authProxy = true;
	}

	public String getAddress() {
		return address;
	}

	public String getPort() {
		return port;
	}

	public String getUserName() {
		return userName;
	}

	public String getPassword() {
		return password;
	}

	public boolean isAuthProxy() {
		return authProxy;
	}
}

2- Update the com.adobe.target.edge.client.ClientConfig class to have an instance of the ClientProxyConfig

private ClientProxyConfig proxy;

public ClientProxyConfig getProxy() {
	return proxy;
}

public void setProxy(ClientProxyConfig proxy) {
	this.proxy = proxy;
}

public boolean isProxyEnabled() {
	return proxy != null;
}

3- Update the constructor of the com.adobe.target.edge.client.http.DefaultTargetHttpClient class to have the following lines:

if (clientConfig.isProxyEnabled()) {
    ClientProxyConfig proxy = clientConfig.getProxy();
    if(proxy.isAuthProxy()) {
        unirestInstance.config().proxy(proxy.getAddress(), proxy.getPort, proxy.getUserName(), proxy.getPassword);
    } else {
        unirestInstance.config().proxy(proxy.getAddress(), proxy.getPort);
    }
}

Server-side experiences not tracking with A4T

There appears to be an issue with new users landing on the targeted page. The server-side implementation does not have an implementation for the Visitor API to get the ECID/MCID, thus causing a mismatch between Target and Analytics. Returning users with AMCV cookies already set do not appear to have an issue.

The example stats below are for a page that is mostly new users landing on it.

Expected Behaviour

A4T accurately tracks user data from server-side requests. # of views in experiences should mimic the total # of views of the given page.

Actual Behaviour

A4T is not attributing the appropriate experience for all views.

The following images were pulled from Analytics for the same time period. The page 'landing page:custom closets' is utilizing the server-side API and every user should be attributed an Experience. The total # of unique views should match between the two charts, as well as the # of submits (the conversion criteria).
Target Experience Views
Total Unique Views

Reproduce Scenario (including but not limited to)

Steps to Reproduce

Implement the target-java-sdk with analytics.
Create a Target Experience. Track the # of views of the page compared to the views of the experiences.

Platform and Version

  • target-java-sdk v1.1.0
  • Spring v4.3.25.RELEASE

Sample Code that illustrates the problem

We followed the sample provided for targetMcid.

The only difference being our integration through Launch. Visitor state is set to a JS variable which is propagated to the Visitor Service through Launch.

Logs taken while reproducing problem

New User Request
{
      "requestId": "1a6560bb-b963-44f5-8e59-802347f7f6d8",
      "context": {
        "channel": "web",
        "address": {
          "url": "https://www.containerstore.com/custom-closets"
        },
        "beacon": false
      },
      "experienceCloud": {
        "analytics": {
          "supplementalDataId": "02BC759D22D4FE7E-62749C19A3060DFA",
          "logging": "server_side",
          "trackingServer": "thecontainerstore.sc.omtrdc.net"
        }
      },
      "execute": {
        "pageLoad": {
          "parameters": {},
          "profileParameters": {}
        },
        "mboxes": []
      },
      "prefetch": {
        "views": [
          {
            "parameters": {},
            "profileParameters": {}
          }
        ],
        "mboxes": []
      },
      "notifications": []
    }
Returning User Request
{
  "requestId": "2d05b638-d461-4377-904b-247b403032de",
  "id": {
    "tntId": "749afadd-3570-4efd-9e6a-84cd2c892160.35_0",
    "marketingCloudVisitorId": "45913002719203183828537149552334816373"
  },
  "context": {
    "channel": "web",
    "address": {
      "url": "https://www.containerstore.com/custom-closets"
    },
    "beacon": false
  },
  "experienceCloud": {
    "analytics": {
      "supplementalDataId": "697825C548C84264-1FC0EB4BDBB0355A",
      "logging": "server_side",
      "trackingServer": "thecontainerstore.sc.omtrdc.net"
    }
  },
  "execute": {
    "pageLoad": {
      "parameters": {},
      "profileParameters": {}
    },
    "mboxes": []
  },
  "prefetch": {
    "views": [
      {
        "parameters": {},
        "profileParameters": {}
      }
    ],
    "mboxes": []
  },
  "notifications": []
}

getOffers does not increment impressions

Expected Behaviour

Impressions to increment in the Target interface.

Actual Behaviour

Impressions remain at 0 for Production and Development environments.

Reproduce Scenario (including but not limited to)

Issue a getOffers request

Steps to Reproduce

Platform and Version

1.1

Sample Code that illustrates the problem

Can provide in a more secure format.

Logs taken while reproducing problem

Can provide in a more secure format.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.