Skip to content

Commit

Permalink
Merge pull request #94 from adjust/HansPfau-feature/ADJAttirbution_ad…
Browse files Browse the repository at this point in the history
…ditional_Label_parameter

Attribution additional label parameter
  • Loading branch information
nonelse committed Apr 9, 2015
2 parents f4232a0 + 4c31212 commit 189aa71
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Adjust.podspec
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Pod::Spec.new do |s|
s.name = "Adjust"
s.version = "4.1.1"
s.version = "4.2.0"
s.summary = "This is the iOS SDK of adjust. You can read more about it at http://adjust.com."
s.homepage = "http://adjust.com"
s.license = { :type => 'MIT', :file => 'MIT-LICENSE' }
s.author = { "Christian Wellenbrock" => "[email protected]" }
s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.1.1" }
s.source = { :git => "https://github.com/adjust/ios_sdk.git", :tag => "v4.2.0" }
s.platform = :ios, '4.3'
s.framework = 'SystemConfiguration'
s.weak_framework = 'AdSupport', 'iAd'
Expand Down
3 changes: 3 additions & 0 deletions Adjust/ADJAttribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
// tracker creative
@property (nonatomic, copy) NSString *creative;

// tracker click_label
@property (nonatomic, copy) NSString *clickLabel;

- (BOOL)isEqualToAttribution:(ADJAttribution *)attribution;

+ (ADJAttribution *)dataWithJsonDict:(NSDictionary *)jsonDict;
Expand Down
25 changes: 18 additions & 7 deletions Adjust/ADJAttribution.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ - (id)initWithJsonDict:(NSDictionary *)jsonDict {
self.campaign = [jsonDict objectForKey:@"campaign"];
self.adgroup = [jsonDict objectForKey:@"adgroup"];
self.creative = [jsonDict objectForKey:@"creative"];
self.clickLabel = [jsonDict objectForKey:@"click_label"];

return self;
}
Expand All @@ -55,6 +56,9 @@ - (BOOL)isEqualToAttribution:(ADJAttribution *)attribution {
if (![NSString adjIsEqual:self.creative toString:attribution.creative]) {
return NO;
}
if (![NSString adjIsEqual:self.clickLabel toString:attribution.clickLabel]) {
return NO;
}

return YES;
}
Expand Down Expand Up @@ -86,13 +90,17 @@ - (NSDictionary *)dictionary {
[responseDataDic setObject:self.creative forKey:@"creative"];
}

if (self.clickLabel != nil) {
[responseDataDic setObject:self.clickLabel forKey:@"click_label"];
}

return responseDataDic;
}

- (NSString *)description {
return [NSString stringWithFormat:@"tt:%@ tn:%@ net:%@ cam:%@ adg:%@ cre:%@",
return [NSString stringWithFormat:@"tt:%@ tn:%@ net:%@ cam:%@ adg:%@ cre:%@ lab:%@",
self.trackerToken, self.trackerName, self.network, self.campaign,
self.adgroup, self.creative];
self.adgroup, self.creative, self.clickLabel];
}


Expand Down Expand Up @@ -121,11 +129,12 @@ -(id)copyWithZone:(NSZone *)zone

if (copy) {
copy.trackerToken = [self.trackerToken copyWithZone:zone];
copy.trackerName = [self.trackerName copyWithZone:zone];
copy.network = [self.network copyWithZone:zone];
copy.campaign = [self.campaign copyWithZone:zone];
copy.adgroup = [self.adgroup copyWithZone:zone];
copy.creative = [self.creative copyWithZone:zone];
copy.trackerName = [self.trackerName copyWithZone:zone];
copy.network = [self.network copyWithZone:zone];
copy.campaign = [self.campaign copyWithZone:zone];
copy.adgroup = [self.adgroup copyWithZone:zone];
copy.creative = [self.creative copyWithZone:zone];
copy.clickLabel = [self.clickLabel copyWithZone:zone];
}

