Skip to content

Commit 4131f7a

Browse files
Pre-Release 2.0.2-beta1 (#252)
* fix to send new events to new endpoint and any old events that might … (#249) * fix to send new events to new endpoint and any old events that might be around to the old events endpoints * use clientEngine instead of client_engine * add a couple of tests for sending to new and old endpoints * Kroach/oasis 2768 upgradev2 (#251) * Forcing old datafile to include anonymizeIP required by V4 format. * Add testOlderV2Datafile unit test * Bump version number to 2.0.2-beta1 * Rebuild universal frameworks * Update CHANGELOG.md
1 parent 1fb761c commit 4131f7a

File tree

32 files changed

+225
-68
lines changed

32 files changed

+225
-68
lines changed

CHANGELOG.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Optimizely Objective-C SDK Changelog
2-
## 2.0.1
3-
May 9, 2018
2+
## 2.0.2-beta1
3+
May 17, 2018
44

5-
### New Features
6-
* Adding mobile 2.x data file CDN url change to support FullStack projects without Feature Management V2 schema.
7-
8-
## 2.0.0
9-
April 23, 2018
5+
**This "-beta1" pre-release corrects two significant bugs present in the
6+
previous 2.0.x releases which have been withdrawn. Please note that
7+
2.0+ SDKs are incompatible with existing 1.x Mobile Optimizely
8+
projects. Before you use 2.0+ and Feature Management, please contact
9+
your Optimizely account team. If you are not upgrading to Feature
10+
Management, we recommend remaining on your current 1.x SDK.**
1011

1112
This major release of the Optimizely SDK introduces APIs for Feature Management.
1213

@@ -80,6 +81,8 @@ with Notification Listeners APIs
8081
* Added `@"$opt_bucketing_id"` in the attribute map for overriding bucketing using the user id. This string is
8182
available as OptimizelyBucketId in OPTLYEventBuilder.h .
8283

84+
* Adding mobile 2.x data file CDN url change to support FullStack projects without Feature Management V2 schema.
85+
8386
### Bug Fixes:
8487
* Fix single quote in events issue. Event was sent repeatedly because it was
8588
unable to be deleted from data store due to syntax error.

OptimizelySDKCore.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "OptimizelySDKCore"
3-
s.version = "2.0.1"
3+
s.version = "2.0.2-beta1"
44
s.summary = "Optimizely server-side testing core framework."
55
s.homepage = "http://developers.optimizely.com/server/reference/index.html?language=objectivec"
66
s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" }

OptimizelySDKCore/OptimizelySDKCore.xcodeproj/project.pbxproj

+10-4
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@
198198
3ECB82061FD92736006505E6 /* OPTLYRollout.m in Sources */ = {isa = PBXBuildFile; fileRef = 3ECB82031FD92736006505E6 /* OPTLYRollout.m */; };
199199
3ECB82071FD92736006505E6 /* OPTLYRollout.m in Sources */ = {isa = PBXBuildFile; fileRef = 3ECB82031FD92736006505E6 /* OPTLYRollout.m */; };
200200
3EE687AA1F312FA30084B375 /* BucketerTestsDatafile2.json in Resources */ = {isa = PBXBuildFile; fileRef = 3E92800D1F26AD4700214C58 /* BucketerTestsDatafile2.json */; };
201+
3EF9D99020AE425000A9B002 /* V2TestDatafile.json in Resources */ = {isa = PBXBuildFile; fileRef = 3EF9D98F20AE424F00A9B002 /* V2TestDatafile.json */; };
202+
3EF9D99120AE425000A9B002 /* V2TestDatafile.json in Resources */ = {isa = PBXBuildFile; fileRef = 3EF9D98F20AE424F00A9B002 /* V2TestDatafile.json */; };
201203
4FFB468BAFC670CF55514638 /* Pods_OptimizelySDKCoreTVOSTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9A3A368275572C29A76DC80A /* Pods_OptimizelySDKCoreTVOSTests.framework */; };
202204
5E4C07F31DFF645C0042B1F8 /* InvalidDatafileVersionDatafile.json in Resources */ = {isa = PBXBuildFile; fileRef = 5E4C07F21DFF645C0042B1F8 /* InvalidDatafileVersionDatafile.json */; };
203205
5E4C07F41DFF645C0042B1F8 /* InvalidDatafileVersionDatafile.json in Resources */ = {isa = PBXBuildFile; fileRef = 5E4C07F21DFF645C0042B1F8 /* InvalidDatafileVersionDatafile.json */; };
@@ -580,6 +582,7 @@
580582
3ECB81FD1FD926FE006505E6 /* OPTLYVariableUsage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OPTLYVariableUsage.m; sourceTree = "<group>"; };
581583
3ECB82021FD92736006505E6 /* OPTLYRollout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OPTLYRollout.h; sourceTree = "<group>"; };
582584
3ECB82031FD92736006505E6 /* OPTLYRollout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OPTLYRollout.m; sourceTree = "<group>"; };
585+
3EF9D98F20AE424F00A9B002 /* V2TestDatafile.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = V2TestDatafile.json; sourceTree = "<group>"; };
583586
51B050141BF2E9277B39EEE8 /* Pods-OptimizelySDKCoreiOSTests.rc.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OptimizelySDKCoreiOSTests.rc.xcconfig"; path = "../Pods/Target Support Files/Pods-OptimizelySDKCoreiOSTests/Pods-OptimizelySDKCoreiOSTests.rc.xcconfig"; sourceTree = "<group>"; };
584587
5E4C07F21DFF645C0042B1F8 /* InvalidDatafileVersionDatafile.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = InvalidDatafileVersionDatafile.json; sourceTree = "<group>"; };
585588
5E4C07FA1DFF66B00042B1F8 /* OPTLYNetworkServiceTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OPTLYNetworkServiceTest.m; sourceTree = "<group>"; };
@@ -1129,6 +1132,7 @@
11291132
EA2FAB971DC6FDFA00B1D81B /* test_data_10_experiments.json */,
11301133
EA2FAB981DC6FDFA00B1D81B /* test_data_25_experiments.json */,
11311134
EA2FAB991DC6FDFA00B1D81B /* test_data_50_experiments.json */,
1135+
3EF9D98F20AE424F00A9B002 /* V2TestDatafile.json */,
11321136
);
11331137
path = TestData;
11341138
sourceTree = "<group>";
@@ -1611,6 +1615,7 @@
16111615
5E4C07F31DFF645C0042B1F8 /* InvalidDatafileVersionDatafile.json in Resources */,
16121616
3E99CF7F1FE02C2D00B16B97 /* optimizely_6372300739_v4.json in Resources */,
16131617
EA2FABC91DC6FDFA00B1D81B /* BucketerTestsDatafile.json in Resources */,
1618+
3EF9D99020AE425000A9B002 /* V2TestDatafile.json in Resources */,
16141619
EA2FABD21DC6FDFA00B1D81B /* test_data_25_experiments.json in Resources */,
16151620
3EE687AA1F312FA30084B375 /* BucketerTestsDatafile2.json in Resources */,
16161621
);
@@ -1634,6 +1639,7 @@
16341639
EA2FABD01DC6FDFA00B1D81B /* test_data_10_experiments.json in Resources */,
16351640
3E99CF801FE02C2E00B16B97 /* optimizely_6372300739_v4.json in Resources */,
16361641
5E4C07F41DFF645C0042B1F8 /* InvalidDatafileVersionDatafile.json in Resources */,
1642+
3EF9D99120AE425000A9B002 /* V2TestDatafile.json in Resources */,
16371643
EA2FABCA1DC6FDFA00B1D81B /* BucketerTestsDatafile.json in Resources */,
16381644
EA2FABD31DC6FDFA00B1D81B /* test_data_25_experiments.json in Resources */,
16391645
);
@@ -2184,8 +2190,8 @@
21842190
OPTIMIZELY_SDK_VERSION = "$(OPTIMIZELY_SDK_VERSION_MAJOR).$(OPTIMIZELY_SDK_VERSION_MINOR).$(OPTIMIZELY_SDK_VERSION_PATCH)$(OPTIMIZELY_SDK_VERSION_SUFFIX)";
21852191
OPTIMIZELY_SDK_VERSION_MAJOR = 2;
21862192
OPTIMIZELY_SDK_VERSION_MINOR = 0;
2187-
OPTIMIZELY_SDK_VERSION_PATCH = 1;
2188-
OPTIMIZELY_SDK_VERSION_SUFFIX = "";
2193+
OPTIMIZELY_SDK_VERSION_PATCH = 2;
2194+
OPTIMIZELY_SDK_VERSION_SUFFIX = "-beta1";
21892195
PRODUCT_MODULE_NAME = "$(PRODUCT_NAME)";
21902196
SDKROOT = iphoneos;
21912197
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
@@ -2461,8 +2467,8 @@
24612467
OPTIMIZELY_SDK_VERSION = "$(OPTIMIZELY_SDK_VERSION_MAJOR).$(OPTIMIZELY_SDK_VERSION_MINOR).$(OPTIMIZELY_SDK_VERSION_PATCH)$(OPTIMIZELY_SDK_VERSION_SUFFIX)";
24622468
OPTIMIZELY_SDK_VERSION_MAJOR = 2;
24632469
OPTIMIZELY_SDK_VERSION_MINOR = 0;
2464-
OPTIMIZELY_SDK_VERSION_PATCH = 1;
2465-
OPTIMIZELY_SDK_VERSION_SUFFIX = "";
2470+
OPTIMIZELY_SDK_VERSION_PATCH = 2;
2471+
OPTIMIZELY_SDK_VERSION_SUFFIX = "-beta1";
24662472
PRODUCT_MODULE_NAME = "$(PRODUCT_NAME)";
24672473
SDKROOT = iphoneos;
24682474
TARGETED_DEVICE_FAMILY = "1,2";

