Skip to content

Commit

Permalink
Merge pull request #991 from adobe/staging
Browse files Browse the repository at this point in the history
Staging to main 4.2.2
  • Loading branch information
cdhoffmann authored Jan 22, 2024
2 parents fd41234 + a181ec3 commit d91de55
Show file tree
Hide file tree
Showing 22 changed files with 340 additions and 112 deletions.
4 changes: 2 additions & 2 deletions AEPCore.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "AEPCore"
s.version = "4.2.1"
s.version = "4.2.2"
s.summary = "Core library for Adobe Experience Platform Mobile SDK. Written and maintained by Adobe."
s.description = <<-DESC
The core library provides the foundation for the Adobe Experience Platform SDK. Having the core library installed is a pre-requisite for any other Adobe Experience Platform SDK extension to work.
Expand All @@ -18,7 +18,7 @@ Pod::Spec.new do |s|
s.pod_target_xcconfig = { 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES' }

s.dependency 'AEPRulesEngine', '>= 4.0.0'
s.dependency 'AEPServices', '>= 4.2.1'
s.dependency 'AEPServices', '>= 4.2.2'


s.source_files = 'AEPCore/Sources/**/*.swift'
Expand Down
32 changes: 18 additions & 14 deletions AEPCore.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@
75550A3F2A9930A500747BB7 /* NamedCollectionDataStoreFunctionalTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75550A3E2A9930A500747BB7 /* NamedCollectionDataStoreFunctionalTests.swift */; };
75C0D9052A9D545100EF74BC /* DatastoreUtilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75C0D9042A9D545100EF74BC /* DatastoreUtilities.swift */; };
75C0D9062AA1287B00EF74BC /* AEPServicesMocks.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3FE6DDA924C62C090065EA05 /* AEPServicesMocks.framework */; };
75ED44D12B56F0B400F2CEB1 /* rules_testAttachDataArray.json in Resources */ = {isa = PBXBuildFile; fileRef = 75ED44D02B56F0B300F2CEB1 /* rules_testAttachDataArray.json */; };
7814B23325CB455200841429 /* URL+Validator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7814B23225CB455200841429 /* URL+Validator.swift */; };
786C000525B8EE2100F26D34 /* DefaultHeadersFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 786C000425B8EE2100F26D34 /* DefaultHeadersFormatter.swift */; };
786C001525B8EE6200F26D34 /* HttpConnectionConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 786C001425B8EE6200F26D34 /* HttpConnectionConstants.swift */; };
Expand Down Expand Up @@ -1058,6 +1059,7 @@
75408CF62948EA0A00C44CE1 /* AtomicCounterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AtomicCounterTests.swift; sourceTree = "<group>"; };
75550A3E2A9930A500747BB7 /* NamedCollectionDataStoreFunctionalTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NamedCollectionDataStoreFunctionalTests.swift; sourceTree = "<group>"; };
75C0D9042A9D545100EF74BC /* DatastoreUtilities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatastoreUtilities.swift; sourceTree = "<group>"; };
75ED44D02B56F0B300F2CEB1 /* rules_testAttachDataArray.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = rules_testAttachDataArray.json; sourceTree = "<group>"; };
7814B23225CB455200841429 /* URL+Validator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URL+Validator.swift"; sourceTree = "<group>"; };
786C000425B8EE2100F26D34 /* DefaultHeadersFormatter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultHeadersFormatter.swift; sourceTree = "<group>"; };
786C001425B8EE6200F26D34 /* HttpConnectionConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HttpConnectionConstants.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1854,6 +1856,7 @@
3F08FF9A24DA0DA100D34DE3 /* rules_functional_1.zip */,
BBA512B624F6C4D90030DAD1 /* rules_testAttachData_invalidJson.json */,
BBA512B124F5CF380030DAD1 /* rules_testAttachData.json */,
75ED44D02B56F0B300F2CEB1 /* rules_testAttachDataArray.json */,
BF4A6EB726BB3B9D00612434 /* rules_testDispatchEventCopy.json */,
BF4A6F2326BB4A1A00612434 /* rules_testDispatchEventInvalidAction.json */,
BF4A6F8C26BBAE6500612434 /* rules_testDispatchEventChain.json */,
Expand Down Expand Up @@ -2664,6 +2667,7 @@
BB3E86E224F975E000E39C53 /* rules_testMatcherWithDifferentTypesOfParameters.json in Resources */,
3F39520D24CA096100F7325B /* ADBMobileConfig.json in Resources */,
24A1FCE72704CE6000D28D26 /* rules_testHistory.json in Resources */,
75ED44D12B56F0B400F2CEB1 /* rules_testAttachDataArray.json in Resources */,
BBA5129D24F4899B0030DAD1 /* rules_testMatcherGt.json in Resources */,
BF4A6F0526BB48A200612434 /* rules_testDispatchEventNewNoData.json in Resources */,
BF4A6F2826BB4A1B00612434 /* rules_testDispatchEventNoSource.json in Resources */,
Expand Down Expand Up @@ -3891,7 +3895,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 4.2.1;
MARKETING_VERSION = 4.2.2;
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.core;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -3924,7 +3928,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 4.2.1;
MARKETING_VERSION = 4.2.2;
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.core;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -4005,7 +4009,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 4.2.1;
MARKETING_VERSION = 4.2.2;
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.signal;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -4036,7 +4040,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 4.2.1;
MARKETING_VERSION = 4.2.2;
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.signal;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -4108,7 +4112,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 4.2.1;
MARKETING_VERSION = 4.2.2;
PRODUCT_BUNDLE_IDENTIFIER = come.adobe.aep.services;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -4138,7 +4142,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 4.2.1;
MARKETING_VERSION = 4.2.2;
PRODUCT_BUNDLE_IDENTIFIER = come.adobe.aep.services;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -4279,7 +4283,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 4.2.1;
MARKETING_VERSION = 4.2.2;
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.AEPServicesMocks;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -4309,7 +4313,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 4.2.1;
MARKETING_VERSION = 4.2.2;
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.AEPServicesMocks;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -4338,7 +4342,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 4.2.1;
MARKETING_VERSION = 4.2.2;
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.lifecycle;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -4368,7 +4372,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 4.2.1;
MARKETING_VERSION = 4.2.2;
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.lifecycle;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -4442,7 +4446,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 4.2.1;
MARKETING_VERSION = 4.2.2;
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.identity;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -4472,7 +4476,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 4.2.1;
MARKETING_VERSION = 4.2.2;
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.identity;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -4546,7 +4550,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 4.2.1;
MARKETING_VERSION = 4.2.2;
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.AEPCoreMocks;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -4576,7 +4580,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 4.2.1;
MARKETING_VERSION = 4.2.2;
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.AEPCoreMocks;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down
2 changes: 1 addition & 1 deletion AEPCore/Sources/configuration/ConfigurationConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Foundation
struct ConfigurationConstants {
static let EXTENSION_NAME = "com.adobe.module.configuration"
static let FRIENDLY_NAME = "Configuration"
static let EXTENSION_VERSION = "4.2.1"
static let EXTENSION_VERSION = "4.2.2"
static let DATA_STORE_NAME = EXTENSION_NAME

static let CONFIG_URL_BASE = "https://assets.adobedtm.com/"
Expand Down
2 changes: 1 addition & 1 deletion AEPCore/Sources/eventhub/EventHubConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ enum EventHubConstants {
static let XDM_STATE_CHANGE = "Shared state change (XDM)"
static let NAME = "com.adobe.module.eventhub"
static let FRIENDLY_NAME = "EventHub"
static let VERSION_NUMBER = "4.2.1"
static let VERSION_NUMBER = "4.2.2"

enum EventDataKeys {
static let VERSION = "version"
Expand Down
3 changes: 3 additions & 0 deletions AEPCore/Sources/eventhub/history/EventHistory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/

import Foundation
import AEPServices

/// Provides CRUD support for storing `Event` objects in a local database.
class EventHistory {
Expand Down Expand Up @@ -62,6 +63,7 @@ class EventHistory {
let from = previousEventOldestOccurrence ?? event.fromDate
let semaphore = DispatchSemaphore(value: 0)
db.select(hash: eventHash, from: from, to: event.toDate) { result in
Log.debug(label: "EventHistory", "EventHistoryRequest[\(event.hashValue)] - request for events with hash (\(eventHash)) between (\(from?.millisecondsSince1970 ?? 0)) and (\(event.toDate?.millisecondsSince1970 ?? 0)) with enforceOrder enabled returned \(result.count) record(s).")
previousEventOldestOccurrence = result.oldestOccurrence
results.append(result)
semaphore.signal()
Expand All @@ -73,6 +75,7 @@ class EventHistory {
let semaphore = DispatchSemaphore(value: 0)
let eventHash = event.mask.fnv1a32()
db.select(hash: eventHash, from: event.fromDate, to: event.toDate) { result in
Log.debug(label: "EventHistory", "EventHistoryRequest[\(event.hashValue)] - request for events with hash (\(eventHash)) between (\(event.fromDate?.millisecondsSince1970 ?? 0)) and (\(event.toDate?.millisecondsSince1970 ?? 0)) with enforceOrder disabled returned \(result.count) record(s).")
results.append(result)
semaphore.signal()
}
Expand Down
8 changes: 4 additions & 4 deletions AEPCore/Sources/eventhub/history/EventHistoryDatabase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class EventHistoryDatabase {
// first verify we can get a connection handle
guard let connection = self.connection else {
Log.warning(label: self.LOG_PREFIX, "Unable to get a connection to the event history database.")
handler(EventHistoryResult(count: 0))
handler(EventHistoryResult(count: -1))
return
}

Expand All @@ -113,11 +113,11 @@ class EventHistoryDatabase {
AND \(self.columnTimestamp) <= \(to?.millisecondsSince1970 ?? Date().millisecondsSince1970)
"""

// a nil result means there was no query results to be returned
// a nil result means something went wrong with the database query
guard let result = SQLiteWrapper.query(database: connection, sql: selectStatement),
let row = result.first else {
Log.trace(label: self.LOG_PREFIX, "No query results were returned for event '\(hash)' between \(String(describing: from)) and \(String(describing: to)).")
handler(EventHistoryResult(count: 0))
Log.warning(label: self.LOG_PREFIX, "An error occurred when attempting to query for event(s) '\(hash)' between \(String(describing: from)) and \(String(describing: to)).")
handler(EventHistoryResult(count: -1))
return
}

Expand Down
26 changes: 23 additions & 3 deletions AEPCore/Sources/rules/JSONRulesParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ class JSONCondition: Codable {
return ComparisonExpression(lhs: historyOperand, operationName: matcher, rhs: Operand(integerLiteral: valueAsInt))
}

/// Queries the EventHistory database for matching entries
///
/// For an `.any` search (event order does not matter), the value returned will be the count of all matching events in EventHistory
/// For an `.ordered` search (events must occur in the provided order), the value returned will be 1 if the events were found in the provided order, or 0 otherwise.
/// If a database error occurred, this method will always return -1
///
/// - Parameter parameters: An array of parameters containing, in order, an `ExtensionRuntime`, `[EventHistoryRequest]`, and an `EventHistorySearchType`.
/// - Returns: the number of matching records for an `.any` search, or a boolean (1 or 0) indicating whether search conditions were met for an `.ordered` search.
func getHistoricalEventCount(parameters: [Any]?) -> Int {
guard let params = parameters,
let runtime = params[0] as? ExtensionRuntime,
Expand All @@ -183,8 +191,13 @@ class JSONCondition: Codable {
runtime.getHistoricalEvents(requestEvents, enforceOrder: searchType == .ordered) { results in
if searchType == .ordered {
for result in results {
if result.count < 1 {
// quick exit on ordered searches if any result has a count < 1
if result.count == -1 {
// database error
returnValue = -1
semaphore.signal()
break
} else if result.count == 0 {
// quick exit on ordered searches if any result has a count == 0
returnValue = 0
semaphore.signal()
break
Expand All @@ -194,7 +207,14 @@ class JSONCondition: Codable {
}
} else {
for result in results {
returnValue += result.count
if result.count == -1 {
// database error
returnValue = -1
semaphore.signal()
break
} else {
returnValue += result.count
}
}
}

Expand Down
27 changes: 19 additions & 8 deletions AEPCore/Sources/rules/LaunchRulesEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -284,22 +284,33 @@ public class LaunchRulesEngine {
return RuleConsequence(id: consequence.id, type: consequence.type, details: dict)
}

private func replaceToken(in value: Any, data: Traversable) -> Any {
switch value {
case let valString as String:
return replaceToken(for: valString, data: data)
case let nestedDict as [String: Any?]:
return replaceToken(in: nestedDict, data: data)
case let nestedArray as [Any]:
return replaceToken(in: nestedArray, data: data)
default:
return value
}
}

private func replaceToken(in dict: [String: Any?], data: Traversable) -> [String: Any?] {
var mutableDict = dict
for (key, value) in mutableDict {
switch value {
case is String:
mutableDict[key] = replaceToken(for: value as! String, data: data)
case is [String: Any]:
let valueDict = mutableDict[key] as! [String: Any]
mutableDict[key] = replaceToken(in: valueDict, data: data)
default:
break
if let value = value {
mutableDict[key] = replaceToken(in: value, data: data)
}
}
return mutableDict
}

private func replaceToken(in array: [Any], data: Traversable) -> [Any] {
return array.map { replaceToken(in: $0, data: data) }
}

private func replaceToken(for value: String, data: Traversable) -> String {
let template = Template(templateString: value, tagDelimiterPair: (LaunchRulesEngine.LAUNCH_RULE_TOKEN_LEFT_DELIMITER, LaunchRulesEngine.LAUNCH_RULE_TOKEN_RIGHT_DELIMITER))
return template.render(data: data, transformers: transformer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class EventHistoryDatabaseTests: XCTestCase {

eventHistoryDatabase.select(hash: testHash, from: nil, to: nil) { result in
XCTAssertNotNil(result)
XCTAssertEqual(0, result.count)
XCTAssertEqual(-1, result.count)
XCTAssertNil(result.newestOccurrence)
XCTAssertNil(result.oldestOccurrence)
selectExpectation.fulfill()
Expand Down
Loading

0 comments on commit d91de55

Please sign in to comment.