return copy;
Expand All @@ -144,6 +153,7 @@ - (id)initWithCoder:(NSCoder *)decoder {
self.campaign = [decoder decodeObjectForKey:@"campaign"];
self.adgroup = [decoder decodeObjectForKey:@"adgroup"];
self.creative = [decoder decodeObjectForKey:@"creative"];
self.clickLabel = [decoder decodeObjectForKey:@"click_label"];

return self;
}
Expand All @@ -155,6 +165,7 @@ - (void)encodeWithCoder:(NSCoder *)encoder {
[encoder encodeObject:self.campaign forKey:@"campaign"];
[encoder encodeObject:self.adgroup forKey:@"adgroup"];
[encoder encodeObject:self.creative forKey:@"creative"];
[encoder encodeObject:self.clickLabel forKey:@"click_label"];
}

@end
2 changes: 1 addition & 1 deletion Adjust/ADJUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <sys/xattr.h>

static NSString * const kBaseUrl = @"https://app.adjust.com";
static NSString * const kClientSdk = @"ios4.1.1";
static NSString * const kClientSdk = @"ios4.2.0";

static NSString * const kDateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'Z";
static NSDateFormatter *dateFormat;
Expand Down
15 changes: 9 additions & 6 deletions AdjustTests/ADJActivityHandlerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ - (void)testFirstRun
ADJActivityPackage *activityPackage = (ADJActivityPackage *) self.packageHandlerMock.packageQueue[0];

// check the Sdk version is being tested
XCTAssertEqual(@"ios4.1.1", activityPackage.clientSdk, @"%@", activityPackage.extendedString);
XCTAssertEqual(@"ios4.2.0", activityPackage.clientSdk, @"%@", activityPackage.extendedString);

