-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add API to decorate link with user/session info
- Loading branch information
Showing
5 changed files
with
127 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
Sources/Snowplow/Tracker/CrossDeviceParameterConfiguration.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved. | ||
// | ||
// This program is licensed to you under the Apache License Version 2.0, | ||
// and you may not use this file except in compliance with the Apache License | ||
// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the Apache License Version 2.0 is distributed on | ||
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
// express or implied. See the Apache License Version 2.0 for the specific | ||
// language governing permissions and limitations there under. | ||
|
||
import Foundation | ||
|
||
public class CrossDeviceParameterConfiguration : NSObject { | ||
var sessionId: Bool | ||
var subjectUserId: Bool | ||
var sourceId: Bool | ||
var sourcePlatform: Bool | ||
var reason: String? | ||
|
||
init( | ||
sessionId: Bool = true, | ||
subjectUserId: Bool = false, | ||
sourceId: Bool = false, | ||
sourcePlatform: Bool = false, | ||
reason: String? = nil | ||
) { | ||
self.sessionId = sessionId | ||
self.subjectUserId = subjectUserId | ||
self.sourceId = sourceId | ||
self.sourcePlatform = sourcePlatform | ||
self.reason = reason | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) 2013-2023 Snowplow Analytics Ltd. All rights reserved. | ||
// | ||
// This program is licensed to you under the Apache License Version 2.0, | ||
// and you may not use this file except in compliance with the Apache License | ||
// Version 2.0. You may obtain a copy of the Apache License Version 2.0 at | ||
// http://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the Apache License Version 2.0 is distributed on | ||
// an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
// express or implied. See the Apache License Version 2.0 for the specific | ||
// language governing permissions and limitations there under. | ||
|
||
import XCTest | ||
@testable import SnowplowTracker | ||
|
||
class TestLinkDecorator : XCTest { | ||
|
||
func testTest() { | ||
let tracker = getTracker() | ||
|
||
let test = URL(string: "https://example.com")! | ||
let result = tracker.decorateLink(test) | ||
} | ||
|
||
func getTracker() -> TrackerController { | ||
let networkConnection = MockNetworkConnection(requestOption: .post, statusCode: 200) | ||
let emitterConfig = EmitterConfiguration() | ||
emitterConfig.eventStore = MockEventStore() | ||
emitterConfig.bufferOption = .single | ||
let networkConfig = NetworkConfiguration(networkConnection: networkConnection) | ||
|
||
return createTracker(networkConfig: networkConfig, emitterConfig: emitterConfig) | ||
} | ||
|
||
private func createTracker(networkConfig: NetworkConfiguration, emitterConfig: EmitterConfiguration) -> TrackerController { | ||
let trackerConfig = TrackerConfiguration() | ||
trackerConfig.installAutotracking = false | ||
trackerConfig.screenViewAutotracking = false | ||
trackerConfig.lifecycleAutotracking = false | ||
let namespace = "testEmitter" + String(describing: Int.random(in: 0..<100)) | ||
return Snowplow.createTracker(namespace: namespace, | ||
network: networkConfig, | ||
configurations: [trackerConfig, emitterConfig])! | ||
} | ||
} |