Skip to content

Commit

Permalink
Merge pull request #55 from adjust/development
Browse files Browse the repository at this point in the history
New response data fields
  • Loading branch information
nonelse committed Jun 25, 2014
2 parents 2c86dbb + 6b9e947 commit ec65a8e
Show file tree
Hide file tree
Showing 25 changed files with 166 additions and 283 deletions.
2 changes: 1 addition & 1 deletion Adjust/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
defaultConfig {
versionCode 11
versionName '3.3.3'
versionName '3.3.4'
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
}
Expand Down
2 changes: 1 addition & 1 deletion Adjust/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>adjust-android</artifactId>
<groupId>com.adjust.sdk</groupId>
<version>3.3.3</version>
<version>3.3.4</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
12 changes: 6 additions & 6 deletions Adjust/src/com/adjust/sdk/ActivityHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Adjust
//
// Created by Christian Wellenbrock on 2013-06-25.
// Copyright (c) 2013 adeven. All rights reserved.
// Copyright (c) 2013 adjust GmbH. All rights reserved.
// See the file MIT-LICENSE for copying permission.
//

Expand Down Expand Up @@ -113,11 +113,6 @@ private void initActivityHandler(Activity activity) {
enabled = true;

logger = AdjustFactory.getLogger();

String gpsAdid = Util.getGpsAdid(context);
if (gpsAdid == null) {
logger.info("Unable to get Google Play Services Advertising ID at start time");
}
}

