Skip to content

Commit

Permalink
[MOBILE-12406] Release 0.7.2, filtering empty events (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
bnickel authored Oct 8, 2024
1 parent 79bac91 commit c4a7608
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

## [0.7.2]

### Fixed

- Zero length events (`Heap.shared.track("")`) are no longer uploaded to the server, where they were
being rejected.

## [0.7.1]

### Added
Expand Down Expand Up @@ -198,7 +205,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support for manual capture within WKWebView.
- Support for platforms targeting Swift: macOS, watchOS, iOS, iPadOS, tvOS.

[Unreleased]: https://github.com/heap/heap-swift-core-sdk/compare/0.7.1...main
[Unreleased]: https://github.com/heap/heap-swift-core-sdk/compare/0.7.2...main
[0.7.2]: https://github.com/heap/heap-swift-core-sdk/compare/0.7.1...0.7.2
[0.7.1]: https://github.com/heap/heap-swift-core-sdk/compare/0.7.0...0.7.1
[0.7.0]: https://github.com/heap/heap-swift-core-sdk/compare/0.6.1...0.7.0
[0.6.1]: https://github.com/heap/heap-swift-core-sdk/compare/0.6.0...0.6.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,13 @@ extension EventConsumer {

func track(_ event: String, properties: [String: HeapPropertyValue] = [:], timestamp: Date = Date(), sourceInfo: SourceInfo? = nil, pageview: Pageview? = nil) {

if event.utf16.count == 0 {
HeapLogger.shared.warn("Event without a name will not be logged.")
return
}

if event.utf16.count > 512 {
HeapLogger.shared.warn("Event \(event) was not logged because its name exceeds 512 UTF-16 code units")
HeapLogger.shared.warn("Event \(event) was not logged because its name exceeds 512 UTF-16 code units.")
return
}

Expand Down
2 changes: 1 addition & 1 deletion Development/Sources/HeapSwiftCore/Version.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct Version {
static let minor = 7

/// Revision number.
static let revision = 1
static let revision = 2

/// Optional pre-release version
static let prerelease: String? = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,18 @@ final class EventConsumer_TrackSpec: HeapSpec {
try dataStore.assertExactPendingMessagesCountInOnlySession(for: user, count: 4)
}

it("does not send event where the event name is above the maximum length") {
it("does not send an event where the event name is above the maximum length") {
let name = String(repeating: "", count: 513)
consumer.track(name)
let user = try dataStore.assertOnlyOneUserToUpload()
expect(user.sessionIds).to(beEmpty(), description: "The event should have been suppressed, so the first session should not have started.")
}

it("does not send an event where the event name is empty") {
consumer.track("")
let user = try dataStore.assertOnlyOneUserToUpload()
expect(user.sessionIds).to(beEmpty(), description: "The event should have been suppressed, so the first session should not have started.")
}

it("records events sequentially on the main thread") {

Expand Down
2 changes: 1 addition & 1 deletion HeapSwiftCore.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'HeapSwiftCore'
s.version = '0.7.1'
s.version = '0.7.2'
s.license = { :type => 'MIT' }
s.summary = 'The core Heap library used for apps on Apple platforms.'
s.homepage = 'https://heap.io'
Expand Down

0 comments on commit c4a7608

Please sign in to comment.