OptimizelySDKCore/OptimizelySDKCore/OPTLYEventBuilder.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ - (NSDictionary *)createCommonParams:(OPTLYProjectConfig *)config userId:(NSStri
262262
params[OPTLYEventParameterKeysClientEngine] = [OPTLYEventBuilderDefault stringOrEmpty:[config clientEngine]];
263263
params[OPTLYEventParameterKeysClientVersion] = [OPTLYEventBuilderDefault stringOrEmpty:[config clientVersion]];
264264
params[OPTLYEventParameterKeysRevision] = [OPTLYEventBuilderDefault stringOrEmpty:config.revision];
265-
params[OPTLYEventParameterKeysAnonymizeIP] = config.anonymizeIP ? @YES : @NO;
265+
params[OPTLYEventParameterKeysAnonymizeIP] = @(config.anonymizeIP.boolValue);
266266

267267
return [params copy];
268268
}

OptimizelySDKCore/OptimizelySDKCore/OPTLYProjectConfig.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ NS_ASSUME_NONNULL_END
4545
/// Datafile Revision number
4646
@property (nonatomic, strong, nonnull) NSString *revision;
4747
/// Flag for IP anonymization
48-
@property (nonatomic, assign) BOOL anonymizeIP;
48+
@property (nonatomic) NSNumber<Optional> *anonymizeIP;
4949
/// List of Optimizely Experiment objects
5050
@property (nonatomic, strong, nonnull) NSArray<OPTLYExperiment> *experiments;
5151
/// List of Optimizely Event Type objects

