Skip to content

Commit

Permalink
Testing updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bsneed committed Oct 30, 2023
1 parent 3b538e2 commit 6dde3bf
Show file tree
Hide file tree
Showing 18 changed files with 995 additions and 156 deletions.
34 changes: 15 additions & 19 deletions Example/BasicExample/BasicExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
objects = {

/* Begin PBXBuildFile section */
4648A3DA2AC62135000D4775 /* SegmentConsent in Frameworks */ = {isa = PBXBuildFile; productRef = 4648A3D92AC62135000D4775 /* SegmentConsent */; };
4648A3DD2AC62195000D4775 /* SegmentConsentOneTrust in Frameworks */ = {isa = PBXBuildFile; productRef = 4648A3DC2AC62195000D4775 /* SegmentConsentOneTrust */; };
4648A3E32ACCE39B000D4775 /* DummyDestination.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4648A3E22ACCE39B000D4775 /* DummyDestination.swift */; };
46797C6F2AD71FC400A0C863 /* SegmentConsent in Frameworks */ = {isa = PBXBuildFile; productRef = 46797C6E2AD71FC400A0C863 /* SegmentConsent */; };
46EDC6F627C6B8D100B870D7 /* BasicExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46EDC6F527C6B8D100B870D7 /* BasicExampleApp.swift */; };
46EDC6F827C6B8D100B870D7 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46EDC6F727C6B8D100B870D7 /* ContentView.swift */; };
46EDC6FA27C6B8D200B870D7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 46EDC6F927C6B8D200B870D7 /* Assets.xcassets */; };
Expand Down Expand Up @@ -38,6 +39,7 @@

