Skip to content

Commit 183aa60

Browse files
authored
[HEAP-44118] Expose track with SourceInfo to Objective-C (#114)
1 parent 28acf74 commit 183aa60

File tree

5 files changed

+16
-24
lines changed

5 files changed

+16
-24
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
1414
## [Unreleased]
1515

16+
### Added
17+
18+
- Exposed `+[HeapSourceInfo sourceInfoWithName:version:platform:properties:]` and
19+
`-[Heap track:properties:sourceInfo:]` to Objective-C.
20+
1621
## [0.3.0]
1722

1823
### Added
@@ -22,7 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2227

2328
### Changed
2429

25-
- Changed process to retrieve iOS device model. 'sysctlbyname' is now used to retrieve the
30+
- Changed process to retrieve iOS device model. `sysctlbyname` is now used to retrieve the
2631
detailed hardware identifier (e.g., "iPhone10,3"). This results in more specific
2732
model identification than the generic `UIDevice.model` approach which is now used
2833
as a fallback.

Development/Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ let package = Package(
3434
]),
3535
.binaryTarget(
3636
name: "HeapSwiftCoreInterfaces",
37-
url: "https://cdn.heapanalytics.com/ios/heap-swift-core-interfaces-0.1.2.zip", // END HeapSwiftCoreInterfaces URL
38-
checksum: "6ed9d3af50cfe083f24fec6357fb26fc023d0caf5bbf9629a735c58da5ffe8b1" // END HeapSwiftCoreInterfaces checksum
37+
url: "https://cdn.heapanalytics.com/ios/heap-swift-core-interfaces-0.3.0.zip", // END HeapSwiftCoreInterfaces URL
38+
checksum: "df611a027a390100799a73c0bff26d6b6b70da72c1f58276120819b582924f36" // END HeapSwiftCoreInterfaces checksum
3939
),
4040
.target(
4141
name: "HeapSwiftCoreTestSupport",

Development/Sources/HeapSwiftCore/Public SDK/Heap+ObjcRefinements.swift

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
11
import Foundation
22
import HeapSwiftCoreInterfaces
33

4-
@objc
5-
public protocol HeapObjcPropertyValue: NSObjectProtocol {
6-
var heapValue: String { get }
7-
}
8-
9-
extension NSString: HeapObjcPropertyValue, HeapPropertyValue {
10-
public var heapValue: String { return self as String }
11-
}
12-
13-
extension NSNumber: HeapObjcPropertyValue, HeapPropertyValue {
14-
public var heapValue: String {
15-
if CFGetTypeID(self) == CFBooleanGetTypeID() {
16-
return self.boolValue ? "true" : "false"
17-
}
18-
return self.stringValue
19-
}
20-
}
21-
224
public extension Heap {
235

246
@objc(startRecording:)
@@ -36,6 +18,11 @@ public extension Heap {
3618
track(event, properties: properties.mapValues(\.heapValue))
3719
}
3820

21+
@objc(track:properties:sourceInfo:)
22+
func __track(_ event: String, properties: [String: HeapObjcPropertyValue], sourceInfo: SourceInfo?) {
23+
track(event, properties: properties.mapValues(\.heapValue), sourceInfo: sourceInfo)
24+
}
25+
3926
@objc(addUserProperties:)
4027
func __addUserProperties(_ properties: [String: HeapObjcPropertyValue]) {
4128
addUserProperties(properties.mapValues(\.heapValue))

HeapSwiftCore.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Pod::Spec.new do |s|
1818
s.source_files = 'Development/Sources/HeapSwiftCore/**/*.swift'
1919

2020
s.dependency 'SwiftProtobuf', '~> 1.6'
21-
s.dependency 'HeapSwiftCoreInterfaces', '0.1.2'
21+
s.dependency 'HeapSwiftCoreInterfaces', '0.3.0'
2222

2323
s.swift_versions = ['5.0']
2424
end

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ let package = Package(
3232
path: "Development/Sources/HeapSwiftCore"),
3333
.binaryTarget(
3434
name: "HeapSwiftCoreInterfaces",
35-
url: "https://cdn.heapanalytics.com/ios/heap-swift-core-interfaces-0.1.2.zip", // END HeapSwiftCoreInterfaces URL
36-
checksum: "6ed9d3af50cfe083f24fec6357fb26fc023d0caf5bbf9629a735c58da5ffe8b1" // END HeapSwiftCoreInterfaces checksum
35+
url: "https://cdn.heapanalytics.com/ios/heap-swift-core-interfaces-0.3.0.zip", // END HeapSwiftCoreInterfaces URL
36+
checksum: "df611a027a390100799a73c0bff26d6b6b70da72c1f58276120819b582924f36" // END HeapSwiftCoreInterfaces checksum
3737
)
3838
]
3939
)

0 commit comments

Comments
 (0)