OptimizelySDKCore/OptimizelySDKCore/OPTLYProjectConfig.m

+6
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ - (instancetype)initWithBuilder:(OPTLYProjectConfigBuilder *)builder {
113113
[builder.logger logMessage:logMessage withLevel:OptimizelyLogLevelWarning];
114114
}
115115

116+
if (projectConfig.anonymizeIP == nil) {
117+
NSString *logMessage = @"Forcing old datafile to include anonymizeIP required by V4 format.";
118+
[builder.logger logMessage:logMessage withLevel:OptimizelyLogLevelWarning];
119+
projectConfig.anonymizeIP = @1;
120+
}
121+
116122
if (datafileError)
117123
{
118124
NSError *error = [NSError errorWithDomain:OPTLYErrorHandlerMessagesDomain

OptimizelySDKCore/OptimizelySDKCoreTests/OPTLYProjectConfigTest.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ - (void)testInitWithAnonymizeIPFalse {
153153
NSData *datafile = [OPTLYTestHelper loadJSONDatafileIntoDataObject:kDatafileNameAnonymizeIPFalse];
154154
OPTLYProjectConfig *projectConfig = [[OPTLYProjectConfig alloc] initWithDatafile:datafile];
155155

156-
XCTAssertFalse(projectConfig.anonymizeIP, @"IP anonymization should be set to false.");
156+
XCTAssertFalse(projectConfig.anonymizeIP.boolValue, @"IP anonymization should be set to false.");
157157
}
158158

159159
#pragma mark - Test getExperimentForKey:
@@ -467,7 +467,7 @@ - (void)checkProjectConfigProperties:(OPTLYProjectConfig *)projectConfig
467467
NSAssert([projectConfig.revision isEqualToString:kRevision], @"Invalid revision number.");
468468

469469
// validate IP anonymization value
470-
XCTAssertTrue(projectConfig.anonymizeIP, @"IP anonymization should be set to true.");
470+
XCTAssertTrue(projectConfig.anonymizeIP.boolValue, @"IP anonymization should be set to true.");
471471

472472
// check experiments
473473
NSAssert([projectConfig.experiments count] == kNumberOfExperimentObjects, @"deserializeJSONArray failed to deserialize the right number of experiments objects in project config.");

OptimizelySDKCore/OptimizelySDKCoreTests/OptimizelyTest.m

+10
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
static NSString *const kEventNameWithMultipleExperiments = @"testEventWithMultipleExperiments";
3838

3939
// datafiles
40+
static NSString *const kV2TestDatafileName = @"V2TestDatafile";
4041
static NSString *const kBucketerTestDatafileName = @"BucketerTestsDatafile";
4142

4243
// user IDs
@@ -157,6 +158,15 @@ - (void)testVariationWithAudience {
157158
XCTAssertNotNil(variation);
158159
}
159160

161+
// Test initializing with older V2 datafile
162+
- (void)testOlderV2Datafile {
163+
NSData *datafile = [OPTLYTestHelper loadJSONDatafileIntoDataObject:kV2TestDatafileName];
164+
Optimizely *optimizely = [Optimizely init:^(OPTLYBuilder * _Nullable builder) {
165+
builder.datafile = datafile;
166+
}];
167+
XCTAssertNotNil(optimizely);
168+
}
169+
160170
// Test whitelisting works with get variation
161171
- (void)testVariationWhitelisting {
162172
NSData *datafile = [OPTLYTestHelper loadJSONDatafileIntoDataObject:kBucketerTestDatafileName];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"accountId": "12345",
3+
"projectId": "23456",
4+
"revision": "6",
5+
"version": "2",
6+
"experiments": [
7+
{
8+
"key": "my_experiment",
9+
"id": "45678",
10+
"layerId": "34567",
11+
"status": "Running",
12+
"variations": [
13+
{
14+
"id": "56789",
15+
"key": "control"
16+
},
17+
{
18+
"id": "67890",
19+
"key": "treatment"
20+
}
21+
],
22+
"trafficAllocation": [
23+
{
24+
"entityId": "56789",
25+
"endOfRange": 5000
26+
},
27+
{
28+
"entityId": "67890",
29+
"endOfRange": 10000
30+
}
31+
],
32+
"audienceIds": [],
33+
"forcedVariations": {}
34+
}
35+
],
36+
"events": [
37+
{
38+
"experimentIds": [
39+
"34567"
40+
],
41+
"id": "56789",
42+
"key": "my_conversion"
43+
}
44+
],
45+
"audiences": [],
46+
"attributes": [],
47+
"groups": []
48+
}

OptimizelySDKDatafileManager.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "OptimizelySDKDatafileManager"
3-
s.version = "2.0.1"
3+
s.version = "2.0.2-beta1"
44
s.summary = "Optimizely server-side testing datafile manager framework."
55
s.homepage = "http://developers.optimizely.com/server/reference/index.html?language=objectivec"
66
s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" }
@@ -16,5 +16,5 @@ Pod::Spec.new do |s|
1616
s.framework = "Foundation"
1717
s.requires_arc = true
1818
s.xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => "OPTIMIZELY_SDK_VERSION=@\\\"#{s.version}\\\"" }
19-
s.dependency 'OptimizelySDKShared', '2.0.1'
19+
s.dependency 'OptimizelySDKShared', '2.0.2-beta1'
2020
end

OptimizelySDKDatafileManager/OptimizelySDKDatafileManager.xcodeproj/project.pbxproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -833,8 +833,8 @@
833833
OPTIMIZELY_SDK_VERSION = "$(OPTIMIZELY_SDK_VERSION_MAJOR).$(OPTIMIZELY_SDK_VERSION_MINOR).$(OPTIMIZELY_SDK_VERSION_PATCH)$(OPTIMIZELY_SDK_VERSION_SUFFIX)";
834834
OPTIMIZELY_SDK_VERSION_MAJOR = 2;
835835
OPTIMIZELY_SDK_VERSION_MINOR = 0;
836-
OPTIMIZELY_SDK_VERSION_PATCH = 1;
837-
OPTIMIZELY_SDK_VERSION_SUFFIX = "";
836+
OPTIMIZELY_SDK_VERSION_PATCH = 2;
837+
OPTIMIZELY_SDK_VERSION_SUFFIX = "-beta1";
838838
SDKROOT = iphoneos;
839839
TARGETED_DEVICE_FAMILY = "1,2";
840840
VALIDATE_PRODUCT = YES;
@@ -901,8 +901,8 @@
901901
OPTIMIZELY_SDK_VERSION = "$(OPTIMIZELY_SDK_VERSION_MAJOR).$(OPTIMIZELY_SDK_VERSION_MINOR).$(OPTIMIZELY_SDK_VERSION_PATCH)$(OPTIMIZELY_SDK_VERSION_SUFFIX)";
902902
OPTIMIZELY_SDK_VERSION_MAJOR = 2;
903903
OPTIMIZELY_SDK_VERSION_MINOR = 0;
904-
OPTIMIZELY_SDK_VERSION_PATCH = 1;
905-
OPTIMIZELY_SDK_VERSION_SUFFIX = "";
904+
OPTIMIZELY_SDK_VERSION_PATCH = 2;
905+
OPTIMIZELY_SDK_VERSION_SUFFIX = "-beta1";
906906
SDKROOT = iphoneos;
907907
TARGETED_DEVICE_FAMILY = "1,2";
908908
VERSIONING_SYSTEM = "apple-generic";

OptimizelySDKEventDispatcher.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "OptimizelySDKEventDispatcher"
3-
s.version = "2.0.1"
3+
s.version = "2.0.2-beta1"
44
s.summary = "Optimizely server-side testing event dispatcher framework."
55
s.homepage = "http://developers.optimizely.com/server/reference/index.html?language=objectivec"
66
s.license = { :type => "Apache License, Version 2.0", :file => "LICENSE" }
@@ -16,5 +16,5 @@ Pod::Spec.new do |s|
1616
s.framework = "Foundation"
1717
s.requires_arc = true
1818
s.xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => "OPTIMIZELY_SDK_VERSION=@\\\"#{s.version}\\\"" }
19-
s.dependency 'OptimizelySDKShared', '2.0.1'
19+
s.dependency 'OptimizelySDKShared', '2.0.2-beta1'
2020
end

