|
6 | 6 | static NSString *const LabelKey = @"label"; |
7 | 7 | static NSString *const LastDeploymentReportKey = @"CODE_PUSH_LAST_DEPLOYMENT_REPORT"; |
8 | 8 |
|
9 | | -@implementation CodePushStatusReport |
| 9 | +@implementation CodePushTelemetryManager |
10 | 10 |
|
11 | | -+ (NSString *)getDeploymentKeyFromStatusReportIdentifier:(NSString *)statusReportIdentifier |
| 11 | ++ (NSDictionary *)getBinaryUpdateReport:(NSString *)appVersion |
12 | 12 | { |
13 | | - return [[statusReportIdentifier componentsSeparatedByString:@":"] firstObject]; |
| 13 | + NSString *previousStatusReportIdentifier = [self getPreviousStatusReportIdentifier]; |
| 14 | + if (previousStatusReportIdentifier == nil) { |
| 15 | + [self recordDeploymentStatusReported:appVersion]; |
| 16 | + return @{ @"appVersion": appVersion }; |
| 17 | + } else if (![previousStatusReportIdentifier isEqualToString:appVersion]) { |
| 18 | + [self recordDeploymentStatusReported:appVersion]; |
| 19 | + if ([self isStatusReportIdentifierCodePushLabel:previousStatusReportIdentifier]) { |
| 20 | + NSString *previousDeploymentKey = [self getDeploymentKeyFromStatusReportIdentifier:previousStatusReportIdentifier]; |
| 21 | + NSString *previousLabel = [self getVersionLabelFromStatusReportIdentifier:previousStatusReportIdentifier]; |
| 22 | + return @{ |
| 23 | + @"appVersion": appVersion, |
| 24 | + @"previousDeploymentKey": previousDeploymentKey, |
| 25 | + @"previousLabelOrAppVersion": previousLabel |
| 26 | + }; |
| 27 | + } else { |
| 28 | + // Previous status report was with a binary app version. |
| 29 | + return @{ |
| 30 | + @"appVersion": appVersion, |
| 31 | + @"previousLabelOrAppVersion": previousStatusReportIdentifier |
| 32 | + }; |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + return nil; |
14 | 37 | } |
15 | 38 |
|
16 | | -+ (NSDictionary *)getFailedUpdateStatusReport:(NSDictionary *)lastFailedPackage |
| 39 | ++ (NSDictionary *)getRollbackReport:(NSDictionary *)lastFailedPackage |
17 | 40 | { |
18 | 41 | return @{ |
19 | 42 | @"package": lastFailedPackage, |
20 | 43 | @"status": DeploymentFailed |
21 | 44 | }; |
22 | 45 | } |
23 | 46 |
|
24 | | -+ (NSDictionary *)getNewPackageStatusReport:(NSDictionary *)currentPackage |
| 47 | ++ (NSDictionary *)getUpdateReport:(NSDictionary *)currentPackage |
25 | 48 | { |
26 | 49 | NSString *currentPackageIdentifier = [self getPackageStatusReportIdentifier:currentPackage]; |
27 | 50 | NSString *previousStatusReportIdentifier = [self getPreviousStatusReportIdentifier]; |
@@ -57,32 +80,9 @@ + (NSDictionary *)getNewPackageStatusReport:(NSDictionary *)currentPackage |
57 | 80 | return nil; |
58 | 81 | } |
59 | 82 |
|
60 | | -+ (NSDictionary *)getNewAppVersionStatusReport:(NSString *)appVersion |
| 83 | ++ (NSString *)getDeploymentKeyFromStatusReportIdentifier:(NSString *)statusReportIdentifier |
61 | 84 | { |
62 | | - NSString *previousStatusReportIdentifier = [self getPreviousStatusReportIdentifier]; |
63 | | - if (previousStatusReportIdentifier == nil) { |
64 | | - [self recordDeploymentStatusReported:appVersion]; |
65 | | - return @{ @"appVersion": appVersion }; |
66 | | - } else if (![previousStatusReportIdentifier isEqualToString:appVersion]) { |
67 | | - [self recordDeploymentStatusReported:appVersion]; |
68 | | - if ([self isStatusReportIdentifierCodePushLabel:previousStatusReportIdentifier]) { |
69 | | - NSString *previousDeploymentKey = [self getDeploymentKeyFromStatusReportIdentifier:previousStatusReportIdentifier]; |
70 | | - NSString *previousLabel = [self getVersionLabelFromStatusReportIdentifier:previousStatusReportIdentifier]; |
71 | | - return @{ |
72 | | - @"appVersion": appVersion, |
73 | | - @"previousDeploymentKey": previousDeploymentKey, |
74 | | - @"previousLabelOrAppVersion": previousLabel |
75 | | - }; |
76 | | - } else { |
77 | | - // Previous status report was with a binary app version. |
78 | | - return @{ |
79 | | - @"appVersion": appVersion, |
80 | | - @"previousLabelOrAppVersion": previousStatusReportIdentifier |
81 | | - }; |
82 | | - } |
83 | | - } |
84 | | - |
85 | | - return nil; |
| 85 | + return [[statusReportIdentifier componentsSeparatedByString:@":"] firstObject]; |
86 | 86 | } |
87 | 87 |
|
88 | 88 | + (NSString *)getPackageStatusReportIdentifier:(NSDictionary *)package |
|
0 commit comments