Skip to content

Commit e70edfc

Browse files
author
kai
committed
convert to constant
1 parent 2383e2a commit e70edfc

File tree

4 files changed

+33
-10
lines changed

4 files changed

+33
-10
lines changed

.github/workflows/auto-retag.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ name: Auto-retag UNTAGGED entries
55

66
on:
77
workflow_dispatch: # Manual trigger
8-
push:
8+
pull_request:
99
branches:
10-
- '**' # All branches
10+
- dev # Only for PRs targeting dev branch
1111
paths:
1212
- 'IdentityCore/src/telemetry/execution_flow/MSIDExecutionFlowConstants.m'
1313

IdentityCore/src/telemetry/execution_flow/MSIDExecutionFlow.m

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#import "MSIDJsonSerializer.h"
2828
#import "NSDate+MSIDExtensions.h"
2929
#import "NSString+MSIDExtensions.h"
30+
#import "MSIDExecutionFlowConstants.h"
3031

3132
#define MAX_EXECUTION_FLOW_SIZE 50
3233

@@ -59,19 +60,19 @@ - (void)insertTag:(NSString *)tag
5960
{
6061
if ([NSString msidIsStringNilOrBlank:tag])
6162
{
62-
MSID_LOG_WITH_CTX_PII(MSIDLogLevelWarning, nil, @"Tag cannot be nil", nil);
63+
MSID_LOG_WITH_CTX_PII(MSIDLogLevelWarning, nil, MSID_EXECUTION_FLOW_TAG_NIL_MESSAGE, nil);
6364
return;
6465
}
6566

6667
if (!tid)
6768
{
68-
MSID_LOG_WITH_CTX_PII(MSIDLogLevelWarning, nil, @"tid cannot be nil", nil);
69+
MSID_LOG_WITH_CTX_PII(MSIDLogLevelWarning, nil, MSID_EXECUTION_FLOW_TID_NIL_MESSAGE, nil);
6970
return;
7071
}
7172

7273
if (!triggeringTime)
7374
{
74-
MSID_LOG_WITH_CTX_PII(MSIDLogLevelWarning, nil, @"triggeringTime cannot be nil", nil);
75+
MSID_LOG_WITH_CTX_PII(MSIDLogLevelWarning, nil, MSID_EXECUTION_FLOW_TRIGGERING_TIME_NIL_MESSAGE, nil);
7576
return;
7677
}
7778

@@ -91,7 +92,7 @@ - (void)insertTag:(NSString *)tag
9192
MSIDExecutionFlowBlob *blob = [[MSIDExecutionFlowBlob alloc] initWithTag:tag timeStep:@(ts) threadId:tid];
9293
if (!blob)
9394
{
94-
MSID_LOG_WITH_CTX_PII(MSIDLogLevelWarning, nil, @"Failed to create execution flow blob", nil);
95+
MSID_LOG_WITH_CTX_PII(MSIDLogLevelWarning, nil, MSID_EXECUTION_FLOW_FAILED_TO_CREATE_BLOB_MESSAGE, nil);
9596
return;
9697
}
9798

@@ -115,7 +116,7 @@ - (void)insertTag:(NSString *)tag
115116
- (NSString *)exportExecutionFlowToJSONsWithKeys:(NSSet<NSString *> *)queryKeys
116117
{
117118

118-
__block NSMutableString *jsonArray = [NSMutableString stringWithString:@"["];
119+
__block NSMutableString *jsonArray = [NSMutableString stringWithString:MSID_EXECUTION_FLOW_JSON_OPEN_BRACKET];
119120

120121
dispatch_sync(self.executionFlowWritingQueue, ^{
121122
for (NSUInteger i = 0; i < self.executionFlow.count; i++)
@@ -130,16 +131,16 @@ - (NSString *)exportExecutionFlowToJSONsWithKeys:(NSSet<NSString *> *)queryKeys
130131
// Add comma separator if not the last element
131132
if (i < self.executionFlow.count - 1)
132133
{
133-
[jsonArray appendString:@","];
134+
[jsonArray appendString:MSID_EXECUTION_FLOW_JSON_COMMA];
134135
}
135136
}
136137
}
137138
});
138139