OptimizelySDKEventDispatcher/OptimizelySDKEventDispatcher.xcodeproj/project.pbxproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -709,8 +709,8 @@
709709
OPTIMIZELY_SDK_VERSION = "$(OPTIMIZELY_SDK_VERSION_MAJOR).$(OPTIMIZELY_SDK_VERSION_MINOR).$(OPTIMIZELY_SDK_VERSION_PATCH)$(OPTIMIZELY_SDK_VERSION_SUFFIX)";
710710
OPTIMIZELY_SDK_VERSION_MAJOR = 2;
711711
OPTIMIZELY_SDK_VERSION_MINOR = 0;
712-
OPTIMIZELY_SDK_VERSION_PATCH = 1;
713-
OPTIMIZELY_SDK_VERSION_SUFFIX = "";
712+
OPTIMIZELY_SDK_VERSION_PATCH = 2;
713+
OPTIMIZELY_SDK_VERSION_SUFFIX = "-beta1";
714714
SDKROOT = iphoneos;
715715
TARGETED_DEVICE_FAMILY = "1,2";
716716
VALIDATE_PRODUCT = YES;
@@ -779,8 +779,8 @@
779779
OPTIMIZELY_SDK_VERSION = "$(OPTIMIZELY_SDK_VERSION_MAJOR).$(OPTIMIZELY_SDK_VERSION_MINOR).$(OPTIMIZELY_SDK_VERSION_PATCH)$(OPTIMIZELY_SDK_VERSION_SUFFIX)";
780780
OPTIMIZELY_SDK_VERSION_MAJOR = 2;
781781
OPTIMIZELY_SDK_VERSION_MINOR = 0;
782-
OPTIMIZELY_SDK_VERSION_PATCH = 1;
783-
OPTIMIZELY_SDK_VERSION_SUFFIX = "";
782+
OPTIMIZELY_SDK_VERSION_PATCH = 2;
783+
OPTIMIZELY_SDK_VERSION_SUFFIX = "-beta1";
784784
SDKROOT = iphoneos;
785785
TARGETED_DEVICE_FAMILY = "1,2";
786786
VERSIONING_SYSTEM = "apple-generic";

