Digital PCT265 defect DE307-687: Re-log all analytics on page state return.
This commit is contained in:
parent
1fcd8854f5
commit
be797aaee2
@ -20,7 +20,7 @@ public class ReplaceableMoleculeBehaviorModel: PageBehaviorModelProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
public class ReplaceableMoleculeBehavior: PageMoleculeTransformationBehavior, CoreLogging {
|
||||
public class ReplaceableMoleculeBehavior: PageMoleculeTransformationBehavior, PageVisibilityBehavior, CoreLogging {
|
||||
|
||||
public var loggingPrefix: String {
|
||||
"\(self) \(ObjectIdentifier(self).hashValue) \(moleculeIds.prefix(3)) \(moleculeIds.count > 3 ? "+ \(moleculeIds.count - 3) more" : ""):\n"
|
||||
@ -30,6 +30,8 @@ public class ReplaceableMoleculeBehavior: PageMoleculeTransformationBehavior, Co
|
||||
String(describing: Self.self)
|
||||
}
|
||||
|
||||
var hasPreviouslyBeenShown = false
|
||||
var previouslyReplacedIds = Set<String>()
|
||||
var moleculeIds: [String]
|
||||
public var modulesToListenFor: [String]
|
||||
private var observingForResponses: NSObjectProtocol?
|
||||
@ -75,7 +77,7 @@ public class ReplaceableMoleculeBehavior: PageMoleculeTransformationBehavior, Co
|
||||
return rootMolecule
|
||||
}
|
||||
debugLog("top replacing \(rootMolecule) with \(updatedMolecule)")
|
||||
logUpdated(molecule: updatedMolecule)
|
||||
logUpdated(moleculeId: updatedMolecule.id)
|
||||
changeList.append(updatedMolecule)
|
||||
return updatedMolecule
|
||||
}
|
||||
@ -92,7 +94,7 @@ public class ReplaceableMoleculeBehavior: PageMoleculeTransformationBehavior, Co
|
||||
return
|
||||
}
|
||||
debugLog("deep replacing \(replacedMolecule) with \(newMolecule)")
|
||||
logUpdated(molecule: newMolecule)
|
||||
logUpdated(moleculeId: newMolecule.id)
|
||||
changeList.append(newMolecule)
|
||||
}
|
||||
} catch {
|
||||
@ -111,15 +113,28 @@ public class ReplaceableMoleculeBehavior: PageMoleculeTransformationBehavior, Co
|
||||
return hasReplacement ? updatedRootMolecules : nil
|
||||
}
|
||||
|
||||
private func logUpdated(molecule: MoleculeModelProtocol) {
|
||||
guard let module: [AnyHashable: Any] = delegateObject?.moleculeDelegate?.getModuleWithName(molecule.id),
|
||||
private func logUpdated(moleculeId: String) {
|
||||
guard let module: [AnyHashable: Any] = delegateObject?.moleculeDelegate?.getModuleWithName(moleculeId),
|
||||
let viewController = delegateObject?.moleculeDelegate as? MVMCoreViewControllerProtocol else {
|
||||
debugLog("Missing the originating module \(molecule.id) creating this molecule!")
|
||||
debugLog("Missing the originating module \(moleculeId) creating this molecule!")
|
||||
return
|
||||
}
|
||||
previouslyReplacedIds.insert(moleculeId)
|
||||
MVMCoreUILoggingHandler.shared()?.defaultLogPageUpdate(forController: viewController, from: module)
|
||||
}
|
||||
|
||||
public func onPageShown(_ delegateObject: MVMCoreUIDelegateObject?) {
|
||||
guard hasPreviouslyBeenShown else {
|
||||
// Skip first replacement build handled in onPageNew. (Pulled and reported from cache.)
|
||||
hasPreviouslyBeenShown = true
|
||||
return
|
||||
}
|
||||
debugLog("Page reshown. Resend replaced molecule analytics for: \(previouslyReplacedIds)")
|
||||
previouslyReplacedIds.forEach { id in
|
||||
logUpdated(moleculeId: id)
|
||||
}
|
||||
}
|
||||
|
||||
deinit {
|
||||
debugLog("deinit")
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user