2 * Copyright (c) 2017 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
24 #import <Foundation/Foundation.h>
27 #import "Analytics/SFAnalytics.h"
29 extern NSString
* const CKKSAnalyticsInCircle
;
30 extern NSString
* const CKKSAnalyticsHasTLKs
;
31 extern NSString
* const CKKSAnalyticsSyncedClassARecently
;
32 extern NSString
* const CKKSAnalyticsSyncedClassCRecently
;
33 extern NSString
* const CKKSAnalyticsIncomingQueueIsErrorFree
;
34 extern NSString
* const CKKSAnalyticsOutgoingQueueIsErrorFree
;
35 extern NSString
* const CKKSAnalyticsInSync
;
36 extern NSString
* const CKKSAnalyticsValidCredentials
;
37 extern NSString
* const CKKSAnalyticsLastUnlock
;
38 extern NSString
* const CKKSAnalyticsLastKeystateReady
;
39 extern NSString
* const CKKSAnalyticsLastInCircle
;
41 extern NSString
* const OctagonAnalyticsStateMachineState
;
42 extern NSString
* const OctagonAnalyticIcloudAccountState
;
43 extern NSString
* const OctagonAnalyticCDPBitStatus
;
44 extern NSString
* const OctagonAnalyticsTrustState
;
45 extern NSString
* const OctagonAnalyticsAttemptedJoin
;
46 extern NSString
* const OctagonAnalyticsLastHealthCheck
;
47 extern NSString
* const OctagonAnalyticsSOSStatus
;
48 extern NSString
* const OctagonAnalyticsDateOfLastPreflightPreapprovedJoin
;
49 extern NSString
* const OctagonAnalyticsLastKeystateReady
;
50 extern NSString
* const OctagonAnalyticsLastCoreFollowup
;
51 extern NSString
* const OctagonAnalyticsCoreFollowupFailureCount
;
52 extern NSString
* const OctagonAnalyticsCoreFollowupLastFailureTime
;
53 extern NSString
* const OctagonAnalyticsPrerecordPending
;
54 extern NSString
* const OctagonAnalyticsCDPStateRun
;
56 extern NSString
* const OctagonAnalyticsHaveMachineID
;
57 extern NSString
* const OctagonAnalyticsMIDOnMemoizedList
;
58 extern NSString
* const OctagonAnalyticsPeersWithMID
;
60 extern NSString
* const CKKSAnalyticsLastCKKSPush
;
61 extern NSString
* const CKKSAnalyticsLastOctagonPush
;
63 extern NSString
* const OctagonAnalyticsKVSProvisioned
;
64 extern NSString
* const OctagonAnalyticsKVSEnabled
;
65 extern NSString
* const OctagonAnalyticsKeychainSyncProvisioned
;
66 extern NSString
* const OctagonAnalyticsKeychainSyncEnabled
;
67 extern NSString
* const OctagonAnalyticsCloudKitProvisioned
;
68 extern NSString
* const OctagonAnalyticsCloudKitEnabled
;
70 extern NSString
* const OctagonAnalyticsBottledUniqueTLKsRecovered
;
71 extern NSString
* const OctagonAnalyticsBottledTotalTLKShares
;
72 extern NSString
* const OctagonAnalyticsBottledTotalTLKSharesRecovered
;
73 extern NSString
* const OctagonAnalyticsBottledUniqueTLKsWithSharesCount
;
74 extern NSString
* const OctagonAnalyticsBottledTLKUniqueViewCount
;
76 @
class CKKSKeychainView
;
78 @protocol CKKSAnalyticsFailableEvent
<NSObject
>
80 typedef NSString
<CKKSAnalyticsFailableEvent
> CKKSAnalyticsFailableEvent
;
81 extern CKKSAnalyticsFailableEvent
* const CKKSEventProcessIncomingQueueClassA
;
82 extern CKKSAnalyticsFailableEvent
* const CKKSEventProcessIncomingQueueClassC
;
83 extern CKKSAnalyticsFailableEvent
* const CKKSEventProcessOutgoingQueue
;
84 extern CKKSAnalyticsFailableEvent
* const CKKSEventUploadChanges
;
85 extern CKKSAnalyticsFailableEvent
* const CKKSEventStateError
;
86 extern CKKSAnalyticsFailableEvent
* const CKKSEventProcessHealKeyHierarchy
;
87 extern CKKSAnalyticsFailableEvent
* const CKKSEventProcessReencryption
;
89 extern CKKSAnalyticsFailableEvent
* const OctagonEventPreflightBottle
;
90 extern CKKSAnalyticsFailableEvent
* const OctagonEventLaunchBottle
;
91 extern CKKSAnalyticsFailableEvent
* const OctagonEventScrubBottle
;
92 extern CKKSAnalyticsFailableEvent
* const OctagonEventSignIn
;
93 extern CKKSAnalyticsFailableEvent
* const OctagonEventSignOut
;
94 extern CKKSAnalyticsFailableEvent
* const OctagonEventRestoreBottle
;
95 extern CKKSAnalyticsFailableEvent
* const OctagonEventRamp
;
96 extern CKKSAnalyticsFailableEvent
* const OctagonEventBottleCheck
;
97 extern CKKSAnalyticsFailableEvent
* const OctagonEventCoreFollowUp
;
98 extern CKKSAnalyticsFailableEvent
* const OctagonEventUpdateBottle
;
100 extern CKKSAnalyticsFailableEvent
* const OctagonEventRecoverBottle
;
101 extern CKKSAnalyticsFailableEvent
* const OctagonEventFetchAllBottles
;
102 extern CKKSAnalyticsFailableEvent
* const OctagonEventFetchEscrowContents
;
104 extern CKKSAnalyticsFailableEvent
* const OctagonEventRestoredSignedBottlePeer
;
105 extern CKKSAnalyticsFailableEvent
* const OctagonEventRestoredOctagonPeerEncryptionKey
;
106 extern CKKSAnalyticsFailableEvent
* const OctagonEventRestoredOctagonPeerSigningKey
;
107 extern CKKSAnalyticsFailableEvent
* const OctagonEventRestoreComplete
;
109 /* Initial health check */
110 extern CKKSAnalyticsFailableEvent
* const OctagonEventCheckTrustState
;
112 /* Outer calls as seen by the client */
113 extern CKKSAnalyticsFailableEvent
* const OctagonEventBottledPeerRestore
;
114 extern CKKSAnalyticsFailableEvent
* const OctagonEventFetchEscrowContents
;
115 extern CKKSAnalyticsFailableEvent
* const OctagonEventResetAndEstablish
;
116 extern CKKSAnalyticsFailableEvent
* const OctagonEventEstablish
;
117 extern CKKSAnalyticsFailableEvent
* const OctagonEventLeaveClique
;
118 extern CKKSAnalyticsFailableEvent
* const OctagonEventRemoveFriendsInClique
;
119 extern CKKSAnalyticsFailableEvent
* const OctagonEventRecoveryKey
;
121 /* Inner calls as seen by TPH and securityd */
123 extern CKKSAnalyticsFailableEvent
* const OctagonEventUpgradeFetchDeviceIDs
;
124 extern CKKSAnalyticsFailableEvent
* const OctagonEventUpgradeSetAllowList
;
125 extern CKKSAnalyticsFailableEvent
* const OctagonEventUpgradeSilentEscrow
;
126 extern CKKSAnalyticsFailableEvent
* const OctagonEventUpgradePreapprovedJoin
;
127 extern CKKSAnalyticsFailableEvent
* const OctagonEventUpgradePreflightPreapprovedJoin
;
128 extern CKKSAnalyticsFailableEvent
* const OctagonEventUpgradePrepare
;
129 extern CKKSAnalyticsFailableEvent
* const OctagonEventUpgradePreapprovedJoinAfterPairing
;
131 /* inner: join with voucher */
132 extern CKKSAnalyticsFailableEvent
* const OctagonEventJoinWithVoucher
;
134 /* inner: join with bottle */
135 extern CKKSAnalyticsFailableEvent
* const OctagonEventPreflightVouchWithBottle
;
136 extern CKKSAnalyticsFailableEvent
* const OctagonEventVoucherWithBottle
;
138 /* inner: join with recovery key */
139 extern CKKSAnalyticsFailableEvent
* const OctagonEventPreflightVouchWithRecoveryKey
;
140 extern CKKSAnalyticsFailableEvent
* const OctagonEventVoucherWithRecoveryKey
;
141 extern CKKSAnalyticsFailableEvent
* const OctagonEventJoinRecoveryKeyValidationFailed
;
142 extern CKKSAnalyticsFailableEvent
* const OctagonEventJoinRecoveryKeyFailed
;
143 extern CKKSAnalyticsFailableEvent
* const OctagonEventJoinRecoveryKeyCircleReset
;
144 extern CKKSAnalyticsFailableEvent
* const OctagonEventJoinRecoveryKeyCircleResetFailed
;
145 extern CKKSAnalyticsFailableEvent
* const OctagonEventJoinRecoveryKeyEnrollFailed
;
147 /* inner: set recovery key */
148 extern CKKSAnalyticsFailableEvent
* const OctagonEventSetRecoveryKey
;
149 extern CKKSAnalyticsFailableEvent
* const OctagonEventSetRecoveryKeyValidationFailed
;
152 extern CKKSAnalyticsFailableEvent
* const OctagonEventReset
;
155 extern CKKSAnalyticsFailableEvent
* const OctagonEventPrepareIdentity
;
157 /* inner: establish */
158 extern CKKSAnalyticsFailableEvent
* const OctagonEventEstablishIdentity
;
160 /* inner: fetchviews */
161 extern CKKSAnalyticsFailableEvent
* const OctagonEventFetchViews
;
164 extern CKKSAnalyticsFailableEvent
* const OctagonEventStateTransition
;
166 /* become untrusted */
167 extern CKKSAnalyticsFailableEvent
* const OctagonEventCheckTrustForCFU
;
169 /* watchOS only: pairing with companion */
170 extern CKKSAnalyticsFailableEvent
* const OctagonEventCompanionPairing
;
172 /* trust state from trusted peers helper*/
173 extern CKKSAnalyticsFailableEvent
* const OctagonEventTPHHealthCheckStatus
;
175 extern CKKSAnalyticsFailableEvent
* const OctagonEventAuthKitDeviceList
;
177 @protocol CKKSAnalyticsSignpostEvent
<NSObject
>
179 typedef NSString
<CKKSAnalyticsSignpostEvent
> CKKSAnalyticsSignpostEvent
;
180 extern CKKSAnalyticsSignpostEvent
* const CKKSEventPushNotificationReceived
;
181 extern CKKSAnalyticsSignpostEvent
* const CKKSEventItemAddedToOutgoingQueue
;
182 extern CKKSAnalyticsSignpostEvent
* const CKKSEventReachabilityTimerExpired
;
183 extern CKKSAnalyticsSignpostEvent
* const CKKSEventMissingLocalItemsFound
;
185 @protocol CKKSAnalyticsActivity
<NSObject
>
187 typedef NSString
<CKKSAnalyticsActivity
> CKKSAnalyticsActivity
;
188 extern CKKSAnalyticsActivity
* const CKKSActivityOTFetchRampState
;
189 extern CKKSAnalyticsActivity
* const CKKSActivityOctagonPreflightBottle
;
190 extern CKKSAnalyticsActivity
* const CKKSActivityOctagonLaunchBottle
;
191 extern CKKSAnalyticsActivity
* const CKKSActivityOctagonRestore
;
192 extern CKKSAnalyticsActivity
* const CKKSActivityScrubBottle
;
193 extern CKKSAnalyticsActivity
* const CKKSActivityBottleCheck
;
194 extern CKKSAnalyticsActivity
* const CKKSActivityOctagonUpdateBottle
;
196 extern CKKSAnalyticsActivity
* const OctagonActivityAccountAvailable
;
197 extern CKKSAnalyticsActivity
* const OctagonActivityAccountNotAvailable
;
198 extern CKKSAnalyticsActivity
* const OctagonActivityResetAndEstablish
;
199 extern CKKSAnalyticsActivity
* const OctagonActivityEstablish
;
200 extern CKKSAnalyticsActivity
* const OctagonActivityFetchAllViableBottles
;
201 extern CKKSAnalyticsActivity
* const OctagonActivityFetchEscrowContents
;
202 extern CKKSAnalyticsActivity
* const OctagonActivityBottledPeerRestore
;
203 extern CKKSAnalyticsActivity
* const OctagonActivitySetRecoveryKey
;
204 extern CKKSAnalyticsActivity
* const OctagonActivityLeaveClique
;
205 extern CKKSAnalyticsActivity
* const OctagonActivityRemoveFriendsInClique
;
206 extern CKKSAnalyticsActivity
* const OctagonActivityJoinWithRecoveryKey
;
207 extern CKKSAnalyticsActivity
* const OctagonSOSAdapterUpdateKeys
;
210 @interface CKKSAnalytics
: SFAnalytics
212 + (instancetype
)logger
;
214 - (void)logSuccessForEvent
:(CKKSAnalyticsFailableEvent
*)event inView
:(CKKSKeychainView
*)view
;
215 - (void)logRecoverableError
:(NSError
*)error
216 forEvent
:(CKKSAnalyticsFailableEvent
*)event
217 inView
:(CKKSKeychainView
*)view
218 withAttributes
:(NSDictionary
*)attributes
;
220 - (void)logRecoverableError
:(NSError
*)error
221 forEvent
:(CKKSAnalyticsFailableEvent
*)event
222 zoneName
:(NSString
*)zoneName
223 withAttributes
:(NSDictionary
*)attributes
;
225 - (void)logRecoverableError
:(NSError
*)error
226 forEvent
:(CKKSAnalyticsFailableEvent
*)event
227 withAttributes
:(NSDictionary
*)attributes
;
229 - (void)logUnrecoverableError
:(NSError
*)error
230 forEvent
:(CKKSAnalyticsFailableEvent
*)event
231 withAttributes
:(NSDictionary
*)attributes
;
233 - (void)logUnrecoverableError
:(NSError
*)error
234 forEvent
:(CKKSAnalyticsFailableEvent
*)event
235 inView
:(CKKSKeychainView
*)view
236 withAttributes
:(NSDictionary
*)attributes
;
238 - (void)noteEvent
:(CKKSAnalyticsSignpostEvent
*)event
;
239 - (void)noteEvent
:(CKKSAnalyticsSignpostEvent
*)event inView
:(CKKSKeychainView
*)view
;
241 - (void)setDateProperty
:(NSDate
*)date forKey
:(NSString
*)key inView
:(CKKSKeychainView
*)view
;
242 - (NSDate
*)datePropertyForKey
:(NSString
*)key inView
:(CKKSKeychainView
*)view
;
246 @interface
CKKSAnalytics (UnitTesting
)
248 - (NSDate
*)dateOfLastSuccessForEvent
:(CKKSAnalyticsFailableEvent
*)event
249 inView
:(CKKSKeychainView
*)view
;
250 - (NSDictionary
*)errorChain
:(NSError
*)error
251 depth
:(NSUInteger
)depth
;
252 - (NSDictionary
*)createErrorAttributes
:(NSError
*)error
253 depth
:(NSUInteger
)depth
254 attributes
:(NSDictionary
*)attributes
;