Skip to content

Commit

Permalink
Release 4.5.17
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoyue committed Aug 29, 2023
1 parent 9c7159c commit 929b921
Show file tree
Hide file tree
Showing 11 changed files with 292 additions and 7 deletions.
13 changes: 10 additions & 3 deletions SensorsAnalyticsSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "SensorsAnalyticsSDK"
s.version = "4.5.16"
s.version = "4.5.17"
s.summary = "The official iOS SDK of Sensors Analytics."
s.homepage = "http://www.sensorsdata.cn"
s.source = { :git => 'https://github.com/sensorsdata/sa-sdk-ios.git', :tag => "v#{s.version}" }
Expand All @@ -21,7 +21,7 @@ Pod::Spec.new do |s|
s.subspec 'Base' do |b|
core_dir = "SensorsAnalyticsSDK/Core/"
b.source_files = core_dir + "**/*.{h,m}"
b.exclude_files = core_dir + "SAAlertController.h", core_dir + "SAAlertController.m"
b.exclude_files = core_dir + 'SAAlertController.{h,m}'
b.public_header_files = core_dir + "SensorsAnalyticsSDK.h", core_dir + "SensorsAnalyticsExtension.h", core_dir + "SensorsAnalyticsSDK+Public.h", core_dir + "SASecurityPolicy.h", core_dir + "SAConfigOptions.h", core_dir + "SAConstants.h", core_dir + "PropertyPlugin/SAPropertyPlugin.h"
b.ios.frameworks = 'CoreTelephony'
b.dependency 'SensorsAnalyticsSDK/__Store'
Expand Down Expand Up @@ -49,7 +49,7 @@ Pod::Spec.new do |s|
g.frameworks = 'UIKit'
end

# 可视化相关功能,包含可视化全埋点和点击图
# 可视化相关功能,包含可视化全埋点和点击图
s.subspec 'Visualized' do |f|
f.ios.deployment_target = '9.0'
f.dependency 'SensorsAnalyticsSDK/AutoTrack'
Expand Down Expand Up @@ -127,4 +127,11 @@ Pod::Spec.new do |s|
h.public_header_files = 'SensorsAnalyticsSDK/Exposure/SAConfigOptions+Exposure.h', 'SensorsAnalyticsSDK/Exposure/SAExposureConfig.h', 'SensorsAnalyticsSDK/Exposure/SAExposureData.h', 'SensorsAnalyticsSDK/Exposure/SensorsAnalyticsSDK+Exposure.h', 'SensorsAnalyticsSDK/Exposure/UIView+ExposureIdentifier.h', 'SensorsAnalyticsSDK/Exposure/SAExposureListener.h'
end

