Analytics
Last updated
Last updated
The SDK provides an interface that you can implement and that will be used by the SDK to send events. The interface is simply the one below:
@interface UQTracer : NSObject
- (void)trace:(UQTrace *)trace;
@end
Trace is the object passed to your implementation and you can use it with any of your analytics tools or any custom tracing mechanism. Make sure to avoid blocking calls if you push the information of the trace object to any external system.
The UQTrace object has the following properties:
Property | Type | Optional | Default | |
---|---|---|---|---|
UQTraceCategory has the following properties:
Property | Type | Description |
---|---|---|
UQTraceEvent has following properties:
UQTraceStatus has the following parameters:
UQTracePage has following properties:
UQTraceStatusCode has the following properties:
Note: Please be aware that all codes with event IN_PROGRESS, except for SCAN_DOCUMENT_FRONT_PROCESSED and SCAN_DOCUMENT_BACK_PROCESSED, are throttled (limited to one identical event every 5 seconds). This is to ensure that your client is not overwhelmed and to accommodate varying speeds of different phones, which may send different numbers of events.
To enable the tracing mechanism, pass your implementation to the init method like the example below. Even in a Swift project you have to write the implementation in Objective-C. You can then decide to follow up with Swift passing the trace data from objective c to Swift.
Tracer implementation example:
@implementation UQTracer
- (void)trace:(UQTrace *)trace {
NSString *documentTypeName = @"";
if (trace.documentType != UNSPECIFY) {
UQDocumentConfig *document = [[UQDocumentConfig alloc] initWithDocumentType:trace.documentType];
documentTypeName = document.documentName;
}
NSString *timeStamp = [self timeStamp:trace.timestamp];
NSLog(@"Trace(sessionId=%@, category=%@, event=%@, page=%@, status=%@, statusCode=%@, statusMessage=%@, documentType=%@, timestamp=%@)" , trace.sessionId, trace.category->name, trace.event->name, trace.page->name ,trace.status->name, trace.statusCode->name, trace.statusMessage, documentTypeName, timeStamp);
}
- (NSString *)timeStamp:(NSDate *)currentDate {
return [NSDateFormatter localizedStringFromDate:currentDate
dateStyle:NSDateFormatterFullStyle
timeStyle:NSDateFormatterFullStyle];
}
@end
Tracer implementation example passing the trace data to Swift (the example below assumes that you have the SwiftTracer object defined in your Swift project with method signature trace):
@interface UQTracer ()
@property (nonatomic) SwiftTracer *swiftTracer;
@end
@implementation UQTracer
- (instancetype)init {
self = [super init];
if (self) {
self.swiftTracer = [[SwiftTracer alloc] init];
}
return self;
}
- (void)trace:(UQTrace *)trace {
NSString *documentTypeName = @"";
if (trace.documentType != UNSPECIFY) {
UQDocumentConfig *document = [[UQDocumentConfig alloc] initWithDocumentType:trace.documentType];
documentTypeName = document.documentName;
}
[self.swiftTracer traceWithSessionId:trace.sessionId
category:trace.category->name
event:trace.event->name
status:trace.status->name
page:trace.page->name
statusCode:trace.statusCode->name
statusMessage:trace.statusMessage
document:documentTypeName
timestamp:trace.timestamp];
}
@end
Initialize SDK with tracer in Objective-C:
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey,id> *)launchOptions {
UQTracer *tracer = [[UQTracer alloc] init];
[[UQBuilderController alloc] initWithTracer:tracer];
return YES;
}
@end
Initialize SDK with tracer in Swift:
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let tracer = UQTracer()
_ = UQBuilderController.init(tracer: tracer)
return true
}
}
Below you can find an example of the tracing above for a full enrollment flow with some errors in between to showcase the events:
2021-02-04 23:55:52.835375+0700 UqudoSDKDemo[520:87001] Trace(sessionId=(null), category=SDK, event=INIT, page=(null), status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=, timestamp=Thursday, 4 February BE 2564 23:55:52 Indochina Time)
2021-02-04 23:56:30.331468+0700 UqudoSDKDemo[520:87090] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=VIEW, page=SCAN, status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=PASSPORT, timestamp=Thursday, 4 February BE 2564 23:56:30 Indochina Time)
2021-02-04 23:56:31.270246+0700 UqudoSDKDemo[520:87090] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=START, page=SCAN, status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=PASSPORT, timestamp=Thursday, 4 February BE 2564 23:56:31 Indochina Time)
2021-02-04 23:56:43.938264+0700 UqudoSDKDemo[520:87259] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=COMPLETE, page=SCAN, status=FAILURE, statusCode=SCAN_DOCUMENT_NOT_RECOGNIZED, statusMessage=(null), documentType=PASSPORT, timestamp=Thursday, 4 February BE 2564 23:56:43 Indochina Time)
2021-02-04 23:56:52.071336+0700 UqudoSDKDemo[520:87279] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=START, page=SCAN, status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=PASSPORT, timestamp=Thursday, 4 February BE 2564 23:56:52 Indochina Time)
2021-02-04 23:57:05.886765+0700 UqudoSDKDemo[520:87280] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=COMPLETE, page=SCAN, status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=PASSPORT, timestamp=Thursday, 4 February BE 2564 23:57:05 Indochina Time)
2021-02-04 23:57:05.903494+0700 UqudoSDKDemo[520:87280] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=VIEW, page=READ, status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=PASSPORT, timestamp=Thursday, 4 February BE 2564 23:57:05 Indochina Time)
2021-02-04 23:57:10.125406+0700 UqudoSDKDemo[520:87280] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=START, page=READ, status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=PASSPORT, timestamp=Thursday, 4 February BE 2564 23:57:10 Indochina Time)
2021-02-04 23:57:25.038866+0700 UqudoSDKDemo[520:87259] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=COMPLETE, page=READ, status=FAILURE, statusCode=READ_DOCUMENT_DISCONNECTED, statusMessage=(null), documentType=PASSPORT, timestamp=Thursday, 4 February BE 2564 23:57:25 Indochina Time)
2021-02-04 23:57:35.027795+0700 UqudoSDKDemo[520:87259] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=START, page=READ, status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=PASSPORT, timestamp=Thursday, 4 February BE 2564 23:57:35 Indochina Time)
2021-02-04 23:57:39.185936+0700 UqudoSDKDemo[520:87399] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=COMPLETE, page=READ, status=FAILURE, statusCode=USER_CANCEL, statusMessage=(null), documentType=PASSPORT, timestamp=Thursday, 4 February BE 2564 23:57:39 Indochina Time)
2021-02-04 23:57:42.994229+0700 UqudoSDKDemo[520:87401] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=START, page=READ, status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=PASSPORT, timestamp=Thursday, 4 February BE 2564 23:57:42 Indochina Time)
2021-02-04 23:58:09.691329+0700 UqudoSDKDemo[520:87752] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=COMPLETE, page=READ, status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=PASSPORT, timestamp=Thursday, 4 February BE 2564 23:58:09 Indochina Time)
2021-02-04 23:58:09.695761+0700 UqudoSDKDemo[520:87752] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=VIEW, page=FACE, status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=, timestamp=Thursday, 4 February BE 2564 23:58:09 Indochina Time)
2021-02-04 23:58:11.906030+0700 UqudoSDKDemo[520:87792] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=START, page=FACE, status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=, timestamp=Thursday, 4 February BE 2564 23:58:11 Indochina Time)
2021-02-04 23:58:20.427607+0700 UqudoSDKDemo[520:87752] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=COMPLETE, page=FACE, status=FAILURE, statusCode=FACE_TIMEOUT, statusMessage=(null), documentType=, timestamp=Thursday, 4 February BE 2564 23:58:20 Indochina Time)
2021-02-04 23:58:23.958376+0700 UqudoSDKDemo[520:87913] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=START, page=FACE, status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=, timestamp=Thursday, 4 February BE 2564 23:58:23 Indochina Time)
2021-02-04 23:58:32.470057+0700 UqudoSDKDemo[520:87802] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=COMPLETE, page=FACE, status=FAILURE, statusCode=FACE_TIMEOUT, statusMessage=(null), documentType=, timestamp=Thursday, 4 February BE 2564 23:58:32 Indochina Time)
2021-02-04 23:58:34.140175+0700 UqudoSDKDemo[520:87913] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=START, page=FACE, status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=, timestamp=Thursday, 4 February BE 2564 23:58:34 Indochina Time)
2021-02-04 23:58:50.816411+0700 UqudoSDKDemo[520:87924] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=COMPLETE, page=FACE, status=FAILURE, statusCode=FACE_TIMEOUT, statusMessage=(null), documentType=, timestamp=Thursday, 4 February BE 2564 23:58:50 Indochina Time)
2021-02-04 23:58:51.657288+0700 UqudoSDKDemo[520:87912] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=START, page=FACE, status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=, timestamp=Thursday, 4 February BE 2564 23:58:51 Indochina Time)
2021-02-04 23:58:58.925882+0700 UqudoSDKDemo[520:87924] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=COMPLETE, page=FACE, status=FAILURE, statusCode=FACE_NO_MATCH, statusMessage=(null), documentType=, timestamp=Thursday, 4 February BE 2564 23:58:58 Indochina Time)
2021-02-04 23:59:05.496069+0700 UqudoSDKDemo[520:87913] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=START, page=FACE, status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=, timestamp=Thursday, 4 February BE 2564 23:59:05 Indochina Time)
2021-02-04 23:59:17.045578+0700 UqudoSDKDemo[520:87913] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=COMPLETE, page=FACE, status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=, timestamp=Thursday, 4 February BE 2564 23:59:17 Indochina Time)
2021-02-04 23:59:17.137647+0700 UqudoSDKDemo[520:88083] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=VIEW, page=BACKGROUND_CHECK, status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=, timestamp=Thursday, 4 February BE 2564 23:59:17 Indochina Time)
2021-02-04 23:59:19.777937+0700 UqudoSDKDemo[520:87924] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=START, page=BACKGROUND_CHECK, status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=, timestamp=Thursday, 4 February BE 2564 23:59:19 Indochina Time)
2021-02-04 23:59:21.272898+0700 UqudoSDKDemo[520:88037] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=COMPLETE, page=BACKGROUND_CHECK, status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=, timestamp=Thursday, 4 February BE 2564 23:59:21 Indochina Time)
2021-02-04 23:59:22.857039+0700 UqudoSDKDemo[520:87913] Trace(sessionId=9C40E0C2-A7C2-4FF2-B0C1-C22DE3E99D18, category=ENROLLMENT, event=FINISH, page=(null), status=SUCCESS, statusCode=(null), statusMessage=(null), documentType=, timestamp=Thursday, 4 February BE 2564 23:59:22 Indochina Time)
Below you can find an example on how to use the trace information with Firebase Analytics:
#import <Foundation/Foundation.h>
#import <UqudoSDK/UqudoSDK.h>
@import FirebaseAnalytics;
@implementation UQTracer
- (void)trace:(UQTrace *)trace {
NSString *timeStamp = [self timeStamp:trace.timestamp];
NSMutableDictionary* parameters = [[NSMutableDictionary alloc] init];
[parameters setValue:trace.event->name forKey:@"event"];
[parameters setValue:trace.status->name forKey:@"status"];
[parameters setValue:timeStamp forKey:@"timestamp"];
if (trace.sessionId) {
[parameters setValue:trace.sessionId forKey:@"sessionId"];
}
if (TP_NULL != trace.page) {
[parameters setValue:trace.page->name forKey:@"page"];
}
if (TSC_NULL != trace.statusCode) {
[parameters setValue:trace.statusCode->name forKey:@"statusCode"];
}
if (trace.documentType != UNSPECIFY) {
UQDocumentConfig *document = [[UQDocumentConfig alloc] initWithDocumentType:trace.documentType];
[parameters setValue:document.documentName forKey:@"documentType"];
}
if (trace.statusMessage) {
[parameters setValue:trace.statusMessage forKey:@"statusMessage"];
}
[FIRAnalytics logEventWithName:trace.category->name parameters:parameters];
}
- (NSString *)timeStamp:(NSDate *)currentDate {
NSISO8601DateFormatter *dateFormatter = [[NSISO8601DateFormatter alloc] init];
return [dateFormatter stringFromDate:currentDate];
}
@end
Property | Type | Description |
---|---|---|
Property | Type | Description |
---|---|---|
Property | Type | Description |
---|---|---|
Property | Type | Description |
---|---|---|