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

feat(autocapture): auto capture element interactions #224

Merged
merged 31 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
dc2a112
feat: add PostHogExampleAutocapture sample project
ioannisj Oct 17, 2024
26b97af
feat: add base autocapture integration
ioannisj Oct 17, 2024
8b1406f
feat(autocapture): process captured events
ioannisj Oct 23, 2024
3a0b5f6
feat(autocapture): add support for debouncing events for
ioannisj Oct 23, 2024
045f07c
feat(autocapture): update CHANGELOG.md
ioannisj Oct 24, 2024
d2eefda
feat(autocapture): add support for UIScrollView
ioannisj Oct 24, 2024
110835b
feat(autocapture): add support for UISwitch
ioannisj Oct 24, 2024
b16b265
feat(autocapture): add support for UIPickerView
ioannisj Oct 24, 2024
4b32319
feat(autocapture): add autocapture configuration
ioannisj Oct 25, 2024
d3d687d
feat(autocapture): fix UITextField sample
ioannisj Oct 25, 2024
f2857d1
feat(autocapture): fix support for UITextField
ioannisj Oct 25, 2024
9995435
fix(autocapture): replace with hedgelog
ioannisj Oct 30, 2024
3770e24
feat(autocapture): sanitize text similar to js sdk
ioannisj Oct 30, 2024
eebccf4
fix(autocapture): revert view controller name
ioannisj Oct 30, 2024
3c67b79
refactor(autocapture): route events to shared instance
ioannisj Oct 30, 2024
ef22d11
feat(autocapture): skip sensitive inputs and ph-no-capture
ioannisj Oct 30, 2024
4997575
fix(autocapture): invalidate and clear debounce timers on stop
ioannisj Oct 30, 2024
b14c5da
feat(tests): add unit tests
ioannisj Oct 31, 2024
6b4ff59
chore: format and lint
ioannisj Oct 31, 2024
52f16ba
Merge branch 'main' into feat/auto-capture-element-interactions
ioannisj Oct 31, 2024
0d19fce
chore(autocapture): lint file name
ioannisj Nov 1, 2024
1113c69
ci(test): run iOS tests
ioannisj Nov 1, 2024
56bbdc9
ci(tests): run on latest iOS version available
ioannisj Nov 1, 2024
b705fdc
ci(test): revert iOS tests
ioannisj Nov 1, 2024
cf70679
Merge branch 'main' into feat/auto-capture-element-interactions
ioannisj Nov 5, 2024
e04ec68
feat(autocapture): simplify configuration options
ioannisj Nov 7, 2024
35d7bfb
fix: lint
ioannisj Nov 7, 2024
333f170
Merge branch 'main' into feat/auto-capture-element-interactions
ioannisj Nov 7, 2024
02119ed
chore: revert new formats
ioannisj Nov 8, 2024
2c3574d
chore: revert workflow changes
ioannisj Nov 8, 2024
d5ca9e6
Merge branch 'main' into feat/auto-capture-element-interactions
ioannisj Nov 8, 2024
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
36 changes: 18 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name: Tests
on:
push:
branches:
- main
pull_request:
paths-ignore:
- "**/*.md"
jobs:
test:
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Test SDK
run: make test
name: Tests
on:
push:
branches:
- main
pull_request:
paths-ignore:
- "**/*.md"
jobs:
test:
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Test SDK
run: make test
96 changes: 96 additions & 0 deletions .swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
--acronyms ID,URL,UUID
--allman false
--anonymousforeach convert
--assetliterals visual-width
--asynccapturing
--beforemarks
--binarygrouping none
--callsiteparen default
--categorymark "MARK: %c"
--classthreshold 0
--closingparen balanced
--closurevoid remove
--commas inline
--complexattrs preserve
--computedvarattrs preserve
--condassignment after-property
--conflictmarkers reject
--dateformat system
--decimalgrouping none
--doccomments before-declarations
--elseposition same-line
--emptybraces no-space
--enumnamespaces always
--enumthreshold 0
--exponentcase lowercase
--exponentgrouping disabled
--extensionacl on-extension
--extensionlength 0
--extensionmark "MARK: - %t + %c"
--fractiongrouping disabled
--fragment false
--funcattributes preserve
--generictypes
--groupedextension "MARK: %c"
--guardelse auto
--header ignore
--hexgrouping 4,8
--hexliteralcase uppercase
--ifdef indent
--importgrouping alpha
--indent 4
--indentcase false
--indentstrings false
--initcodernil false
--lifecycle
--lineaftermarks true
--linebreaks lf
--markcategories true
--markextensions always
--marktypes always
--maxwidth none
--modifierorder
--nevertrailing
--nilinit remove
--noncomplexattrs
--nospaceoperators
--nowrapoperators
--octalgrouping none
--onelineforeach ignore
--operatorfunc spaced
--organizationmode visibility
--organizetypes actor,class,enum,struct
--patternlet hoist
--ranges spaced
--redundanttype infer-locals-only
--self remove
--selfrequired
--semicolons never
--shortoptionals except-properties
--smarttabs enabled
--someany true
--storedvarattrs preserve
--stripunusedargs always
--structthreshold 0
--tabwidth unspecified
--throwcapturing
--timezone system
--trailingclosures
--trimwhitespace always
--typeattributes preserve
--typeblanklines remove
--typedelimiter space-after
--typemark "MARK: - %t"
--voidtype void
--wraparguments preserve
--wrapcollections preserve
--wrapconditions preserve
--wrapeffects preserve
--wrapenumcases always
--wrapparameters default
--wrapreturntype preserve
--wrapternary default
--wraptypealiases preserve
--xcodeindentation disabled
--yodaswap always
--exclude PostHogExampleAutocapture,PostHogExample,PostHogExampleWithSPM,PostHogExampleAutocapture,PostHogTests,Pods,.build
6 changes: 6 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
excluded: # case-sensitive paths to ignore during linting. Takes precedence over `included`
- PostHogExample
- PostHogExampleWithSPM
- PostHogExampleAutocapture
- PostHogTests
- PostHog/Utils/ReadWriteLock.swift
- PostHog/Utils/Reachability.swift
Expand All @@ -19,6 +20,11 @@ file_length:
warning: 1000
error: 1200

