Skip to content

Commit e832cde

Browse files
committed
Merge remote-tracking branch 'origin/master' into mokagio/swiftlint-autocorrect-format
2 parents 1c81cc7 + 9ec7343 commit e832cde

File tree

4 files changed

+47
-20
lines changed

4 files changed

+47
-20
lines changed

CHANGES.rst

+21
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,27 @@ _None_
1212
Bugfixes
1313
--------
1414

15+
_None_
16+
17+
0.2.5 (1-08-2025)
18+
19+
Changes
20+
-------
21+
22+
* The logs show more information #93
23+
24+
0.2.4 (1-28-2024)
25+
26+
Changes
27+
-------
28+
29+
* Implementation cleanups: Remove unnecessary Optionals, IUOs, force casts and the like [#88, #89]
30+
31+
0.2.3 (1-28-2024)
32+
33+
Bugfixes
34+
--------
35+
1536
* Prevented a crash in the rare occurrence when a `VideoManager` attempted to send an heartbeat for a video it had not tracked [#83]
1637

1738
0.2.2 (5-10-2023)

Demo/ParselyDemo/FirstViewController.swift

+9-5
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,31 @@ class FirstViewController: UIViewController {
66
let delegate = UIApplication.shared.delegate as! AppDelegate
77

88
@IBAction func didTouchButton(_ sender: Any) {
9-
os_log("didTouchButton", log: OSLog.default, type: .debug)
9+
log("didTouchButton")
1010
let demoMetas = ParselyMetadata(authors: ["Yogi Berr"])
1111
delegate.parsely.trackPageView(url: "http://parsely.com/path/cool-blog-post/1?qsarg=nawp&anotherone=yup", metadata: demoMetas, extraData: ["product-id": "12345"], siteId: "subdomain.parsely-test.com")
1212
}
1313

1414
@IBAction func didStartEngagement(_ sender: Any) {
15-
os_log("didStartEngagement", log: OSLog.default, type: .debug)
15+
log("didStartEngagement")
1616
delegate.parsely.startEngagement(url: "http://parsely.com/very-not-real", urlref: "http://parsely.com/not-real", extraData: ["product-id": "12345"], siteId: "engaged.parsely-test.com")
1717
}
1818

1919
@IBAction func didStopEngagement(_ sender: Any) {
20-
os_log("didStopEngagement", log: OSLog.default, type: .debug)
20+
log("didStopEngagement")
2121
delegate.parsely.stopEngagement()
2222
}
2323
@IBAction func didStartVideo(_ sender: Any) {
24-
os_log("didStartVideo", log: OSLog.default, type: .debug)
24+
log("didStartVideo")
2525
let demoMetas = ParselyMetadata(authors: ["Yogi Berr"], duration: TimeInterval(10))
2626
delegate.parsely.trackPlay(url: "http://parsely.com/path/cool-blog-post/1?qsarg=nawp&anotherone=yup", urlref: "not-a-real-urlref", videoID: "videoOne", duration: TimeInterval(6000), metadata: demoMetas, extraData: ["product-id": "12345", "ts": "should be overwritten"])
2727
}
2828
@IBAction func didPauseVideo(_ sender: Any) {
29-
os_log("didStopVideo", log: OSLog.default, type: .debug)
29+
log("didStopVideo")
3030
delegate.parsely.trackPause()
3131
}
32+
33+
private func log(_ message: String) {
34+
os_log("[Parsely Demo App] %@", log: OSLog.default, type: .debug, message)
35+
}
3236
}

Sources/Sampler.swift

+14-4
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,28 @@ class Sampler {
146146
os_log("No accumulator found for %s, skipping sendHeartbeat", log: OSLog.tracker, type: .debug, key)
147147
return
148148
}
149+
let now = Date()
149150
let incSecs: TimeInterval = trackedData.accumulatedTime
150151
if incSecs > 0 {
151-
os_log("Sending heartbeat for %s", log: OSLog.tracker, type: .debug, key)
152+
os_log(
153+
"Sending heartbeat for %s. Timestamp: %s.",
154+
log: OSLog.tracker,
155+
type: .debug,
156+
key,
157+
now.description
158+
)
152159
heartbeatFn(data: trackedData, enableHeartbeats: true)
153160
}
154161
trackedData.accumulatedTime = 0
155-
let totalTrackedTime: TimeInterval = Date().timeIntervalSince(trackedData.firstSampleTime!)
156-
trackedData.heartbeatTimeout = self.getHeartbeatInterval(
162+
let totalTrackedTime: TimeInterval = now.timeIntervalSince(trackedData.firstSampleTime!)
163+
trackedData.heartbeatTimeout = getHeartbeatInterval(
157164
existingTimeout: trackedData.heartbeatTimeout!,
158-
totalTrackedTime: totalTrackedTime)
165+
totalTrackedTime: totalTrackedTime
166+
)
159167
updateAccumulator(acc: trackedData)
160168
heartbeatInterval = trackedData.heartbeatTimeout!
169+
170+
os_log("Send heartbeat completed. New heartbeat timeout %.2f seconds.", trackedData.heartbeatTimeout!)
161171
}
162172

163173
@objc internal func sendHeartbeats() -> Void {

Sources/Track.swift

+3-11
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,9 @@ class Track {
8282
}
8383
}
8484

85-
/// Utitlity to log sending event with a dump of the event.
85+
/// Utility to log sending event with a dump of the event.
8686
private func os_log_sending_event(_ event: Event, log: OSLog = .tracker, type: OSLogType = .debug) {
87-
var eventDump = DumpOutput()
87+
var eventDump = ""
8888
dump(event.toDict(), to: &eventDump)
89-
os_log("Sending an event from Track:\n%@", log: log, type: type, eventDump.content)
90-
}
91-
92-
private struct DumpOutput: TextOutputStream {
93-
private(set) var content = ""
94-
95-
mutating func write(_ string: String) {
96-
content.append(string)
97-
}
89+
os_log("Sending an event from Track:\n%@", log: log, type: type, eventDump)
9890
}

0 commit comments

Comments
 (0)