139-
[jsonArray appendString:@"]"];
140+
[jsonArray appendString:MSID_EXECUTION_FLOW_JSON_CLOSE_BRACKET];
140141

141142
// Return nil if array is empty
142-
if ([jsonArray isEqualToString:@"[]"])
143+
if ([jsonArray isEqualToString:MSID_EXECUTION_FLOW_JSON_EMPTY_ARRAY])
143144
{
144145
return nil;
145146
}

IdentityCore/src/telemetry/execution_flow/MSIDExecutionFlowConstants.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ extern NSString * _Nonnull const MSID_EXECUTION_FLOW_THREAD_ID;
4646
extern NSString * _Nonnull const MSID_EXECUTION_FLOW_DIAGNOSTIC_ID;
4747
extern NSString * _Nonnull const MSID_EXECUTION_FLOW_ERROR_CODE;
4848

49+
// Log messages
50+
FOUNDATION_EXPORT NSString * _Nonnull const MSID_EXECUTION_FLOW_TAG_NIL_MESSAGE;
51+
FOUNDATION_EXPORT NSString * _Nonnull const MSID_EXECUTION_FLOW_TID_NIL_MESSAGE;
52+
FOUNDATION_EXPORT NSString * _Nonnull const MSID_EXECUTION_FLOW_TRIGGERING_TIME_NIL_MESSAGE;
53+
FOUNDATION_EXPORT NSString * _Nonnull const MSID_EXECUTION_FLOW_FAILED_TO_CREATE_BLOB_MESSAGE;
54+
55+
// JSON formatting constants
56+
FOUNDATION_EXPORT NSString * _Nonnull const MSID_EXECUTION_FLOW_JSON_OPEN_BRACKET;
57+
FOUNDATION_EXPORT NSString * _Nonnull const MSID_EXECUTION_FLOW_JSON_COMMA;
58+
FOUNDATION_EXPORT NSString * _Nonnull const MSID_EXECUTION_FLOW_JSON_CLOSE_BRACKET;
59+
FOUNDATION_EXPORT NSString * _Nonnull const MSID_EXECUTION_FLOW_JSON_EMPTY_ARRAY;
4960
/// A enum of MSIDExecutionFlowNetworkT@"e"ag.
5061
typedef NS_ENUM(NSInteger, MSIDExecutionFlowNetworkTag)
5162
{

IdentityCore/src/telemetry/execution_flow/MSIDExecutionFlowConstants.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@
3434

3535
NSString *const MSID_EXECUTION_FLOW_ERROR_CODE = @"e";
3636

37+
// Log messages
38+
NSString *const MSID_EXECUTION_FLOW_TAG_NIL_MESSAGE = @"Tag cannot be nil";
39+
NSString *const MSID_EXECUTION_FLOW_TID_NIL_MESSAGE = @"tid cannot be nil";
40+
NSString *const MSID_EXECUTION_FLOW_TRIGGERING_TIME_NIL_MESSAGE = @"triggeringTime cannot be nil";
41+
NSString *const MSID_EXECUTION_FLOW_FAILED_TO_CREATE_BLOB_MESSAGE = @"Failed to create execution flow blob";
42+
43+
// JSON formatting constants
44+
NSString *const MSID_EXECUTION_FLOW_JSON_OPEN_BRACKET = @"[";
45+
NSString *const MSID_EXECUTION_FLOW_JSON_COMMA = @",";
46+
NSString *const MSID_EXECUTION_FLOW_JSON_CLOSE_BRACKET = @"]";
47+
NSString *const MSID_EXECUTION_FLOW_JSON_EMPTY_ARRAY = @"[]";
3748

3849
NSString *MSIDExecutionFlowNetworkTagToString(MSIDExecutionFlowNetworkTag state)
3950
{

0 commit comments

Comments
 (0)