Skip to content

Commit 723814a

Browse files
committed
Initial commit.
0 parents  commit 723814a

25 files changed

+2510
-0
lines changed

.github/workflows/swift.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Swift
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
cancel_previous:
11+
permissions: write-all
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: styfle/[email protected]
15+
with:
16+
workflow_id: ${{ github.event.workflow.id }}
17+
18+
build_and_test_spm_mac:
19+
needs: cancel_previous
20+
runs-on: macos-latest
21+
steps:
22+
- uses: maxim-lobanov/setup-xcode@v1
23+
with:
24+
xcode-version: latest-stable
25+
- uses: actions/checkout@v2
26+
- name: Build
27+
run: swift build
28+
- name: Run tests
29+
run: swift test
30+
31+
build_and_test_ios:
32+
needs: cancel_previous
33+
runs-on: macos-latest
34+
steps:
35+
- uses: maxim-lobanov/setup-xcode@v1
36+
with:
37+
xcode-version: latest-stable
38+
- uses: actions/checkout@v2
39+
- run: xcodebuild -scheme SegmentConsent test -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13'
40+
41+
build_and_test_tvos:
42+
needs: cancel_previous
43+
runs-on: macos-latest
44+
steps:
45+
- uses: maxim-lobanov/setup-xcode@v1
46+
with:
47+
xcode-version: latest-stable
48+
- uses: actions/checkout@v2
49+
- run: xcodebuild -scheme SegmentConsent test -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV'
50+
51+