public void setSdkPrefix(String sdkPrefx) {
Expand Down Expand Up @@ -283,6 +278,11 @@ private void initInternal(boolean fromBundle) {
fbAttributionId = Util.getAttributionId(context);
userAgent = Util.getUserAgent(context);

String gpsAdid = Util.getGpsAdid(context);
if (gpsAdid == null) {
logger.info("Unable to get Google Play Services Advertising ID at start time");
}

packageHandler = AdjustFactory.getPackageHandler(this, context, dropOfflineActivities);

readActivityState();
Expand Down
2 changes: 1 addition & 1 deletion Adjust/src/com/adjust/sdk/ActivityPackage.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Adjust
//
// Created by Christian Wellenbrock on 2013-06-25.
// Copyright (c) 2013 adeven. All rights reserved.
// Copyright (c) 2013 adjust GmbH. All rights reserved.
// See the file MIT-LICENSE for copying permission.
//

Expand Down
2 changes: 1 addition & 1 deletion Adjust/src/com/adjust/sdk/ActivityState.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Adjust
//
// Created by Christian Wellenbrock on 2013-06-25.
// Copyright (c) 2013 adeven. All rights reserved.
// Copyright (c) 2013 adjust GmbH. All rights reserved.
// See the file MIT-LICENSE for copying permission.
//

Expand Down
6 changes: 3 additions & 3 deletions Adjust/src/com/adjust/sdk/Adjust.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Adjust
//
// Created by Christian Wellenbrock on 2012-10-11.
// Copyright (c) 2012-2013 adeven. All rights reserved.
// Copyright (c) 2012-2014 adjust GmbH. All rights reserved.
// See the file MIT-LICENSE for copying permission.
//

Expand Down Expand Up @@ -68,13 +68,13 @@ public static void setOnFinishedListener(OnFinishedListener listener) {
/**
* Tell Adjust that a particular event has happened.
* <p/>
* In your dashboard at http://adjust.io you can assign a callback URL to each
* In your dashboard at http://adjust.com you can assign a callback URL to each
* event type. That URL will get called every time the event is triggered. On
* top of that you can pass a set of parameters to the following method that
* will be forwarded to these callbacks.
*
* @param eventToken The Event Token for this kind of event. They are created
* in the dashboard at http://adjust.io and should be six characters long.
* in the dashboard at http://adjust.com and should be six characters long.
* @param parameters An optional dictionary containing the callback parameters.
* Provide key-value-pairs to be forwarded to your callbacks.
*/
Expand Down
4 changes: 2 additions & 2 deletions Adjust/src/com/adjust/sdk/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Adjust
//
// Created by keyboardsurfer on 2013-11-08.
// Copyright (c) 2012-2013 adeven. All rights reserved.
// Copyright (c) 2012-2014 adjust GmbH. All rights reserved.
// See the file MIT-LICENSE for copying permission.
//

Expand All @@ -19,7 +19,7 @@ public interface Constants {
int THIRTY_MINUTES = 30 * ONE_MINUTE;

String BASE_URL = "https://app.adjust.io";
String CLIENT_SDK = "android3.3.3";
String CLIENT_SDK = "android3.3.4";
String LOGTAG = "Adjust";

String SESSION_STATE_FILENAME = "AdjustIoActivityState";
Expand Down
2 changes: 1 addition & 1 deletion Adjust/src/com/adjust/sdk/LogCatLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Adjust
//
// Created by Christian Wellenbrock on 2013-04-18.
// Copyright (c) 2013 adeven. All rights reserved.
// Copyright (c) 2013 adjust GmbH. All rights reserved.
// See the file MIT-LICENSE for copying permission.
//

Expand Down
2 changes: 1 addition & 1 deletion Adjust/src/com/adjust/sdk/PackageBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Adjust
//
// Created by Christian Wellenbrock on 2013-06-25.
// Copyright (c) 2013 adeven. All rights reserved.
// Copyright (c) 2013 adjust GmbH. All rights reserved.
// See the file MIT-LICENSE for copying permission.
//

Expand Down
2 changes: 1 addition & 1 deletion Adjust/src/com/adjust/sdk/PackageHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Adjust
//
// Created by Christian Wellenbrock on 2013-06-25.
// Copyright (c) 2013 adeven. All rights reserved.
// Copyright (c) 2013 adjust GmbH. All rights reserved.
// See the file MIT-LICENSE for copying permission.
//

Expand Down
2 changes: 1 addition & 1 deletion Adjust/src/com/adjust/sdk/RequestHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Adjust
//
// Created by Christian Wellenbrock on 2013-06-25.
// Copyright (c) 2013 adeven. All rights reserved.
// Copyright (c) 2013 adjust GmbH. All rights reserved.
// See the file MIT-LICENSE for copying permission.
//

Expand Down
55 changes: 53 additions & 2 deletions Adjust/src/com/adjust/sdk/ResponseData.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,26 @@ public String getTrackerName() {
return trackerName;
}

// network of the tracker
public String getNetwork() {
return network;
}

// campaign of the tracker
public String getCampaign() {
return campaign;
}

// adgroup of the tracker
public String getAdgroup() {
return adgroup;
}

// creative of the tracker
public String getCreative() {
return creative;
}

// internals

private ActivityKind activityKind = ActivityKind.UNKNOWN;
Expand All @@ -68,6 +88,10 @@ public String getTrackerName() {
private String error;
private String trackerToken;
private String trackerName;
private String network;
private String campaign;
private String adgroup;
private String creative;

public static ResponseData fromJson(String jsonString) {
try {
Expand All @@ -77,6 +101,10 @@ public static ResponseData fromJson(String jsonString) {
data.error = jsonObject.optString("error", null);
data.trackerToken = jsonObject.optString("tracker_token", null);
data.trackerName = jsonObject.optString("tracker_name", null);
data.network = jsonObject.optString("network", null);
data.campaign = jsonObject.optString("campaign", null);
data.adgroup = jsonObject.optString("adgroup", null);
data.creative = jsonObject.optString("creative", null);

return data;
} catch (JSONException e) {
Expand All @@ -91,15 +119,22 @@ public static ResponseData fromError(String error) {
return data;
}

@Override
public String toString() {
return String.format(Locale.US,
"[kind:%s success:%b willRetry:%b error:%s trackerToken:%s trackerName:%s]",
"[kind:%s success:%b willRetry:%b "
+ "error:%s trackerToken:%s trackerName:%s "
+ "network:%s campaign:%s adgroup:%s creative:%s]",
getActivityKindString(),
success,
willRetry,
Util.quote(error),
trackerToken,
Util.quote(trackerName));
Util.quote(trackerName),
Util.quote(network),
Util.quote(campaign),
Util.quote(adgroup),
Util.quote(creative));
}

public void setActivityKind(ActivityKind activityKind) {
Expand Down Expand Up @@ -133,6 +168,22 @@ public Map<String, String> toDic() {
responseDataDic.put("trackerName", trackerName);
}

if (!TextUtils.isEmpty(network)) {
responseDataDic.put("network", network);
}

if (!TextUtils.isEmpty(campaign)) {
responseDataDic.put("campaign", campaign);
}

if (!TextUtils.isEmpty(adgroup)) {
responseDataDic.put("adgroup", adgroup);
}

if (!TextUtils.isEmpty(creative)) {
responseDataDic.put("creative", creative);
}

return responseDataDic;
}
}
16 changes: 10 additions & 6 deletions Adjust/src/com/adjust/sdk/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Adjust
//
// Created by Christian Wellenbrock on 2012-10-11.
// Copyright (c) 2012-2013 adeven. All rights reserved.
// Copyright (c) 2012-2014 adjust GmbH. All rights reserved.
// See the file MIT-LICENSE for copying permission.
//

Expand Down Expand Up @@ -367,13 +367,17 @@ public static String getGpsAdid(Context context) {

Boolean isLimitedTrackingEnabled = (Boolean) isLimitedTrackingEnabledObject;

if (!isLimitedTrackingEnabled) {
Method getIdMethod = AdvertisingInfoClass.getMethod("getId");
if (isLimitedTrackingEnabled) {
return null;
}

Object getIdObject = getIdMethod.invoke(AdvertisingInfoObject);
Method getIdMethod = AdvertisingInfoClass.getMethod("getId");

String gpsAdid = (String) getIdObject;
}
Object getIdObject = getIdMethod.invoke(AdvertisingInfoObject);

String gpsAdid = (String) getIdObject;

return gpsAdid;
}
catch (Exception e) {
}
Expand Down
29 changes: 28 additions & 1 deletion Adjust/test/src/com/adjust/sdk/test/MockHttpClient.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
package com.adjust.sdk.test;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;

import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.ProtocolVersion;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.entity.BasicHttpEntity;
import org.apache.http.message.BasicHttpResponse;
import org.apache.http.message.BasicStatusLine;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HttpContext;

Expand All @@ -18,6 +26,7 @@ public class MockHttpClient implements HttpClient {
private MockLogger testLogger;
private String prefix = "HttpClient ";
private String messageError;
private String responseError;

public MockHttpClient(MockLogger testLogger) {
this.testLogger = testLogger;
Expand All @@ -33,13 +42,31 @@ public HttpResponse execute(HttpUriRequest request) throws IOException,
throw new ClientProtocolException(messageError);
}

return new MockHttpResponse();
if (responseError != null)
return getMockResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, "{ \"error\": \"" + responseError + "\"}");
else
return getMockResponse(HttpStatus.SC_OK, "{ \"tracker_token\": \"token\", \"tracker_name\": \"name\", \"network\": \"network\", \"campaign\": \"campaign\", \"adgroup\": \"adgroup\", \"creative\": \"creative\"}");
}

private HttpResponse getMockResponse(int statusCode, String responseData) throws IOException {
StatusLine statusLine = new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), statusCode, null);
HttpResponse response = new BasicHttpResponse(statusLine);
BasicHttpEntity entity = new BasicHttpEntity();
InputStream inStream = new ByteArrayInputStream(responseData.getBytes("UTF-8"));

entity.setContent(inStream);
response.setEntity(entity);
return response;
}

public void setMessageError(String messageError) {
this.messageError = messageError;
}

public void setResponseError(String responseError) {
this.responseError = responseError;
}

@Override
public HttpResponse execute(HttpUriRequest request, HttpContext context)
throws IOException, ClientProtocolException {
Expand Down
Loading

0 comments on commit ec65a8e

Please sign in to comment.