/* Begin PBXFileReference section */
4648A3DE2AC75809000D4775 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
4648A3E22ACCE39B000D4775 /* DummyDestination.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DummyDestination.swift; sourceTree = "<group>"; };
46EDC6F227C6B8D100B870D7 /* BasicExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BasicExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
46EDC6F527C6B8D100B870D7 /* BasicExampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BasicExampleApp.swift; sourceTree = "<group>"; };
46EDC6F727C6B8D100B870D7 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
Expand All @@ -55,9 +57,9 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
46797C6F2AD71FC400A0C863 /* SegmentConsent in Frameworks */,
4648A3DD2AC62195000D4775 /* SegmentConsentOneTrust in Frameworks */,
46EDC72127C6B92C00B870D7 /* Segment in Frameworks */,
4648A3DA2AC62135000D4775 /* SegmentConsent in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -111,6 +113,7 @@
children = (
4648A3DE2AC75809000D4775 /* Info.plist */,
46EDC6F527C6B8D100B870D7 /* BasicExampleApp.swift */,
4648A3E22ACCE39B000D4775 /* DummyDestination.swift */,
46EDC6F727C6B8D100B870D7 /* ContentView.swift */,
46EDC6F927C6B8D200B870D7 /* Assets.xcassets */,
46EDC6FB27C6B8D200B870D7 /* Preview Content */,
Expand Down Expand Up @@ -161,8 +164,8 @@
name = BasicExample;
packageProductDependencies = (
46EDC72027C6B92C00B870D7 /* Segment */,
4648A3D92AC62135000D4775 /* SegmentConsent */,
4648A3DC2AC62195000D4775 /* SegmentConsentOneTrust */,
46797C6E2AD71FC400A0C863 /* SegmentConsent */,
);
productName = BasicExample;
productReference = 46EDC6F227C6B8D100B870D7 /* BasicExample.app */;
Expand Down Expand Up @@ -212,7 +215,7 @@
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1320;
LastUpgradeCheck = 1320;
LastUpgradeCheck = 1500;
TargetAttributes = {
46EDC6F127C6B8D100B870D7 = {
CreatedOnToolsVersion = 13.2.1;
Expand All @@ -238,7 +241,6 @@
mainGroup = 46EDC6E927C6B8D100B870D7;
packageReferences = (
46EDC71F27C6B92C00B870D7 /* XCRemoteSwiftPackageReference "analytics-swift" */,
4648A3D82AC62135000D4775 /* XCRemoteSwiftPackageReference "analytics-swift-consent" */,
);
productRefGroup = 46EDC6F327C6B8D100B870D7 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -284,6 +286,7 @@
files = (
46EDC6F827C6B8D100B870D7 /* ContentView.swift in Sources */,
46EDC6F627C6B8D100B870D7 /* BasicExampleApp.swift in Sources */,
4648A3E32ACCE39B000D4775 /* DummyDestination.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -357,6 +360,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -418,6 +422,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down Expand Up @@ -610,34 +615,25 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
4648A3D82AC62135000D4775 /* XCRemoteSwiftPackageReference "analytics-swift-consent" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "/Users/brandonsneed/work/analytics-swift-consent";
requirement = {
branch = main;
kind = branch;
};
};
46EDC71F27C6B92C00B870D7 /* XCRemoteSwiftPackageReference "analytics-swift" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/segmentio/analytics-swift";
requirement = {
branch = main;
branch = bsneed/fixups;
kind = branch;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
4648A3D92AC62135000D4775 /* SegmentConsent */ = {
isa = XCSwiftPackageProductDependency;
package = 4648A3D82AC62135000D4775 /* XCRemoteSwiftPackageReference "analytics-swift-consent" */;
productName = SegmentConsent;
};
4648A3DC2AC62195000D4775 /* SegmentConsentOneTrust */ = {
isa = XCSwiftPackageProductDependency;
productName = SegmentConsentOneTrust;
};
46797C6E2AD71FC400A0C863 /* SegmentConsent */ = {
isa = XCSwiftPackageProductDependency;
productName = SegmentConsent;
};
46EDC72027C6B92C00B870D7 /* Segment */ = {
isa = XCSwiftPackageProductDependency;
package = 46EDC71F27C6B92C00B870D7 /* XCRemoteSwiftPackageReference "analytics-swift" */;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"object": {
"pins": [
{
"package": "Segment",
"repositoryURL": "https://github.com/segmentio/analytics-swift",
"state": {
"branch": "bsneed/fixups",
"revision": "44d7054066ca5d55e8bde10762a109e042c93331",
"version": null
}
},
{
"package": "OTPublishersHeadlessSDK",
"repositoryURL": "https://github.com/Zentrust/OTPublishersHeadlessSDK",
"state": {
"branch": null,
"revision": "e318c893a790e6f58bd0c67e64d0ef204c482c31",
"version": "202309.1.0"
}
},
{
"package": "OTPublishersHeadlessSDKtvOS",
"repositoryURL": "https://github.com/Zentrust/OTPublishersHeadlessSDKtvOS",
"state": {
"branch": null,
"revision": "13e371adfcce89dff5d1c22f1160d5c213a9ccdb",
"version": "202309.1.0"
}
},
{
"package": "Sovran",
"repositoryURL": "https://github.com/segmentio/Sovran-Swift.git",
"state": {
"branch": null,
"revision": "64f3b5150c282a34af4578188dce2fd597e600e3",
"version": "1.1.0"
}
}
]
},
"version": 1
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
{
"pins" : [
{
"identity" : "analytics-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/segmentio/analytics-swift",
"state" : {
"branch" : "main",
"revision" : "ad34912ad10478f3308d30b68a7119fcef68981f"
"object": {
"pins": [
{
"package": "Segment",
"repositoryURL": "https://github.com/segmentio/analytics-swift",
"state": {
"branch": "bsneed/fixups",
"revision": "44d7054066ca5d55e8bde10762a109e042c93331",
"version": null
}
},
{
"package": "OTPublishersHeadlessSDK",
"repositoryURL": "https://github.com/Zentrust/OTPublishersHeadlessSDK",
"state": {
"branch": null,
"revision": "e318c893a790e6f58bd0c67e64d0ef204c482c31",
"version": "202309.1.0"
}
},
{
"package": "OTPublishersHeadlessSDKtvOS",
"repositoryURL": "https://github.com/Zentrust/OTPublishersHeadlessSDKtvOS",
"state": {
"branch": null,
"revision": "13e371adfcce89dff5d1c22f1160d5c213a9ccdb",
"version": "202309.1.0"
}
},
{
"package": "Sovran",
"repositoryURL": "https://github.com/segmentio/Sovran-Swift.git",
"state": {
"branch": null,
"revision": "64f3b5150c282a34af4578188dce2fd597e600e3",
"version": "1.1.0"
}
}
},
{
"identity" : "analytics-swift-consent",
"kind" : "localSourceControl",
"location" : "/Users/brandonsneed/work/analytics-swift-consent",
"state" : {
"branch" : "main",
"revision" : "450a72a7a63e74ee513f40f92a6e562f881307fc"
}
},
{
"identity" : "sovran-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/segmentio/Sovran-Swift.git",
"state" : {
"revision" : "64f3b5150c282a34af4578188dce2fd597e600e3",
"version" : "1.1.0"
}
}
],
"version" : 2
]
},
"version": 1
}
69 changes: 52 additions & 17 deletions Example/BasicExample/BasicExample/BasicExampleApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,71 @@ import OTPublishersHeadlessSDK
struct BasicExampleApp: App {
var body: some Scene {
WindowGroup {
ContentView()
// necessary to get us a viewcontroller for onetrust to use.
UIHostingController(rootView: ContentView()).rootView
}
}
}

extension UIApplication {
// get the view controller we set up in swiftUI to give to onetrust.
// maybe they'll support SwiftUI at some point. :man-shrugging:
var mainViewController: UIViewController? {
let windowScenes = UIApplication.shared.connectedScenes
.compactMap { $0 as? UIWindowScene }
let activeScene = windowScenes
.filter { $0.activationState == .foregroundActive }
let firstActiveScene = activeScene.first
let keyWindow = firstActiveScene?.keyWindow
let windowScenes = UIApplication.shared.connectedScenes.compactMap { $0 as? UIWindowScene }
let activeScene = windowScenes.first
let keyWindow = activeScene?.keyWindow
return keyWindow?.rootViewController
}
}

/*
let consentManager = ConsentManager(provider: OneTrustProvider())
analytics.add(plugin: MyBrazePlugin())
analytics.add(plugin: Taplytics())
analytics.add(plugin: Adjust())
analytics.add(plugin: Firebase())
...
let consentManager = ConsentManager(provider: OneTrustProvider())
let brazePlugin = MyBrazePlugin()
analytics.add(plugin: braze)
let taplytics = MyTaplyticsPlugin()
analytics.add(plugin: taplytics)
let adjust = Adjust()
analytics.add(plugin: adjust)
let firebase = Firebase()
analytics.add(plugin: firebase)
braze.add(plugin: ConsentManagerBlocker(key: braze.key))
braze.add(plugin: ConsentManagerBlocker(key: taplytics.key))
braze.add(plugin: ConsentManagerBlocker(key: adjust.key))
braze.add(plugin: ConsentManagerBlocker(key: firebase.key))
*/

extension Analytics {
static var main: Analytics {
let analytics = Analytics(configuration: Configuration(writeKey: "<YOUR WRITE KEY>")
.flushAt(3)
static var main: Analytics = {
Analytics.debugLogsEnabled = true

let analytics = Analytics(configuration: Configuration(writeKey: "EGCcsy2aeYnDBfJewFOzcy91SUHg2QTF")
.flushAt(1)
.trackApplicationLifecycleEvents(true))
let consentManager = ConsentManager(provider: OneTrustProvider(categories: []))
let consentManager = ConsentManager(provider: OneTrustProvider())
analytics.add(plugin: consentManager)
// per destination; we only have one in the example app though.
analytics.add(plugin: ConsentBlocker(destinationKey: "Segment.io", store: consentManager.store))

// add dummy destinations to represent our consent settings on segment.com
analytics.add(plugin: DummyDestination(key: "WebhookC0001", consentKey: "C0001"))
analytics.add(plugin: DummyDestination(key: "WebhookC0002", consentKey: "C0002"))
analytics.add(plugin: DummyDestination(key: "WebhookC0003", consentKey: "C0003"))
analytics.add(plugin: DummyDestination(key: "WebhookC0004", consentKey: "C0004"))
analytics.add(plugin: DummyDestination(key: "WebhookC0005", consentKey: "C0005"))

// once we do the setup, onetrust triggers the consent UI to pop up on
// it's own. you can do it manually if you prefer though, but any way
// you slice it, you'll need a uiviewcontroller.
if let mainViewController = UIApplication.shared.mainViewController {
OTPublishersHeadlessSDK.shared.setupUI(mainViewController, UIType: .preferenceCenter)
}
Expand All @@ -56,12 +94,9 @@ extension Analytics {
domainIdentifier: "aaa2b4b9-3a9c-450c-b82b-60bc3bfc8e19-test",
languageCode: "en"
) { response in
print("status: \(response.status)")
print("result: \(response.responseString ?? "")")
print("error: \(String(describing: response.error))")
consentManager.start()
}

return analytics
}
}()
}
18 changes: 17 additions & 1 deletion Example/BasicExample/BasicExample/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,29 @@

import SwiftUI
import Segment
#if os(tvOS)
import OTPublishersHeadlessSDKtvOS
#else
import OTPublishersHeadlessSDK
#endif

struct ContentView: View {
var body: some View {
VStack {
Button {
OTPublishersHeadlessSDK.shared.showPreferenceCenterUI()
} label: {
Text("Show Consent UI")
}
Button {
Analytics.main.reset()
} label: {
Text("Reset")
}

HStack {
Button(action: {
Analytics.main.track(name: "Track")
Analytics.main.track(name: "Track Tapped")
}, label: {
Text("Track")
}).padding(6)
Expand Down
Loading

0 comments on commit 6dde3bf

Please sign in to comment.