diff --git a/.spm-version b/.spm-version index c910885..79a00e9 100644 --- a/.spm-version +++ b/.spm-version @@ -1 +1 @@ -2.15.0 \ No newline at end of file +2.16.0 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 0986dc5..d691e0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ | モジュール名 | Description | 最新のバージョン | | :-- | :-- | :-- | -| KarteCore | イベントトラッキング機能を提供します。 | 2.27.0 | +| KarteCore | イベントトラッキング機能を提供します。 | 2.28.0 | | KarteInAppMessaging | アプリ内メッセージ機能を提供します。 | 2.17.1 | | KarteRemoteNotification | プッシュ通知の受信および効果測定機能を提供します。 | 2.11.0 | | KarteVariables | 設定値配信機能を提供します。 | 2.10.0 | @@ -11,13 +11,20 @@ | KarteUtilities | KarteCore モジュール等が利用するUtility機能を提供します。通常直接参照する必要はありません。 | 3.12.0 | | KarteNotificationServiceExtension | リッチプッシュ通知機能を提供します。 | 1.2.0 | +# Releases - 2024.06.25 +## Version 2.16.0 + +### Core 2.28.0 +** 🔨CHANGED** +- AppTrackingTransparencyの許諾状況をKARTE側に同期する機能を追加しました。 + # Releases - 2024.06.13 ## Version 2.15.0 ### CrashReporting 2.8.0 ** 🔨CHANGED** - Privacy manifestの設定を更新しました。 - + ### InAppMessaging 2.17.1 ** 💊FIXED** - 一部の別ライブラリと併用した場合にcrashする不具合を修正しました。 diff --git a/Karte.xcodeproj/project.pbxproj b/Karte.xcodeproj/project.pbxproj index 98a2b5f..a0a3032 100644 --- a/Karte.xcodeproj/project.pbxproj +++ b/Karte.xcodeproj/project.pbxproj @@ -343,6 +343,9 @@ 0CFD001924ECF53100598C8C /* TrackClientSessionMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CFD001824ECF53100598C8C /* TrackClientSessionMock.swift */; }; 0CFD001D24ECF8BB00598C8C /* TrackClientTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CFD001C24ECF8BB00598C8C /* TrackClientTests.swift */; }; 0CFD001F24ED08E800598C8C /* ReachabilityServiceMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CFD001E24ED08E800598C8C /* ReachabilityServiceMock.swift */; }; + 142B4AEA2C2551DD0090ADDD /* ATTService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 142B4AE92C2551DD0090ADDD /* ATTService.swift */; }; + 142B4AEC2C25542C0090ADDD /* ATTStatusUpdatedSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 142B4AEB2C25542C0090ADDD /* ATTStatusUpdatedSpec.swift */; }; + 142B4AEE2C2554D00090ADDD /* ATTServiceSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 142B4AED2C2554D00090ADDD /* ATTServiceSpec.swift */; }; 1E9A3C652949BBFD006B54D3 /* ApiKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E9A3C642949BBFD006B54D3 /* ApiKey.swift */; }; 1ECAFE542B5D3608003638E8 /* DecodingError+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ECAFE532B5D3608003638E8 /* DecodingError+Extension.swift */; }; 1EE766B7297546440040278E /* Karte-custom-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 1EE766B6297544B60040278E /* Karte-custom-Info.plist */; }; @@ -931,6 +934,9 @@ 0CFD001824ECF53100598C8C /* TrackClientSessionMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackClientSessionMock.swift; sourceTree = ""; }; 0CFD001C24ECF8BB00598C8C /* TrackClientTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackClientTests.swift; sourceTree = ""; }; 0CFD001E24ED08E800598C8C /* ReachabilityServiceMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReachabilityServiceMock.swift; sourceTree = ""; }; + 142B4AE92C2551DD0090ADDD /* ATTService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ATTService.swift; sourceTree = ""; }; + 142B4AEB2C25542C0090ADDD /* ATTStatusUpdatedSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ATTStatusUpdatedSpec.swift; sourceTree = ""; }; + 142B4AED2C2554D00090ADDD /* ATTServiceSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ATTServiceSpec.swift; sourceTree = ""; }; 1E9A3C642949BBFD006B54D3 /* ApiKey.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApiKey.swift; sourceTree = ""; }; 1ECAFE532B5D3608003638E8 /* DecodingError+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DecodingError+Extension.swift"; sourceTree = ""; }; 1EE766B6297544B60040278E /* Karte-custom-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Karte-custom-Info.plist"; sourceTree = ""; }; @@ -1814,6 +1820,7 @@ 683762F8252F201D00E690CE /* SelectorDetector.swift */, 0C50509129C17ECA007C5C9B /* JailbreakDetection.swift */, 0C8392C02406C7750014C2BF /* CoreService.swift */, + 142B4AE82C2551C90090ADDD /* ATT */, 0C8392582406C4260014C2BF /* AppInfo */, 1E9A3C632949BBFD006B54D3 /* ApiKey */, 0CE339AF23F39C9300E2EB98 /* AppKey */, @@ -2157,6 +2164,7 @@ 0CE792FF238653AD00F0D932 /* PluginNativeAppIdentifyEventSpec.swift */, 0CE79300238653AD00F0D932 /* ViewEventSpec.swift */, 0CE79301238653AD00F0D932 /* FetchVariablesEventSpec.swift */, + 142B4AEB2C25542C0090ADDD /* ATTStatusUpdatedSpec.swift */, 0CE79302238653AD00F0D932 /* EventSpec.swift */, 0CE79303238653AD00F0D932 /* EventFieldNameSpec.swift */, 0CE79304238653AD00F0D932 /* IdentifyEventSpec.swift */, @@ -2236,6 +2244,7 @@ isa = PBXGroup; children = ( 0CA52D5C2387BE9E00A575BC /* ConfigurationTests.swift */, + 142B4AED2C2554D00090ADDD /* ATTServiceSpec.swift */, 6807B2AA251D80C900CDAB43 /* ExperimentalConfigurationTests.swift */, 0CA52D582387BE4C00A575BC /* OptOutConfigSpec.swift */, 0CA52D682387CC4D00A575BC /* VersionServiceSpec.swift */, @@ -2276,6 +2285,14 @@ path = KarteVariablesTests; sourceTree = ""; }; + 142B4AE82C2551C90090ADDD /* ATT */ = { + isa = PBXGroup; + children = ( + 142B4AE92C2551DD0090ADDD /* ATTService.swift */, + ); + path = ATT; + sourceTree = ""; + }; 1E9A3C632949BBFD006B54D3 /* ApiKey */ = { isa = PBXGroup; children = ( @@ -3106,6 +3123,7 @@ 0C69D41524EB9DC600D75893 /* TrackingTask.swift in Sources */, 0CE339EC23F39C9300E2EB98 /* AppKey.swift in Sources */, 36F3BC7824F8DAC1002D4382 /* LogAppender.swift in Sources */, + 142B4AEA2C2551DD0090ADDD /* ATTService.swift in Sources */, 0C8392652406C54E0014C2BF /* SystemInfo.swift in Sources */, 0C8392BB2406C7010014C2BF /* JSONConvertible.swift in Sources */, 0C75093925007A7500624E3C /* OperationMode.swift in Sources */, @@ -3316,6 +3334,7 @@ 0C8392FD240822A40014C2BF /* EventNameSpec.swift in Sources */, 0CFD001D24ECF8BB00598C8C /* TrackClientTests.swift in Sources */, 0C69D41824EBA34500D75893 /* RegisterPushCommandSpec.swift in Sources */, + 142B4AEC2C25542C0090ADDD /* ATTStatusUpdatedSpec.swift in Sources */, 0CFD001124EBD2DC00598C8C /* TrackCallbackSpec.swift in Sources */, 0C83931A240838050014C2BF /* InspectorSpec.swift in Sources */, 0C839312240831B30014C2BF /* LifecycleEventSpec.swift in Sources */, @@ -3343,6 +3362,7 @@ 68BBBCD524BB5156009A1CE0 /* IAMProcessSpec.swift in Sources */, 0CE79326238653AD00F0D932 /* Support.swift in Sources */, 680C29B52446B99200FB1363 /* TrackBodyParametersSpec.swift in Sources */, + 142B4AEE2C2554D00090ADDD /* ATTServiceSpec.swift in Sources */, 0C8392F02407BF370014C2BF /* VisitorIdGeneratorMock.swift in Sources */, 0C8393112408319F0014C2BF /* IdentifySpec.swift in Sources */, 0CCFA7BB24A5D8D500E0F184 /* NotificationSettingsProviderMock.swift in Sources */, @@ -3828,7 +3848,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 2.27.0; + MARKETING_VERSION = 2.28.0; PRODUCT_BUNDLE_IDENTIFIER = io.karte.KarteCore; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; @@ -3863,7 +3883,7 @@ "@executable_path/Frameworks", "@loader_path/Frameworks", ); - MARKETING_VERSION = 2.27.0; + MARKETING_VERSION = 2.28.0; PRODUCT_BUNDLE_IDENTIFIER = io.karte.KarteCore; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; SKIP_INSTALL = YES; diff --git a/KarteCore.podspec b/KarteCore.podspec index 2e4ac13..cd598fc 100644 --- a/KarteCore.podspec +++ b/KarteCore.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'KarteCore' - s.version = '2.27.0' + s.version = '2.28.0' s.summary = 'KARTE Core SDK' s.homepage = 'https://karte.io' s.author = { 'PLAID' => 'dev.share@plaid.co.jp' } diff --git a/KarteCore/Core/ATT/ATTService.swift b/KarteCore/Core/ATT/ATTService.swift new file mode 100644 index 0000000..0168123 --- /dev/null +++ b/KarteCore/Core/ATT/ATTService.swift @@ -0,0 +1,41 @@ +// +// Copyright 2024 PLAID, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import Foundation +import AppTrackingTransparency + +@available(iOS 14, *) +internal class ATTService { + static func getATTStatusLabel(attStatus: ATTrackingManager.AuthorizationStatus) -> String { + switch attStatus { + case .authorized: + "authorized" + case .restricted: + "restricted" + case .notDetermined: + "notDetermined" + case .denied: + "denied" + @unknown default: + "unknown" + } + } + + static func sendATTStatus(attStatus: ATTrackingManager.AuthorizationStatus) { + let attStatusLabel = getATTStatusLabel(attStatus: attStatus) + Tracker.track(event: Event(.attStatusUpdated(attStatus: attStatusLabel))) + } +} diff --git a/KarteCore/Core/CoreService.swift b/KarteCore/Core/CoreService.swift index 3b7285c..df6a8a2 100644 --- a/KarteCore/Core/CoreService.swift +++ b/KarteCore/Core/CoreService.swift @@ -16,11 +16,13 @@ import Foundation import KarteUtilities +import AppTrackingTransparency internal class CoreService { lazy var appInfo: AppInfo = { AppInfo() }() + lazy var pvService: PvService = { PvService() }() @@ -116,6 +118,11 @@ internal class CoreService { visitorIdService.renew() } + @available(iOS 14, *) + func sendATTStatus(attStatus: ATTrackingManager.AuthorizationStatus) { + ATTService.sendATTStatus(attStatus: attStatus) + } + func teardown() { visitorIdService.clean() versionService.clean() diff --git a/KarteCore/KarteApp.swift b/KarteCore/KarteApp.swift index 3131388..2f90c84 100644 --- a/KarteCore/KarteApp.swift +++ b/KarteCore/KarteApp.swift @@ -16,6 +16,7 @@ import KarteUtilities import UIKit +import AppTrackingTransparency /// KARTE SDKのエントリポイントであると共に、SDKの構成および依存ライブラリ等の管理を行うクラスです。 /// @@ -164,6 +165,18 @@ public extension KarteApp { shared.renewVisitorId() } + /// AppTrackingTransparencyの許諾状況をKARTE側に送信します。 + /// + /// att_status_updatedというイベント経由で送信許諾状況を送信しています。 + /// + /// - Parameters: + /// - attStatus: `ATTrackingManager.AuthorizationStatus` + @available(iOS 14, *) + @objc + class func sendATTStatus(attStatus: ATTrackingManager.AuthorizationStatus) { + shared.sendATTStatus(attStatus: attStatus) + } + /// KARTE SDKの機能に関連するカスタムURLスキームを処理します。 /// /// なお初期化が行われていない状態で呼び出した場合はカスタムURLスキームの処理は行われません。 @@ -317,6 +330,11 @@ extension KarteApp { coreService?.renewVisitorId() } + @available(iOS 14, *) + func sendATTStatus(attStatus: ATTrackingManager.AuthorizationStatus) { + coreService?.sendATTStatus(attStatus: attStatus) + } + func application(_ app: UIApplication, open url: URL) -> Bool { var handled = false for module in modules { diff --git a/KarteCore/Tracking/Event/Event.swift b/KarteCore/Tracking/Event/Event.swift index 3d39070..2b80f15 100644 --- a/KarteCore/Tracking/Event/Event.swift +++ b/KarteCore/Tracking/Event/Event.swift @@ -106,6 +106,8 @@ public extension Event { case pluginNativeAppIdentify(subscribe: Bool, fcmToken: String?) /// `_fetch_variables` イベント case fetchVariables + /// `att_status_updated`イベント + case attStatusUpdated(attStatus: String) /// 列挙子に応じた `イベント名` および `オブジェクト` を返します。 func build() -> (EventName, [String: JSONValue]) { @@ -185,6 +187,14 @@ public extension Event { name = .pluginNativeAppIdentify vals = values.compactMapValues { $0 } + case let .attStatusUpdated(attStatus: attStatus): + let values: [String: JSONConvertible?] = [ + field(.attStatus): attStatus + ] + + name = .attStatusUpdated + vals = values.compactMapValues { $0 } + case .fetchVariables: name = .fetchVariables vals = [:] diff --git a/KarteCore/Tracking/Event/EventFieldName.swift b/KarteCore/Tracking/Event/EventFieldName.swift index b16b27d..80521e0 100644 --- a/KarteCore/Tracking/Event/EventFieldName.swift +++ b/KarteCore/Tracking/Event/EventFieldName.swift @@ -59,6 +59,8 @@ public extension EventFieldName { static let viewName = EventFieldName("view_name") /// title フィールド static let title = EventFieldName("title") + // attStatusフィールド + static let attStatus = EventFieldName("att_status") } extension EventFieldName { diff --git a/KarteCore/Tracking/Event/EventName.swift b/KarteCore/Tracking/Event/EventName.swift index 291d28d..d6e8d7e 100644 --- a/KarteCore/Tracking/Event/EventName.swift +++ b/KarteCore/Tracking/Event/EventName.swift @@ -50,7 +50,8 @@ public struct EventName: Codable { .messageReady, .messageOpen, .messageClick, .messageClose, .messageSuppressed, .massPushClick, .pluginNativeAppIdentify, - .fetchVariables: + .fetchVariables, + .attStatusUpdated: return false default: return true @@ -122,4 +123,6 @@ public extension EventName { static let pluginNativeAppIdentify = EventName("plugin_native_app_identify") /// _fetch_variables イベント static let fetchVariables = EventName("_fetch_variables") + /// att_status_updated イベント + static let attStatusUpdated = EventName("att_status_updated") } diff --git a/KarteTests/KarteCoreTests/UnitTests/Core/ATTServiceSpec.swift b/KarteTests/KarteCoreTests/UnitTests/Core/ATTServiceSpec.swift new file mode 100644 index 0000000..94e1160 --- /dev/null +++ b/KarteTests/KarteCoreTests/UnitTests/Core/ATTServiceSpec.swift @@ -0,0 +1,57 @@ +// +// Copyright 2024 PLAID, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import Quick +import Nimble +@testable import KarteCore +import AppTrackingTransparency + + +class ATTServiceSpec: QuickSpec { + + override func spec() { + describe("its run") { + it("returns authorized label") { + if #available(iOS 14, *) { + let result = ATTService.getATTStatusLabel(attStatus: ATTrackingManager.AuthorizationStatus.authorized) + expect(result).to(equal("authorized")) + } + } + + it("returns denied label") { + if #available(iOS 14, *) { + let result = ATTService.getATTStatusLabel(attStatus: ATTrackingManager.AuthorizationStatus.denied) + expect(result).to(equal("denied")) + } + } + + it("returns restricted label") { + if #available(iOS 14, *) { + let result = ATTService.getATTStatusLabel(attStatus: ATTrackingManager.AuthorizationStatus.restricted) + expect(result).to(equal("restricted")) + } + + } + + it("returns notDetermined label") { + if #available(iOS 14, *) { + let result = ATTService.getATTStatusLabel(attStatus: ATTrackingManager.AuthorizationStatus.notDetermined) + expect(result).to(equal("notDetermined")) + } + } + } + } +} diff --git a/KarteTests/KarteCoreTests/UnitTests/Tracking/Event/ATTStatusUpdatedSpec.swift b/KarteTests/KarteCoreTests/UnitTests/Tracking/Event/ATTStatusUpdatedSpec.swift new file mode 100644 index 0000000..20fb963 --- /dev/null +++ b/KarteTests/KarteCoreTests/UnitTests/Tracking/Event/ATTStatusUpdatedSpec.swift @@ -0,0 +1,54 @@ +// +// Copyright 2024 PLAID, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import Quick +import Nimble +@testable import KarteCore + +class ATTStatusUpdatedSpec: QuickSpec { + + override func spec() { + describe("a `att_status_updated` event") { + var event: Event! + + beforeEach { + event = Event(.attStatusUpdated(attStatus: "denied")) + } + + describe("its eventName") { + it("is attStatusUpdated") { + expect(event.eventName).to(equal(.attStatusUpdated)) + } + } + + describe("its values") { + it("is not nil") { + expect(event.values).toNot(beNil()) + } + } + + describe("its build values") { + it("count is 1") { + expect(event.values.count).to(equal(1)) + } + + it("values.attStatus is `denied`") { + expect(event.values.string(forKey: "att_status")).to(equal("denied")) + } + } + } + } +} diff --git a/Package.swift b/Package.swift index 0181fe1..121f941 100644 --- a/Package.swift +++ b/Package.swift @@ -54,7 +54,7 @@ let package = Package( name: "KarteUtilities", url: "https://sdk.karte.io/ios/swiftpm/Utilities-3.12.0/KarteUtilities.xcframework.zip", checksum: "850abc71a8bc28e415f4b11e3072ff741a1d908c13b951a4676bc2e675eaf634" ), .binaryTarget( - name: "KarteCore", url: "https://sdk.karte.io/ios/swiftpm/Core-2.27.0/KarteCore.xcframework.zip", checksum: "4d84780cffc846c46a135e1462e20b1ddd5b533c4aed6816bb9a45989f32eb2e" + name: "KarteCore", url: "https://sdk.karte.io/ios/swiftpm/Core-2.28.0/KarteCore.xcframework.zip", checksum: "535947825797d5f339c814e308a21b0ff2980b32f1a8fcba7c0ef1ad54413256" ), .binaryTarget( name: "KarteInAppMessaging", url: "https://sdk.karte.io/ios/swiftpm/InAppMessaging-2.17.1/KarteInAppMessaging.xcframework.zip", checksum: "ece8b3cadb4956b2c8951486bb9e51c20f1a2abef6e3d3ccb8c548f42bcb724e"