Please see the main PostHog docs.
Specifically, the iOS docs details.
PostHog iOS SDK
Home Page: https://posthog.com/docs/libraries/ios
License: MIT License
Please see the main PostHog docs.
Specifically, the iOS docs details.
Thanks for your great product.
I'm using PostHog package as a dependency of another package.
The other package has basic Swift tests that are run with swift test
command on CI.
With the PostHog dependency, I got an error because your package references UIKit. So I cannot test anymore my package.
Is it possible to split the PostHog package to have core classes in one target and UI classes in another?
Let me know if I can help more.
Regards, Benoit
Starting spring of 2024, Apple will be mandating the use of xcprivacy
file to be included by all the libraries.
The relevant Apple requirement/documentation is as follows:
https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api
Can you please provide timelines on when this would be resolved, as it will directly impact our AppStore submissions.
No response
Versions:
PostHog iOS: 1.4.0 from SPM
iOS: 12.5.4
iPhone: 5S
Crashes on launch when initialising PostHog.
Crashed: com.apple.main-thread
0 ??? 0x101e2a418 (Missing)
1 ??? 0x101e29a58 (Missing)
2 ??? 0x101e29a88 (Missing)
3 ??? 0x101dec8f8 (Missing)
4 ??? 0x101deca14 (Missing)
5 libdyld.dylib 0x21b6c4848 dyld_stub_binder + 60
6 ECHOES 0x101566194 -[PHGPayloadManager initWithPostHog:] + 2556484
7 ECHOES 0x101568674 -[PHGPostHog initWithConfiguration:] + 2565924
8 ECHOES 0x1015685a8 __37+[PHGPostHog setupWithConfiguration:]_block_invoke + 2565720
9 libdispatch.dylib 0x21b6b17d4 _dispatch_client_callout + 16
10 libdispatch.dylib 0x21b654eb8 _dispatch_once_callout + 28
11 ECHOES 0x101568578 +[PHGPostHog setupWithConfiguration:] + 2565672
12 ECHOES 0x100f94c14 specialized static AnalyticsManager.initializeAnalytics() + 16 (AnalyticsManager.swift:16)
13 ECHOES 0x100f9892c specialized AppDelegate.application(_:didFinishLaunchingWithOptions:) + 4306045228 (<compiler-generated>:4306045228)
14 ECHOES 0x100f97adc @objc AppDelegate.application(_:didFinishLaunchingWithOptions:) + 4306041564 (<compiler-generated>:4306041564)
15 UIKitCore 0x2484880f0 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 412
16 UIKitCore 0x248489854 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3352
17 UIKitCore 0x24848efe0 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1540
18 UIKitCore 0x247d522a4 __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 776
19 UIKitCore 0x247d5a83c +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 160
20 UIKitCore 0x247d51f28 -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 236
21 UIKitCore 0x247d52818 -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 1064
22 UIKitCore 0x247d50b64 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 744
23 UIKitCore 0x247d5082c -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 428
24 UIKitCore 0x247d5536c __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 220
25 UIKitCore 0x247d56150 _performActionsWithDelayForTransitionContext + 112
26 UIKitCore 0x247d55224 -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 244
27 UIKitCore 0x247d59f24 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 360
28 UIKitCore 0x24848d5e8 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 540
29 UIKitCore 0x248089e04 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 360
30 FrontBoardServices 0x21e5ef9fc -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 440
31 FrontBoardServices 0x21e5f940c __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 256
32 FrontBoardServices 0x21e5f8c14 __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 64
33 libdispatch.dylib 0x21b6b17d4 _dispatch_client_callout + 16
34 libdispatch.dylib 0x21b6565dc _dispatch_block_invoke_direct$VARIANT$mp + 224
35 FrontBoardServices 0x21e62a040 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40
36 FrontBoardServices 0x21e629cdc -[FBSSerialQueue _performNext] + 408
37 FrontBoardServices 0x21e62a294 -[FBSSerialQueue _performNextFromRunLoopSource] + 52
38 CoreFoundation 0x21bc04f1c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
39 CoreFoundation 0x21bc04e9c __CFRunLoopDoSource0 + 88
40 CoreFoundation 0x21bc04784 __CFRunLoopDoSources0 + 176
41 CoreFoundation 0x21bbff6c0 __CFRunLoopRun + 1004
42 CoreFoundation 0x21bbfefb4 CFRunLoopRunSpecific + 436
43 GraphicsServices 0x21de0079c GSEventRunModal + 104
44 UIKitCore 0x248490c38 UIApplicationMain + 212
45 ECHOES 0x100eb3828 main + 17 (AppDelegate.swift:17)
46 libdyld.dylib 0x21b6c28e0 start + 4
The current version of the SDK appears to be 2.0.0, but the string "1.3.0" is hard-coded in the SDK:
posthog-ios/PostHog/Classes/PHGPostHog.m
Lines 528 to 533 in 9ab4b60
This is reported in events as the $lib_version
property.
I'm using your SDK with Xcode 15.3, and I'm getting a warning about a static property not being concurrency-safe. Can you please update the SDK to make it Swift 6 compatible and fix the warning?
Here's the warning I'm getting in PostHogSDK.swift:54:
Class property 'shared' is not concurrency-safe because it is not either conforming to 'Sendable' or isolated to a global actor; this is an error in Swift 6
Thanks!
No response
Steps to reproduce:
posthog-ios
lib v.2.0.0
ViewController
and invoke testPostHogReset()
method in ViewController
's viewDidLoad
method (updating the value of apiKey
in setupPostHog
method)var client: PHGPostHog?
func testPostHogReset() {
setupPostHog()
identifyAndGroup()
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
self.client?.reset()
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
self.identifyAndGroup()
}
}
}
func setupPostHog() {
let apiKey = "..."
let hostString = "https://eu.posthog.com"
let configuration = PHGPostHogConfiguration(apiKey: apiKey, host: hostString)
configuration.captureApplicationLifecycleEvents = true
PHGPostHog.setup(with: configuration)
client = PHGPostHog.shared()
}
func identifyAndGroup() {
client?.identify("test_user")
client?.group("project", groupKey: "Test Project")
}
3.1.0
Trigger any event.
Wait for send to the /batch
endpoint.
Expected HTTP 2xx code after send.
Expected to see some events in Activity feed.
No logs are shown in the Xcode console.
No events are shown in Activity feed on website.
Debug with breakpoint indicates a response status code is always 400
(PostHogApi.batch()
) without any error.
SDK is initialised with:
let configuration = PostHogConfig(apiKey: postHogKey, host: "https://eu.posthog.com")
configuration.captureApplicationLifecycleEvents = false
configuration.captureScreenViews = false
configuration.debug = true
PostHogSDK.shared.setup(configuration)
I want to be able to react to when certain functionality concludes. For example, I want to be able to trigger something after a capture call or a feature flag is evaluated.
When importing PostHog
via Swift Package Manager I end up with an error.
Could not build Objective-C module 'PostHog'
Simply create a new Xcode project using Swift and import PostHog from "https://github.com/PostHog/posthog-ios".
I'm not sure if I'm missing something basic or the package is not compatible with SPM. All ideas are appreciated!
Due to usage of PHGReachability
/ SystemConfiguration.h
this library is incompatible with WatchOS. Other analytics collection libraries like Segment are compatible.
It would be great if feature flag support is available in iOS SDK.
Android already supports the $session_id
iOS not yet, this will be done with iOS session recording
Relates to #32 but this PR is table since the SDK was rewritten.
Feature Flag payloads are returned as a string and the expectation is that we JSON parse the value into the primitive type (see posthog-js.
Our tests incorrectly assume the response type is pre-parsed (although one could argue that would be the expectation I would have of the API - that's a separate discussion...)
Hi,
I got an exception while using PHGPostHog.shared()?.receivedRemoteNotification(userInfo)
.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PHGPostHogIntegration receivedRemoteNotification:]: unrecognized selector sent to instance'
terminating with uncaught exception of type NSException
It seems that receivedRemoteNotification
is not yet implemented.
I'm using PostHog SDK 2.0.3 through SPM.
Am I doing something wrong?
Thanks for your help.
Benoit
Can't install on a macOS target in a multi-paltform app (iOS+macOS).
It seems that capturing screen of selected controller in UITabbarController is not triggering. Do i have to capture them manually?
https://posthog.com/docs/feature-flags/common-questions#4-user-or-group-properties-may-not-have-been-ingested-yet
https://posthog.com/docs/feature-flags/adding-feature-flag-code?tab=Web#overriding-server-properties
PostHog/posthog-js-lite#235 (comment)
Ideally, this is called automatically when identify
is called as well.
reset
should clear this metadata.
Methods:
setPersonPropertiesForFlags
setGroupPropertiesForFlags
resetGroupPropertiesForFlags
resetPersonPropertiesForFlags
Hi,
Unable to reopen #109. We are still facing this issue, as we are using SPM and the privacy file did not make it through to our archive. I think you need to add the privacy file to the package.swift
file as follows.
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "PostHog",
path: "PostHog",
resources: [
.copy("PrivacyInfo.xcprivacy")
]
),
.testTarget(
name: "PostHogTests",
dependencies: [
"PostHog",
"Quick",
"Nimble",
"OHHTTPStubs",
.product(name: "OHHTTPStubsSwift", package: "OHHTTPStubs"),
],
path: "PostHogTests"
),
]
Please test before closing as follows:
To generate a privacy report, Archive the app which consumes the library using SPM, and then in Xcode -> Window -> Organizer -> Under Archives, right click on the archive -> Generate Privacy Report.
I try to configure SDK and have some troubles (is not a problem), I go to enable SDK logs to check what is going wrong but logs are not work, after this I have open source code and found this interesting think.
which mean you cannot get logs without setup SDK but for setup SDK when you are have some issue you are need logs which need configured SDK
@objc public func debug(_ enabled: Bool = true) {
if !isEnabled() {
return
}
toggleHedgeLog(enabled)
}
Please give possibility to enable logs without SDK configuration
@objc public func debug(_ enabled: Bool = true) {
toggleHedgeLog(enabled)
}
https://posthog.com/docs/feature-flags/bootstrapping
Inspire from RN implementation https://github.com/PostHog/posthog-js-lite/blob/f00594a1e9b08c0d4785139a0df98dae31c16c34/posthog-core/src/types.ts#L22-L28
This should go somewhere here
posthog-ios/PostHog/Replay/URLSessionInterceptor.swift
Lines 108 to 117 in b0c6c18
Some builtin PII scrubbing is necessary, take a look at the JS SDK.
It would be great to have a Package.swift file for PostHog, so it could be easily installed.
Firebase crashlytics has been flagging some crashes caused by the PHFileStorage.m file, somewhere around the -[PHGFileStorage setJSON:forkey:]
.
This is causing issues for users of our app.
Kindly take a look at this.
Thank you.
I am getting an Exception when loading the lib.
It's caused when invoking PHGPostHog.setup(with: configuration)
.
This happens no matter whether I enable captureApplicationLifecycleEvents
or not (since it's related to applicationDidFinishLaunching
.
2020-05-13 17:02:33.310694+0100 ECHOES[5617:2930869] -[PHGPostHogIntegration applicationDidFinishLaunching:]: unrecognized selector sent to instance 0x600002614600
2020-05-13 17:02:33.312232+0100 ECHOES[5617:2930869] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PHGPostHogIntegration applicationDidFinishLaunching:]: unrecognized selector sent to instance 0x600002614600'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23e39f0e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff50ad79b2 objc_exception_throw + 48
2 CoreFoundation 0x00007fff23e5ac34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00007fff23e3e6b6 ___forwarding___ + 838
4 CoreFoundation 0x00007fff23e40bf8 _CF_forwarding_prep_0 + 120
5 CoreFoundation 0x00007fff23e40e8c __invoking___ + 140
6 CoreFoundation 0x00007fff23e3e071 -[NSInvocation invoke] + 321
7 CoreFoundation 0x00007fff23e3e344 -[NSInvocation invokeWithTarget:] + 68
8 PostHog 0x000000010ac26512 -[PHGPayloadManager invokeIntegration:key:selector:arguments:options:] + 290
9 PostHog 0x000000010ac263b5 -[PHGPayloadManager forwardSelector:arguments:options:] + 165
10 PostHog 0x000000010ac26fa7 __56-[PHGPayloadManager callWithSelector:arguments:options:]_block_invoke + 135
11 PostHog 0x000000010ac330a1 __phg_dispatch_specific_block_invoke + 49
12 libdispatch.dylib 0x000000010d52bf11 _dispatch_call_block_and_release + 12
13 libdispatch.dylib 0x000000010d52ce8e _dispatch_client_callout + 8
14 libdispatch.dylib 0x000000010d5336fd _dispatch_lane_serial_drain + 788
15 libdispatch.dylib 0x000000010d53428f _dispatch_lane_invoke + 422
16 libdispatch.dylib 0x000000010d53fb65 _dispatch_workloop_worker_thread + 719
17 libsystem_pthread.dylib 0x00007fff51b37a3d _pthread_wqthread + 290
18 libsystem_pthread.dylib 0x00007fff51b36b77 start_wqthread + 15
)
This means that it'll be automatically masked if maskAllImages
is set to true
, even if the maskAllTextInputs
is disabled
Today recording starts and ends automatically.
We need to give the option to either choose which screens have to be recorded/ignored, or the ability to start/pause dynamically as well.
Relates to PostHog/posthog-android#113
Sets a property if the running version was installed via testflight or its sideloaded.
See https://posthog.com/docs/cdp/geoip-enrichment#how-do-i-skip-events-without-applying-geoip-enrichment
The same applies to Mobile if you don't want the server to infer the user's IP addresses.
If disableGeoip
is enabled, set$geoip_disable: true
to the props.
Another option is to disable via project config https://us.posthog.com/project/$projectId/settings/project#datacapture
Or
https://us.posthog.com/project/$projectId/pipeline/transformations
GeoIP
You don't support Codable when using capture
for events.
Getting error: key does not conform to NSCoding and cannot be serialized for delivery.
Allow Codable
Thanks! Looking forward to reply.
With the latest 2.0.3
version it seems like when you call the method to initialize the library if this is not called on the main thread, the console is filling with tons of errors.
As the title suggests, the method that is causing these errors is
PHGPostHog.setup(with: configuration)
Main Thread Checker: UI API called on a background thread: -[UIApplication connectedScenes]
PID: 43007, TID: 2562761, Thread name: (none), Queue name: SerialQueue, QoS: 25
Backtrace:
4 XXXXX 0x00000001050f994c -[PHGApplicationUtils windows] + 208
5 XXXXX 0x00000001050fd150 -[PHGPostHogIntegration staticContext] + 1256
6 XXXXX 0x00000001050fc974 -[PHGPostHogIntegration initWithPostHog:httpClient:fileStorage:userDefaultsStorage:] + 560
7 XXXXX 0x00000001050f0634 -[PHGPayloadManager initWithPostHog:] + 1020
8 XXXXX 0x00000001050f4110 -[PHGPostHog initWithConfiguration:] + 352
9 XXXXX 0x00000001050f3f90 __37+[PHGPostHog setupWithConfiguration:]_block_invoke + 56
10 libdispatch.dylib 0x00000001092927c0 _dispatch_client_callout + 20
11 libdispatch.dylib 0x0000000109294364 _dispatch_once_callout + 136
12 XXXXX 0x00000001050f3f1c +[PHGPostHog setupWithConfiguration:] + 184
...
...
...
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIScene delegate]
PID: 43007, TID: 2562761, Thread name: (none), Queue name: SerialQueue, QoS: 25
Backtrace:
4 XXXXX 0x00000001050f9a80 -[PHGApplicationUtils windows] + 516
5 XXXXX 0x00000001050fd150 -[PHGPostHogIntegration staticContext] + 1256
6 XXXXX 0x00000001050fc974 -[PHGPostHogIntegration initWithPostHog:httpClient:fileStorage:userDefaultsStorage:] + 560
7 XXXXX 0x00000001050f0634 -[PHGPayloadManager initWithPostHog:] + 1020
8 XXXXX 0x00000001050f4110 -[PHGPostHog initWithConfiguration:] + 352
9 XXXXX 0x00000001050f3f90 __37+[PHGPostHog setupWithConfiguration:]_block_invoke + 56
10 libdispatch.dylib 0x00000001092927c0 _dispatch_client_callout + 20
11 libdispatch.dylib 0x0000000109294364 _dispatch_once_callout + 136
12 XXXXX 0x00000001050f3f1c +[PHGPostHog setupWithConfiguration:] + 184
...
...
...
It seems like the setup method is now calling some UIApplication's method.
Since this behaviour is not indicated anywhere nor in the internal or external documentation, I'm actually using this API on a parallel Thread and this is causing the errors.
Is this side effect to be considered a new requirement to use your library, or is it actually a bug?
Otherwise, I have to rethink all the way I'm initiating the PostHog component
Got a reproducible error with 1.0.2 when entering foreground after having backgrounded the app. Seems to be a similar problem with the selectors as the previous didFinishLaunching
crash.
Here is the crashlog:
Last Exception Backtrace:
0 CoreFoundation 0x1bca52a48 __exceptionPreprocess + 220 (NSException.m:199)
1 libobjc.A.dylib 0x1bc779fa4 objc_exception_throw + 56 (objc-exception.mm:565)
2 CoreFoundation 0x1bc9565a8 -[NSObject(NSObject) doesNotRecognizeSelector:] + 140 (NSObject.m:144)
3 CoreFoundation 0x1bca56af4 ___forwarding___ + 1324 (NSForwarding.m:3514)
4 CoreFoundation 0x1bca58a7c _CF_forwarding_prep_0 + 92
5 PostHog 0x107f24cd8 -[PHGPostHogIntegration staticContext] + 1116 (PHGPostHogIntegration.m:51)
6 PostHog 0x107f25024 -[PHGPostHogIntegration updateStaticContext] + 28 (PHGPostHogIntegration.m:198)
7 CoreFoundation 0x1bc9ae288 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20 (CFNotificationCenter.c:787)
8 CoreFoundation 0x1bc9ae2d0 ___CFXRegistrationPost1_block_invoke + 64 (CFNotificationCenter.c:175)
9 CoreFoundation 0x1bc9ad630 _CFXRegistrationPost1 + 368 (CFNotificationCenter.c:198)
10 CoreFoundation 0x1bc9ad2e8 ___CFXNotificationPost_block_invoke + 104 (CFNotificationCenter.c:1371)
11 CoreFoundation 0x1bc92959c -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1416 (CFXNotificationRegistrarOld.m:168)
12 CoreFoundation 0x1bc9acc38 _CFXNotificationPost + 1244 (CFNotificationCenter.c:1359)
13 Foundation 0x1bcd090c8 -[NSNotificationCenter postNotificationName:object:userInfo:] + 60 (NSNotification.m:576)
14 UIKitCore 0x1c0aee2a4 -[UIApplication _sendWillEnterForegroundCallbacks] + 280 (UIApplication.m:10519)
…
On Android we can do:
propertiesSanitizer =
PostHogPropertiesSanitizer { properties ->
properties.apply {
remove("\$device_name")
}
}
This has to be implemented on iOS yet.
https://posthog.com/questions/how-to-filter-out-usage-from-i-os-android-simulators-emulators
Taxonomy added.
Similar to getsentry/sentry-cocoa#2741, there is an issue when using PostHog in a SwiftUI app. Steps to reproduce:
App
struct with the following code:PHGPostHog(configuration: .init(apiKey: ""))
The fix is the same as Sentry implemented and stop using the now deprecated UIScreen.main
. The simplest solution if there isn't access to an actual view is to do this via UIApplication's windows
property.
$ flutter build macos
warning: no rule to process file 'macos/Pods/PostHog/PostHog/Resources/PrivacyInfo.xcprivacy' of type 'text.xml' for architecture 'arm64' (in target 'PostHog' from project 'Pods')
posthog_flutter: ^4.0.0
[✓] Flutter (Channel stable, 3.22.0, on macOS 14.5 23F79 darwin-x64, locale en-GB)
• Flutter version 3.22.0 on channel stable at /Users/fractale/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5dcb86f68f (11 days ago), 2024-05-09 07:39:20 -0500
• Engine revision f6344b75dc
• Dart version 3.4.0
• DevTools version 2.34.3
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/fractale/Library/Android/sdk
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
[✓] VS Code (version 1.89.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.88.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS 14.5 23F79 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.208
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category.
No response
3.6.1
When using the provided SwiftUI example of the SwiftFortuneWheel package with PostHog integrated and session replay with screenshot mode turned on then the example project behaves strangely. When turning off screenshot mode it works as expected.
https://github.com/sh-khashimov/SwiftFortuneWheel
let postHogApiKey = "xxxxxxxxxxxxxx"
let postHogHost = "https://eu.i.posthog.com"
let config = PostHogConfig(apiKey: postHogApiKey, host: postHogHost)
config.sessionReplay = true
config.sessionReplayConfig.maskAllImages = false
config.sessionReplayConfig.maskAllTextInputs = false
config.sessionReplayConfig.screenshotMode = true
PostHogSDK.shared.setup(config)
The wheel should spin smoothly and come to an end.
The wheel stops abruptly and the console spams some warnings. I guess some constant SwiftUI redrawing is causing the issue.
Hey 👋 are you new around here? Feel free to contribute to this issue! It is quite straightforward since there's a clear spec - no need to think about what's the best solution.
However, it isn't a teeny tiny task, which is why we're offering a $100 gift card for PostHog merch for a merged PR that implements this. You'll also be listed as a contributor on our main repo's README (4.3k stars) and get a digital contributor card.
PostHog provides support for feature flags. These allow turning functionality on and off based on a response from the PostHog API.
For a client-side library like this one, we'd need an implementation similar to that of posthog-js
.
Here's an overview of what implementing this entails:
A mechanism to send a POST
request to /decide/
with the following data:
// Content-Type: application/json
{
token: <posthog_project_api_key>,
distinct_id: <user_distinct_id>
}
The response will contain an array/list at response['featureFlags']
with the flags that are enabled for this user. The distinct ID should be already available from existing methods implemented in this lib.
The response should be cached and refreshed periodically.
A method isFeatureEnabled
This method takes a feature flag key as an input and returns a boolean indicating if the given flag is on or off for the user based on the response from above.
A method reloadFeatureFlags
This forces a refresh of the cache by calling /decide/
again.
A method onFeatureFlagsLoaded
Every time the flags are reloaded, this should be called as a callback.
Feel free to ask me anything about this! I'm also reachable on the PostHog Slack.
It is not possible to use posthog in an App Extension (Notification Service).
Build Fails here
With:
UIViewController.swift:34:44 'shared' is unavailable in application extensions for iOS: Use view controller based solutions where appropriate instead.
No response
Relates to PostHog/posthog-android#141
3.2.4
PostHogSDK.shared.reset()
Only delete PostHog related data
PostHog wipes the entire directory!! Shame on you guys for doing this, we have valuable data in this directory.
posthog-ios/PostHog/PostHogStorage.swift
Lines 17 to 20 in a12c341
When installing posthog via carthage I am getting the following build error:
note: Building targets in dependency order
/Carthage/Checkouts/posthog-ios/Pods/Target Support Files/Pods-PostHog/Pods-PostHog.release.xcconfig:1:1: error: unable to open configuration settings file
warning: no rule to process file '/Users/rickharrison/Development/narwhal2/Carthage/Checkouts/posthog-ios/CHANGELOG.md' of type 'net.daringfireball.markdown' for architecture 'arm64' (in target 'PostHog' from project 'PostHog')
** ARCHIVE FAILED **
Xcode version: 14.3.1
macOS: 13.4.1
Any ideas on how to install this using carthage?
With Apple further restricting apps that track users in iOS 14, I'd like to see a version of this framework that removed any references to AdSupport or the IDFA (identifier for advertisers). The "upstream" repo that this one is based on has done this for their current 4.x release (see this pull request), allowing apps that want to collect the IDFA to provide it, rather than having the framework itself make those calls into AdSupport.
How do PostHog iOS users feel about such a change? I'm happy to make the changes and create a PR if there is interest.
iOS unrecognized selector sent to instance
Currently there is no information about PostHog using SPM?
Are there plans updating project for adding this functionality?
Hey there,
Just wanted to share some AppStore results of ours with IDFA. Our app is catered towards kids and IDFA tracking is not allowed according to the security guidelines. We used a recent version 1.1.0
of posthog-ios
in an AppStore submission. The app was rejected because of this class being used in code even as a static string constant. Since this string is used to dynamically initialize an instance of ASIdentifierManager
class, it triggers a rejection from Apple.
This happens even though AdSupport
framework is not directly referenced or imported. 100% sure we didn't have AdSupport.framework
file in the binary sent to Apple. Reviewed it with https://github.com/MobSF/Mobile-Security-Framework-MobSF
We ended up applying a patch to remove the constant and set the default value for ad tracking to false. After this, a new version of the app was approved.
Hope this helps! Cheers!
See note https://posthog.com/docs/session-replay/ios
.accessibilityIdentifier("btnLogin")
when reading the accessibilityIdentifier
property, it always returns nil
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.