// check the server url
XCTAssertEqual(@"https://app.adjust.com", ADJUtil.baseUrl);
Expand Down Expand Up @@ -621,7 +621,7 @@ - (void)testChecks {
[firstEvent setRevenue:0 currency:@""];
[firstEvent setRevenue:-0.0001 currency:@"EUR"];

[firstEvent setReceipt:@"value" transactionId:nil];
[firstEvent setReceipt:[@"value" dataUsingEncoding:NSUTF8StringEncoding] transactionId:nil];

[activityHandler trackEvent:firstEvent];

Expand Down Expand Up @@ -1073,6 +1073,7 @@ - (void)testAttribution {
[jsonDictionary setObject:@"campaignValue" forKey:@"campaign"];
[jsonDictionary setObject:@"adgroupValue" forKey:@"adgroup"];
[jsonDictionary setObject:@"creativeValue" forKey:@"creative"];
[jsonDictionary setObject:@"clickLabelValue" forKey:@"click_label"];

// build, update attribution and launch it to delegate
ADJAttribution * attribution = [[ADJAttribution alloc] initWithJsonDict:jsonDictionary];
Expand All @@ -1083,7 +1084,7 @@ - (void)testAttribution {

// check the first attribution is written
XCTAssert([self.loggerMock containsMessage:ADJLogLevelDebug
beginsWith:@"Wrote Attribution: tt:trackerTokenValue tn:trackerNameValue net:networkValue cam:campaignValue adg:adgroupValue cre:creativeValue"], @"%@", self.loggerMock);
beginsWith:@"Wrote Attribution: tt:trackerTokenValue tn:trackerNameValue net:networkValue cam:campaignValue adg:adgroupValue cre:creativeValue lab:clickLabelValue"], @"%@", self.loggerMock);

// change values of the same attribution
attribution.trackerName = @"trackerNameValueNew";
Expand All @@ -1092,6 +1093,7 @@ - (void)testAttribution {
attribution.campaign = @"campaignValueNew";
attribution.adgroup = @"adgroupValueNew";
attribution.creative = @"creativeValueNew";
attribution.clickLabel = @"clickLabelValueNew";

// update it and launch delegate
BOOL attributeUpdatedNewValues = [activityHandler updateAttribution:attribution];
Expand All @@ -1101,7 +1103,7 @@ - (void)testAttribution {

// check the second attribution is written
XCTAssert([self.loggerMock containsMessage:ADJLogLevelDebug
beginsWith:@"Wrote Attribution: tt:trackerTokenValueNew tn:trackerNameValueNew net:networkValueNew cam:campaignValueNew adg:adgroupValueNew cre:creativeValueNew"], @"%@", self.loggerMock);
beginsWith:@"Wrote Attribution: tt:trackerTokenValueNew tn:trackerNameValueNew net:networkValueNew cam:campaignValueNew adg:adgroupValueNew cre:creativeValueNew lab:clickLabelValueNew"], @"%@", self.loggerMock);

// build a json dictionary equal to the updated Attribution
NSMutableDictionary * newJsonDictionary = [[NSMutableDictionary alloc] init];
Expand All @@ -1111,6 +1113,7 @@ - (void)testAttribution {
[newJsonDictionary setObject:@"campaignValueNew" forKey:@"campaign"];
[newJsonDictionary setObject:@"adgroupValueNew" forKey:@"adgroup"];
[newJsonDictionary setObject:@"creativeValueNew" forKey:@"creative"];
[newJsonDictionary setObject:@"clickLabelValueNew" forKey:@"click_label"];

// build, update attribution and launch new attribution to delegate
ADJAttribution * newAttribution = [[ADJAttribution alloc] initWithJsonDict:newJsonDictionary];
Expand All @@ -1121,7 +1124,7 @@ - (void)testAttribution {

// check the same attribution is not written again
XCTAssertFalse([self.loggerMock containsMessage:ADJLogLevelDebug
beginsWith:@"Wrote Attribution: tt:trackerTokenValueNew tn:trackerNameValueNew net:networkValueNew cam:campaignValueNew adg:adgroupValueNew cre:creativeValueNew"], @"%@", self.loggerMock);
beginsWith:@"Wrote Attribution: tt:trackerTokenValueNew tn:trackerNameValueNew net:networkValueNew cam:campaignValueNew adg:adgroupValueNew cre:creativeValueNew lab:clickLabelValueNew"], @"%@", self.loggerMock);


[activityHandler setAskingAttribution:NO];
Expand Down Expand Up @@ -1172,7 +1175,7 @@ - (void)testAttribution {

// check new attribution after restart
XCTAssert([self.loggerMock containsMessage:ADJLogLevelDebug
beginsWith:@"Wrote Attribution: tt:trackerTokenValue tn:trackerNameValue net:networkValue cam:campaignValue adg:adgroupValue cre:creativeValue"], @"%@", self.loggerMock);
beginsWith:@"Wrote Attribution: tt:trackerTokenValue tn:trackerNameValue net:networkValue cam:campaignValue adg:adgroupValue cre:creativeValue lab:clickLabelValue"], @"%@", self.loggerMock);

[newActivityHandler setAskingAttribution:YES];

Expand Down
7 changes: 4 additions & 3 deletions AdjustTests/ADJAttributionHandlerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ - (void) checkGetCheckAttributionNoAskIn:(BOOL)update {

// check the response was verbosed
XCTAssert([self.loggerMock containsMessage:ADJLogLevelVerbose
beginsWith:@"status code 200 for attribution response: {\"attribution\":{\"tracker_token\":\"trackerTokenValue\",\"tracker_name\":\"trackerNameValue\", \"network\":\"networkValue\",\"campaign\":\"campaignValue\", \"adgroup\":\"adgroupValue\",\"creative\":\"creativeValue\"}, \"message\":\"response OK\",\"deeplink\":\"testApp://\"}"],
beginsWith:@"status code 200 for attribution response: {\"attribution\":{\"tracker_token\":\"trackerTokenValue\",\"tracker_name\":\"trackerNameValue\",\"network\":\"networkValue\",\"campaign\":\"campaignValue\",\"adgroup\":\"adgroupValue\",\"creative\":\"creativeValue\",\"click_label\":\"clickLabelValue\"},\"message\":\"response OK\",\"deeplink\":\"testApp://\"}"],
@"%@", self.loggerMock);

