Skip to content

Commit

Permalink
Release 6.1.0 (#270)
Browse files Browse the repository at this point in the history
## [6.1.0] - 2022-05-17
### Added
- Added the `LDUser.isAnonymousNullable` property that allows treating the `isAnonymous` property as nullable.

### Fixed
- Correctly track whether the `LDUser.isAnonymous` property was set explicitly (or by not specifying a key). The variation result for flag rules targeting the `anonymous` property can differ depending on whether the property is set explicitly.
  • Loading branch information
gwhelanLD authored May 17, 2022
1 parent 3b63e5b commit cfe3e47
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 277 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to the LaunchDarkly iOS SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).

## [6.1.0] - 2022-05-17
### Added
- Added the `LDUser.isAnonymousNullable` property that allows treating the `isAnonymous` property as nullable.

### Fixed
- Correctly track whether the `LDUser.isAnonymous` property was set explicitly (or by not specifying a key). The variation result for flag rules targeting the `anonymous` property can differ depending on whether the property is set explicitly.

## [6.0.0] - 2022-05-04
This major version has accompanying migration guides for [Swift](https://docs.launchdarkly.com/sdk/client-side/ios/migration-5-to-6-swift) and [Objective-C](https://docs.launchdarkly.com/sdk/client-side/ios/migration-5-to-6-objc). Please see the guide for more information on updating to this version of the SDK, as the following is just a summary of the changes.

Expand Down
2 changes: 1 addition & 1 deletion LaunchDarkly.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Pod::Spec.new do |ld|

ld.name = "LaunchDarkly"
ld.version = "6.0.0"
ld.version = "6.1.0"
ld.summary = "iOS SDK for LaunchDarkly"

ld.description = <<-DESC
Expand Down
24 changes: 12 additions & 12 deletions LaunchDarkly.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,7 @@
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = "$(PROJECT_DIR)/LaunchDarkly/LaunchDarkly/Support/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
MARKETING_VERSION = 6.0.0;
MARKETING_VERSION = 6.1.0;
MODULEMAP_FILE = "";
PRODUCT_BUNDLE_IDENTIFIER = "com.launchdarkly.Darkly-tvOS";
PRODUCT_NAME = LaunchDarkly_tvOS;
Expand All @@ -1420,7 +1420,7 @@
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = "$(PROJECT_DIR)/LaunchDarkly/LaunchDarkly/Support/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
MARKETING_VERSION = 6.0.0;
MARKETING_VERSION = 6.1.0;
MODULEMAP_FILE = "";
PRODUCT_BUNDLE_IDENTIFIER = "com.launchdarkly.Darkly-tvOS";
PRODUCT_NAME = LaunchDarkly_tvOS;
Expand All @@ -1443,7 +1443,7 @@
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = "$(PROJECT_DIR)/LaunchDarkly/LaunchDarkly/Support/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
MARKETING_VERSION = 6.0.0;
MARKETING_VERSION = 6.1.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.launchdarkly.Darkly-macOS";
PRODUCT_NAME = LaunchDarkly_macOS;
SDKROOT = macosx;
Expand All @@ -1464,7 +1464,7 @@
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = "$(PROJECT_DIR)/LaunchDarkly/LaunchDarkly/Support/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
MARKETING_VERSION = 6.0.0;
MARKETING_VERSION = 6.1.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.launchdarkly.Darkly-macOS";
PRODUCT_NAME = LaunchDarkly_macOS;
SDKROOT = macosx;
Expand Down Expand Up @@ -1507,8 +1507,8 @@
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
DYLIB_COMPATIBILITY_VERSION = 6.0.0;
DYLIB_CURRENT_VERSION = 6.0.0;
DYLIB_COMPATIBILITY_VERSION = 6.1.0;
DYLIB_CURRENT_VERSION = 6.1.0;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
FRAMEWORK_VERSION = C;
Expand Down Expand Up @@ -1578,8 +1578,8 @@
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DYLIB_COMPATIBILITY_VERSION = 6.0.0;
DYLIB_CURRENT_VERSION = 6.0.0;
DYLIB_COMPATIBILITY_VERSION = 6.1.0;
DYLIB_CURRENT_VERSION = 6.1.0;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
FRAMEWORK_VERSION = C;
Expand Down Expand Up @@ -1618,7 +1618,7 @@
INFOPLIST_FILE = "$(PROJECT_DIR)/LaunchDarkly/LaunchDarkly/Support/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_DYLIB_INSTALL_NAME = "$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)";
MARKETING_VERSION = 6.0.0;
MARKETING_VERSION = 6.1.0;
MODULEMAP_FILE = "$(PROJECT_DIR)/Framework/module.modulemap";
PRODUCT_BUNDLE_IDENTIFIER = com.launchdarkly.Darkly;
PRODUCT_NAME = LaunchDarkly;
Expand All @@ -1638,7 +1638,7 @@
INFOPLIST_FILE = "$(PROJECT_DIR)/LaunchDarkly/LaunchDarkly/Support/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_DYLIB_INSTALL_NAME = "$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)";
MARKETING_VERSION = 6.0.0;
MARKETING_VERSION = 6.1.0;
MODULEMAP_FILE = "$(PROJECT_DIR)/Framework/module.modulemap";
PRODUCT_BUNDLE_IDENTIFIER = com.launchdarkly.Darkly;
PRODUCT_NAME = LaunchDarkly;
Expand Down Expand Up @@ -1680,7 +1680,7 @@
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = "$(PROJECT_DIR)/LaunchDarkly/LaunchDarkly/Support/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
MARKETING_VERSION = 6.0.0;
MARKETING_VERSION = 6.1.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.launchdarkly.Darkly-watchOS";
PRODUCT_NAME = LaunchDarkly_watchOS;
SDKROOT = watchos;
Expand All @@ -1702,7 +1702,7 @@
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = "$(PROJECT_DIR)/LaunchDarkly/LaunchDarkly/Support/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
MARKETING_VERSION = 6.0.0;
MARKETING_VERSION = 6.1.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.launchdarkly.Darkly-watchOS";
PRODUCT_NAME = LaunchDarkly_watchOS;
SDKROOT = watchos;
Expand Down
2 changes: 1 addition & 1 deletion LaunchDarkly/LaunchDarkly/LDClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ public class LDClient {
return
}
let event = CustomEvent(key: key, user: user, data: data ?? .null, metricValue: metricValue)
Log.debug(typeName(and: #function) + "event: \(event), data: \(String(describing: data)), metricValue: \(String(describing: metricValue))")
Log.debug(typeName(and: #function) + "key: \(key), data: \(String(describing: data)), metricValue: \(String(describing: metricValue))")
eventReporter.record(event)
}

Expand Down
23 changes: 19 additions & 4 deletions LaunchDarkly/LaunchDarkly/Models/LDUser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,19 @@ public struct LDUser: Encodable, Equatable {
/// Client app defined dictionary for the user. The client app may declare top level dictionary items as private, see `privateAttributes` for details. (Default: [:])
public var custom: [String: LDValue]
/// Client app defined isAnonymous for the user. If the client app does not define isAnonymous, the SDK will use the `key` to set this attribute. isAnonymous cannot be made private. (Default: true)
public var isAnonymous: Bool
public var isAnonymous: Bool {
get { isAnonymousNullable == true }
set { isAnonymousNullable = newValue }
}

/**
Whether or not the user is anonymous, if that has been specified (or set due to the lack of a `key` property).
Although the `isAnonymous` property defaults to `false` in terms of LaunchDarkly's indexing behavior, for historical
reasons flag evaluation may behave differently if the value is explicitly set to `false` verses being omitted. This
field allows treating the property as optional for consisent evaluation with other LaunchDarkly SDKs.
*/
public var isAnonymousNullable: Bool?

/**
Client app defined privateAttributes for the user.
Expand Down Expand Up @@ -91,7 +103,10 @@ public struct LDUser: Encodable, Equatable {
self.ipAddress = ipAddress
self.email = email
self.avatar = avatar
self.isAnonymous = isAnonymous ?? (selectedKey == LDUser.defaultKey(environmentReporter: environmentReporter))
self.isAnonymousNullable = isAnonymous
if isAnonymous == nil && selectedKey == LDUser.defaultKey(environmentReporter: environmentReporter) {
self.isAnonymousNullable = true
}
self.custom = custom ?? [:]
self.custom.merge(["device": .string(environmentReporter.deviceModel),
"os": .string(environmentReporter.systemVersion)]) { lhs, _ in lhs }
Expand Down Expand Up @@ -135,8 +150,8 @@ public struct LDUser: Encodable, Equatable {
var container = encoder.container(keyedBy: DynamicKey.self)
try container.encode(key, forKey: DynamicKey(stringValue: "key")!)

if isAnonymous {
try container.encode(isAnonymous, forKey: DynamicKey(stringValue: "anonymous")!)
if let anonymous = isAnonymousNullable {
try container.encode(anonymous, forKey: DynamicKey(stringValue: "anonymous")!)
}

try LDUser.optionalAttributes.forEach { attribute in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ struct EnvironmentReporter: EnvironmentReporting {

var shouldThrottleOnlineCalls: Bool { !isDebugBuild }

let sdkVersion = "6.0.0"
let sdkVersion = "6.1.0"
// Unfortunately, the following does not function in certain configurations, such as when included through SPM
// var sdkVersion: String {
// Bundle(for: LDClient.self).infoDictionary?["CFBundleShortVersionString"] as? String ?? "5.x"
Expand Down
9 changes: 9 additions & 0 deletions LaunchDarkly/LaunchDarklyTests/Models/User/LDUserSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,19 @@ final class LDUserSpec: QuickSpec {
expect(user.firstName) == LDUser.StubConstants.firstName
expect(user.lastName) == LDUser.StubConstants.lastName
expect(user.isAnonymous) == LDUser.StubConstants.isAnonymous
expect(user.isAnonymousNullable) == LDUser.StubConstants.isAnonymous
expect(user.country) == LDUser.StubConstants.country
expect(user.ipAddress) == LDUser.StubConstants.ipAddress
expect(user.email) == LDUser.StubConstants.email
expect(user.avatar) == LDUser.StubConstants.avatar
expect(user.custom == LDUser.StubConstants.custom(includeSystemValues: true)).to(beTrue())
expect(user.privateAttributes) == LDUser.optionalAttributes
}
it("without setting anonymous") {
user = LDUser(key: "abc")
expect(user.isAnonymous) == false
expect(user.isAnonymousNullable).to(beNil())
}
context("called without optional elements") {
var environmentReporter: EnvironmentReporter!
beforeEach {
Expand All @@ -52,6 +58,7 @@ final class LDUserSpec: QuickSpec {
it("creates a LDUser without optional elements") {
expect(user.key) == LDUser.defaultKey(environmentReporter: environmentReporter)
expect(user.isAnonymous) == true
expect(user.isAnonymousNullable) == true

expect(user.name).to(beNil())
expect(user.firstName).to(beNil())
Expand Down Expand Up @@ -79,6 +86,7 @@ final class LDUserSpec: QuickSpec {
users.forEach { user in
expect(user.key) == LDUser.defaultKey(environmentReporter: environmentReporter)
expect(user.isAnonymous) == true
expect(user.isAnonymousNullable) == true
}
}
}
Expand All @@ -96,6 +104,7 @@ final class LDUserSpec: QuickSpec {
it("creates a user with system values matching the environment reporter") {
expect(user.key) == LDUser.defaultKey(environmentReporter: environmentReporter)
expect(user.isAnonymous) == true
expect(user.isAnonymousNullable) == true

expect(user.secondary).to(beNil())
expect(user.name).to(beNil())
Expand Down
Loading

0 comments on commit cfe3e47

Please sign in to comment.