identifier_name:
excluded:
- id
- ^ph_.*$

function_body_length:
- 1000 # warning
- 1200 # error
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Next

- add autocapture support for UIKit ([#224](https://github.com/PostHog/posthog-ios/pull/224))

## 3.14.0 - 2024-11-05

- add option to pass a custom timestamp when calling capture() ([#228](https://github.com/PostHog/posthog-ios/pull/228))
Expand Down
30 changes: 25 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
SIMULATOR_IOS_VERSION = $(shell xcrun simctl list | grep ^iOS | ruby -e 'puts /\(([0-9.]+).*\)/.match(STDIN.read.chomp.split("\n").last).to_a[1]')
SIMULATOR_ID = $(call udid_for,$(SIMULATOR_IOS_VERSION),iPhone [0-9]+ [^M])
TEST_ITERATIONS = 1

.PHONY: build buildSdk buildExamples format swiftLint swiftFormat test testOniOSSimulator testOnMacSimulator lint bootstrap releaseCocoaPods

build: buildSdk buildExamples
Expand Down Expand Up @@ -25,22 +29,26 @@ buildExamples:

format: swiftLint swiftFormat

print-env:
@echo "Simulator iOS version: '$(SIMULATOR_IOS_VERSION)'"
@echo "Simulator UUID: '$(SIMULATOR_ID)'"

swiftLint:
swiftlint --fix

swiftFormat:
swiftformat . --swiftversion 5.3

testOniOSSimulator:
set -o pipefail && xcrun xcodebuild test -scheme PostHog -destination 'platform=iOS Simulator,name=iPhone 15,OS=18.0' | xcpretty
test-ios: print-env
set -o pipefail && xcrun xcodebuild test -scheme PostHog -destination platform="iOS Simulator,id=$(SIMULATOR_ID)" $(if $(filter-out 1,$(TEST_ITERATIONS)), -run-tests-until-failure -test-iterations $(TEST_ITERATIONS)) | xcpretty

testOnMacSimulator:
test-macos:
set -o pipefail && xcrun xcodebuild test -scheme PostHog -destination 'platform=macOS' | xcpretty

test:
test:
swift test | xcpretty

lint:
lint:
swiftformat . --lint --swiftversion 5.3 && swiftlint

# requires gem and brew
Expand All @@ -51,3 +59,15 @@ bootstrap:

releaseCocoaPods:
pod trunk push PostHog.podspec --allow-warnings


define udid_for
$(shell xcrun simctl list --json devices available "$(1)" | jq -r --arg regex "$(2)" '
.devices
| to_entries
| map(select(.value | length > 0))
| map({key: .key, value: (.value | map(select(.name | test($$regex))))})
| map(select(.value | length > 0))
| .[0].value[0].udid
')
endef
12 changes: 6 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import PackageDescription
let package = Package(
name: "PostHog",
platforms: [
.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6),
.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "PostHog",
targets: ["PostHog"]
),
)
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/Quick/Quick.git", from: "6.0.0"),
.package(url: "https://github.com/Quick/Nimble.git", from: "12.0.0"),
.package(url: "https://github.com/AliSoftware/OHHTTPStubs.git", from: "9.0.0"),
.package(url: "https://github.com/AliSoftware/OHHTTPStubs.git", from: "9.0.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
Expand All @@ -26,7 +26,7 @@ let package = Package(
name: "PostHog",
path: "PostHog",
resources: [
.copy("Resources/PrivacyInfo.xcprivacy"),
.copy("Resources/PrivacyInfo.xcprivacy")
]
),
.testTarget(
Expand All @@ -36,9 +36,9 @@ let package = Package(
"Quick",
"Nimble",
"OHHTTPStubs",
.product(name: "OHHTTPStubsSwift", package: "OHHTTPStubs"),
.product(name: "OHHTTPStubsSwift", package: "OHHTTPStubs")
],
path: "PostHogTests"
),
)
]
)
Loading
Loading