Skip to content

Commit 22532b4

Browse files
Hongyan JiangGitHub Enterprise
authored andcommitted
add to mobile feature list if autoCaptureScreenNames is enabled (#45)
1 parent a9cb08b commit 22532b4

File tree

9 files changed

+57
-17
lines changed

9 files changed

+57
-17
lines changed

Changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 1.7.1
4+
- add to mobile feature list if `autoCaptureScreenNames` is enabled
5+
36
## 1.7.0
47
- introduce `autoCaptureScreenNames` to auto capture view names and `debugAllScreenNames` to debug all screen names
58

InstanaAgent.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
1616
#
1717

1818
s.name = "InstanaAgent"
19-
s.version = "1.7.0"
19+
s.version = "1.7.1"
2020
s.summary = "Instana iOS agent."
2121

2222
# This description is used to generate tags and improve search results.

Sources/InstanaAgent/Beacons/CoreBeacon/CoreBeaconFactory.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@ class CoreBeaconFactory {
88
private let session: InstanaSession
99
private var conf: InstanaConfiguration { session.configuration }
1010
private var properties: InstanaProperties { session.propertyHandler.properties }
11-
private var mobileFeatures: String? {
12-
if conf.monitorTypes.contains(.crash) { return "c" } else { return nil }
11+
internal var mobileFeatures: String? {
12+
var array: [String] = []
13+
if conf.monitorTypes.contains(.crash) {
14+
array.append(mobileFeatureCrash)
15+
}
16+
if session.autoCaptureScreenNames {
17+
array.append(mobileFeatureAutoScreenNameCapture)
18+
}
19+
return array.isEmpty ? nil : array.joined(separator: ",")
1320
}
1421

1522
init(_ session: InstanaSession) {

Sources/InstanaAgent/Configuration/Defines.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,9 @@ let maxSecondsToKeepCrashLog = (maxDaysToKeepCrashLog * 60 * 60 * 24)
5555
let internalMetaDataKeyView_accbltyLabel = "view.accLabel" // accessibilityLabel
5656
let internalMetaDataKeyView_navItemTitle = "view.navItemTitle" // navigationItemTitle
5757
let internalMetaDataKeyView_className = "view.clsName" // className
58+
59+
///
60+
/// Mobile Features
61+
///
62+
let mobileFeatureCrash = "c"
63+
let mobileFeatureAutoScreenNameCapture = "sn"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
struct VersionConfig {
2-
static let agentVersion = "1.7.0"
2+
static let agentVersion = "1.7.1"
33
}

Tests/InstanaAgentTests/Beacons/CoreBeacon/CoreBeaconFactoryTests.swift

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,30 @@ class CoreBeaconFactoryTests: InstanaTestCase {
2222
}
2323
}
2424

25+
func test_mobileFeatures_autoCaptureScreenNames_enabled() {
26+
// Given
27+
let mfSession = InstanaSession(configuration: config, propertyHandler: InstanaPropertyHandler(),
28+
collectionEnabled: true, autoCaptureScreenNames: true)
29+
30+
// When
31+
let mfs = CoreBeaconFactory(mfSession)
32+
33+
// Then
34+
AssertEqualAndNotNil(mfs.mobileFeatures!, "\(mobileFeatureCrash),\(mobileFeatureAutoScreenNameCapture)")
35+
}
36+
37+
func test_mobileFeatures_autoCaptureScreenNames_disabled() {
38+
// Given
39+
let mfSession = InstanaSession(configuration: config, propertyHandler: InstanaPropertyHandler(),
40+
collectionEnabled: true)
41+
42+
// When
43+
let mfs = CoreBeaconFactory(mfSession)
44+
45+
// Then
46+
AssertEqualAndNotNil(mfs.mobileFeatures!, "\(mobileFeatureCrash)")
47+
}
48+
2549
func test_map_beacon() {
2650
// Given
2751
let timestamp = Date().millisecondsSince1970
@@ -41,7 +65,7 @@ class CoreBeaconFactoryTests: InstanaTestCase {
4165
AssertEqualAndNotNil(sut.k, key)
4266
AssertEqualAndNotNil(sut.ti, "\(beacon.timestamp)")
4367
AssertEqualAndNotNil(sut.bid, "\(beacon.id)")
44-
AssertEqualAndNotNil(sut.uf, "c")
68+
AssertEqualAndNotNil(sut.uf, mobileFeatureCrash)
4569
AssertEqualAndNotNil(sut.bi, "\(InstanaSystemUtils.applicationBundleIdentifier)")
4670
AssertEqualAndNotNil(sut.ul, "en")
4771
AssertEqualAndNotNil(sut.agv, InstanaSystemUtils.agentVersion)
@@ -144,7 +168,7 @@ class CoreBeaconFactoryTests: InstanaTestCase {
144168
AssertEqualAndNotNil(sut.sid, "70BED140-D947-4EC7-ADE9-8F1F7C6955D0")
145169
AssertEqualAndNotNil(sut.usi, "70BED140-D947-4EC7-ADE9-8F1F7C6955D0")
146170
AssertEqualAndNotNil(sut.ti, "1578569955952")
147-
AssertEqualAndNotNil(sut.uf, "c")
171+
AssertEqualAndNotNil(sut.uf, mobileFeatureCrash)
148172
AssertEqualAndNotNil(sut.ul, "en")
149173
AssertEqualAndNotNil(sut.vh, "1792")
150174
AssertEqualAndNotNil(sut.vw, "828")

Tests/InstanaAgentTests/Beacons/CoreBeacon/CoreBeaconTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class CoreBeaconTests: InstanaTestCase {
3333
sid: sessionID,
3434
usi: session.usi,
3535
id: beaconID,
36-
mobileFeatures: "c",
36+
mobileFeatures: mobileFeatureCrash,
3737
hybridAgentId: nil,
3838
hybridAgentVersion: nil)
3939
coreBeacon.append(props)
@@ -43,7 +43,7 @@ class CoreBeaconTests: InstanaTestCase {
4343
sid: sessionID,
4444
usi: session.usi,
4545
id: beaconID,
46-
mobileFeatures: "c",
46+
mobileFeatures: mobileFeatureCrash,
4747
hybridAgentId: "f",
4848
hybridAgentVersion: "3.0.6",
4949
connection: .wifi,
@@ -62,7 +62,7 @@ class CoreBeaconTests: InstanaTestCase {
6262
XCTAssertNotNil(sut.usi)
6363
AssertEqualAndNotNil(sut.bid, beaconID)
6464
AssertEqualAndNotNil(sut.bi, InstanaSystemUtils.applicationBundleIdentifier)
65-
AssertEqualAndNotNil(sut.uf, "c")
65+
AssertEqualAndNotNil(sut.uf, mobileFeatureCrash)
6666
AssertEqualAndNotNil(sut.ul, Locale.current.languageCode)
6767
AssertEqualAndNotNil(sut.ab, InstanaSystemUtils.applicationBuildNumber)
6868
AssertEqualAndNotNil(sut.av, InstanaSystemUtils.applicationVersion)
@@ -153,7 +153,7 @@ class CoreBeaconTests: InstanaTestCase {
153153
sid: sessionID,
154154
usi: sessionUsi.usi,
155155
id: beaconID,
156-
mobileFeatures: "c",
156+
mobileFeatures: mobileFeatureCrash,
157157
hybridAgentId: "nil",
158158
hybridAgentVersion: nil,
159159
connection: .wifi,

Tests/InstanaAgentTests/Configuration/InstanaSystemUtilsTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class InstanaSystemUtilsTests: InstanaTestCase {
55

66
func test_AgentVersion() {
77
// Then
8-
AssertTrue(InstanaSystemUtils.agentVersion == "1.7.0")
8+
AssertTrue(InstanaSystemUtils.agentVersion == "1.7.1")
99
}
1010

1111
func test_systemVersion() {

Tests/InstanaAgentTests/Utils_Tests/InstanaPersistableQueueTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ class InstanaPersistableQueueTests: InstanaTestCase {
4949
let sessionID = UUID()
5050
let id = Beacon.generateUniqueIdImpl()
5151
let beacon1 = CoreBeacon.createDefault(viewName: "View_1", key: "Key_1", timestamp: 0,
52-
sid: sessionID, usi: session.usi, id: id, mobileFeatures: "c",
52+
sid: sessionID, usi: session.usi, id: id, mobileFeatures: mobileFeatureCrash,
5353
hybridAgentId: "f", hybridAgentVersion: "3.0.6")
5454
let beacon2 = CoreBeacon.createDefault(viewName: "View_2", key: "Key_2", timestamp: 0,
55-
sid: sessionID, usi: session.usi, id: id, mobileFeatures: "c",
55+
sid: sessionID, usi: session.usi, id: id, mobileFeatures: mobileFeatureCrash,
5656
hybridAgentId: "r", hybridAgentVersion: "2.0.3")
5757
let queueHandler = InstanaPersistableQueue<CoreBeacon>(identifier: "queue", maxItems: 100)
5858
queueHandler.removeAll()
@@ -74,15 +74,15 @@ class InstanaPersistableQueueTests: InstanaTestCase {
7474
func test_persisted_beacons_plus_new() {
7575
// Given
7676
let oldBeacons = [CoreBeacon.createDefault(viewName: "V", key: "K", timestamp: 1, sid: UUID(),
77-
usi: session.usi, id: Beacon.generateUniqueIdImpl(), mobileFeatures: "c",
77+
usi: session.usi, id: Beacon.generateUniqueIdImpl(), mobileFeatures: mobileFeatureCrash,
7878
hybridAgentId: "f", hybridAgentVersion: "3.0.6"),]
7979
var queueHandler = InstanaPersistableQueue<CoreBeacon>(identifier: "queue", maxItems: 100)
8080
queueHandler.removeAll()
8181
queueHandler.add(oldBeacons) {_ in}
8282

8383
// When
8484
let newBeacons = [CoreBeacon.createDefault(viewName: "V", key: "K", timestamp: 2, sid: UUID(),
85-
usi: session.usi, id: Beacon.generateUniqueIdImpl(), mobileFeatures: "c",
85+
usi: session.usi, id: Beacon.generateUniqueIdImpl(), mobileFeatures: mobileFeatureCrash,
8686
hybridAgentId: "f", hybridAgentVersion: "3.0.6")]
8787
queueHandler = InstanaPersistableQueue<CoreBeacon>(identifier: "queue", maxItems: 100)
8888
queueHandler.add(newBeacons) {result in
@@ -101,15 +101,15 @@ class InstanaPersistableQueueTests: InstanaTestCase {
101101
// Given
102102
let id = Beacon.generateUniqueIdImpl()
103103
let oldBeacons = [CoreBeacon.createDefault(viewName: "V", key: "K", timestamp: 1,
104-
sid: UUID(), usi: session.usi, id: id, mobileFeatures: "c",
104+
sid: UUID(), usi: session.usi, id: id, mobileFeatures: mobileFeatureCrash,
105105
hybridAgentId: "f", hybridAgentVersion: "3.0.6")]
106106
var queueHandler = InstanaPersistableQueue<CoreBeacon>(identifier: "queue", maxItems: 100)
107107
queueHandler.removeAll()
108108
queueHandler.add(oldBeacons) {_ in}
109109

110110
// When
111111
let newBeacon = CoreBeacon.createDefault(viewName: "V", key: "K", timestamp: 2,
112-
sid: UUID(), usi: session.usi, id: id, mobileFeatures: "c",
112+
sid: UUID(), usi: session.usi, id: id, mobileFeatures: mobileFeatureCrash,
113113
hybridAgentId: "r", hybridAgentVersion: "2.0.3")
114114
queueHandler = InstanaPersistableQueue<CoreBeacon>(identifier: "queue", maxItems: 100)
115115
queueHandler.add(newBeacon) {result in

0 commit comments

Comments
 (0)