// check that the package was successfully sent
Expand Down Expand Up @@ -140,6 +140,7 @@ - (void) checkGetCheckAttributionNoAskIn:(BOOL)update {
[jsonDictionary setObject:@"campaignValue" forKey:@"campaign"];
[jsonDictionary setObject:@"adgroupValue" forKey:@"adgroup"];
[jsonDictionary setObject:@"creativeValue" forKey:@"creative"];
[jsonDictionary setObject:@"clickLabelValue" forKey:@"click_label"];

ADJAttribution * attribution = [[ADJAttribution alloc] initWithJsonDict:jsonDictionary];

Expand All @@ -160,7 +161,7 @@ -(void) testAskInConnectionError {

[NSURLConnection setConnectionError:YES];

NSDictionary *jsonDict = [ADJUtil buildJsonDict:@"{\"attribution\":{\"tracker_token\":\"trackerTokenValue\",\"tracker_name\":\"trackerNameValue\", \"network\":\"networkValue\",\"campaign\":\"campaignValue\", \"adgroup\":\"adgroupValue\",\"creative\":\"creativeValue\"}, \"ask_in\":0, \"message\":\"response OK\",\"deeplink\":\"testApp://\"}"];
NSDictionary *jsonDict = [ADJUtil buildJsonDict:@"{\"attribution\":{\"tracker_token\":\"trackerTokenValue\",\"tracker_name\":\"trackerNameValue\",\"network\":\"networkValue\",\"campaign\":\"campaignValue\",\"adgroup\":\"adgroupValue\",\"creative\":\"creativeValue\",\"click_label\":\"clickLabelValue\"},\"ask_in\":0,\"message\":\"response OK\",\"deeplink\":\"testApp://\"}"];

[attributionHandler checkAttribution:jsonDict];

Expand Down Expand Up @@ -294,7 +295,7 @@ -(void) testCancelTimer {

[NSURLConnection setConnectionError:YES];

NSString * jsonString = @"{\"attribution\":{\"tracker_token\":\"trackerTokenValue\",\"tracker_name\":\"trackerNameValue\", \"network\":\"networkValue\",\"campaign\":\"campaignValue\", \"adgroup\":\"adgroupValue\",\"creative\":\"creativeValue\"}, \"message\":\"response OK\",\"ask_in\":\"5000\"}";
NSString * jsonString = @"{\"attribution\":{\"tracker_token\":\"trackerTokenValue\",\"tracker_name\":\"trackerNameValue\",\"network\":\"networkValue\",\"campaign\":\"campaignValue\",\"adgroup\":\"adgroupValue\",\"creative\":\"creativeValue\",\"click_label\":\"clickLabelValue\"},\"message\":\"response OK\",\"ask_in\":\"5000\"}";

NSDictionary * jsonDict = [ADJUtil buildJsonDict:jsonString];

Expand Down
2 changes: 1 addition & 1 deletion AdjustTests/AIRequestHandlerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ - (void)checkSendPackage:(BOOL)isClickPackage {

// check the response was verbosed
XCTAssert([self.loggerMock containsMessage:ADJLogLevelVerbose
beginsWith:@"status code 200 for package response: {\"attribution\":{\"tracker_token\":\"trackerTokenValue\",\"tracker_name\":\"trackerNameValue\", \"network\":\"networkValue\",\"campaign\":\"campaignValue\", \"adgroup\":\"adgroupValue\",\"creative\":\"creativeValue\"}, \"message\":\"response OK\",\"deeplink\":\"testApp://\"}"],
beginsWith:@"status code 200 for package response: {\"attribution\":{\"tracker_token\":\"trackerTokenValue\",\"tracker_name\":\"trackerNameValue\",\"network\":\"networkValue\",\"campaign\":\"campaignValue\",\"adgroup\":\"adgroupValue\",\"creative\":\"creativeValue\",\"click_label\":\"clickLabelValue\"},\"message\":\"response OK\",\"deeplink\":\"testApp://\"}"],
@"%@", self.loggerMock);

// check that the package was successfully sent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ + (NSData *)sendSynchronousRequest:(NSURLRequest *)request returningResponse:(NS
NSString * sResponse;
if (triggerResponse == 0) {
statusCode = 200;
sResponse = @"{\"attribution\":{\"tracker_token\":\"trackerTokenValue\",\"tracker_name\":\"trackerNameValue\", \"network\":\"networkValue\",\"campaign\":\"campaignValue\", \"adgroup\":\"adgroupValue\",\"creative\":\"creativeValue\"}, \"message\":\"response OK\",\"deeplink\":\"testApp://\"}";
sResponse = @"{\"attribution\":{\"tracker_token\":\"trackerTokenValue\",\"tracker_name\":\"trackerNameValue\",\"network\":\"networkValue\",\"campaign\":\"campaignValue\",\"adgroup\":\"adgroupValue\",\"creative\":\"creativeValue\",\"click_label\":\"clickLabelValue\"},\"message\":\"response OK\",\"deeplink\":\"testApp://\"}";
} else if (triggerResponse == 1) {
statusCode = 0;
sResponse = @"{\"message\":\"response error\"}";
Expand All @@ -41,7 +41,7 @@ + (NSData *)sendSynchronousRequest:(NSURLRequest *)request returningResponse:(NS
sResponse = @"{}";
} else if (triggerResponse == 4) {
statusCode = 200;
sResponse = @"{\"attribution\":{\"tracker_token\":\"trackerTokenValue\",\"tracker_name\":\"trackerNameValue\", \"network\":\"networkValue\",\"campaign\":\"campaignValue\", \"adgroup\":\"adgroupValue\",\"creative\":\"creativeValue\"}, \"message\":\"response OK\",\"ask_in\":\"2000\"}";
sResponse = @"{\"attribution\":{\"tracker_token\":\"trackerTokenValue\",\"tracker_name\":\"trackerNameValue\",\"network\":\"networkValue\",\"campaign\":\"campaignValue\",\"adgroup\":\"adgroupValue\",\"creative\":\"creativeValue\",\"click_label\":\"clickLabelValue\"}, \"message\":\"response OK\",\"ask_in\":\"2000\"}";
} else {

statusCode = 0;
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ If you're using [CocoaPods][cocoapods], you can add the following line to your
`Podfile` and continue with [step 3](#step3):

```ruby
pod 'Adjust', :git => 'git://github.com/adjust/ios_sdk.git', :tag => 'v4.1.1'
pod 'Adjust', :git => 'git://github.com/adjust/ios_sdk.git', :tag => 'v4.2.0'
```

### 1. Get the SDK
Expand Down Expand Up @@ -325,6 +325,7 @@ Here is a quick summary of its properties:
- `NSString campaign` the campaign grouping level of the current install.
- `NSString adgroup` the ad group grouping level of the current install.
- `NSString creative` the creative grouping level of the current install.
- `NSString clickLabel` the click label of the current install.
### 10. Disable tracking
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1.1
4.2.0
2 changes: 1 addition & 1 deletion doc/migrate.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Migrate your adjust SDK for iOS to v4.1.1 from v3.4.0
## Migrate your adjust SDK for iOS to v4.2.0 from v3.4.0

### Initial setup

Expand Down

0 comments on commit 189aa71

Please sign in to comment.