Skip to content

Commit

Permalink
feat: 合并 LaunchMonitor、UIMonitor
Browse files Browse the repository at this point in the history
  • Loading branch information
YoloMao committed Oct 25, 2022
1 parent 57c775e commit b60ed03
Show file tree
Hide file tree
Showing 22 changed files with 23 additions and 202 deletions.
12 changes: 0 additions & 12 deletions Core/GrowingAPM+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@
#import "GrowingAPM.h"
#import "GrowingAPMMonitor.h"

#if __has_include(<GrowingAPMLaunchMonitor/GrowingAPMLaunchMonitor.h>)
#ifndef GROWING_APM_LAUNCH
#define GROWING_APM_LAUNCH
#endif
#elif __has_include("GrowingAPMLaunchMonitor.h")
#ifndef GROWING_APM_LAUNCH
#define GROWING_APM_LAUNCH
#define GROWING_APM_LAUNCH_SOURCE
#endif
#endif

#if __has_include(<GrowingAPMUIMonitor/GrowingAPMUIMonitor.h>)
#ifndef GROWING_APM_UI
#define GROWING_APM_UI
Expand Down Expand Up @@ -71,7 +60,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface GrowingAPM (Private)

@property (nonatomic, strong, readonly) id <GrowingAPMMonitor> crashMonitor;
@property (nonatomic, strong, readonly) id <GrowingAPMMonitor> launchMonitor;
@property (nonatomic, strong, readonly) id <GrowingAPMMonitor> pageLoadMonitor;
@property (nonatomic, strong, readonly) id <GrowingAPMMonitor> networkMonitor;

Expand Down
37 changes: 4 additions & 33 deletions Core/GrowingAPM.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,9 @@
#import "GrowingViewControllerLifecycle.h"
#import "GrowingAppLifecycle.h"

// -------- LAUNCH MONITOR --------
#ifdef GROWING_APM_LAUNCH
#import "GrowingTimeUtil.h"

#ifdef GROWING_APM_LAUNCH_SOURCE
#import "GrowingAPMLaunchMonitor.h"
#else
#import <GrowingAPMLaunchMonitor/GrowingAPMLaunchMonitor.h>
#endif

#endif
// -------- LAUNCH MONITOR --------

// -------- UI MONITOR --------
#ifdef GROWING_APM_UI
#import "GrowingTimeUtil.h"

#ifdef GROWING_APM_UI_SOURCE
#import "GrowingAPMUIMonitor.h"
Expand Down Expand Up @@ -71,11 +59,10 @@ @interface GrowingAPM ()

@property (nonatomic, copy) GrowingAPMConfig *config;
@property (nonatomic, strong, readwrite) id <GrowingAPMMonitor> crashMonitor;
@property (nonatomic, strong, readwrite) id <GrowingAPMMonitor> launchMonitor;
@property (nonatomic, strong, readwrite) id <GrowingAPMMonitor> pageLoadMonitor;
@property (nonatomic, strong, readwrite) id <GrowingAPMMonitor> networkMonitor;

#ifdef GROWING_APM_LAUNCH
#ifdef GROWING_APM_UI
@property (nonatomic, assign) double coldRebootBeginTime;
#endif

Expand Down Expand Up @@ -108,18 +95,10 @@ + (void)startWithConfig:(GrowingAPMConfig *)config {
}
apm.config = config;

if (config.monitors & GrowingAPMMonitorsLaunch) {
#ifdef GROWING_APM_LAUNCH
GrowingAPMLaunchMonitor *monitor = [GrowingAPMLaunchMonitor sharedInstance];
monitor.coldRebootBeginTime = apm.coldRebootBeginTime;
[monitor startMonitor];
apm.launchMonitor = (id <GrowingAPMMonitor>)monitor;
#endif
}

