Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[WEEX-620][iOS] pageName check and interaction code revert (#1539)
Browse files Browse the repository at this point in the history
* [iOS] before render,check pagename is nil or "",if yes, set pagename order  url -> vcname -> "unKnowSet"

* [iOS] revert interaction code (revert ignore countDown top10 view)
  • Loading branch information
lucky-chen authored and cxfeng1 committed Sep 20, 2018
1 parent 2b46ca7 commit 8041950
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 57 deletions.
22 changes: 19 additions & 3 deletions ios/sdk/WeexSDK/Sources/Model/WXComponent_performance.h
Original file line number Diff line number Diff line change
@@ -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
29 changes: 14 additions & 15 deletions ios/sdk/WeexSDK/Sources/Model/WXSDKInstance.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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]]) {
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
{
Expand All @@ -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);
Expand Down
20 changes: 1 addition & 19 deletions ios/sdk/WeexSDK/Sources/Model/WXSDKInstance_performance.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
#import "WXUtility.h"

@interface WXPerformance()
{
NSMutableArray<WXComponent*>* _mCountDownComponentList;
}
@property (nonatomic, assign) bool hasRecordFsRenderTimeByPosition;
@property (nonatomic, assign) double interactionAddCountRecord;
@end
Expand Down Expand Up @@ -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;
}

Expand Down
21 changes: 20 additions & 1 deletion ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.h
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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
68 changes: 49 additions & 19 deletions ios/sdk/WeexSDK/Sources/Performance/WXApmForInstance.m
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -93,6 +112,8 @@ @interface WXApmForInstance ()
BOOL _isEnd;
NSDictionary* _responseHeader;
BOOL _hasRecordInteractionTime;
BOOL _hasRecordDownLoadStart;
BOOL _hasRecordDownLoadEnd;
}

@property (nonatomic,strong) id<WXApmProtocol> apmProtocolInstance;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8041950

Please sign in to comment.