Skip to content

Commit

Permalink
Release 4.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
王洋洋 committed Jun 30, 2022
1 parent 018c20a commit 48933bd
Show file tree
Hide file tree
Showing 178 changed files with 6,926 additions and 2,469 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
Expand All @@ -52,8 +50,8 @@
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -75,8 +73,6 @@
ReferencedContainer = "container:Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
2 changes: 1 addition & 1 deletion 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.3.4"
s.version = "4.4.0"
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 Down
555 changes: 502 additions & 53 deletions SensorsAnalyticsSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@
</dict>
</dict>
</dict>
<key>SANetworkInfoPropertyPluginTests</key>
<dict>
<key>testPerformanceStart</key>
<dict>
<key>com.apple.XCTPerformanceMetric_WallClockTime</key>
<dict>
<key>baselineAverage</key>
<real>0.000050</real>
<key>baselineIntegrationDisplayName</key>
<string>Local Baseline</string>
<key>maxPercentRelativeStandardDeviation</key>
<real>10.000000</real>
</dict>
</dict>
</dict>
<key>SAPhonePresetPropertyTest</key>
<dict>
<key>testPerformanceProperties</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "CB2D018522379F7300A958C5"
BlueprintIdentifier = "CB6EBAE2228551EC003CFBA8"
BuildableName = "SensorsAnalyticsTests.xctest"
BlueprintName = "SensorsAnalyticsTests"
ReferencedContainer = "container:SensorsAnalyticsSDK.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
Expand All @@ -36,8 +34,6 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ - (void)trackPageLeave:(UIViewController *)viewController {

- (void)trackWithProperties:(NSDictionary *)properties {
SAPresetEventObject *object = [[SAPresetEventObject alloc] initWithEventId:kSAEventNameAppPageLeave];
[SensorsAnalyticsSDK.sharedInstance asyncTrackEventObject:object properties:properties];

[SensorsAnalyticsSDK.sharedInstance trackEventObject:object properties:properties];
}

- (void)appLifecycleStateWillChange:(NSNotification *)notification {
Expand Down
6 changes: 4 additions & 2 deletions SensorsAnalyticsSDK/AutoTrack/SAAppTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ - (NSString *)eventId {

- (void)trackAutoTrackEventWithProperties:(NSDictionary *)properties {
SAAutoTrackEventObject *object = [[SAAutoTrackEventObject alloc] initWithEventId:[self eventId]];
[SensorsAnalyticsSDK.sharedInstance asyncTrackEventObject:object properties:properties];

[SensorsAnalyticsSDK.sharedInstance trackEventObject:object properties:properties];
}

- (void)trackPresetEventWithProperties:(NSDictionary *)properties {
SAPresetEventObject *object = [[SAPresetEventObject alloc] initWithEventId:[self eventId]];
[SensorsAnalyticsSDK.sharedInstance asyncTrackEventObject:object properties:properties];

[SensorsAnalyticsSDK.sharedInstance trackEventObject:object properties:properties];
}

- (BOOL)shouldTrackViewController:(UIViewController *)viewController {
Expand Down
31 changes: 31 additions & 0 deletions SensorsAnalyticsSDK/ChannelMatch/SAChannelInfoPropertyPlugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// SAChannelInfoPropertyPlugin.h
// SensorsAnalyticsSDK
//
// Created by  储强盛 on 2022/4/26.
// Copyright © 2015-2022 Sensors Data Co., Ltd. All rights reserved.
//
// Licensed 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 "SAPropertyPlugin.h"

NS_ASSUME_NONNULL_BEGIN

/// 渠道属性插件
@interface SAChannelInfoPropertyPlugin : SAPropertyPlugin

@end

NS_ASSUME_NONNULL_END
54 changes: 54 additions & 0 deletions SensorsAnalyticsSDK/ChannelMatch/SAChannelInfoPropertyPlugin.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//
// SAChannelInfoPropertyPlugin.m
// SensorsAnalyticsSDK
//
// Created by  储强盛 on 2022/4/26.
// Copyright © 2015-2022 Sensors Data Co., Ltd. All rights reserved.
//
// Licensed 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.
//

#if ! __has_feature(objc_arc)
#error This file must be compiled with ARC. Either turn on ARC for the project or use -fobjc-arc flag on this file.
#endif

#import "SAChannelInfoPropertyPlugin.h"
#import "SAPropertyPlugin+SAPrivate.h"
#import "SAConstants+Private.h"
#import "SAModuleManager.h"
#import "SATrackEventObject.h"

@implementation SAChannelInfoPropertyPlugin

- (BOOL)isMatchedWithFilter:(id<SAPropertyPluginEventFilter>)filter {
// 不支持 H5 打通事件
// 开启 enableAutoAddChannelCallbackEvent 后,只有手动 track 事件包含渠道信息
if ([filter hybridH5] || ![filter isKindOfClass:SACustomEventObject.class]) {
return NO;
}

return filter.type & SAEventTypeTrack;
}

- (SAPropertyPluginPriority)priority {
return SAPropertyPluginPriorityLow;
}

- (NSDictionary<NSString *,id> *)properties {
if (!self.filter) {
return nil;
}

return [SAModuleManager.sharedInstance channelInfoWithEvent:self.filter.event];
}
@end
3 changes: 1 addition & 2 deletions SensorsAnalyticsSDK/ChannelMatch/SAChannelMatchManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ NS_ASSUME_NONNULL_BEGIN
* @param event event 的名称
* @param properties event 的属性
* @param disableCallback 是否关闭这次渠道匹配的回调请求
* @param dynamicProperties 动态公共属性 (需要在切换 serialQueue 前获取)
*/
- (void)trackAppInstall:(NSString *)event properties:(nullable NSDictionary *)properties disableCallback:(BOOL)disableCallback dynamicProperties:(NSDictionary *)dynamicProperties;
- (void)trackAppInstall:(NSString *)event properties:(nullable NSDictionary *)properties disableCallback:(BOOL)disableCallback;

/// 调用 track 接口并附加渠道信息
///
Expand Down
28 changes: 17 additions & 11 deletions SensorsAnalyticsSDK/ChannelMatch/SAChannelMatchManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#import "SensorsAnalyticsSDK+SAChannelMatch.h"
#import "SAApplication.h"
#import "SAProfileEventObject.h"
#import "SAPropertyPluginManager.h"
#import "SAChannelInfoPropertyPlugin.h"

NSString * const kSAChannelDebugFlagKey = @"com.sensorsdata.channeldebug.flag";
NSString * const kSAChannelDebugInstallEventName = @"$ChannelDebugInstall";
Expand Down Expand Up @@ -71,6 +73,10 @@ - (void)setConfigOptions:(SAConfigOptions *)configOptions {
}
_configOptions = configOptions;
self.enable = configOptions.enableChannelMatch;

// 注册渠道相关属性插件 Channel
SAChannelInfoPropertyPlugin *channelInfoPropertyPlugin = [[SAChannelInfoPropertyPlugin alloc] init];
[SensorsAnalyticsSDK.sharedInstance registerPropertyPlugin:channelInfoPropertyPlugin];
}

#pragma mark -
Expand Down Expand Up @@ -161,16 +167,14 @@ - (void)setTrackedAppInstallWithDisableCallback:(BOOL)disableCallback {
}

#pragma mark - 激活事件
- (void)trackAppInstall:(NSString *)event properties:(NSDictionary *)properties disableCallback:(BOOL)disableCallback dynamicProperties:(NSDictionary *)dynamicProperties {
- (void)trackAppInstall:(NSString *)event properties:(NSDictionary *)properties disableCallback:(BOOL)disableCallback{
// 采集激活事件
SAPresetEventObject *eventObject = [[SAPresetEventObject alloc] initWithEventId:event];
eventObject.dynamicSuperProperties = dynamicProperties;
NSDictionary *eventProps = [self eventProperties:properties disableCallback:disableCallback];
[SensorsAnalyticsSDK.sharedInstance trackEventObject:eventObject properties:eventProps];

// 设置用户属性
SAProfileEventObject *profileObject = [[SAProfileEventObject alloc] initWithType:SA_PROFILE_SET_ONCE];
profileObject.dynamicSuperProperties = dynamicProperties;
SAProfileEventObject *profileObject = [[SAProfileEventObject alloc] initWithType:kSAProfileSetOnce];
NSDictionary *profileProps = [self profileProperties:properties];
[SensorsAnalyticsSDK.sharedInstance trackEventObject:profileObject properties:profileProps];
}
Expand All @@ -182,14 +186,14 @@ - (NSDictionary *)eventProperties:(NSDictionary *)properties disableCallback:(BO
}

if (disableCallback) {
result[SA_EVENT_PROPERTY_APP_INSTALL_DISABLE_CALLBACK] = @YES;
result[kSAEventPropertyInstallDisableCallback] = @YES;
}

if ([result[kSAEventPropertyUserAgent] length] == 0) {
result[kSAEventPropertyUserAgent] = [self simulateUserAgent];
}

result[SA_EVENT_PROPERTY_APP_INSTALL_SOURCE] = [self appInstallSource];
result[kSAEventPropertyInstallSource] = [self appInstallSource];

return result;
}
Expand All @@ -204,13 +208,13 @@ - (NSDictionary *)profileProperties:(NSDictionary *)properties {
result[kSAEventPropertyUserAgent] = [self simulateUserAgent];
}

result[SA_EVENT_PROPERTY_APP_INSTALL_SOURCE] = [self appInstallSource];
result[kSAEventPropertyInstallSource] = [self appInstallSource];

// 用户属性中不需要添加 $ios_install_disable_callback,这里主动移除掉
// (也会移除自定义属性中的 $ios_install_disable_callback, 和原有逻辑保持一致)
[result removeObjectForKey:SA_EVENT_PROPERTY_APP_INSTALL_DISABLE_CALLBACK];
[result removeObjectForKey:kSAEventPropertyInstallDisableCallback];

[result setValue:[NSDate date] forKey:SA_EVENT_PROPERTY_APP_INSTALL_FIRST_VISIT_TIME];
[result setValue:[NSDate date] forKey:kSAEventPropertyAppInstallFirstVisitTime];

return result;
}
Expand Down Expand Up @@ -404,9 +408,11 @@ - (void)showChannelDebugInstall {
SAAlertController *alertController = [[SAAlertController alloc] initWithTitle:title message:content preferredStyle:SAAlertControllerStyleAlert];
[alertController addActionWithTitle:SALocalizedString(@"SAChannelActivate") style:SAAlertActionStyleDefault handler:^(SAAlertAction * _Nonnull action) {
dispatch_queue_t serialQueue = SensorsAnalyticsSDK.sharedInstance.serialQueue;
NSDictionary *dynamicProperties = [SensorsAnalyticsSDK.sharedInstance.superProperty acquireDynamicSuperProperties];
// 入队列前,执行动态公共属性采集 block
[SensorsAnalyticsSDK.sharedInstance buildDynamicSuperProperties];

dispatch_async(serialQueue, ^{
[self trackAppInstall:kSAChannelDebugInstallEventName properties:nil disableCallback:NO dynamicProperties:dynamicProperties];
[self trackAppInstall:kSAChannelDebugInstallEventName properties:nil disableCallback:NO];
});
[SensorsAnalyticsSDK.sharedInstance flush];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,13 @@
#import "SensorsAnalyticsSDK+Private.h"
#import "SATrackEventObject.h"
#import "SAModuleManager.h"
#import "SASuperProperty.h"
#import "SAEventTracker.h"
#import "SAChannelMatchManager.h"

// 激活事件
static NSString * const kSAEventNameAppInstall = @"$AppInstall";

@interface SensorsAnalyticsSDK ()

@property (nonatomic, strong, readonly) SAEventTracker *eventTracker;

@end

@implementation SensorsAnalyticsSDK (SAChannelMatch)
Expand All @@ -47,7 +43,9 @@ - (void)trackChannelEvent:(NSString *)event {

- (void)trackChannelEvent:(NSString *)event properties:(nullable NSDictionary *)propertyDict {
SACustomEventObject *object = [[SACustomEventObject alloc] initWithEventId:event];
object.dynamicSuperProperties = [self.superProperty acquireDynamicSuperProperties];

// 入队列前,执行动态公共属性采集 block
[self buildDynamicSuperProperties];
dispatch_async(self.serialQueue, ^{
[SAChannelMatchManager.defaultManager trackChannelWithEventObject:object properties:propertyDict];
});
Expand All @@ -62,12 +60,14 @@ - (void)trackAppInstallWithProperties:(NSDictionary *)properties {
}

- (void)trackAppInstallWithProperties:(NSDictionary *)properties disableCallback:(BOOL)disableCallback {
NSDictionary *dynamicProperties = [self.superProperty acquireDynamicSuperProperties];
// 入队列前,执行动态公共属性采集 block
[self buildDynamicSuperProperties];

dispatch_async(self.serialQueue, ^{
if (![SAChannelMatchManager.defaultManager isTrackedAppInstallWithDisableCallback:disableCallback]) {
[SAChannelMatchManager.defaultManager setTrackedAppInstallWithDisableCallback:disableCallback];
[SAChannelMatchManager.defaultManager trackAppInstall:kSAEventNameAppInstall properties:properties disableCallback:disableCallback dynamicProperties:dynamicProperties];
[self.eventTracker flushAllEventRecords];
[SAChannelMatchManager.defaultManager trackAppInstall:kSAEventNameAppInstall properties:properties disableCallback:disableCallback];
[self flush];
}
});
}
Expand All @@ -81,12 +81,14 @@ - (void)trackInstallation:(NSString *)event withProperties:(NSDictionary *)prope
}

- (void)trackInstallation:(NSString *)event withProperties:(NSDictionary *)properties disableCallback:(BOOL)disableCallback {
NSDictionary *dynamicProperties = [self.superProperty acquireDynamicSuperProperties];

// 入队列前,执行动态公共属性采集 block
[self buildDynamicSuperProperties];
dispatch_async(self.serialQueue, ^{
if (![SAChannelMatchManager.defaultManager isTrackedAppInstallWithDisableCallback:disableCallback]) {
[SAChannelMatchManager.defaultManager setTrackedAppInstallWithDisableCallback:disableCallback];
[SAChannelMatchManager.defaultManager trackAppInstall:event properties:properties disableCallback:disableCallback dynamicProperties:dynamicProperties];
[self.eventTracker flushAllEventRecords];
[SAChannelMatchManager.defaultManager trackAppInstall:event properties:properties disableCallback:disableCallback];
[self flush];
}
});
}
Expand Down
Loading

0 comments on commit 48933bd

Please sign in to comment.