if (config.monitors & GrowingAPMMonitorsUserInterface) {
#ifdef GROWING_APM_UI
GrowingAPMUIMonitor *monitor = [GrowingAPMUIMonitor sharedInstance];
monitor.coldRebootBeginTime = apm.coldRebootBeginTime;
[monitor startMonitor];
apm.pageLoadMonitor = (id <GrowingAPMMonitor>)monitor;
#endif
Expand All @@ -141,19 +120,11 @@ + (void)startWithConfig:(GrowingAPMConfig *)config {
}

+ (void)swizzle:(GrowingAPMMonitors)monitors {
if (monitors & GrowingAPMMonitorsLaunch) {
#ifdef GROWING_APM_LAUNCH
[GrowingViewControllerLifecycle setup];
[GrowingAppLifecycle setup];
[GrowingAPMLaunchMonitor setup];
GrowingAPM.sharedInstance.coldRebootBeginTime = GrowingTimeUtil.currentSystemTimeMillis;
#endif
}

if (monitors & GrowingAPMMonitorsUserInterface) {
#ifdef GROWING_APM_UI
[GrowingAppLifecycle setup];
[GrowingAPMUIMonitor setup];
GrowingAPM.sharedInstance.coldRebootBeginTime = GrowingTimeUtil.currentSystemTimeMillis;
#endif
}

Expand Down
7 changes: 3 additions & 4 deletions Core/GrowingAPMConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@
NS_ASSUME_NONNULL_BEGIN

typedef NS_OPTIONS(NSUInteger, GrowingAPMMonitors) {
GrowingAPMMonitorsLaunch = 1 << 0,
GrowingAPMMonitorsUserInterface = 1 << 1,
GrowingAPMMonitorsCrash = 1 << 2,
GrowingAPMMonitorsNetwork = 1 << 3
GrowingAPMMonitorsUserInterface = 1 << 0,
GrowingAPMMonitorsCrash = 1 << 1,
GrowingAPMMonitorsNetwork = 1 << 2
};

@interface GrowingAPMConfig : NSObject <NSCopying>
Expand Down
14 changes: 7 additions & 7 deletions CrashMonitor/GrowingAPMCrashMonitor.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@
<array>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64_i386_x86_64-simulator</string>
<string>ios-arm64_armv7</string>
<key>LibraryPath</key>
<string>GrowingAPMCrashMonitor.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>i386</string>
<string>x86_64</string>
<string>armv7</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64_armv7</string>
<string>ios-arm64_i386_x86_64-simulator</string>
<key>LibraryPath</key>
<string>GrowingAPMCrashMonitor.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>armv7</string>
<string>i386</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand Down
Binary file not shown.
Binary file not shown.
9 changes: 2 additions & 7 deletions GrowingAPM.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'GrowingAPM'
s.version = '0.0.1'
s.version = '0.0.2'
s.summary = 'iOS SDK of GrowingIO.'
s.description = <<-DESC
GrowingAPM提供移动端性能采集分析功能,包括崩溃分析、启动分析、页面加载分析等。
Expand All @@ -15,7 +15,7 @@ GrowingAPM提供移动端性能采集分析功能,包括崩溃分析、启动
s.pod_target_xcconfig = { "OTHER_LDFLAGS" => '$(inherited) -ObjC'}

s.subspec 'Core' do |core|
core.dependency 'GrowingUtils/AutotrackerCore'
core.dependency 'GrowingUtils/TrackerCore'
core.source_files = 'Core/**/*.{h,m,mm,c,cpp}'
end

Expand All @@ -26,11 +26,6 @@ GrowingAPM提供移动端性能采集分析功能,包括崩溃分析、启动
monitor.dependency 'GrowingAPM/Core'
end

s.subspec 'LaunchMonitor' do |monitor|
monitor.vendored_framework = "LaunchMonitor/GrowingAPMLaunchMonitor.xcframework"
monitor.dependency 'GrowingAPM/Core'
end

s.subspec 'UIMonitor' do |monitor|
monitor.vendored_framework = "UIMonitor/GrowingAPMUIMonitor.xcframework"
monitor.dependency 'GrowingAPM/Core'
Expand Down
42 changes: 0 additions & 42 deletions LaunchMonitor/GrowingAPMLaunchMonitor.xcframework/Info.plist

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

7 changes: 1 addition & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ let package = Package(
dependencies: [
"GrowingAPMCrashMonitor",
"GrowingAPMUIMonitor",
"GrowingAPMLaunchMonitor",
.product(name: "GrowingUtilsAutotrackerCore", package: "GrowingUtils"),
.product(name: "GrowingUtilsTrackerCore", package: "GrowingUtils"),
],
path: "Core",
publicHeadersPath: ".",
Expand All @@ -71,9 +70,5 @@ let package = Package(
name: "GrowingAPMUIMonitor",
path: "UIMonitor/GrowingAPMUIMonitor.xcframework"
),
.binaryTarget(
name: "GrowingAPMLaunchMonitor",
path: "LaunchMonitor/GrowingAPMLaunchMonitor.xcframework"
),
]
)
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pod 'GrowingAPM'
```ruby
# 按照所需模块自由组合
pod 'GrowingAPM/UIMonitor'
pod 'GrowingAPM/LaunchMonitor'
pod 'GrowingAPM/CrashMonitor'
# ...
```
Expand All @@ -37,7 +36,7 @@ pod 'GrowingAPM/CrashMonitor'
```objc
int main(int argc, char * argv[]) {
// GrowingAPM Swizzle
[GrowingAPM swizzle:GrowingAPMMonitorsCrash | GrowingAPMMonitorsLaunch | GrowingAPMMonitorsUserInterface];
[GrowingAPM swizzle:GrowingAPMMonitorsCrash | GrowingAPMMonitorsUserInterface];
NSString * appDelegateClassName;
@autoreleasepool {
// Setup code that might create autoreleased objects goes here.
Expand All @@ -53,7 +52,7 @@ int main(int argc, char * argv[]) {
// 添加 GrowingAPM 初始化配置
GrowingAPMConfig *config = GrowingAPMConfig.config;
// 根据您需要的监控类型
config.monitors = GrowingAPMMonitorsCrash | GrowingAPMMonitorsLaunch | GrowingAPMMonitorsUserInterface;
config.monitors = GrowingAPMMonitorsCrash | GrowingAPMMonitorsUserInterface;
// 初始化 GrowingAPM
[GrowingAPM startWithConfig:config];
```
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@

NS_ASSUME_NONNULL_BEGIN

typedef void(^GrowingAPMUIMonitorBlock)(NSString *pageName, double loadDuration);
typedef void(^GrowingAPMUIMonitorBlock)(NSString *pageName, double loadDuration, double rebootTime, BOOL isWarm);

@interface GrowingAPMUIMonitor : NSObject

@property (nonatomic, copy) GrowingAPMUIMonitorBlock monitorBlock;
@property (nonatomic, assign) double coldRebootBeginTime;

+ (instancetype)sharedInstance;
+ (void)setup;
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@

NS_ASSUME_NONNULL_BEGIN

typedef void(^GrowingAPMUIMonitorBlock)(NSString *pageName, double loadDuration);
typedef void(^GrowingAPMUIMonitorBlock)(NSString *pageName, double loadDuration, double rebootTime, BOOL isWarm);

@interface GrowingAPMUIMonitor : NSObject

@property (nonatomic, copy) GrowingAPMUIMonitorBlock monitorBlock;
@property (nonatomic, assign) double coldRebootBeginTime;

+ (instancetype)sharedInstance;
+ (void)setup;
Expand Down

0 comments on commit b60ed03

Please sign in to comment.