Add script to extract and gather analytics event names.
// FREEBIE
This commit is contained in:
parent
31ab9a00da
commit
b4f348ad14
|
@ -48,6 +48,7 @@
|
|||
#import <SignalServiceKit/NSTimer+OWS.h>
|
||||
#import <SignalServiceKit/OWSAcknowledgeMessageDeliveryRequest.h>
|
||||
#import <SignalServiceKit/OWSAnalytics.h>
|
||||
#import <SignalServiceKit/OWSAnalyticsEvents.h>
|
||||
#import <SignalServiceKit/OWSAttachmentsProcessor.h>
|
||||
#import <SignalServiceKit/OWSCallAnswerMessage.h>
|
||||
#import <SignalServiceKit/OWSCallBusyMessage.h>
|
||||
|
|
|
@ -273,8 +273,8 @@ protocol CallServiceObserver: class {
|
|||
let errorDescription = "\(TAG) call was unexpectedly already set."
|
||||
Logger.error(errorDescription)
|
||||
call.state = .localFailure
|
||||
OWSProdError("call_service_call_already_set", file:#file, function:#function, line:#line)
|
||||
return Promise(error: .assertionError(errorDescription))
|
||||
OWSProdError(OWSAnalyticsEvents.call_service_call_already_set(), file:#file, function:#function, line:#line)
|
||||
return Promise(error: CallError.assertionError(description:errorDescription))
|
||||
}
|
||||
|
||||
self.call = call
|
||||
|
@ -297,7 +297,7 @@ protocol CallServiceObserver: class {
|
|||
let errorDescription = "\(self.TAG) peerconnection was unexpectedly already set."
|
||||
Logger.error(errorDescription)
|
||||
OWSProdError("call_service_peer_connection_already_set", file:#file, function:#function, line:#line)
|
||||
throw .assertionError(errorDescription)
|
||||
throw CallError.assertionError(description:errorDescription)
|
||||
}
|
||||
|
||||
let useTurnOnly = Environment.getCurrent().preferences.doCallsHideIPAddress()
|
||||
|
@ -374,7 +374,7 @@ protocol CallServiceObserver: class {
|
|||
|
||||
guard let fulfillReadyToSendIceUpdatesPromise = self.fulfillReadyToSendIceUpdatesPromise else {
|
||||
OWSProdError("call_service_missing_fulfill_ready_to_send_ice_updates_promise", file:#file, function:#function, line:#line)
|
||||
self.handleFailedCall(failedCall: call, error: .assertionError("failed to create fulfillReadyToSendIceUpdatesPromise"))
|
||||
self.handleFailedCall(failedCall: call, error: CallError.assertionError(description:"failed to create fulfillReadyToSendIceUpdatesPromise"))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -413,7 +413,7 @@ protocol CallServiceObserver: class {
|
|||
|
||||
guard let peerConnectionClient = self.peerConnectionClient else {
|
||||
OWSProdError("call_service_peer_connection_missing", file:#file, function:#function, line:#line)
|
||||
handleFailedCall(failedCall: call, error: .assertionError("peerConnectionClient was unexpectedly nil in \(#function)"))
|
||||
handleFailedCall(failedCall: call, error: CallError.assertionError(description:"peerConnectionClient was unexpectedly nil in \(#function)"))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -702,7 +702,7 @@ protocol CallServiceObserver: class {
|
|||
|
||||
guard let call = self.call else {
|
||||
OWSProdError("call_service_call_missing", file:#file, function:#function, line:#line)
|
||||
self.handleFailedCurrentCall(error: .assertionError("ignoring local ice candidate, since there is no current call."))
|
||||
self.handleFailedCurrentCall(error: CallError.assertionError(description:"ignoring local ice candidate, since there is no current call."))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -718,7 +718,7 @@ protocol CallServiceObserver: class {
|
|||
// This will only be called for the current peerConnectionClient, so
|
||||
// fail the current call.
|
||||
OWSProdError("call_service_call_unexpectedly_idle", file:#file, function:#function, line:#line)
|
||||
self.handleFailedCurrentCall(error: .assertionError("ignoring local ice candidate, since call is now idle."))
|
||||
self.handleFailedCurrentCall(error: CallError.assertionError(description:"ignoring local ice candidate, since call is now idle."))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -755,7 +755,7 @@ protocol CallServiceObserver: class {
|
|||
// This will only be called for the current peerConnectionClient, so
|
||||
// fail the current call.
|
||||
OWSProdError("call_service_call_missing", file:#file, function:#function, line:#line)
|
||||
handleFailedCurrentCall(error: .assertionError("\(TAG) ignoring \(#function) since there is no current call."))
|
||||
handleFailedCurrentCall(error: CallError.assertionError(description:"\(TAG) ignoring \(#function) since there is no current call."))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -825,7 +825,7 @@ protocol CallServiceObserver: class {
|
|||
// This should never happen; return to a known good state.
|
||||
owsFail("\(TAG) call was unexpectedly nil in \(#function)")
|
||||
OWSProdError("call_service_call_missing", file:#file, function:#function, line:#line)
|
||||
handleFailedCurrentCall(error: .assertionError("\(TAG) call was unexpectedly nil in \(#function)"))
|
||||
handleFailedCurrentCall(error: CallError.assertionError(description:"\(TAG) call was unexpectedly nil in \(#function)"))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -833,7 +833,7 @@ protocol CallServiceObserver: class {
|
|||
// This should never happen; return to a known good state.
|
||||
owsFail("\(TAG) callLocalId:\(localId) doesn't match current calls: \(call.localId)")
|
||||
OWSProdError("call_service_call_id_mismatch", file:#file, function:#function, line:#line)
|
||||
handleFailedCurrentCall(error: .assertionError("\(TAG) callLocalId:\(localId) doesn't match current calls: \(call.localId)"))
|
||||
handleFailedCurrentCall(error: CallError.assertionError(description:"\(TAG) callLocalId:\(localId) doesn't match current calls: \(call.localId)"))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -850,7 +850,7 @@ protocol CallServiceObserver: class {
|
|||
|
||||
guard let currentCall = self.call else {
|
||||
OWSProdError("call_service_call_missing", file:#file, function:#function, line:#line)
|
||||
handleFailedCall(failedCall: call, error: .assertionError("\(TAG) ignoring \(#function) since there is no current call"))
|
||||
handleFailedCall(failedCall: call, error: CallError.assertionError(description:"\(TAG) ignoring \(#function) since there is no current call"))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -863,7 +863,7 @@ protocol CallServiceObserver: class {
|
|||
|
||||
guard let peerConnectionClient = self.peerConnectionClient else {
|
||||
OWSProdError("call_service_peer_connection_missing", file:#file, function:#function, line:#line)
|
||||
handleFailedCall(failedCall: call, error: .assertionError("\(TAG) missing peerconnection client in \(#function)"))
|
||||
handleFailedCall(failedCall: call, error: CallError.assertionError(description:"\(TAG) missing peerconnection client in \(#function)"))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -889,7 +889,7 @@ protocol CallServiceObserver: class {
|
|||
|
||||
guard let peerConnectionClient = self.peerConnectionClient else {
|
||||
OWSProdError("call_service_peer_connection_missing", file:#file, function:#function, line:#line)
|
||||
handleFailedCall(failedCall: call, error: .assertionError("\(TAG) peerConnectionClient unexpectedly nil in \(#function)"))
|
||||
handleFailedCall(failedCall: call, error: CallError.assertionError(description:"\(TAG) peerConnectionClient unexpectedly nil in \(#function)"))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -920,7 +920,7 @@ protocol CallServiceObserver: class {
|
|||
// This should never happen; return to a known good state.
|
||||
owsFail("\(TAG) call was unexpectedly nil in \(#function)")
|
||||
OWSProdError("call_service_call_missing", file:#file, function:#function, line:#line)
|
||||
handleFailedCurrentCall(error: .assertionError("\(TAG) call was unexpectedly nil in \(#function)"))
|
||||
handleFailedCurrentCall(error: CallError.assertionError(description:"\(TAG) call was unexpectedly nil in \(#function)"))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -928,7 +928,7 @@ protocol CallServiceObserver: class {
|
|||
// This should never happen; return to a known good state.
|
||||
owsFail("\(TAG) callLocalId:\(localId) doesn't match current calls: \(call.localId)")
|
||||
OWSProdError("call_service_call_id_mismatch", file:#file, function:#function, line:#line)
|
||||
handleFailedCurrentCall(error: .assertionError("\(TAG) callLocalId:\(localId) doesn't match current calls: \(call.localId)"))
|
||||
handleFailedCurrentCall(error: CallError.assertionError(description:"\(TAG) callLocalId:\(localId) doesn't match current calls: \(call.localId)"))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -968,19 +968,19 @@ protocol CallServiceObserver: class {
|
|||
|
||||
guard let currentCall = self.call else {
|
||||
OWSProdError("call_service_call_missing", file:#file, function:#function, line:#line)
|
||||
handleFailedCall(failedCall: call, error: .assertionError("\(TAG) ignoring \(#function) since there is no current call"))
|
||||
handleFailedCall(failedCall: call, error: CallError.assertionError(description:"\(TAG) ignoring \(#function) since there is no current call"))
|
||||
return
|
||||
}
|
||||
|
||||
guard call == currentCall else {
|
||||
OWSProdError("call_service_call_mismatch", file:#file, function:#function, line:#line)
|
||||
handleFailedCall(failedCall: call, error: .assertionError("\(TAG) ignoring \(#function) for call other than current call"))
|
||||
handleFailedCall(failedCall: call, error: CallError.assertionError(description:"\(TAG) ignoring \(#function) for call other than current call"))
|
||||
return
|
||||
}
|
||||
|
||||
guard let peerConnectionClient = self.peerConnectionClient else {
|
||||
OWSProdError("call_service_peer_connection_missing", file:#file, function:#function, line:#line)
|
||||
handleFailedCall(failedCall: call, error: .assertionError("\(TAG) missing peerconnection client in \(#function)"))
|
||||
handleFailedCall(failedCall: call, error: CallError.assertionError(description:"\(TAG) missing peerconnection client in \(#function)"))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1021,7 +1021,7 @@ protocol CallServiceObserver: class {
|
|||
// This should never happen; return to a known good state.
|
||||
owsFail("\(TAG) call was unexpectedly nil in \(#function)")
|
||||
OWSProdError("call_service_call_missing", file:#file, function:#function, line:#line)
|
||||
handleFailedCurrentCall(error: .assertionError("\(TAG) call unexpectedly nil in \(#function)"))
|
||||
handleFailedCurrentCall(error: CallError.assertionError(description:"\(TAG) call unexpectedly nil in \(#function)"))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1076,7 +1076,7 @@ protocol CallServiceObserver: class {
|
|||
// This should never happen; return to a known good state.
|
||||
owsFail("\(TAG) call was unexpectedly nil in \(#function)")
|
||||
OWSProdError("call_service_call_missing", file:#file, function:#function, line:#line)
|
||||
handleFailedCurrentCall(error: .assertionError("\(TAG) call unexpectedly nil in \(#function)"))
|
||||
handleFailedCurrentCall(error: CallError.assertionError(description:"\(TAG) call unexpectedly nil in \(#function)"))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1115,7 +1115,7 @@ protocol CallServiceObserver: class {
|
|||
// This should never happen; return to a known good state.
|
||||
owsFail("\(TAG) received data message, but there is no current call. Ignoring.")
|
||||
OWSProdError("call_service_call_missing", file:#file, function:#function, line:#line)
|
||||
handleFailedCurrentCall(error: .assertionError("\(TAG) received data message, but there is no current call. Ignoring."))
|
||||
handleFailedCurrentCall(error: CallError.assertionError(description:"\(TAG) received data message, but there is no current call. Ignoring."))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1128,7 +1128,7 @@ protocol CallServiceObserver: class {
|
|||
// This should never happen; return to a known good state.
|
||||
owsFail("\(TAG) received connected message for call with id:\(connected.id) but current call has id:\(call.signalingId)")
|
||||
OWSProdError("call_service_call_id_mismatch", file:#file, function:#function, line:#line)
|
||||
handleFailedCurrentCall(error: .assertionError("\(TAG) received connected message for call with id:\(connected.id) but current call has id:\(call.signalingId)"))
|
||||
handleFailedCurrentCall(error: CallError.assertionError(description:"\(TAG) received connected message for call with id:\(connected.id) but current call has id:\(call.signalingId)"))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1144,7 +1144,7 @@ protocol CallServiceObserver: class {
|
|||
// This should never happen; return to a known good state.
|
||||
owsFail("\(TAG) received hangup message for call with id:\(hangup.id) but current call has id:\(call.signalingId)")
|
||||
OWSProdError("call_service_call_id_mismatch", file:#file, function:#function, line:#line)
|
||||
handleFailedCurrentCall(error: .assertionError("\(TAG) received hangup message for call with id:\(hangup.id) but current call has id:\(call.signalingId)"))
|
||||
handleFailedCurrentCall(error: CallError.assertionError(description:"\(TAG) received hangup message for call with id:\(hangup.id) but current call has id:\(call.signalingId)"))
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -1252,7 +1252,7 @@ protocol CallServiceObserver: class {
|
|||
|
||||
guard let readyToSendIceUpdatesPromise = self.readyToSendIceUpdatesPromise else {
|
||||
OWSProdError("call_service_could_not_create_ready_to_send_ice_updates_promise", file:#file, function:#function, line:#line)
|
||||
return Promise(error: .assertionError("failed to create readyToSendIceUpdatesPromise"))
|
||||
return Promise(error: CallError.assertionError(description:"failed to create readyToSendIceUpdatesPromise"))
|
||||
}
|
||||
|
||||
return readyToSendIceUpdatesPromise
|
||||
|
@ -1296,7 +1296,7 @@ protocol CallServiceObserver: class {
|
|||
|
||||
guard let peerConnectionClientPromise = self.peerConnectionClientPromise else {
|
||||
OWSProdError("call_service_could_not_create_peer_connection_client_promise", file:#file, function:#function, line:#line)
|
||||
return Promise(error: .assertionError("failed to create peerConnectionClientPromise"))
|
||||
return Promise(error: CallError.assertionError(description:"failed to create peerConnectionClientPromise"))
|
||||
}
|
||||
|
||||
return peerConnectionClientPromise
|
||||
|
@ -1375,7 +1375,7 @@ protocol CallServiceObserver: class {
|
|||
public func handleFailedCall(failedCall: SignalCall?, error: CallError) {
|
||||
AssertIsOnMainThread()
|
||||
|
||||
if case .assertionError(let description) = error {
|
||||
if case CallError.assertionError(description:let description) = error {
|
||||
owsFail(description)
|
||||
}
|
||||
|
||||
|
|
|
@ -27,9 +27,10 @@ def splitall(path):
|
|||
path = parts[0]
|
||||
allparts.insert(0, parts[1])
|
||||
return allparts
|
||||
|
||||
event_names = []
|
||||
|
||||
|
||||
def process(filepath, macros):
|
||||
def process(filepath, c_macros, swift_macros):
|
||||
|
||||
short_filepath = filepath[len(git_repo_path):]
|
||||
if short_filepath.startswith(os.sep):
|
||||
|
@ -44,22 +45,11 @@ def process(filepath, macros):
|
|||
|
||||
is_swift = file_ext in ('.swift')
|
||||
|
||||
if is_swift:
|
||||
macros = macros + ['OWSProdCallAssertionError',]
|
||||
# print 'macros', macros
|
||||
|
||||
if file_ext in ('.swift'):
|
||||
# env_copy = os.environ.copy()
|
||||
# env_copy["SCRIPT_INPUT_FILE_COUNT"] = "1"
|
||||
# env_copy["SCRIPT_INPUT_FILE_0"] = '%s' % ( short_filepath, )
|
||||
# lint_output = subprocess.check_output(['swiftlint', 'autocorrect', '--use-script-input-files'], env=env_copy)
|
||||
# print lint_output
|
||||
# try:
|
||||
# lint_output = subprocess.check_output(['swiftlint', 'lint', '--use-script-input-files'], env=env_copy)
|
||||
# except subprocess.CalledProcessError, e:
|
||||
# lint_output = e.output
|
||||
# print lint_output
|
||||
pass
|
||||
if is_swift:
|
||||
macros = swift_macros
|
||||
else:
|
||||
macros = c_macros
|
||||
|
||||
# print short_filepath, is_swift
|
||||
|
||||
|
@ -100,6 +90,7 @@ def process(filepath, macros):
|
|||
break
|
||||
|
||||
event_name = best_match.group(1).strip()
|
||||
event_names.append(event_name)
|
||||
if not has_printed_filename:
|
||||
has_printed_filename = True
|
||||
print short_filepath
|
||||
|
@ -110,7 +101,7 @@ def process(filepath, macros):
|
|||
|
||||
# break
|
||||
|
||||
return
|
||||
return
|
||||
|
||||
with open(filepath, 'rt') as f:
|
||||
text = f.read()
|
||||
|
@ -158,7 +149,7 @@ def should_ignore_path(path):
|
|||
return False
|
||||
|
||||
|
||||
def process_if_appropriate(filepath, macros):
|
||||
def process_if_appropriate(filepath, c_macros, swift_macros):
|
||||
filename = os.path.basename(filepath)
|
||||
if filename.startswith('.'):
|
||||
return
|
||||
|
@ -167,11 +158,15 @@ def process_if_appropriate(filepath, macros):
|
|||
return
|
||||
if should_ignore_path(filepath):
|
||||
return
|
||||
process(filepath, macros)
|
||||
process(filepath, c_macros, swift_macros)
|
||||
|
||||
|
||||
def extract_macros(filepath):
|
||||
|
||||
filename = os.path.basename(filepath)
|
||||
file_ext = os.path.splitext(filename)[1]
|
||||
is_swift = file_ext in ('.swift')
|
||||
|
||||
macros = []
|
||||
|
||||
with open(filepath, 'rt') as f:
|
||||
|
@ -181,7 +176,11 @@ def extract_macros(filepath):
|
|||
for line in lines:
|
||||
# Match lines of this form:
|
||||
# #define OWSProdCritical(__eventName) ...
|
||||
matcher = re.compile(r'#define (OWSProd[^\(]+)\(.+[,\)]')
|
||||
|
||||
if is_swift:
|
||||
matcher = re.compile(r'func (OWSProd[^\(]+)\(.+[,\)]')
|
||||
else:
|
||||
matcher = re.compile(r'#define (OWSProd[^\(]+)\(.+[,\)]')
|
||||
# matcher = re.compile(r'#define (OWSProd)')
|
||||
match = matcher.search(line)
|
||||
if match:
|
||||
|
@ -199,10 +198,20 @@ if __name__ == "__main__":
|
|||
if not os.path.exists(macros_header_file_path):
|
||||
print 'Macros header does not exist:', macros_header_file_path
|
||||
sys.exit(1)
|
||||
macros = extract_macros(macros_header_file_path)
|
||||
print 'macros:', macros
|
||||
|
||||
c_macros = extract_macros(macros_header_file_path)
|
||||
print 'c_macros:', c_macros
|
||||
|
||||
macros_header_file_path = os.path.join(git_repo_path, 'Signal', 'src', 'util', 'OWSAnalytics.swift')
|
||||
if not os.path.exists(macros_header_file_path):
|
||||
print 'Macros header does not exist:', macros_header_file_path
|
||||
sys.exit(1)
|
||||
swift_macros = extract_macros(macros_header_file_path)
|
||||
print 'swift_macros:', swift_macros
|
||||
|
||||
for rootdir, dirnames, filenames in os.walk(git_repo_path):
|
||||
for filename in filenames:
|
||||
file_path = os.path.abspath(os.path.join(rootdir, filename))
|
||||
process_if_appropriate(file_path, macros)
|
||||
process_if_appropriate(file_path, c_macros, swift_macros)
|
||||
|
||||
print
|
||||
print 'event_names', sorted(set(event_names))
|
||||
|
|
|
@ -4,4 +4,12 @@
|
|||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface OWSAnalyticsEvents : NSObject
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
+ (NSString *)call_service_call_already_set;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -6,5 +6,13 @@
|
|||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@implementation OWSAnalyticsEvents
|
||||
|
||||
+ (NSString *)call_service_call_already_set
|
||||
{
|
||||
return @"call_service_call_already_set";
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
Loading…
Reference in New Issue