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

chore: add Is Emulator support #190

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Next

- chore: add Is Emulator support ([#190](https://github.com/PostHog/posthog-ios/pull/190))

## 3.11.0 - 2024-09-11

- chore: add personProfiles support ([#187](https://github.com/PostHog/posthog-ios/pull/187))
Expand Down
6 changes: 6 additions & 0 deletions PostHog/PostHogContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ class PostHogContext {
properties["$device_manufacturer"] = "Apple"
properties["$device_model"] = platform()

#if targetEnvironment(simulator)
properties["$is_emulator"] = true
#else
properties["$is_emulator"] = false
#endif

#if os(iOS) || os(tvOS)
let device = UIDevice.current
// use https://github.com/devicekit/DeviceKit
Expand Down
1 change: 1 addition & 0 deletions PostHog/PostHogSDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ let maxRetryDelay = 30.0
)
}

@discardableResult
private func requirePersonProcessing() -> Bool {
if config.personProfiles == .never {
hedgeLog("personProfiles is set to `never`. This call will be ignored.")
Expand Down
1 change: 1 addition & 0 deletions PostHogTests/PostHogContextTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class PostHogContextTest: QuickSpec {
expect(context["$app_version"] as? String) != nil
expect(context["$app_build"] as? String) != nil
expect(context["$app_namespace"] as? String) == "com.apple.dt.xctest.tool"
expect(context["$is_emulator"] as? Bool) != nil
#if os(iOS) || os(tvOS)
expect(context["$device_name"] as? String) != nil
expect(context["$os_name"] as? String) != nil
Expand Down
Loading