OptimizelySDKEventDispatcher/OptimizelySDKEventDispatcher/OPTLYEventDispatcher.m

+34-6
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
// TODO - Flush events when network connection has become available.
2424

2525
// --- Event URLs ----
26-
NSString * const OPTLYEventDispatcherImpressionEventURL = @"https://logx.optimizely.com/log/decision";
27-
NSString * const OPTLYEventDispatcherConversionEventURL = @"https://logx.optimizely.com/log/event";
26+
NSString * const OPTLYEventDispatcherEventsURL = @"https://logx.optimizely.com/v1/events";
27+
28+
NSString * const oldOPTLYEventDispatcherImpressionEventURL = @"https://logx.optimizely.com/log/decision";
29+
NSString * const oldOPTLYEventDispatcherConversionEventURL = @"https://logx.optimizely.com/log/event";
2830

2931
// Default interval and timeout values (in s) if not set by users
3032
const NSInteger OPTLYEventDispatcherDefaultDispatchIntervalTime_s = 0;
@@ -207,6 +209,16 @@ - (void)dispatchNewEvent:(nonnull NSDictionary *)params
207209
}];
208210
}
209211

212+
// A saved event has entityId and json in its dictionary so that it can be deleted by entityId
213+
- (bool)isSavedEvent:(nonnull NSDictionary *)event {
214+
return event[@"json"] != nil;
215+
}
216+
// It is an old single point event if it contains clientEngine. So, send it to the appropriate endpoint.
217+
// This may not be necessary but just in case there are some old events in the queue.
218+
- (bool)isOldEvent:(nonnull NSDictionary *)event {
219+
return [self isSavedEvent:event] && event[@"json"][@"clientEngine"] != nil;
220+
}
221+
210222
- (void)dispatchEvent:(nonnull NSDictionary *)event
211223
backoffRetry:(BOOL)backoffRetry
212224
eventType:(OPTLYDataStoreEventType)eventType
@@ -228,9 +240,10 @@ - (void)dispatchEvent:(nonnull NSDictionary *)event
228240
[self.pendingDispatchEvents addObject:event];
229241
}
230242

