]> git.saurik.com Git - apple/security.git/blob - keychain/ckks/CKKSAnalytics.h
Security-58286.270.3.0.1.tar.gz
[apple/security.git] / keychain / ckks / CKKSAnalytics.h
1 /*
2 * Copyright (c) 2017 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #import <Foundation/Foundation.h>
25
26 #if OCTAGON
27 #import "Analytics/SFAnalytics.h"
28
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;
40
41 @class CKKSKeychainView;
42
43 @protocol CKKSAnalyticsFailableEvent <NSObject>
44 @end
45 typedef NSString<CKKSAnalyticsFailableEvent> CKKSAnalyticsFailableEvent;
46 extern CKKSAnalyticsFailableEvent* const CKKSEventProcessIncomingQueueClassA;
47 extern CKKSAnalyticsFailableEvent* const CKKSEventProcessIncomingQueueClassC;
48 extern CKKSAnalyticsFailableEvent* const CKKSEventProcessOutgoingQueue;
49 extern CKKSAnalyticsFailableEvent* const CKKSEventUploadChanges;
50 extern CKKSAnalyticsFailableEvent* const CKKSEventStateError;
51 extern CKKSAnalyticsFailableEvent* const CKKSEventProcessHealKeyHierarchy;
52
53 extern CKKSAnalyticsFailableEvent* const OctagonEventPreflightBottle;
54 extern CKKSAnalyticsFailableEvent* const OctagonEventLaunchBottle;
55 extern CKKSAnalyticsFailableEvent* const OctagonEventScrubBottle;
56 extern CKKSAnalyticsFailableEvent* const OctagonEventSignIn;
57 extern CKKSAnalyticsFailableEvent* const OctagonEventSignOut;
58 extern CKKSAnalyticsFailableEvent* const OctagonEventRestoreBottle;
59 extern CKKSAnalyticsFailableEvent* const OctagonEventRamp;
60 extern CKKSAnalyticsFailableEvent* const OctagonEventBottleCheck;
61 extern CKKSAnalyticsFailableEvent* const OctagonEventCoreFollowUp;
62
63 extern CKKSAnalyticsFailableEvent* const OctagonEventRestoredSignedBottlePeer;
64 extern CKKSAnalyticsFailableEvent* const OctagonEventRestoredOctagonPeerEncryptionKey;
65 extern CKKSAnalyticsFailableEvent* const OctagonEventRestoredOctagonPeerSigningKey;
66 extern CKKSAnalyticsFailableEvent* const OctagonEventRestoreComplete;
67
68
69 @protocol CKKSAnalyticsSignpostEvent <NSObject>
70 @end
71 typedef NSString<CKKSAnalyticsSignpostEvent> CKKSAnalyticsSignpostEvent;
72 extern CKKSAnalyticsSignpostEvent* const CKKSEventPushNotificationReceived;
73 extern CKKSAnalyticsSignpostEvent* const CKKSEventItemAddedToOutgoingQueue;
74 extern CKKSAnalyticsSignpostEvent* const CKKSEventReachabilityTimerExpired;
75 extern CKKSAnalyticsSignpostEvent* const CKKSEventMissingLocalItemsFound;
76
77 @protocol CKKSAnalyticsActivity <NSObject>
78 @end
79 typedef NSString<CKKSAnalyticsActivity> CKKSAnalyticsActivity;
80 extern CKKSAnalyticsActivity* const CKKSActivityOTFetchRampState;
81 extern CKKSAnalyticsActivity* const CKKSActivityOctagonSignIn;
82 extern CKKSAnalyticsActivity* const CKKSActivityOctagonPreflightBottle;
83 extern CKKSAnalyticsActivity* const CKKSActivityOctagonLaunchBottle;
84 extern CKKSAnalyticsActivity* const CKKSActivityOctagonRestore;
85 extern CKKSAnalyticsActivity* const CKKSActivityScrubBottle;
86 extern CKKSAnalyticsActivity* const CKKSActivityBottleCheck;
87
88 @interface CKKSAnalytics : SFAnalytics
89
90 + (instancetype)logger;
91
92 - (void)logSuccessForEvent:(CKKSAnalyticsFailableEvent*)event inView:(CKKSKeychainView*)view;
93 - (void)logRecoverableError:(NSError*)error
94 forEvent:(CKKSAnalyticsFailableEvent*)event
95 inView:(CKKSKeychainView*)view
96 withAttributes:(NSDictionary*)attributes;
97
98 - (void)logRecoverableError:(NSError*)error
99 forEvent:(CKKSAnalyticsFailableEvent*)event
100 zoneName:(NSString*)zoneName
101 withAttributes:(NSDictionary *)attributes;
102
103
104 - (void)logUnrecoverableError:(NSError*)error
105 forEvent:(CKKSAnalyticsFailableEvent*)event
106 withAttributes:(NSDictionary *)attributes;
107
108 - (void)logUnrecoverableError:(NSError*)error
109 forEvent:(CKKSAnalyticsFailableEvent*)event
110 inView:(CKKSKeychainView*)view
111 withAttributes:(NSDictionary*)attributes;
112
113 - (void)noteEvent:(CKKSAnalyticsSignpostEvent*)event;
114 - (void)noteEvent:(CKKSAnalyticsSignpostEvent*)event inView:(CKKSKeychainView*)view;
115
116 - (void)setDateProperty:(NSDate*)date forKey:(NSString*)key inView:(CKKSKeychainView *)view;
117 - (NSDate *)datePropertyForKey:(NSString *)key inView:(CKKSKeychainView *)view;
118
119 @end
120
121 @interface CKKSAnalytics (UnitTesting)
122
123 - (NSDate*)dateOfLastSuccessForEvent:(CKKSAnalyticsFailableEvent*)event inView:(CKKSKeychainView*)view;
124 - (NSDictionary *)errorChain:(NSError *)error depth:(NSUInteger)depth;
125
126 @end
127
128 #endif
129
130