cxfeng1 closed pull request #1539: [WEEX-620][iOS] pageName check and 
render_error report modify
URL: https://github.com/apache/incubator-weex/pull/1539
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ios/sdk/WeexSDK/Sources/Model/WXComponent_performance.h 
b/ios/sdk/WeexSDK/Sources/Model/WXComponent_performance.h
index 042fd30a1d..17153ee160 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXComponent_performance.h
+++ b/ios/sdk/WeexSDK/Sources/Model/WXComponent_performance.h
@@ -1,10 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 #import "WXComponent.h"
 
 @interface WXComponent()
 
 @property (nonatomic,assign) bool hasAdd;
 
-
-@property (nonatomic,assign) long interactionTime;
-
 @end
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m 
b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
index 0a96e2d360..0ea6d59223 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
@@ -228,12 +228,25 @@ - (void)renderWithURL:(NSURL *)url
     [self renderWithURL:url options:nil data:nil];
 }
 
+- (void)_checkPageName
+{
+    if (nil == self.pageName || [self.pageName isEqualToString:@""]) {
+        self.pageName = [self.scriptURL isFileURL] ? 
self.scriptURL.path.lastPathComponent: self.scriptURL.absoluteString;
+    }
+    if (nil == self.pageName || [self.pageName isEqualToString:@""]) {
+        self.pageName = 
NSStringFromClass(self.viewController.class)?:@"unkonwPageCauseUnsetNameAndUrlAndVc";
+    }
+}
+
 - (void)renderWithURL:(NSURL *)url options:(NSDictionary *)options 
data:(id)data
 {
     if (!url) {
         WXLogError(@"Url must be passed if you use renderWithURL");
         return;
     }
+  
+    _scriptURL = url;
+    [self _checkPageName];
     [self.apmInstance startRecord:self.instanceId];
     self.apmInstance.isStartRender = YES;
     
@@ -251,7 +264,6 @@ - (void)renderView:(id)source options:(NSDictionary 
*)options data:(id)data
     
     self.needValidate = [[WXHandlerFactory 
handlerForProtocol:@protocol(WXValidateProtocol)] needValidate:self.scriptURL];
     
-    [self _setPageNameValue:nil];
     if ([source isKindOfClass:[NSString class]]) {
         [self _renderWithMainBundleString:source];
     } else if ([source isKindOfClass:[NSData class]]) {
@@ -343,6 +355,7 @@ - (void)_renderWithMainBundleString:(NSString 
*)mainBundleString
     }
 
     //some case , with out render (url)
+    [self _checkPageName];
     [self.apmInstance startRecord:self.instanceId];
     self.apmInstance.isStartRender = YES;
     
@@ -458,18 +471,6 @@ - 
(void)renderWithMainBundleString:(NSNotification*)notification {
     [self _renderWithMainBundleString:_mainBundleString];
 }
 
-- (void) _setPageNameValue:(NSURL*) url
-{
-    if (!self.pageName || [self.pageName isEqualToString:@""]) {
-        self.pageName = url.absoluteString;
-    }
-    if (nil == self.pageName && nil != self.viewController) {
-        self.pageName = NSStringFromClass(self.viewController.class);
-    }
-    if (nil == self.pageName) {
-        self.pageName = @"unSetPageNameOrUrl-checkByRenderWithRequest";
-    }
-}
 
 - (void)_renderWithRequest:(WXResourceRequest *)request options:(NSDictionary 
*)options data:(id)data;
 {
@@ -488,8 +489,6 @@ - (void)_renderWithRequest:(WXResourceRequest *)request 
options:(NSDictionary *)
     }
     _options = [newOptions copy];
   
-    [self _setPageNameValue:url];
-    
     request.userAgent = [WXUtility userAgent];
     
     WX_MONITOR_INSTANCE_PERF_START(WXPTJSDownload, self);
diff --git a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m 
b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m
index dc1987a41c..49da81345e 100644
--- a/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m
+++ b/ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m
@@ -29,9 +29,6 @@
 #import "WXUtility.h"
 
 @interface WXPerformance()
-{
-    NSMutableArray<WXComponent*>* _mCountDownComponentList;
-}
 @property (nonatomic, assign) bool hasRecordFsRenderTimeByPosition;
 @property (nonatomic, assign) double interactionAddCountRecord;
 @end
@@ -128,24 +125,9 @@ - (void) _handleRenderTime:(WXComponent*)targetComponent 
withModifyTime:(double)
         targetComponent.weexInstance.apmInstance.hasRecordFirstInterationView 
= YES;
         [targetComponent.weexInstance.apmInstance 
onStage:KEY_PAGE_STAGES_FIRST_INTERACTION_VIEW];
     }
-    self.lastRealInteractionTime = [WXUtility getUnixFixTimeMillis];
-    
-    targetComponent.interactionTime = self.lastRealInteractionTime ;
-    if (nil == _mCountDownComponentList) {
-        _mCountDownComponentList = [[NSMutableArray alloc] init];
-    }
-    if (_mCountDownComponentList.count <10) {
-        [_mCountDownComponentList addObject:targetComponent];
-        return;
-    }
-    [_mCountDownComponentList addObject:targetComponent];
-    WXComponent* preComponent = [_mCountDownComponentList objectAtIndex:0];
-    [_mCountDownComponentList removeObjectAtIndex:0];
-    
-    [targetComponent.weexInstance.apmInstance 
onStageWithTime:KEY_PAGE_STAGES_INTERACTION time:preComponent.interactionTime];
+    [targetComponent.weexInstance.apmInstance 
onStage:KEY_PAGE_STAGES_INTERACTION];
     self.interactionLimitAddOpCount++;
     self.interactionAddCount = self.interactionAddCountRecord;
