Skip to content

Commit

Permalink
chore: add Is Emulator support (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto authored Sep 11, 2024
1 parent 991c436 commit dce58bf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
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

0 comments on commit dce58bf

Please sign in to comment.