Skip to content

Commit dc111f3

Browse files
Now only defined key can be transfered via internal meta
1 parent f11da68 commit dc111f3

File tree

4 files changed

+25
-12
lines changed

4 files changed

+25
-12
lines changed

Sources/InstanaAgent/Beacons/Beacons Types/ViewChange.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ class ViewChange: Beacon {
88
var accessibilityLabel: String?
99
var navigationItemTitle: String?
1010
var className: String?
11-
var viewInternalMetaMap: [String: String]
11+
var viewInternalCPMetaMap: [String: String]
1212

1313
init(timestamp: Instana.Types.Milliseconds = Date().millisecondsSince1970,
1414
viewName: String? = nil, accessibilityLabel: String? = nil,
1515
navigationItemTitle: String? = nil,
16-
className: String? = nil, isSwiftUI: Bool = false, viewInternalMetaMap: [String: String] = [:]) {
17-
self.viewInternalMetaMap = [:]
16+
className: String? = nil, isSwiftUI: Bool = false, viewInternalCPMetaMap: [String: String] = [:]) {
17+
self.viewInternalCPMetaMap = [:]
1818
var canonicalName: String? = viewName
1919
var prefix = ""
2020
if accessibilityLabel != nil, !accessibilityLabel!.isEmpty {
@@ -34,8 +34,8 @@ class ViewChange: Beacon {
3434
canonicalName = prefix.isEmpty ? "@\(self.className!)" : prefix
3535
}
3636
}
37-
for (key, value) in viewInternalMetaMap {
38-
self.viewInternalMetaMap[key] = value
37+
for (key, value) in viewInternalCPMetaMap {
38+
self.viewInternalCPMetaMap[key] = value
3939
}
4040
super.init(timestamp: timestamp, viewName: canonicalName)
4141
}

Sources/InstanaAgent/Beacons/CoreBeacon/CoreBeaconFactory.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ extension CoreBeacon {
109109
if beacon.className != nil {
110110
im![internalMetaDataKeyView_className] = beacon.className!
111111
}
112-
if !beacon.viewInternalMetaMap.isEmpty {
113-
for (key, value) in beacon.viewInternalMetaMap {
112+
if !beacon.viewInternalCPMetaMap.isEmpty {
113+
for (key, value) in beacon.viewInternalCPMetaMap {
114114
im![key] = value
115115
}
116116
}

Sources/InstanaAgent/Configuration/Defines.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ let internalMetaDataKeyView_accbltyLabel = "view.accLabel" // accessibilityLabel
5656
let internalMetaDataKeyView_navItemTitle = "view.navItemTitle" // navigationItemTitle
5757
let internalMetaDataKeyView_className = "view.clsName" // className
5858

59+
let internalMetaFlutterKeys = ["settings.route.name", "widget.name", "child.widget.name", "child.widget.title", "go.router.path"] // keys given from flutter agent
60+
5961
///
6062
/// Mobile Features
6163
///

Sources/InstanaAgent/Instana.swift

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -414,22 +414,33 @@ import Foundation
414414

415415
/// Set the screen name and its meta details from crossplatfrom services (Flutter & React Native agents)
416416
///
417+
/// ONLY TO BE USED BY FLUTTER/REACT NATIVE AGENTS!
418+
///
417419
/// This is exposed for internal use, for the communication between the instana agents, not to be consumed by developers
418420
/// Call this method from instana cross platform agents when need to provide auto capture of screen names and its meta details
419421
/// - Parameters:
420422
/// - name: The screen name identified from cross platform agents
421-
/// - viewInternalMetaMap: Dictionary of keys and values of meta details from cross platform agents
423+
/// - viewInternalCPMetaMap: Dictionary of keys and values of meta details from CROSS PLATFORM agents
422424
@objc
423-
public static func setViewMetaCPInternal(name: String, viewInternalMetaMap: [String: String] = [:]) {
424-
Instana.current?.setViewInternal(name: name, viewInternalMetaMap: viewInternalMetaMap)
425+
public static func setViewMetaCPInternal(name: String, viewInternalCPMetaMap: [String: String] = [:]) {
426+
var isAllKeyValid = true
427+
for key in viewInternalCPMetaMap.keys {
428+
if !internalMetaFlutterKeys.contains(key) {
429+
isAllKeyValid = false
430+
break
431+
}
432+
}
433+
if isAllKeyValid {
434+
Instana.current?.setViewInternal(name: name, viewInternalCPMetaMap: viewInternalCPMetaMap)
435+
}
425436
}
426437

427438
public func setViewInternal(name: String?,
428439
accessibilityLabel: String? = nil,
429440
navigationItemTitle: String? = nil,
430441
className: String? = nil,
431442
isSwiftUI: Bool = false,
432-
viewInternalMetaMap: [String: String] = [:]) {
443+
viewInternalCPMetaMap: [String: String] = [:]) {
433444
guard let propertyHandler = Instana.current?.session.propertyHandler else { return }
434445
let isIdentical = propertyHandler.properties.view?.isSame(name: name,
435446
accessibilityLabel: accessibilityLabel,
@@ -441,7 +452,7 @@ import Foundation
441452
navigationItemTitle: navigationItemTitle,
442453
className: className,
443454
isSwiftUI: isSwiftUI,
444-
viewInternalMetaMap: viewInternalMetaMap)
455+
viewInternalCPMetaMap: viewInternalCPMetaMap)
445456
propertyHandler.properties.view = view
446457

447458
guard view.viewName != nil else { return }

0 commit comments

Comments
 (0)