-    diff = modifyTime - self.renderTimeOrigin;
     self.interactionTime = self.interactionTime < diff ? diff 
:self.interactionTime;
 }
 
diff --git a/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h 
b/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h
index c1a15610c9..e92bab0306 100644
--- a/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h
+++ b/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 #import <Foundation/Foundation.h>
 #import "WXJSExceptionInfo.h"
 
@@ -120,6 +139,6 @@ extern NSString* const VALUE_ERROR_CODE_DEFAULT;
 - (void) recordErrorMsg:(WXJSExceptionInfo *)exception;
 - (NSDictionary<NSString*,NSNumber*>*) stageDic;
 
-#pragma templateinfo
+#pragma mark templateinfo
 - (NSString*) templateInfo;
 @end
diff --git a/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m 
b/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
index 5959143e59..170e03347f 100644
--- a/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
+++ b/ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 #import "WXApmForInstance.h"
 #import "WXApmProtocol.h"
 #import "WXHandlerFactory.h"
@@ -93,6 +112,8 @@ @interface WXApmForInstance ()
     BOOL _isEnd;
     NSDictionary* _responseHeader;
     BOOL _hasRecordInteractionTime;
+    BOOL _hasRecordDownLoadStart;
+    BOOL _hasRecordDownLoadEnd;
 }
 
 @property (nonatomic,strong) id<WXApmProtocol> apmProtocolInstance;
@@ -142,6 +163,19 @@ - (void) onStageWithTime:(NSString*)name 
time:(long)unixTime
     if (nil == _apmProtocolInstance || _isEnd) {
         return;
     }
+    if ([KEY_PAGE_STAGES_DOWN_BUNDLE_START isEqualToString:name]) {
+        if (_hasRecordDownLoadStart) {
+            return;
+        }
+        _hasRecordDownLoadStart = YES;
+    }
+    if ([KEY_PAGE_STAGES_DOWN_BUNDLE_END isEqualToString:name]) {
+        if (_hasRecordDownLoadEnd) {
+            return;
+        }
+        _hasRecordDownLoadEnd = YES;
+    }
+    
     if ([KEY_PAGE_STAGES_INTERACTION isEqualToString:name]) {
         _hasRecordInteractionTime = YES;
     }
@@ -175,30 +209,26 @@ - (void) startRecord:(NSString*) instanceId
     if (nil == _apmProtocolInstance || _isRecord) {
         return;
     }
-    _isRecord = YES;
-    _instanceId = instanceId;
-    
-    [self.apmProtocolInstance onStart:instanceId topic:WEEX_PAGE_TOPIC];
     WXSDKInstance* instance = [WXSDKManager instanceForID:instanceId];
-    if (nil != instance) {
-        for (NSString* key in instance.continerInfo) {
-            id value = [instance.continerInfo objectForKey:key];
-            [self setProperty:key withValue:value];
-        }
+    if (nil == instance) {
+        return;
     }
-    NSString* pageUrl = instance.scriptURL.absoluteString;
-    pageUrl = nil == pageUrl || [@"" 
isEqualToString:pageUrl]?@"unKnowUrl":pageUrl;
-    NSString* pageName = instance.pageName?:@"unKnowPageName";
-    NSString* vcName = @"unKnowVCName";
-    if (nil != instance.viewController) {
-        vcName = NSStringFromClass(instance.viewController.class);
+    
+    _isRecord = YES;
+
+    
+    [self.apmProtocolInstance onStart:instance.instanceId 
topic:WEEX_PAGE_TOPIC];
+    for (NSString* key in instance.continerInfo) {
+        id value = [instance.continerInfo objectForKey:key];
+        [self setProperty:key withValue:value];
     }
-    [self setProperty:KEY_PAGE_PROPERTIES_CONTAINER_NAME withValue:vcName];
+
+    [self setProperty:KEY_PAGE_PROPERTIES_CONTAINER_NAME 
withValue:NSStringFromClass(instance.viewController.class)?:@"unknownVCName"];
     [self setProperty:KEY_PAGE_PROPERTIES_INSTANCE_TYPE withValue:@"page"];
-    [self setProperty:KEY_PAGE_PROPERTIES_BIZ_ID withValue:pageName];
-    [self setProperty:KEY_PAGE_PROPERTIES_BUBDLE_URL withValue:pageUrl];
+    [self setProperty:KEY_PAGE_PROPERTIES_BIZ_ID withValue: 
instance.pageName?:@"unknownPageName"];
+    [self setProperty:KEY_PAGE_PROPERTIES_BUBDLE_URL 
withValue:instance.scriptURL.absoluteString?:@"unknownUrl"];
     [self setProperty:KEY_PROPERTIES_ERROR_CODE 
withValue:VALUE_ERROR_CODE_DEFAULT];
-    [self setProperty:KEY_PAGE_PROPERTIES_JSLIB_VERSION 
withValue:[WXAppConfiguration JSFrameworkVersion]];
+    [self setProperty:KEY_PAGE_PROPERTIES_JSLIB_VERSION 
withValue:[WXAppConfiguration 
JSFrameworkVersion]?:@"unknownJSFrameworkVersion"];
     [self setProperty:KEY_PAGE_PROPERTIES_WEEX_VERSION 
withValue:WX_SDK_VERSION];
     
     //for apm protocl


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to