.gitignore

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Xcode
2+
#
3+
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4+
5+
## User settings
6+
xcuserdata/
7+
8+
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
9+
*.xcscmblueprint
10+
*.xccheckout
11+
12+
## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
13+
build/
14+
DerivedData/
15+
*.moved-aside
16+
*.pbxuser
17+
!default.pbxuser
18+
*.mode1v3
19+
!default.mode1v3
20+
*.mode2v3
21+
!default.mode2v3
22+
*.perspectivev3
23+
!default.perspectivev3
24+
25+
## Obj-C/Swift specific
26+
*.hmap
27+
28+
## App packaging
29+
*.ipa
30+
*.dSYM.zip
31+
*.dSYM
32+
33+
## Playgrounds
34+
timeline.xctimeline
35+
playground.xcworkspace
36+
37+
# Swift Package Manager
38+
#
39+
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
40+
# Packages/
41+
# Package.pins
42+
# Package.resolved
43+
# *.xcodeproj
44+
#
45+
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
46+
# hence it is not needed unless you have added a package configuration file to your project
47+
# .swiftpm
48+
49+
.build/
50+
51+
# CocoaPods
52+
#
53+
# We recommend against adding the Pods directory to your .gitignore. However
54+
# you should judge for yourself, the pros and cons are mentioned at:
55+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
56+
#
57+
# Pods/
58+
#
59+
# Add this line if you want to avoid checking in source code from the Xcode workspace
60+
# *.xcworkspace
61+
62+
# Carthage
63+
#
64+
# Add this line if you want to avoid checking in source code from Carthage dependencies.
65+
# Carthage/Checkouts
66+
67+
Carthage/Build/
68+
69+
# Accio dependency management
70+
Dependencies/
71+
.accio/
72+
73+
# fastlane
74+
#
75+
# It is recommended to not store the screenshots in the git repo.
76+
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
77+
# For more information about the recommended setup visit:
78+
# https://docs.fastlane.tools/best-practices/source-control/#source-control
79+
80+
fastlane/report.xml
81+
fastlane/Preview.html
82+
fastlane/screenshots/**/*.png
83+
fastlane/test_output
84+
85+
# Code Injection
86+
#
87+
# After new code Injection tools there's a generated folder /iOSInjectionProject
88+
# https://github.com/johnno1962/injectionforxcode
89+
90+
iOSInjectionProject/
91+
/Example/BasicExample/BasicExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm
92+
.DS_Store
93+
/.swiftpm

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Segment
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Package.resolved

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// swift-tools-version:5.7
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "SegmentConsent",
8+
platforms: [
9+
.macOS("10.15"),
10+
.iOS("13.0"),
11+
.tvOS("11.0"),
12+
],
13+
products: [
14+
// Products define the executables and libraries a package produces, and make them visible to other packages.
15+
.library(
16+
name: "SegmentConsent",
17+
targets: ["SegmentConsent"]),
18+
],
19+
dependencies: [
20+
// Dependencies declare other packages that this package depends on.
21+
// .package(url: /* package url */, from: "1.0.0"),
22+
.package(url: "https://github.com/segmentio/analytics-swift.git", from: "1.4.8")
23+
],
24+
targets: [
25+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
26+
// Targets can depend on other targets in this package, and on products in packages this package depends on.
27+
.target(
28+
name: "SegmentConsent",
29+
dependencies: [
30+
.product(name: "Segment", package: "analytics-swift")
31+
]),
32+
.testTarget(
33+
name: "SegmentConsent-Tests",
34+
dependencies: ["SegmentConsent"],
35+
resources: [
36+
.process("Resources")
37+
]),
38+
]
39+
)
40+

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Analytics-Swift-Consent
2+
3+
Add Segment driven consent management support for your application via this plugin for [Analytics-Swift](https://github.com/segmentio/analytics-swift)
4+
5+
## Adding the dependency
6+
7+
### via Xcode
8+
In the Xcode `File` menu, click `Add Packages`. You'll see a dialog where you can search for Swift packages. In the search field, enter the URL to this repo.
9+
10+
https://github.com/segment-integrations/analytics-swift-consent
11+
12+
You'll then have the option to pin to a version, or specific branch, as well as which project in your workspace to add it to. Once you've made your selections, click the `Add Package` button.
13+
14+
### via Package.swift
15+
16+
Open your Package.swift file and add the following do your the `dependencies` section:
17+
18+
```
19+
.package(
20+
name: "Segment",
21+
url: "https://github.com/segment-integrations/analytics-swift-consent.git",
22+
from: "1.0.0"
23+
),
24+
```
25+
26+
27+
## Using the Plugin in your App
28+
29+
Open the file where you setup and configure the Analytics-Swift library. Add this plugin to the list of imports.
30+
31+
```
32+
import Segment
33+
import SegmentConsent // <-- Add this line
34+
```
35+
36+
Just under your Analytics-Swift library setup, call `analytics.add(plugin: ...)` to add an instance of the plugin to the Analytics timeline.
37+
38+
```
39+
let analytics = Analytics(configuration: Configuration(writeKey: "<YOUR WRITE KEY>")
40+
.flushAt(3)
41+
.trackApplicationLifecycleEvents(true))
42+
43+
let consentManager = ConsentManager(provider: MyConsentProvider())
44+
analytics.add(plugin: consentManager)
45+
46+
// Note: Different consent management providers may require consentManager.start() be called differently.
47+
// Tell the consent manager to start processing events. It will queue events until start() is called.
48+
consentManager.start()
49+
50+
```
51+
52+
Your events will now begin to have the consent management preferences applied.
53+
54+
55+
## Support
56+
57+
Please use Github issues, Pull Requests, or feel free to reach out to our [support team](https://segment.com/help/).
58+
59+
## Integrating with Segment
60+
61+
Interested in integrating your service with us? Check out our [Partners page](https://segment.com/partners/) for more details.
62+
63+
## License
64+
```
65+
MIT License
66+
67+
Copyright (c) 2023 Segment
68+
69+
Permission is hereby granted, free of charge, to any person obtaining a copy
70+
of this software and associated documentation files (the "Software"), to deal
71+
in the Software without restriction, including without limitation the rights
72+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
73+
copies of the Software, and to permit persons to whom the Software is
74+
furnished to do so, subject to the following conditions:
75+
76+
The above copyright notice and this permission notice shall be included in all
77+
copies or substantial portions of the Software.
78+
79+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
80+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
81+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
82+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
83+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
84+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
85+
SOFTWARE.
86+
```

0 commit comments

Comments
 (0)