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: Extend app launch handler to macCatalyst and visionOS #2033

Merged
merged 1 commit into from
Sep 3, 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [FIX] Propagate global Tracer tags to OpenTelemetry span attributes. See [#2000][]
- [FEATURE] Add Logs event mapper to ObjC API. See [#2008][]
- [IMPROVEMENT] Send retry information with network requests (eg. retry_count, last_failure_status and idempotency key). See [#1991][]
- [IMPROVEMENT] Enable app launch time on mac, macCatalyst and visionOS. See [#1888][] (Thanks [@Hengyu][])
- [FIX] Ignore network reachability on watchOS . See [#2005][] (Thanks [@jfiser-paylocity][])

# 2.16.0 / 20-08-2024
Expand Down Expand Up @@ -755,6 +756,7 @@ Release `2.0` introduces breaking changes. Follow the [Migration Guide](MIGRATIO
[#1988]: https://github.com/DataDog/dd-sdk-ios/pull/1988
[#2000]: https://github.com/DataDog/dd-sdk-ios/pull/2000
[#1991]: https://github.com/DataDog/dd-sdk-ios/pull/1991
[#1888]: https://github.com/DataDog/dd-sdk-ios/pull/1888
[#2008]: https://github.com/DataDog/dd-sdk-ios/pull/2008
[#2005]: https://github.com/DataDog/dd-sdk-ios/pull/2005
[#1998]: https://github.com/DataDog/dd-sdk-ios/pull/1998
Expand Down Expand Up @@ -791,3 +793,4 @@ Release `2.0` introduces breaking changes. Follow the [Migration Guide](MIGRATIO
[@alexfanatics]: https://github.com/alexfanatics
[@changm4n]: https://github.com/changm4n
[@jfiser-paylocity]: https://github.com/jfiser-paylocity
[@Hengyu]: https://github.com/Hengyu
16 changes: 13 additions & 3 deletions DatadogCore/Private/ObjcAppLaunchHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

#import "ObjcAppLaunchHandler.h"

#if TARGET_OS_IOS || TARGET_OS_TV
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_MACCATALYST || TARGET_OS_VISION
#import <UIKit/UIKit.h>
#elif TARGET_OS_OSX
#import <AppKit/AppKit.h>
#endif

// A very long application launch time is most-likely the result of a pre-warmed process.
Expand Down Expand Up @@ -42,9 +44,17 @@ + (void)load {
// This is called at the `DatadogPrivate` load time, keep the work minimal
_shared = [[self alloc] initWithProcessInfo:NSProcessInfo.processInfo
loadTime:CFAbsoluteTimeGetCurrent()];
#if TARGET_OS_IOS || TARGET_OS_TV

NSString *notificationName;
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_MACCATALYST || TARGET_OS_VISION
notificationName = UIApplicationDidBecomeActiveNotification;
#elif TARGET_OS_OSX
notificationName = NSApplicationDidBecomeActiveNotification;
#endif

#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_MACCATALYST || TARGET_OS_VISION || TARGET_OS_OSX
NSNotificationCenter * __weak center = NSNotificationCenter.defaultCenter;
id __block __unused token = [center addObserverForName:UIApplicationDidBecomeActiveNotification
id __block __unused token = [center addObserverForName:notificationName
object:nil
queue:NSOperationQueue.mainQueue
usingBlock:^(NSNotification *_){
Expand Down