diff --git a/MVMCore/MVMCore/ActionHandling/ActionOpenPageHandler.swift b/MVMCore/MVMCore/ActionHandling/ActionOpenPageHandler.swift index 59289a3..8e1981f 100644 --- a/MVMCore/MVMCore/ActionHandling/ActionOpenPageHandler.swift +++ b/MVMCore/MVMCore/ActionHandling/ActionOpenPageHandler.swift @@ -43,6 +43,10 @@ open class ActionOpenPageHandler: MVMCoreJSONActionHandlerProtocol { /// Adds client parameters and makes calls performRequest() open func performRequestAddingClientParameters(with requestParameters: MVMCoreRequestParameters, model: ActionOpenPageModel, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws -> MVMCoreLoadRequestOperation? { + let actionUUID = MVMCoreActionHandler.getUUID(additionalData: additionalData) ?? UUID().uuidString + if !requestParameters.backgroundRequest, let pageType = requestParameters.pageType { + MVMCoreLoggingHandler.shared()?.logCoreEvent(.pageStarted(pageType: pageType, requestUUID: actionUUID)) + } // Adds any client parameters to the request parameters. if let parametersToFetch = model.clientParameters, let fetchedParameters = try await ClientParameterHandler().getClientParameters( @@ -54,9 +58,7 @@ open class ActionOpenPageHandler: MVMCoreJSONActionHandlerProtocol { } try Task.checkCancellation() let coreLoadRequestOperation = MVMCoreLoadHandler.sharedGlobal()?.loadRequest(requestParameters, dataForPage: additionalData, delegateObject: delegateObject) - if let pageType = requestParameters.pageType, let identifier = coreLoadRequestOperation?.identifier { - MVMCoreLoggingHandler.shared()?.logCoreEvent(.pageStarted(pageType: pageType, requestUUID: identifier)) - } + coreLoadRequestOperation?.identifier = actionUUID return coreLoadRequestOperation } diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.h b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.h index 13cf571..72875fa 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.h +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadObject.h @@ -59,7 +59,7 @@ @property (nullable, strong, nonatomic) NSDictionary *responseJSON; //Unique Identifier for event tracking -@property (nonatomic, nonatomic, nonnull) NSString *identifier; +@property (nullable, strong, nonatomic) NSString *identifier; - (nullable instancetype)initWithPageJSON:(nullable NSDictionary *)pageJSON modulesJSON:(nullable NSDictionary *)modulesJSON requestParameters:(nullable MVMCoreRequestParameters *)requestParameters dataForPage:(nullable NSDictionary *)dataForPage delegateObject:(nullable DelegateObject *)delegateObject; diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h index b441019..cbf775e 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.h @@ -26,7 +26,7 @@ @property (nullable, nonatomic, readonly) NSString *finalLoadSource; @property (nonatomic) BOOL backgroundLoad; @property (nonatomic, getter=areDependenciesAdded) BOOL dependenciesAdded; -@property (nonnull, nonatomic, readonly) NSString *identifier; +@property (nonnull, nonatomic, strong) NSString *identifier; /// Legacy flag for if this operation will have an alert to show when finished. @property (nonatomic, readonly) BOOL alertToShow; diff --git a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m index bf8e69a..59048a8 100644 --- a/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m +++ b/MVMCore/MVMCore/LoadHandling/MVMCoreLoadRequestOperation.m @@ -35,7 +35,6 @@ // For temporarily storing any alert to show until we determine it's delegate. @property (nonatomic, readwrite) BOOL alertToShow; @property (strong, nonatomic, nullable) MVMCoreErrorObject *errorForAlertToShow; -@property (nullable, nonatomic, readwrite) NSString *identifier; @end @@ -159,7 +158,7 @@ [MVMCoreLoadRequestOperation handleLoadObject:loadObject error:nil]; } else { - if(loadObject.requestParameters.pageType) { + if(!loadObject.requestParameters.backgroundRequest && loadObject.requestParameters.pageType) { [[MVMCoreLoggingHandler sharedLoggingHandler] logPageLoadStartedFor:loadObject.requestParameters.pageType requestUUID:loadObject.identifier requestURL:@"requestURL"]; } @@ -168,7 +167,7 @@ NSString *serverProcessTime = [(NSDictionary *)json objectChainOfKeysOrIndexes:@[@"ResponseInfo", @"timeStamp"]] ?: @"0"; - if(loadObject.requestParameters.pageType && serverProcessTime) { + if(!loadObject.requestParameters.backgroundRequest && loadObject.requestParameters.pageType && serverProcessTime) { [[MVMCoreLoggingHandler sharedLoggingHandler] logPageLoadCompleteFor:loadObject.requestParameters.pageType serverProcessingTime:serverProcessTime requestURL:@"requestURL" requestUUID:loadObject.identifier isFromCache:loadObject.pageDataFromCache]; } diff --git a/MVMCore/MVMCore/OtherHandlers/MVMCoreEvent.swift b/MVMCore/MVMCore/OtherHandlers/MVMCoreEvent.swift index bbcb6cf..3c1d0dd 100644 --- a/MVMCore/MVMCore/OtherHandlers/MVMCoreEvent.swift +++ b/MVMCore/MVMCore/OtherHandlers/MVMCoreEvent.swift @@ -162,6 +162,10 @@ extension MVMCoreLoggingHandler { @objc public extension MVMCoreLoggingHandler { + @objc func pageStarted(for pageType: String, requestUUID: String) { + logCoreEvent(.pageStarted(pageType: pageType, requestUUID: requestUUID)) + } + @objc func logPageLoadStarted(for pageType: String, requestUUID: String, requestURL: String) { logCoreEvent(.pageLoadStarted(pageType: pageType, requestUUID: requestUUID, requestURL: requestURL)) }