231-
NSURL *url = [self URLForEvent:eventType];
243+
NSURL *url = [self isOldEvent:event] ? [self oldURLForEvent:eventType] : [self URLForEvent:eventType];
232244

233-
NSDictionary *eventToSend = event[@"json"] == nil ? event : event[@"json"];
245+
NSDictionary *eventToSend = [self isSavedEvent:event] ? event[@"json"] : event;
246+
234247
__weak typeof(self) weakSelf = self;
235248
[self.networkService dispatchEvent:eventToSend
236249
backoffRetry:backoffRetry
@@ -465,14 +478,29 @@ - (NSInteger)numberOfEvents
465478
return numberOfImpressionEventsSaved + numberOfConversionEventsSaved;
466479
}
467480

481+
- (NSURL *)oldURLForEvent:(OPTLYDataStoreEventType)eventType {
482+
NSURL *url = nil;
483+
switch(eventType) {
484+
case OPTLYDataStoreEventTypeImpression:
485+
url = [NSURL URLWithString:oldOPTLYEventDispatcherImpressionEventURL];
486+
break;
487+
case OPTLYDataStoreEventTypeConversion:
488+
url = [NSURL URLWithString:oldOPTLYEventDispatcherConversionEventURL];
489+
break;
490+
default:
491+
break;
492+
}
493+
return url;
494+
}
495+
468496
- (NSURL *)URLForEvent:(OPTLYDataStoreEventType)eventType {
469497
NSURL *url = nil;
470498
switch(eventType) {
471499
case OPTLYDataStoreEventTypeImpression:
472-
url = [NSURL URLWithString:OPTLYEventDispatcherImpressionEventURL];
500+
url = [NSURL URLWithString:OPTLYEventDispatcherEventsURL];
473501
break;
474502
case OPTLYDataStoreEventTypeConversion:
475-
url = [NSURL URLWithString:OPTLYEventDispatcherConversionEventURL];
503+
url = [NSURL URLWithString:OPTLYEventDispatcherEventsURL];
476504
break;
477505
default:
478506
break;

0 commit comments

Comments
 (0)