# SDK 切换到英文版,运营商属性、日志和弹框提示等,都换成英文。使用前咨询神策售后技术顾问,否则请慎重使用!
s.subspec 'EnglishResources' do |e|
e.dependency 'SensorsAnalyticsSDK/Base'
e.source_files = 'SpecialFileSources/SACoreResources+English.{h,m}'
e.project_header_files = 'SpecialFileSources/SACoreResources+English.h'
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,19 @@ @implementation SAPropertyInterceptor
- (void)processWithInput:(SAFlowData *)input completion:(SAFlowDataCompletion)completion {
NSParameterAssert(input.eventObject);

// 线上极端情况下,切换到异步 serialQueue 后,eventObject 可能被释放
if(!input.eventObject || ![input.eventObject isKindOfClass:SABaseEventObject.class]) {
input.state = SAFlowStateError;
input.message = @"A memory problem has occurred, eventObject may be freed. End the track flow";
completion(input);
}

// 注册自定义属性采集插件,采集 track 附带属性
SACustomPropertyPlugin *customPlugin = [[SACustomPropertyPlugin alloc] initWithCustomProperties:input.properties];
[[SAPropertyPluginManager sharedInstance] registerCustomPropertyPlugin:customPlugin];

SABaseEventObject *object = input.eventObject;

// 获取插件采集的所有属性
NSDictionary *pluginProperties = [[SAPropertyPluginManager sharedInstance] propertiesWithFilter:object];
// 属性合法性校验
Expand Down
15 changes: 13 additions & 2 deletions SensorsAnalyticsSDK/Core/SAConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#import "SensorsAnalyticsSDK+Private.h"
#import "SACoreResources.h"

#if __has_include("SACoreResources+English.h")
#import "SACoreResources+English.h"
#endif

#pragma mark - Track Timer
NSString *const kSAEventIdSuffix = @"_SATimer";

Expand Down Expand Up @@ -127,7 +131,7 @@
#pragma mark - bridge name
NSString * const SA_SCRIPT_MESSAGE_HANDLER_NAME = @"sensorsdataNativeTracker";

NSSet* sensorsdata_reserved_properties() {
NSSet* sensorsdata_reserved_properties(void) {
return [NSSet setWithObjects:@"date", @"datetime", @"distinct_id", @"event", @"events", @"first_id", @"id", @"original_id", @"properties", @"second_id", @"time", @"user_id", @"users", nil];
}

Expand All @@ -148,8 +152,15 @@ void sensorsdata_dispatch_safe_sync(dispatch_queue_t queue,DISPATCH_NOESCAPE dis
static NSDictionary *languageResources = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// 获取默认语言资源 JSON

#if __has_include("SACoreResources+English.h")
// 获取英文资源
languageResources = [SACoreResources englishLanguageResources];
#else
// 默认加载中文资源
languageResources = [SACoreResources defaultLanguageResources];
#endif

});

return languageResources[key] ?: value;
Expand Down
2 changes: 1 addition & 1 deletion SensorsAnalyticsSDK/Core/SACoreResources.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN

+ (NSDictionary *)mcc;

/// 默认语言资源
/// 默认加载中文资源
+ (NSDictionary *)defaultLanguageResources;

@end
Expand Down
4 changes: 4 additions & 0 deletions SensorsAnalyticsSDK/Core/SACoreResources.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ + (NSDictionary *)mcc {
}

+ (NSDictionary *)defaultLanguageResources {
#if __has_include("SACoreResources+English.h")
return nil;
#else
return @{@"SADebugMode":@"SDK 调试模式选择",@"SADebugOnly":@"开启调试模式(不导入数据)",@"SADebugAndTrack":@"开启调试模式(导入数据)",@"SADebugOff":@"调试模式已关闭",@"SADebugCurrentlyInDebugOnly":@"当前为调试模式(不导入数据)",@"SADebugCurrentlyInDebugAndTrack":@"当前为调试模式(导入数据)",@"SADebugModeTurnedOff":@"已关闭调试模式,重新扫描二维码开启",@"SADebugOnlyModeTurnedOn":@"开启调试模式,校验数据,但不进行数据导入;\n关闭 App 进程后,将自动关闭调试模式。",@"SADebugAndTrackModeTurnedOn":@"开启调试模式,校验数据,并将数据导入神策分析中;\n关闭 App 进程后,将自动关闭调试模式。",@"SADebugNowInDebugOnlyMode":@"现在您打开了'DEBUG_ONLY'模式,此模式下只校验数据但不导入数据,数据出错时会以提示框的方式提示开发者,请上线前一定关闭。",@"SADebugNowInDebugAndTrackMode":@"现在您打开了'DEBUG_AND_TRACK'模式,此模式下会校验数据并且导入数据,数据出错时会以提示框的方式提示开发者,请上线前一定关闭。",@"SADebugNotes":@"SensorsData 重要提示",@"SAVisualizedAutoTrack":@"可视化全埋点",@"SAVisualizedPageErrorTitle":@"当前页面无法进行可视化全埋点",@"SAVisualizedConfigurationDocument":@"配置文档",@"SAVisualizedConnect":@"正在连接 App 可视化全埋点",@"SAVisualizedWifi":@",建议在 WiFi 环境下使用",@"SAVisualizedProjectError":@"App 集成的项目与电脑浏览器打开的项目不同,无法进行可视化全埋点",@"SAVisualizedEnableLogHint":@"可视化全埋点进入 Debug 模式,需要开启日志打印用于收集调试信息,退出 Debug 模式关闭日志打印,是否需要开启呢?",@"SAVisualizedEnableLogAction":@"开启日志打印",@"SAVisualizedTemporarilyDisabled":@"暂不开启",@"SAVisualizedWebPageErrorMessage":@"此页面不是 WKWebView,iOS App 内嵌 H5 可视化全埋点,只支持 WKWebView",@"SAVisualizedJSError":@"此页面未集成 Web JS SDK 或者 Web JS SDK 版本过低,请集成最新版 Web JS SDK",@"SAVisualizedSDKError":@"SDK 没有被正确集成,请联系贵方技术人员开启可视化全埋点",@"SAVisualizedParameterError":@"参数错误",@"SAVisualizedFlutterPageErrorMessage":@"此页面未集成 Flutter 全埋点 SDK 或 Flutter 全埋点 SDK 版本过低,请集成最新版 Flutter 全埋点 SDK",@"SAAppClicksAnalyticsConnect":@"正在连接 App 点击分析",@"SAAppClicksAnalyticsSDKError":@"SDK 没有被正确集成,请联系贵方技术人员开启点击分析",@"SAAppClicksAnalyticsProjectError":@"App 集成的项目与电脑浏览器打开的项目不同,无法进行点击分析",@"SAAppClicksAnalyticsPageErrorTitle":@"当前页面无法进行点击分析",@"SAAppClicksAnalyticsPageWebErrorMessage":@"此页面包含 UIWebView,iOS App 内嵌 H5 点击分析,只支持 WKWebView",@"SAAppClicksAnalytics":@"点击分析",@"SARemoteConfigStart":@"开始获取采集控制信息",@"SARemoteConfigObtainFailed":@"远程配置获取失败,请稍后重新扫描二维码",@"SARemoteConfigProjectError":@"App 集成的项目与二维码对应的项目不同,无法进行调试",@"SARemoteConfigOSError":@"App 与二维码对应的操作系统不同,无法进行调试",@"SARemoteConfigAppError":@"当前 App 与二维码对应的 App 不同,无法进行调试",@"SARemoteConfigQRError":@"二维码信息校验失败,请检查采集控制是否配置正确",@"SARemoteConfigNetworkError":@"网络连接失败,请检查设备网络,确认网络畅通后,请重新扫描二维码进行调试",@"SARemoteConfigWrongVersion":@"版本不一致",@"SARemoteConfigLoaded":@"采集控制加载完成,可以通过 Xcode 控制台日志来调试",@"SARemoteConfigCompareVersion":@"获取到采集控制信息的版本:%@,二维码信息的版本:%@,请稍后重新扫描二维码",@"SAEncryptSelectedKeyInvalid":@"密钥验证不通过,所选密钥无效",@"SAEncryptNotEnabled":@"当前 App 未开启加密,请开启加密后再试",@"SAEncryptAppKeyEmpty":@"密钥验证不通过,App 端密钥为空",@"SAEncryptKeyVerificationPassed":@"密钥验证通过,所选密钥与 App 端密钥相同",@"SAEncryptKeyTypeVerificationFailed":@"密钥验证不通过,所选密钥与 App 端密钥不相同。所选密钥对称算法类型:%@,非对称算法类型:%@,App 端对称算法类型:%@,非对称算法类型:%@",@"SAEncryptKeyVersionVerificationFailed":@"密钥验证不通过,所选密钥与 App 端密钥不相同。所选密钥版本:%@,App 端密钥版本:%@",@"SAChannelReconnectError":@"无法重连,请检查是否更换了联调手机",@"SAChannelServerURLError":@"数据接收地址错误,无法使用联调诊断工具",@"SAChannelProjectError":@"App 集成的项目与电脑浏览器打开的项目不同,无法使用联调诊断工具",@"SAChannelEnableJointDebugging":@"即将开启联调模式",@"SAChannelNetworkError":@"当前网络不可用,请检查网络!",@"SAChannelRequestWhitelistFailed":@"添加白名单请求失败,请联系神策技术支持人员排查问题!",@"SAChannelSuccessfullyEnabled":@"成功开启联调模式",@"SAChannelTriggerActivation":@"此模式下不需要卸载 App,点击“激活”按钮可反复触发激活。",@"SAChannelActivate":@"激活",@"SAChannelDeviceCodeEmpty":@"检测到“设备码为空”,可能的原因如下,请排查:",@"SAChannelTroubleshooting":@"\n1.手机系统设置中「隐私->广告-> 限制广告追踪」;\n\n2.若手机系统为 iOS 14 ,请联系研发人员确认 trackAppInstall 接口是否在 “跟踪” 授权之后调用。\n\n排查修复后,请重新扫码进行联调。\n\n",@"SAChannelNetworkException":@"网络异常,请求失败!",@"SADeepLinkCallback":@"未调用 setDeepLinkCompletion 方法设置回调函数",@"SAAlertCancel":@"取消",@"SAAlertContinue":@"继续",@"SAAlertHint":@"提示",@"SAAlertOK":@"确定",@"SAAlertNotRemind":@"不再提示",@"SAPresetPropertyCarrierMobile":@"中国移动",@"SAPresetPropertyCarrierUnicom":@"中国联通",@"SAPresetPropertyCarrierTelecom":@"中国电信",@"SAPresetPropertyCarrierSatellite":@"中国卫通",@"SAPresetPropertyCarrierTietong":@"中国铁通",@"SADeviceWhiteListTitle":@"添加设备白名单",@"SADeviceWhiteListMessageProject":@"设备白名单配置项目与事件上报项目不一致",@"SADeviceWhiteListMessageDeviceType":@"请使用 iOS 设备类型扫码",@"SADeviceWhiteListMessageRequestSuccess":@"请求成功",@"SADeviceWhiteListMessageRequestFailure":@"请求失败,请重新扫码",@"SADynamicSlinkMessageNoNetwork":@"没有检测到网络连接",@"SADynamicSlinkMessageNoTemplateID":@"Slink 模板 ID 缺少",@"SADynamicSlinkMessageNoChannelName":@"渠道名缺少",@"SADynamicSlinkMessageNoAccessToken":@"token 缺少",@"SADynamicSlinkMessageNoProject":@"获取不到数据埋点地址的项目名称",@"SADynamicSlinkMessageNoRedirectURI":@"通用跳转链接缺少",@"SADynamicSlinkMessageNoDomain":@"自定义域名缺少或者填写格式不对",@"SADynamicSlinkMessageResponseError":@"后端返回数据异常"};
#endif
}

@end
2 changes: 1 addition & 1 deletion SensorsAnalyticsSDK/Core/SensorsAnalyticsSDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#import "SALimitKeyManager.h"
#import "NSDictionary+SACopyProperties.h"

#define VERSION @"4.5.16"
#define VERSION @"4.5.17"

void *SensorsAnalyticsQueueTag = &SensorsAnalyticsQueueTag;

Expand Down
6 changes: 6 additions & 0 deletions SensorsAnalyticsSDK/RemoteConfig/SARemoteConfigInterceptor.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ @implementation SARemoteConfigInterceptor

- (void)processWithInput:(SAFlowData *)input completion:(SAFlowDataCompletion)completion {
NSParameterAssert(input.eventObject);

// 线上极端情况下,切换到异步 serialQueue 后,eventObject 可能被释放
if(!input.eventObject || ![input.eventObject isKindOfClass:SABaseEventObject.class]) {
input.state = SAFlowStateError;
input.message = @"A memory problem has occurred, eventObject may be freed. End the track flow";
}

if ([SAModuleManager.sharedInstance isIgnoreEventObject:input.eventObject]) {
input.state = SAFlowStateStop;
Expand Down
18 changes: 18 additions & 0 deletions SensorsAnalyticsTests/Resources/SACoreResourcesTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#import "SACoreResources.h"
#import "SensorsAnalyticsSDK.h"

// 默认不引入 SACoreResources+English 文件,需要在添加即可
//#import "SACoreResources+English.h"

@interface SACoreResourcesTests : XCTestCase

@property (nonatomic, strong) NSBundle *bundle;
Expand Down Expand Up @@ -83,4 +86,19 @@ - (void)testDefaultLanguageResources {
XCTAssertTrue([[SACoreResources defaultLanguageResources] isEqualToDictionary:localizedDict]);
}

//- (void)testEnglishLanguageResources {
// // 获取语言资源的 Bundle
// NSBundle* languageBundle = nil;
// NSBundle *sensorsBundle = [NSBundle bundleWithPath:[[NSBundle bundleForClass:self.class] pathForResource:@"SensorsAnalyticsSDKTest" ofType:@"bundle"]];
// NSString *path = [sensorsBundle pathForResource:@"en" ofType:@"lproj"];
// if (path) {
// languageBundle = [NSBundle bundleWithPath:path];
// }
//
// NSString *localizablePath = [languageBundle pathForResource:@"Localizable" ofType:@"strings"];
// NSDictionary *localizedDict = [NSDictionary dictionaryWithContentsOfFile:localizablePath];
//
// XCTAssertTrue([[SACoreResources englishLanguageResources] isEqualToDictionary:localizedDict]);
//}

@end
Loading

0 comments on commit 929b921

Please sign in to comment.