From 58bc05d68feb8749ae56ce09d200274f3407bf61 Mon Sep 17 00:00:00 2001 From: Wenxi Zeng Date: Wed, 9 Feb 2022 08:39:12 -0800 Subject: [PATCH 1/5] fix identify doc issue --- Sources/Segment/Events.swift | 14 ++++++++------ Sources/Segment/ObjC/ObjCAnalytics.swift | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Sources/Segment/Events.swift b/Sources/Segment/Events.swift index 39d8e7e2..8218adf2 100644 --- a/Sources/Segment/Events.swift +++ b/Sources/Segment/Events.swift @@ -73,9 +73,10 @@ extension Analytics { /// Associate a user with their unique ID and record traits about them. /// - Parameters: - /// - userId: A database ID (or email address) for this user. If you don't have a userId - /// but want to record traits, you should pass nil. For more information on how we - /// generate the UUID and Apple's policies on IDs, see https://segment.io/libraries/ios#ids + /// - userId: A database ID (or email address) for this user. + /// For more information on how we generate the UUID and Apple's policies on IDs, see + /// https://segment.io/libraries/ios#ids + /// In the case when user logs out, make sure to call ``reset()`` to clear user's identity info. public func identify(userId: String) { let event = IdentifyEvent(userId: userId, traits: nil) store.dispatch(action: UserInfo.SetUserIdAction(userId: userId)) @@ -151,10 +152,11 @@ extension Analytics { /// Associate a user with their unique ID and record traits about them. /// - Parameters: - /// - userId: A database ID (or email address) for this user. If you don't have a userId - /// but want to record traits, you should pass nil. For more information on how we - /// generate the UUID and Apple's policies on IDs, see https://segment.io/libraries/ios#ids + /// - userId: A database ID (or email address) for this user. + /// For more information on how we generate the UUID and Apple's policies on IDs, see + /// https://segment.io/libraries/ios#ids /// - traits: A dictionary of traits you know about the user. Things like: email, name, plan, etc. + /// In the case when user logs out, make sure to call ``reset()`` to clear user's identity info. public func identify(userId: String, traits: [String: Any]? = nil) { do { if let traits = traits { diff --git a/Sources/Segment/ObjC/ObjCAnalytics.swift b/Sources/Segment/ObjC/ObjCAnalytics.swift index 06097289..ea739e8b 100644 --- a/Sources/Segment/ObjC/ObjCAnalytics.swift +++ b/Sources/Segment/ObjC/ObjCAnalytics.swift @@ -38,9 +38,10 @@ extension ObjCAnalytics { /// Associate a user with their unique ID and record traits about them. /// - Parameters: - /// - userId: A database ID (or email address) for this user. If you don't have a userId - /// but want to record traits, you should pass nil. For more information on how we - /// generate the UUID and Apple's policies on IDs, see https://segment.io/libraries/ios#ids + /// - userId: A database ID (or email address) for this user. + /// For more information on how we generate the UUID and Apple's policies on IDs, see + /// https://segment.io/libraries/ios#ids + /// In the case when user logs out, make sure to call ``reset()`` to clear user's identity info. @objc(identify:) public func identify(userId: String) { identify(userId: userId, traits: nil) @@ -48,10 +49,11 @@ extension ObjCAnalytics { /// Associate a user with their unique ID and record traits about them. /// - Parameters: - /// - userId: A database ID (or email address) for this user. If you don't have a userId - /// but want to record traits, you should pass nil. For more information on how we - /// generate the UUID and Apple's policies on IDs, see https://segment.io/libraries/ios#ids + /// - userId: A database ID (or email address) for this user. + /// For more information on how we generate the UUID and Apple's policies on IDs, see + /// https://segment.io/libraries/ios#ids /// - traits: A dictionary of traits you know about the user. Things like: email, name, plan, etc. + /// In the case when user logs out, make sure to call ``reset()`` to clear user's identity info. @objc(identify:traits:) public func identify(userId: String, traits: [String: Any]?) { analytics.identify(userId: userId, traits: traits) From 497335b4d2da44d8fa909f9e74f8d08e97fd1b9a Mon Sep 17 00:00:00 2001 From: Wenxi Zeng Date: Wed, 9 Feb 2022 09:22:11 -0800 Subject: [PATCH 2/5] add codecov to gha workflow --- .github/workflows/swift.yml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index b863a2fc..61cc4aa2 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -29,6 +29,8 @@ jobs: run: swift build - name: Run tests run: swift test + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 build_and_test_spm_linux: needs: cancel_previous @@ -45,6 +47,8 @@ jobs: run: swift build - name: Run tests run: swift test --enable-test-discovery + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 build_and_test_ios: needs: cancel_previous @@ -64,7 +68,8 @@ jobs: with: ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }} - run: xcodebuild -scheme Segment-Package test -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' - + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 build_and_test_tvos: needs: cancel_previous @@ -84,7 +89,9 @@ jobs: with: ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }} - run: xcodebuild -scheme Segment-Package test -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' - + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 + build_and_test_watchos: needs: cancel_previous runs-on: macos-11 @@ -103,7 +110,9 @@ jobs: with: ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }} - run: xcodebuild -scheme Segment-Package test -sdk watchsimulator -destination 'platform=watchOS Simulator,name=Apple Watch Series 5 - 40mm' - + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 + build_and_test_examples: needs: cancel_previous runs-on: macos-11 @@ -137,7 +146,8 @@ jobs: run: | cd Examples/apps/SegmentUIKitExample xcodebuild -workspace "SegmentUIKitExample.xcworkspace" -scheme "SegmentUIKitExample" -destination 'platform=macOS,variant=Mac Catalyst' - + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 build_and_test_dest_examples: needs: cancel_previous @@ -160,3 +170,5 @@ jobs: run: | cd Examples/apps/DestinationsExample xcodebuild -workspace "DestinationsExample.xcworkspace" -scheme "DestinationsExample" -sdk iphonesimulator + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 \ No newline at end of file From 452732c61e40acbf7dcd3901b7d0f23ee915bd9c Mon Sep 17 00:00:00 2001 From: Wenxi Zeng Date: Wed, 9 Feb 2022 09:22:21 -0800 Subject: [PATCH 3/5] add badges --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index afb09288..a7d7a8f2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ # Analytics-Swift +![](https://github.com/segmentio/analytics-swift/actions/workflows/swift.yml/badge.svg) +![](https://img.shields.io/github/license/segmentio/analytics-swift) +[![codecov](https://codecov.io/gh/segmentio/analytics-swift/branch/main/graph/badge.svg?token=59Y47DSEPZ)](https://codecov.io/gh/segmentio/analytics-swift) NOTE: This project is currently in the Beta phase and is covered by Segment's [First Access & Beta Preview Terms](https://segment.com/legal/first-access-beta-preview/). We encourage you to try out this new library. Please provide feedback via Github issues/PRs, and feel free to submit pull requests. From e1dca3cc97ac170e97f14d4c621715ae9b482141 Mon Sep 17 00:00:00 2001 From: Wenxi Zeng Date: Wed, 9 Feb 2022 09:44:29 -0800 Subject: [PATCH 4/5] enable test coverage --- .github/workflows/swift.yml | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 61cc4aa2..046e7837 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -28,7 +28,7 @@ jobs: - name: Build run: swift build - name: Run tests - run: swift test + run: swift test --enable-code-coverage - name: Upload coverage to Codecov uses: codecov/codecov-action@v2 @@ -46,7 +46,7 @@ jobs: - name: Build run: swift build - name: Run tests - run: swift test --enable-test-discovery + run: swift test --enable-test-discovery --enable-code-coverage - name: Upload coverage to Codecov uses: codecov/codecov-action@v2 @@ -67,7 +67,7 @@ jobs: - uses: webfactory/ssh-agent@v0.5.3 with: ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }} - - run: xcodebuild -scheme Segment-Package test -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' + - run: xcodebuild test -scheme Segment-Package test -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' -enableCodeCoverage YES build test - name: Upload coverage to Codecov uses: codecov/codecov-action@v2 @@ -88,7 +88,7 @@ jobs: - uses: webfactory/ssh-agent@v0.5.3 with: ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }} - - run: xcodebuild -scheme Segment-Package test -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' + - run: xcodebuild test -scheme Segment-Package test -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' -enableCodeCoverage YES build test - name: Upload coverage to Codecov uses: codecov/codecov-action@v2 @@ -109,7 +109,7 @@ jobs: - uses: webfactory/ssh-agent@v0.5.3 with: ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }} - - run: xcodebuild -scheme Segment-Package test -sdk watchsimulator -destination 'platform=watchOS Simulator,name=Apple Watch Series 5 - 40mm' + - run: xcodebuild test -scheme Segment-Package test -sdk watchsimulator -destination 'platform=watchOS Simulator,name=Apple Watch Series 5 - 40mm' -enableCodeCoverage YES build test - name: Upload coverage to Codecov uses: codecov/codecov-action@v2 @@ -130,22 +130,32 @@ jobs: - uses: webfactory/ssh-agent@v0.5.3 with: ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }} + - name: build for ios simulator run: | cd Examples/apps/BasicExample - xcodebuild -workspace "BasicExample.xcworkspace" -scheme "BasicExample" -sdk iphonesimulator + xcodebuild test -workspace "BasicExample.xcworkspace" -scheme "BasicExample" -sdk iphonesimulator -enableCodeCoverage YES build test + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 + - name: build for ios simulator run: | cd Examples/apps/ObjCExample - xcodebuild -workspace "ObjCExample.xcworkspace" -scheme "ObjCExample" -sdk iphonesimulator + xcodebuild test -workspace "ObjCExample.xcworkspace" -scheme "ObjCExample" -sdk iphonesimulator -enableCodeCoverage YES build test + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 + - name: build for ios simulator run: | cd Examples/apps/SegmentUIKitExample - xcodebuild -workspace "SegmentUIKitExample.xcworkspace" -scheme "SegmentUIKitExample" -sdk iphonesimulator + xcodebuild test -workspace "SegmentUIKitExample.xcworkspace" -scheme "SegmentUIKitExample" -sdk iphonesimulator -enableCodeCoverage YES build test + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 + - name: build for mac catalyst run: | cd Examples/apps/SegmentUIKitExample - xcodebuild -workspace "SegmentUIKitExample.xcworkspace" -scheme "SegmentUIKitExample" -destination 'platform=macOS,variant=Mac Catalyst' + xcodebuild test -workspace "SegmentUIKitExample.xcworkspace" -scheme "SegmentUIKitExample" -destination 'platform=macOS,variant=Mac Catalyst' -enableCodeCoverage YES build test - name: Upload coverage to Codecov uses: codecov/codecov-action@v2 @@ -169,6 +179,6 @@ jobs: - name: build for ios simulator run: | cd Examples/apps/DestinationsExample - xcodebuild -workspace "DestinationsExample.xcworkspace" -scheme "DestinationsExample" -sdk iphonesimulator + xcodebuild test -workspace "DestinationsExample.xcworkspace" -scheme "DestinationsExample" -sdk iphonesimulator -enableCodeCoverage YES build test - name: Upload coverage to Codecov uses: codecov/codecov-action@v2 \ No newline at end of file From 43bd367c1f7dc3351fffeb88fba5cbb74b336c7d Mon Sep 17 00:00:00 2001 From: Wenxi Zeng Date: Wed, 9 Feb 2022 10:31:24 -0800 Subject: [PATCH 5/5] revert changes on codecov --- .github/workflows/swift.yml | 50 +++++++++++-------------------------- README.md | 1 - 2 files changed, 14 insertions(+), 37 deletions(-) diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 046e7837..b863a2fc 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -28,9 +28,7 @@ jobs: - name: Build run: swift build - name: Run tests - run: swift test --enable-code-coverage - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 + run: swift test build_and_test_spm_linux: needs: cancel_previous @@ -46,9 +44,7 @@ jobs: - name: Build run: swift build - name: Run tests - run: swift test --enable-test-discovery --enable-code-coverage - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 + run: swift test --enable-test-discovery build_and_test_ios: needs: cancel_previous @@ -67,9 +63,8 @@ jobs: - uses: webfactory/ssh-agent@v0.5.3 with: ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }} - - run: xcodebuild test -scheme Segment-Package test -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' -enableCodeCoverage YES build test - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 + - run: xcodebuild -scheme Segment-Package test -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 11' + build_and_test_tvos: needs: cancel_previous @@ -88,10 +83,8 @@ jobs: - uses: webfactory/ssh-agent@v0.5.3 with: ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }} - - run: xcodebuild test -scheme Segment-Package test -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' -enableCodeCoverage YES build test - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 - + - run: xcodebuild -scheme Segment-Package test -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV' + build_and_test_watchos: needs: cancel_previous runs-on: macos-11 @@ -109,10 +102,8 @@ jobs: - uses: webfactory/ssh-agent@v0.5.3 with: ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }} - - run: xcodebuild test -scheme Segment-Package test -sdk watchsimulator -destination 'platform=watchOS Simulator,name=Apple Watch Series 5 - 40mm' -enableCodeCoverage YES build test - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 - + - run: xcodebuild -scheme Segment-Package test -sdk watchsimulator -destination 'platform=watchOS Simulator,name=Apple Watch Series 5 - 40mm' + build_and_test_examples: needs: cancel_previous runs-on: macos-11 @@ -130,34 +121,23 @@ jobs: - uses: webfactory/ssh-agent@v0.5.3 with: ssh-private-key: ${{ secrets.SOVRAN_SSH_KEY }} - - name: build for ios simulator run: | cd Examples/apps/BasicExample - xcodebuild test -workspace "BasicExample.xcworkspace" -scheme "BasicExample" -sdk iphonesimulator -enableCodeCoverage YES build test - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 - + xcodebuild -workspace "BasicExample.xcworkspace" -scheme "BasicExample" -sdk iphonesimulator - name: build for ios simulator run: | cd Examples/apps/ObjCExample - xcodebuild test -workspace "ObjCExample.xcworkspace" -scheme "ObjCExample" -sdk iphonesimulator -enableCodeCoverage YES build test - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 - + xcodebuild -workspace "ObjCExample.xcworkspace" -scheme "ObjCExample" -sdk iphonesimulator - name: build for ios simulator run: | cd Examples/apps/SegmentUIKitExample - xcodebuild test -workspace "SegmentUIKitExample.xcworkspace" -scheme "SegmentUIKitExample" -sdk iphonesimulator -enableCodeCoverage YES build test - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 - + xcodebuild -workspace "SegmentUIKitExample.xcworkspace" -scheme "SegmentUIKitExample" -sdk iphonesimulator - name: build for mac catalyst run: | cd Examples/apps/SegmentUIKitExample - xcodebuild test -workspace "SegmentUIKitExample.xcworkspace" -scheme "SegmentUIKitExample" -destination 'platform=macOS,variant=Mac Catalyst' -enableCodeCoverage YES build test - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 + xcodebuild -workspace "SegmentUIKitExample.xcworkspace" -scheme "SegmentUIKitExample" -destination 'platform=macOS,variant=Mac Catalyst' + build_and_test_dest_examples: needs: cancel_previous @@ -179,6 +159,4 @@ jobs: - name: build for ios simulator run: | cd Examples/apps/DestinationsExample - xcodebuild test -workspace "DestinationsExample.xcworkspace" -scheme "DestinationsExample" -sdk iphonesimulator -enableCodeCoverage YES build test - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 \ No newline at end of file + xcodebuild -workspace "DestinationsExample.xcworkspace" -scheme "DestinationsExample" -sdk iphonesimulator diff --git a/README.md b/README.md index a7d7a8f2..d031e5e0 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Analytics-Swift ![](https://github.com/segmentio/analytics-swift/actions/workflows/swift.yml/badge.svg) ![](https://img.shields.io/github/license/segmentio/analytics-swift) -[![codecov](https://codecov.io/gh/segmentio/analytics-swift/branch/main/graph/badge.svg?token=59Y47DSEPZ)](https://codecov.io/gh/segmentio/analytics-swift) NOTE: This project is currently in the Beta phase and is covered by Segment's [First Access & Beta Preview Terms](https://segment.com/legal/first-access-beta-preview/). We encourage you to try out this new library. Please provide feedback via Github issues/PRs, and feel free to submit pull requests.