Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation issues & cleanup #29

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/segmentio/analytics-swift",
"state" : {
"revision" : "7eeb2abf8452153af056baae5369679589f10936",
"version" : "1.5.9"
"revision" : "338be8f55c83309f10d2cfd0193505117b4ab2d5",
"version" : "1.6.0"
}
},
{
"identity" : "jsonsafeencoder-swift",
"identity" : "jsonsafeencoding-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/segmentio/jsonsafeencoder-swift.git",
"location" : "https://github.com/segmentio/jsonsafeencoding-swift.git",
"state" : {
"revision" : "8b70dc8c01b7b041912e30e29d2b488a43f782ac",
"version" : "1.0.1"
"revision" : "af6a8b360984085e36c6341b21ecb35c12f47ebd",
"version" : "2.0.0"
}
},
{
Expand Down
12 changes: 6 additions & 6 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/segmentio/analytics-swift.git",
"state" : {
"revision" : "7eeb2abf8452153af056baae5369679589f10936",
"version" : "1.5.9"
"revision" : "338be8f55c83309f10d2cfd0193505117b4ab2d5",
"version" : "1.6.0"
}
},
{
"identity" : "jsonsafeencoder-swift",
"identity" : "jsonsafeencoding-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/segmentio/jsonsafeencoder-swift.git",
"location" : "https://github.com/segmentio/jsonsafeencoding-swift.git",
"state" : {
"revision" : "8b70dc8c01b7b041912e30e29d2b488a43f782ac",
"version" : "1.0.1"
"revision" : "af6a8b360984085e36c6341b21ecb35c12f47ebd",
"version" : "2.0.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let package = Package(
dependencies: [
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/segmentio/analytics-swift.git", from: "1.5.9")
.package(url: "https://github.com/segmentio/analytics-swift.git", from: "1.6.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand Down
25 changes: 13 additions & 12 deletions Sources/SegmentAmplitude/AmplitudeSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,23 @@ public class AmplitudeSession: EventPlugin, iOSLifecycle {
private var storage = Storage()

internal var eventSessionID: Int64 = -1
@Atomic internal var sessionID: Int64 {
@Atomic internal var sessionID: Int64 = -1 {
didSet {
storage.write(key: Storage.Constants.previousSessionID, value: sessionID)
debugLog("sessionID set to: \(sessionID)")
}
}

@Atomic internal var lastEventTime: Int64 {
@Atomic internal var lastEventTime: Int64 = -1 {
didSet {
storage.write(key: Storage.Constants.lastEventTime, value: lastEventTime)
}
}

public init() {
self.sessionID = storage.read(key: Storage.Constants.previousSessionID) ?? -1
self.lastEventTime = storage.read(key: Storage.Constants.lastEventTime) ?? -1
_sessionID.set(storage.read(key: Storage.Constants.previousSessionID) ?? -1)
_lastEventTime.set(storage.read(key: Storage.Constants.lastEventTime) ?? -1)

debugLog("startup sessionID = \(sessionID)")
}

Expand All @@ -81,9 +82,9 @@ public class AmplitudeSession: EventPlugin, iOSLifecycle {
if type != .initial { return }

if settings.hasIntegrationSettings(key: key) {
active = true
_active.set(true)
} else {
active = false
_active.set(false)
}
}

Expand Down Expand Up @@ -118,7 +119,7 @@ public class AmplitudeSession: EventPlugin, iOSLifecycle {

// if it's a start event, set a new sessionID
if eventName == Constants.ampSessionStartEvent {
resetPending = false
_resetPending.set(false)
eventSessionID = sessionID
debugLog("NewSession = \(eventSessionID)")
}
Expand All @@ -137,7 +138,7 @@ public class AmplitudeSession: EventPlugin, iOSLifecycle {
workingEvent = trackEvent as? T
}

lastEventTime = newTimestamp()
_lastEventTime.set(newTimestamp())
return workingEvent
}

Expand All @@ -152,7 +153,7 @@ public class AmplitudeSession: EventPlugin, iOSLifecycle {

public func applicationWillResignActive(application: UIApplication?) {
debugLog("Background: \(eventSessionID)")
lastEventTime = newTimestamp()
_lastEventTime.set(newTimestamp())
}
}

Expand Down Expand Up @@ -192,8 +193,8 @@ extension AmplitudeSession {

private func startNewSession() {
if resetPending { return }
resetPending = true
sessionID = newTimestamp()
_resetPending.set(true)
_sessionID.set(newTimestamp())
if eventSessionID == -1 {
// we only wanna do this if we had nothing before, so each
// event actually HAS a sessionID of some kind associated.
Expand All @@ -217,7 +218,7 @@ extension AmplitudeSession {
}

// we'll consider this our new lastEventTime
lastEventTime = timestamp
_lastEventTime.set(timestamp)
// end previous session
endSession()
// start new session
Expand Down
108 changes: 0 additions & 108 deletions Sources/SegmentAmplitude/Session.swift

This file was deleted.

Loading