Ta android + ios
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
#import "ThinkingAnalyticsSDKPrivate.h"
|
||||
#import "TDLogging.h"
|
||||
|
||||
@implementation LightThinkingAnalyticsSDK
|
||||
|
||||
- (instancetype)initWithAPPID:(NSString *)appID withServerURL:(NSString *)serverURL withConfig:(TDConfig *)config {
|
||||
if (self = [self initLight:appID withServerURL:serverURL withConfig:config]) {
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)login:(NSString *)accountId {
|
||||
if ([self hasDisabled])
|
||||
return;
|
||||
|
||||
if (![accountId isKindOfClass:[NSString class]] || accountId.length == 0) {
|
||||
TDLogError(@"accountId invald", accountId);
|
||||
return;
|
||||
}
|
||||
|
||||
@synchronized (self.accountId) {
|
||||
self.accountId = accountId;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)logout {
|
||||
if ([self hasDisabled])
|
||||
return;
|
||||
|
||||
@synchronized (self.accountId) {
|
||||
self.accountId = nil;
|
||||
};
|
||||
}
|
||||
|
||||
- (void)identify:(NSString *)distinctId {
|
||||
if ([self hasDisabled])
|
||||
return;
|
||||
|
||||
if (![distinctId isKindOfClass:[NSString class]] || distinctId.length == 0) {
|
||||
TDLogError(@"identify cannot null");
|
||||
return;
|
||||
}
|
||||
|
||||
@synchronized (self.identifyId) {
|
||||
self.identifyId = distinctId;
|
||||
};
|
||||
}
|
||||
|
||||
- (NSString *)getDistinctId {
|
||||
return [self.identifyId copy];
|
||||
}
|
||||
|
||||
- (void)enableAutoTrack:(ThinkingAnalyticsAutoTrackEventType)eventType {
|
||||
return;
|
||||
}
|
||||
|
||||
- (void)flush {
|
||||
return;
|
||||
}
|
||||
|
||||
#pragma mark - EnableTracking
|
||||
- (void)enableTracking:(BOOL)enabled {
|
||||
TDLogDebug(@"%@light instance: enableTracking...", self);
|
||||
self.isEnabled = enabled;
|
||||
}
|
||||
|
||||
- (void)optOutTracking {
|
||||
TDLogDebug(@"%@light instance: optOutTracking...", self);
|
||||
self.isEnabled = NO;
|
||||
}
|
||||
|
||||
- (void)optOutTrackingAndDeleteUser {
|
||||
TDLogDebug(@"%@light instance: optOutTrackingAndDeleteUser...", self);
|
||||
self.isEnabled = NO;
|
||||
}
|
||||
|
||||
- (void)optInTracking {
|
||||
TDLogDebug(@"%@light instance: optInTracking...", self);
|
||||
self.isEnabled = YES;
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (void)setTrackStatus: (TATrackStatus)status {
|
||||
switch (status) {
|
||||
|
||||
case TATrackStatusPause: {
|
||||
TDLogDebug(@"%@light instance - switchTrackStatus: TATrackStatusStop...", self);
|
||||
self.isEnabled = NO;
|
||||
break;
|
||||
}
|
||||
|
||||
case TATrackStatusStop: {
|
||||
TDLogDebug(@"%@light instance - switchTrackStatus: TATrackStatusStopAndClean...", self);
|
||||
self.isEnabled = NO;
|
||||
break;
|
||||
}
|
||||
|
||||
case TATrackStatusSaveOnly: {
|
||||
TDLogDebug(@"%@light instance - switchTrackStatus: TATrackStatusPausePost...", self);
|
||||
self.trackPause = YES;
|
||||
break;
|
||||
}
|
||||
|
||||
case TATrackStatusNormal: {
|
||||
TDLogDebug(@"%@light instance - switchTrackStatus: TATrackStatusRestartAll...", self);
|
||||
self.trackPause = NO;
|
||||
self.isEnabled = YES;
|
||||
[self flush];
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1848db7016d10b04bb1e6d7e0ac74a54
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// TDEventRecord.h
|
||||
// ThinkingSDK
|
||||
//
|
||||
// Created by wwango on 2022/1/24.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TDEventRecord : NSObject
|
||||
|
||||
// Due to historical reasons, there is no event identifier stored in the database
|
||||
// Record index when fetching data, update uuid before reporting data, remove data according to uuid after successful reporting
|
||||
@property (nonatomic, copy) NSString *uuid;
|
||||
@property (nonatomic, strong) NSNumber *index;
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *content;
|
||||
@property (nonatomic, copy, readonly) NSDictionary *event;
|
||||
@property (nonatomic, assign) BOOL encrypted;
|
||||
@property (nonatomic, copy, readonly) NSString *ekey;
|
||||
|
||||
|
||||
- (instancetype)initWithIndex:(NSNumber *)index content:(NSDictionary *)content;
|
||||
- (instancetype)initWithContent:(NSDictionary *)content;
|
||||
|
||||
- (void)setSecretObject:(NSDictionary *)obj;
|
||||
|
||||
- (NSString *)flushContent:(NSString *)appid;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d24320f1dee61fa4ca4b012fdad15776
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// TDEventRecord.m
|
||||
// ThinkingSDK
|
||||
//
|
||||
// Created by wwango on 2022/1/24.
|
||||
//
|
||||
|
||||
#import "TDEventRecord.h"
|
||||
|
||||
#import "TDJSONUtil.h"
|
||||
|
||||
static NSString * const TDEncryptRecordKeyEKey = @"ekey";
|
||||
static NSString * const TDEncryptRecordKeyPayload = @"payload";
|
||||
|
||||
@implementation TDEventRecord {
|
||||
NSMutableDictionary *_event;
|
||||
}
|
||||
|
||||
|
||||
- (instancetype)initWithEvent:(NSDictionary *)event type:(NSString *)type {
|
||||
if (self = [super init]) {
|
||||
|
||||
_event = [event mutableCopy];
|
||||
_encrypted = _event[TDEncryptRecordKeyEKey] != nil;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithUUID:(NSString *)uuid content:(NSDictionary *)content {
|
||||
if (self = [super init]) {
|
||||
_uuid = uuid;
|
||||
|
||||
if (content && [content isKindOfClass:[NSDictionary class]]) {
|
||||
_event = [NSMutableDictionary dictionaryWithDictionary:content];
|
||||
_encrypted = _event[TDEncryptRecordKeyEKey] != nil;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithIndex:(NSNumber *)index content:(NSDictionary *)content {
|
||||
if (self = [super init]) {
|
||||
_index = index;
|
||||
|
||||
if (content && [content isKindOfClass:[NSDictionary class]]) {
|
||||
_event = [NSMutableDictionary dictionaryWithDictionary:content];
|
||||
_encrypted = _event[TDEncryptRecordKeyEKey] != nil;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithContent:(NSDictionary *)content {
|
||||
if (self = [super init]) {
|
||||
if (content && [content isKindOfClass:[NSDictionary class]]) {
|
||||
_event = [NSMutableDictionary dictionaryWithDictionary:content];
|
||||
_encrypted = _event[TDEncryptRecordKeyEKey] != nil;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString *)ekey {
|
||||
return _event[TDEncryptRecordKeyEKey];
|
||||
}
|
||||
|
||||
- (void)setSecretObject:(NSDictionary *)obj {
|
||||
if (!obj || ![obj isKindOfClass:[NSDictionary class]]) {
|
||||
return;
|
||||
}
|
||||
[_event removeAllObjects];
|
||||
[_event addEntriesFromDictionary:obj];
|
||||
|
||||
_encrypted = YES;
|
||||
}
|
||||
|
||||
- (BOOL)isValid {
|
||||
return self.event.count > 0;
|
||||
}
|
||||
|
||||
- (NSString *)content {
|
||||
return [TDJSONUtil JSONStringForObject:self.event];
|
||||
}
|
||||
|
||||
- (NSString *)flushContent:(NSString *)appid {
|
||||
if (![self isValid]) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
UInt64 time = [[NSDate date] timeIntervalSince1970] * 1000;
|
||||
_event[@"#flush_time"] = @(time);
|
||||
_event[@"#app_id"] =appid;
|
||||
|
||||
return self.content;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6997f69a90a6b3f419fb56a1addd7a94
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,520 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if TARGET_OS_IOS
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#if __has_include(<ThinkingSDK/TAAutoTrackPublicHeader.h>)
|
||||
#import <ThinkingSDK/TAAutoTrackPublicHeader.h>
|
||||
#else
|
||||
#import "TAAutoTrackPublicHeader.h"
|
||||
#endif
|
||||
|
||||
#elif TARGET_OS_OSX
|
||||
#import <AppKit/AppKit.h>
|
||||
#endif
|
||||
|
||||
#if __has_include(<ThinkingSDK/TDFirstEventModel.h>)
|
||||
#import <ThinkingSDK/TDFirstEventModel.h>
|
||||
#else
|
||||
#import "TDFirstEventModel.h"
|
||||
#endif
|
||||
|
||||
#if __has_include(<ThinkingSDK/TDEditableEventModel.h>)
|
||||
#import <ThinkingSDK/TDEditableEventModel.h>
|
||||
#else
|
||||
#import "TDEditableEventModel.h"
|
||||
#endif
|
||||
|
||||
|
||||
#if __has_include(<ThinkingSDK/TDConfig.h>)
|
||||
#import <ThinkingSDK/TDConfig.h>
|
||||
#else
|
||||
#import "TDConfig.h"
|
||||
#endif
|
||||
|
||||
#if __has_include(<ThinkingSDK/TDPresetProperties.h>)
|
||||
#import <ThinkingSDK/TDPresetProperties.h>
|
||||
#else
|
||||
#import "TDPresetProperties.h"
|
||||
#endif
|
||||
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
SDK VERSION = 2.8.6
|
||||
ThinkingData API
|
||||
|
||||
## Initialization
|
||||
|
||||
```objective-c
|
||||
ThinkingAnalyticsSDK *instance = [ThinkingAnalyticsSDK startWithAppId:@"YOUR_APPID" withUrl:@"YOUR_SERVER_URL"];
|
||||
```
|
||||
|
||||
## Track Event
|
||||
|
||||
```objective-c
|
||||
instance.track("some_event");
|
||||
```
|
||||
or
|
||||
```objective-c
|
||||
[[ThinkingAnalyticsSDK sharedInstanceWithAppid:@"YOUR_APPID"] track:@"some_event"];
|
||||
```
|
||||
If you only have one instance in your project, you can also use
|
||||
```objective-c
|
||||
[[ThinkingAnalyticsSDK sharedInstance] track:@"some_event"];
|
||||
```
|
||||
## Detailed Documentation
|
||||
http://doc.thinkingdata.cn/tgamanual/installation/ios_sdk_installation.html
|
||||
|
||||
*/
|
||||
@interface ThinkingAnalyticsSDK : NSObject
|
||||
|
||||
#pragma mark - Tracking
|
||||
|
||||
/**
|
||||
Get default instance
|
||||
|
||||
@return SDK instance
|
||||
*/
|
||||
+ (nullable ThinkingAnalyticsSDK *)sharedInstance;
|
||||
|
||||
/**
|
||||
Get one instance according to appid or instanceName
|
||||
|
||||
@param appid APP ID or instanceName
|
||||
@return SDK instance
|
||||
*/
|
||||
+ (nullable ThinkingAnalyticsSDK *)sharedInstanceWithAppid:(NSString *)appid;
|
||||
|
||||
/**
|
||||
Initialization method
|
||||
After the SDK initialization is complete, the saved instance can be obtained through this api
|
||||
|
||||
@param appId appId
|
||||
@param url server url
|
||||
@return one instance
|
||||
*/
|
||||
+ (ThinkingAnalyticsSDK *)startWithAppId:(NSString *)appId withUrl:(NSString *)url;
|
||||
|
||||
/**
|
||||
Initialization method
|
||||
After the SDK initialization is complete, the saved instance can be obtained through this api
|
||||
|
||||
@param config initialization configuration
|
||||
@return one instance
|
||||
*/
|
||||
+ (ThinkingAnalyticsSDK *)startWithConfig:(nullable TDConfig *)config;
|
||||
|
||||
/**
|
||||
Initialization method
|
||||
After the SDK initialization is complete, the saved instance can be obtained through this api
|
||||
|
||||
@param appId appId
|
||||
@param url server url
|
||||
@param config initialization configuration object
|
||||
@return one instance
|
||||
*/
|
||||
+ (ThinkingAnalyticsSDK *)startWithAppId:(NSString *)appId withUrl:(NSString *)url withConfig:(nullable TDConfig *)config;
|
||||
|
||||
|
||||
#pragma mark - Action Track
|
||||
|
||||
/**
|
||||
Track Events
|
||||
|
||||
@param event event name
|
||||
*/
|
||||
- (void)track:(NSString *)event;
|
||||
|
||||
|
||||
/**
|
||||
Track Events
|
||||
|
||||
@param event event name
|
||||
@param propertieDict event properties
|
||||
*/
|
||||
- (void)track:(NSString *)event properties:(nullable NSDictionary *)propertieDict;
|
||||
|
||||
/**
|
||||
Track Events
|
||||
|
||||
@param event event name
|
||||
@param propertieDict event properties
|
||||
@param time event trigger time
|
||||
*/
|
||||
- (void)track:(NSString *)event properties:(nullable NSDictionary *)propertieDict time:(NSDate *)time __attribute__((deprecated("please use track:properties:time:timeZone: method")));
|
||||
|
||||
/**
|
||||
Track Events
|
||||
|
||||
@param event event name
|
||||
@param propertieDict event properties
|
||||
@param time event trigger time
|
||||
@param timeZone event trigger time time zone
|
||||
*/
|
||||
- (void)track:(NSString *)event properties:(nullable NSDictionary *)propertieDict time:(NSDate *)time timeZone:(NSTimeZone *)timeZone;
|
||||
|
||||
/**
|
||||
Track Events
|
||||
|
||||
@param eventModel event Model
|
||||
*/
|
||||
- (void)trackWithEventModel:(TDEventModel *)eventModel;
|
||||
|
||||
/**
|
||||
Get the events collected in the App Extension and report them
|
||||
|
||||
@param appGroupId The app group id required for data sharing
|
||||
*/
|
||||
- (void)trackFromAppExtensionWithAppGroupId:(NSString *)appGroupId;
|
||||
|
||||
#pragma mark -
|
||||
|
||||
/**
|
||||
Timing Events
|
||||
Record the event duration, call this method to start the timing, stop the timing when the target event is uploaded, and add the attribute #duration to the event properties, in seconds.
|
||||
*/
|
||||
- (void)timeEvent:(NSString *)event;
|
||||
|
||||
/**
|
||||
Identify
|
||||
Set the distinct ID to replace the default UUID distinct ID.
|
||||
*/
|
||||
- (void)identify:(NSString *)distinctId;
|
||||
|
||||
/**
|
||||
Get Distinctid
|
||||
Get a visitor ID: The #distinct_id value in the reported data.
|
||||
*/
|
||||
- (NSString *)getDistinctId;
|
||||
|
||||
/**
|
||||
Get sdk version
|
||||
*/
|
||||
+ (NSString *)getSDKVersion;
|
||||
|
||||
/**
|
||||
Login
|
||||
Set the account ID. Each setting overrides the previous value. Login events will not be uploaded.
|
||||
|
||||
@param accountId account ID
|
||||
*/
|
||||
- (void)login:(NSString *)accountId;
|
||||
|
||||
/**
|
||||
Logout
|
||||
Clearing the account ID will not upload user logout events.
|
||||
*/
|
||||
- (void)logout;
|
||||
|
||||
/**
|
||||
User_Set
|
||||
Sets the user property, replacing the original value with the new value if the property already exists.
|
||||
|
||||
@param properties user properties
|
||||
*/
|
||||
- (void)user_set:(NSDictionary *)properties;
|
||||
|
||||
/**
|
||||
User_Set
|
||||
|
||||
@param properties user properties
|
||||
@param time event trigger time
|
||||
*/
|
||||
- (void)user_set:(NSDictionary *)properties withTime:(NSDate * _Nullable)time;
|
||||
|
||||
/**
|
||||
User_Unset
|
||||
|
||||
@param propertyName user properties
|
||||
*/
|
||||
- (void)user_unset:(NSString *)propertyName;
|
||||
|
||||
/**
|
||||
User_Unset
|
||||
Reset user properties.
|
||||
|
||||
@param propertyName user properties
|
||||
@param time event trigger time
|
||||
*/
|
||||
- (void)user_unset:(NSString *)propertyName withTime:(NSDate * _Nullable)time;
|
||||
|
||||
/**
|
||||
User_SetOnce
|
||||
Sets a single user attribute, ignoring the new attribute value if the attribute already exists.
|
||||
|
||||
@param properties user properties
|
||||
*/
|
||||
- (void)user_setOnce:(NSDictionary *)properties;
|
||||
|
||||
/**
|
||||
User_SetOnce
|
||||
|
||||
@param properties user properties
|
||||
@param time event trigger time
|
||||
*/
|
||||
- (void)user_setOnce:(NSDictionary *)properties withTime:(NSDate * _Nullable)time;
|
||||
|
||||
/**
|
||||
User_Add
|
||||
Adds the numeric type user attributes.
|
||||
|
||||
@param properties user properties
|
||||
*/
|
||||
- (void)user_add:(NSDictionary *)properties;
|
||||
|
||||
/**
|
||||
User_Add
|
||||
|
||||
@param properties user properties
|
||||
@param time event trigger time
|
||||
*/
|
||||
- (void)user_add:(NSDictionary *)properties withTime:(NSDate * _Nullable)time;
|
||||
|
||||
/**
|
||||
User_Add
|
||||
|
||||
@param propertyName propertyName
|
||||
@param propertyValue propertyValue
|
||||
*/
|
||||
- (void)user_add:(NSString *)propertyName andPropertyValue:(NSNumber *)propertyValue;
|
||||
|
||||
/**
|
||||
User_Add
|
||||
|
||||
@param propertyName propertyName
|
||||
@param propertyValue propertyValue
|
||||
@param time event trigger time
|
||||
*/
|
||||
- (void)user_add:(NSString *)propertyName andPropertyValue:(NSNumber *)propertyValue withTime:(NSDate * _Nullable)time;
|
||||
|
||||
/**
|
||||
User_Delete
|
||||
Delete the user attributes,This operation is not reversible and should be performed with caution.
|
||||
*/
|
||||
- (void)user_delete;
|
||||
|
||||
/**
|
||||
User_Delete
|
||||
|
||||
@param time event trigger time
|
||||
*/
|
||||
- (void)user_delete:(NSDate * _Nullable)time;
|
||||
|
||||
/**
|
||||
User_Append
|
||||
Append a user attribute of the List type.
|
||||
|
||||
@param properties user properties
|
||||
*/
|
||||
- (void)user_append:(NSDictionary<NSString *, NSArray *> *)properties;
|
||||
|
||||
/**
|
||||
User_Append
|
||||
The element appended to the library needs to be done to remove the processing,and then import.
|
||||
|
||||
@param properties user properties
|
||||
@param time event trigger time
|
||||
*/
|
||||
- (void)user_append:(NSDictionary<NSString *, NSArray *> *)properties withTime:(NSDate * _Nullable)time;
|
||||
|
||||
/**
|
||||
User_UniqAppend
|
||||
|
||||
@param properties user properties
|
||||
*/
|
||||
- (void)user_uniqAppend:(NSDictionary<NSString *, NSArray *> *)properties;
|
||||
|
||||
/**
|
||||
User_UniqAppend
|
||||
|
||||
@param properties user properties
|
||||
@param time event trigger time
|
||||
*/
|
||||
- (void)user_uniqAppend:(NSDictionary<NSString *, NSArray *> *)properties withTime:(NSDate * _Nullable)time;
|
||||
|
||||
+ (void)setCustomerLibInfoWithLibName:(NSString *)libName libVersion:(NSString *)libVersion;
|
||||
|
||||
/**
|
||||
Static Super Properties
|
||||
Set the public event attribute, which will be included in every event uploaded after that. The public event properties are saved without setting them each time.
|
||||
*
|
||||
*/
|
||||
- (void)setSuperProperties:(NSDictionary *)properties;
|
||||
|
||||
/**
|
||||
Unset Super Property
|
||||
Clears a public event attribute.
|
||||
*/
|
||||
- (void)unsetSuperProperty:(NSString *)property;
|
||||
|
||||
/**
|
||||
Clear Super Properties
|
||||
Clear all public event attributes.
|
||||
*/
|
||||
- (void)clearSuperProperties;
|
||||
|
||||
/**
|
||||
Get Static Super Properties
|
||||
Gets the public event properties that have been set.
|
||||
*/
|
||||
- (NSDictionary *)currentSuperProperties;
|
||||
|
||||
/**
|
||||
Dynamic super properties
|
||||
Set dynamic public properties. Each event uploaded after that will contain a public event attribute.
|
||||
*/
|
||||
- (void)registerDynamicSuperProperties:(NSDictionary<NSString *, id> *(^)(void))dynamicSuperProperties;
|
||||
|
||||
|
||||
/**
|
||||
Dynamic super properties in auto track environment
|
||||
Set dynamic public properties. Each event uploaded after that will contain a public event attribute.
|
||||
*/
|
||||
- (void)setAutoTrackDynamicProperties:(NSDictionary<NSString *, id> *(^)(void))dynamicSuperProperties;
|
||||
|
||||
/**
|
||||
Register TD error callback
|
||||
|
||||
@param errorCallback
|
||||
code = 10001,
|
||||
ext = "string or json string",
|
||||
errorMsg = "error"
|
||||
*/
|
||||
- (void)registerErrorCallback:(void(^)(NSInteger code, NSString * _Nullable errorMsg, NSString * _Nullable ext))errorCallback;
|
||||
|
||||
/**
|
||||
Gets prefabricated properties for all events.
|
||||
*/
|
||||
- (TDPresetProperties *)getPresetProperties;
|
||||
|
||||
/**
|
||||
Set the network conditions for uploading. By default, the SDK will set the network conditions as 3G, 4G and Wifi to upload data
|
||||
*/
|
||||
- (void)setNetworkType:(ThinkingAnalyticsNetworkType)type;
|
||||
|
||||
#if TARGET_OS_IOS
|
||||
|
||||
/**
|
||||
Enable Auto-Tracking
|
||||
|
||||
@param eventType Auto-Tracking type
|
||||
|
||||
detailed documentation http://doc.thinkingdata.cn/tgamanual/installation/ios_sdk_installation/ios_sdk_autotrack.html
|
||||
*/
|
||||
- (void)enableAutoTrack:(ThinkingAnalyticsAutoTrackEventType)eventType;
|
||||
|
||||
/**
|
||||
Enable the auto tracking function.
|
||||
|
||||
@param eventType Auto-Tracking type
|
||||
@param properties properties
|
||||
*/
|
||||
- (void)enableAutoTrack:(ThinkingAnalyticsAutoTrackEventType)eventType properties:(NSDictionary *)properties;
|
||||
|
||||
/**
|
||||
Enable the auto tracking function.
|
||||
|
||||
@param eventType Auto-Tracking type
|
||||
@param callback callback
|
||||
In the callback, eventType indicates the type of automatic collection, properties indicates the event properties before storage, and this block can return a dictionary for adding new properties
|
||||
*/
|
||||
- (void)enableAutoTrack:(ThinkingAnalyticsAutoTrackEventType)eventType callback:(NSDictionary *(^)(ThinkingAnalyticsAutoTrackEventType eventType, NSDictionary *properties))callback;
|
||||
|
||||
/**
|
||||
Set and Update the value of a custom property for Auto-Tracking
|
||||
|
||||
@param eventType A list of ThinkingAnalyticsAutoTrackEventType, indicating the types of automatic collection events that need to be enabled
|
||||
@param properties properties
|
||||
*/
|
||||
- (void)setAutoTrackProperties:(ThinkingAnalyticsAutoTrackEventType)eventType properties:(NSDictionary *)properties;
|
||||
|
||||
/**
|
||||
Ignore the Auto-Tracking of a page
|
||||
|
||||
@param controllers Ignore the name of the UIViewController
|
||||
*/
|
||||
- (void)ignoreAutoTrackViewControllers:(NSArray *)controllers;
|
||||
|
||||
/**
|
||||
Ignore the Auto-Tracking of click event
|
||||
|
||||
@param aClass ignored controls Class
|
||||
*/
|
||||
- (void)ignoreViewType:(Class)aClass;
|
||||
|
||||
#endif
|
||||
|
||||
//MARK: -
|
||||
|
||||
/**
|
||||
Get DeviceId
|
||||
*/
|
||||
- (NSString *)getDeviceId;
|
||||
|
||||
/**
|
||||
H5 is connected with the native APP SDK and used in conjunction with the addWebViewUserAgent interface
|
||||
|
||||
@param webView webView
|
||||
@param request NSURLRequest request
|
||||
@return YES:Process this request NO: This request has not been processed
|
||||
|
||||
detailed documentation http://doc.thinkingdata.cn/tgamanual/installation/h5_app_integrate.html
|
||||
*/
|
||||
- (BOOL)showUpWebView:(id)webView WithRequest:(NSURLRequest *)request;
|
||||
|
||||
/**
|
||||
When connecting data with H5, you need to call this interface to configure UserAgent
|
||||
*/
|
||||
- (void)addWebViewUserAgent;
|
||||
|
||||
/**
|
||||
Set Log level
|
||||
|
||||
*/
|
||||
+ (void)setLogLevel:(TDLoggingLevel)level;
|
||||
|
||||
/**
|
||||
Empty the cache queue. When this api is called, the data in the current cache queue will attempt to be reported.
|
||||
If the report succeeds, local cache data will be deleted.
|
||||
*/
|
||||
- (void)flush;
|
||||
|
||||
/**
|
||||
Switch reporting status
|
||||
|
||||
@param status TATrackStatus reporting status
|
||||
*/
|
||||
- (void)setTrackStatus: (TATrackStatus)status;
|
||||
|
||||
- (void)enableTracking:(BOOL)enabled DEPRECATED_MSG_ATTRIBUTE("Please use instance method setTrackStatus: TATrackStatusPause");
|
||||
|
||||
- (void)optOutTracking DEPRECATED_MSG_ATTRIBUTE("Please use instance method setTrackStatus: TATrackStatusStop");
|
||||
|
||||
- (void)optOutTrackingAndDeleteUser DEPRECATED_MSG_ATTRIBUTE("Please use instance method setTrackStatus: TATrackStatusStop");
|
||||
|
||||
- (void)optInTracking DEPRECATED_MSG_ATTRIBUTE("Please use instance method setTrackStatus: TATrackStatusNormal");
|
||||
|
||||
/**
|
||||
Create a light instance
|
||||
*/
|
||||
- (ThinkingAnalyticsSDK *)createLightInstance;
|
||||
|
||||
+ (void)calibrateTimeWithNtp:(NSString *)ntpServer;
|
||||
|
||||
+ (void)calibrateTime:(NSTimeInterval)timestamp;
|
||||
|
||||
- (NSString *)getTimeString:(NSDate *)date;
|
||||
|
||||
#if TARGET_OS_IOS
|
||||
- (void)enableThirdPartySharing:(TAThirdPartyShareType)type;
|
||||
|
||||
- (void)enableThirdPartySharing:(TAThirdPartyShareType)type customMap:(NSDictionary<NSString *, NSObject *> *)customMap;
|
||||
#endif
|
||||
|
||||
+ (nullable NSString *)getLocalRegion;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0921e73f1e308ce479c5531a7f1224f1
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47769b322b27cff4590e6c5763e19b3c
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,168 @@
|
||||
#if __has_include(<ThinkingSDK/ThinkingAnalyticsSDK.h>)
|
||||
#import <ThinkingSDK/ThinkingAnalyticsSDK.h>
|
||||
#else
|
||||
#import "ThinkingAnalyticsSDK.h"
|
||||
#endif
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreTelephony/CTCarrier.h>
|
||||
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
|
||||
#import <objc/runtime.h>
|
||||
#import <WebKit/WebKit.h>
|
||||
|
||||
#if TARGET_OS_IOS
|
||||
#import "ThinkingExceptionHandler.h"
|
||||
#import "TAAutoTrackEvent.h"
|
||||
#import "TAAutoTrackSuperProperty.h"
|
||||
#import "TDEncrypt.h"
|
||||
#endif
|
||||
|
||||
#import "TDLogging.h"
|
||||
#import "TDDeviceInfo.h"
|
||||
#import "TDConfig.h"
|
||||
#import "TDSqliteDataQueue.h"
|
||||
#import "TDEventModel.h"
|
||||
|
||||
#import "TATrackTimer.h"
|
||||
#import "TASuperProperty.h"
|
||||
#import "TATrackEvent.h"
|
||||
#import "TATrackFirstEvent.h"
|
||||
#import "TATrackOverwriteEvent.h"
|
||||
#import "TATrackUpdateEvent.h"
|
||||
#import "TAUserPropertyHeader.h"
|
||||
#import "TAPropertyPluginManager.h"
|
||||
//#import "TASessionIdPropertyPlugin.h"
|
||||
#import "TAPresetPropertyPlugin.h"
|
||||
#import "TABaseEvent+H5.h"
|
||||
#import "NSDate+TAFormat.h"
|
||||
#import "TAEventTracker.h"
|
||||
#import "TAAppLifeCycle.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
static NSString * const TD_APP_START_EVENT = @"ta_app_start";
|
||||
static NSString * const TD_APP_START_BACKGROUND_EVENT = @"ta_app_bg_start";
|
||||
static NSString * const TD_APP_END_EVENT = @"ta_app_end";
|
||||
static NSString * const TD_APP_VIEW_EVENT = @"ta_app_view";
|
||||
static NSString * const TD_APP_CLICK_EVENT = @"ta_app_click";
|
||||
static NSString * const TD_APP_CRASH_EVENT = @"ta_app_crash";
|
||||
static NSString * const TD_APP_INSTALL_EVENT = @"ta_app_install";
|
||||
|
||||
static NSString * const TD_CRASH_REASON = @"#app_crashed_reason";
|
||||
static NSString * const TD_RESUME_FROM_BACKGROUND = @"#resume_from_background";
|
||||
static NSString * const TD_START_REASON = @"#start_reason";
|
||||
static NSString * const TD_BACKGROUND_DURATION = @"#background_duration";
|
||||
|
||||
static kEDEventTypeName const TD_EVENT_TYPE_TRACK = @"track";
|
||||
|
||||
static kEDEventTypeName const TD_EVENT_TYPE_USER_DEL = @"user_del";
|
||||
static kEDEventTypeName const TD_EVENT_TYPE_USER_ADD = @"user_add";
|
||||
static kEDEventTypeName const TD_EVENT_TYPE_USER_SET = @"user_set";
|
||||
static kEDEventTypeName const TD_EVENT_TYPE_USER_SETONCE = @"user_setOnce";
|
||||
static kEDEventTypeName const TD_EVENT_TYPE_USER_UNSET = @"user_unset";
|
||||
static kEDEventTypeName const TD_EVENT_TYPE_USER_APPEND = @"user_append";
|
||||
static kEDEventTypeName const TD_EVENT_TYPE_USER_UNIQ_APPEND= @"user_uniq_append";
|
||||
|
||||
#ifndef td_dispatch_main_sync_safe
|
||||
#define td_dispatch_main_sync_safe(block)\
|
||||
if (dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL) == dispatch_queue_get_label(dispatch_get_main_queue())) {\
|
||||
block();\
|
||||
} else {\
|
||||
dispatch_sync(dispatch_get_main_queue(), block);\
|
||||
}
|
||||
#endif
|
||||
|
||||
#define kDefaultTimeFormat @"yyyy-MM-dd HH:mm:ss.SSS"
|
||||
|
||||
static NSUInteger const kBatchSize = 50;
|
||||
static NSUInteger const TA_PROPERTY_CRASH_LENGTH_LIMIT = 8191*2;
|
||||
static NSString * const TA_JS_TRACK_SCHEME = @"thinkinganalytics://trackEvent";
|
||||
|
||||
#define kModeEnumArray @"NORMAL", @"DebugOnly", @"Debug", nil
|
||||
|
||||
@interface ThinkingAnalyticsSDK ()
|
||||
|
||||
#if TARGET_OS_IOS
|
||||
@property (nonatomic, strong) TAAutoTrackSuperProperty *autoTrackSuperProperty;
|
||||
@property (nonatomic, strong) TDEncryptManager *encryptManager;
|
||||
@property (strong,nonatomic) id thirdPartyManager;
|
||||
#endif
|
||||
|
||||
@property (atomic, copy) NSString *appid;
|
||||
@property (atomic, copy) NSString *serverURL;
|
||||
@property (atomic, copy, nullable) NSString *accountId;
|
||||
@property (atomic, copy) NSString *identifyId;
|
||||
@property (nonatomic, strong) TASuperProperty *superProperty;
|
||||
@property (nonatomic, strong) TAPropertyPluginManager *propertyPluginManager;
|
||||
//@property (nonatomic, strong) TASessionIdPropertyPlugin *sessionidPlugin;
|
||||
@property (nonatomic, strong) TAAppLifeCycle *appLifeCycle;
|
||||
/// TD error callback
|
||||
@property (atomic, copy) void(^errorCallback)(NSInteger code, NSString * _Nullable errorMsg, NSString * _Nullable ext);
|
||||
|
||||
@property (atomic, strong) NSMutableSet *ignoredViewTypeList;
|
||||
@property (atomic, strong) NSMutableSet *ignoredViewControllers;
|
||||
|
||||
|
||||
@property (atomic, assign, getter=isTrackPause) BOOL trackPause;
|
||||
@property (atomic, assign) BOOL isEnabled;
|
||||
@property (atomic, assign) BOOL isOptOut;
|
||||
|
||||
|
||||
@property (nonatomic, strong, nullable) NSTimer *timer;
|
||||
|
||||
@property (nonatomic, strong) TATrackTimer *trackTimer;
|
||||
|
||||
@property (atomic, strong) TDSqliteDataQueue *dataQueue;
|
||||
@property (nonatomic, copy) TDConfig *config;
|
||||
@property (nonatomic, strong) WKWebView *wkWebView;
|
||||
|
||||
#if TARGET_OS_IOS
|
||||
- (void)autoTrackWithEvent:(TAAutoTrackEvent *)event properties:(nullable NSDictionary *)properties;
|
||||
- (BOOL)isViewControllerIgnored:(UIViewController *)viewController;
|
||||
- (BOOL)isAutoTrackEventTypeIgnored:(ThinkingAnalyticsAutoTrackEventType)eventType;
|
||||
- (BOOL)isViewTypeIgnored:(Class)aClass;
|
||||
#endif
|
||||
|
||||
- (instancetype)initLight:(NSString *)appid withServerURL:(NSString *)serverURL withConfig:(TDConfig *)config;
|
||||
|
||||
- (void)retrievePersistedData;
|
||||
+ (dispatch_queue_t)td_trackQueue;
|
||||
+ (dispatch_queue_t)td_networkQueue;
|
||||
+ (id)sharedUIApplication;
|
||||
- (NSInteger)saveEventsData:(NSDictionary *)data;
|
||||
- (void)flushImmediately:(NSDictionary *)dataDic;
|
||||
- (BOOL)hasDisabled;
|
||||
- (BOOL)isValidName:(NSString *)name isAutoTrack:(BOOL)isAutoTrack;
|
||||
+ (BOOL)isTrackEvent:(NSString *)eventType;
|
||||
- (BOOL)checkEventProperties:(NSDictionary *)properties withEventType:(NSString *_Nullable)eventType haveAutoTrackEvents:(BOOL)haveAutoTrackEvents;
|
||||
- (void)startFlushTimer;
|
||||
- (double)getTimezoneOffset:(NSDate *)date timeZone:(NSTimeZone *)timeZone;
|
||||
+ (NSMutableDictionary *)_getAllInstances;
|
||||
|
||||
+ (NSMutableDictionary *)_getAllInstances;
|
||||
|
||||
@end
|
||||
|
||||
@interface TDEventModel ()
|
||||
|
||||
@property (nonatomic, copy) NSString *timeString;
|
||||
@property (nonatomic, assign) double zoneOffset;
|
||||
@property (nonatomic, assign) TimeValueType timeValueType;
|
||||
@property (nonatomic, copy) NSString *extraID;
|
||||
@property (nonatomic, assign) BOOL persist;
|
||||
@property (nonatomic, strong) NSDate *time;
|
||||
@property (nonatomic, strong) NSTimeZone *timeZone;
|
||||
|
||||
- (instancetype)initWithEventName:(NSString * _Nullable)eventName;
|
||||
|
||||
- (instancetype _Nonnull )initWithEventName:(NSString * _Nullable)eventName eventType:(kEDEventTypeName _Nonnull )eventType;
|
||||
|
||||
@end
|
||||
|
||||
@interface LightThinkingAnalyticsSDK : ThinkingAnalyticsSDK
|
||||
|
||||
- (instancetype)initWithAPPID:(NSString *)appID withServerURL:(NSString *)serverURL withConfig:(TDConfig *)config;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57b9bb9b2e014b242ab0491547002b7c
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if __has_include(<ThinkingSDK/ThinkingAnalyticsSDK.h>)
|
||||
#import <ThinkingSDK/ThinkingAnalyticsSDK.h>
|
||||
#else
|
||||
#import "ThinkingAnalyticsSDK.h"
|
||||
#endif
|
||||
|
||||
#if __has_include(<ThinkingSDK/TDFirstEventModel.h>)
|
||||
#import <ThinkingSDK/TDFirstEventModel.h>
|
||||
#else
|
||||
#import "TDFirstEventModel.h"
|
||||
#endif
|
||||
|
||||
#if __has_include(<ThinkingSDK/TDEditableEventModel.h>)
|
||||
#import <ThinkingSDK/TDEditableEventModel.h>
|
||||
#else
|
||||
#import "TDEditableEventModel.h"
|
||||
#endif
|
||||
|
||||
#if __has_include(<ThinkingSDK/TDConfig.h>)
|
||||
#import <ThinkingSDK/TDConfig.h>
|
||||
#else
|
||||
#import "TDConfig.h"
|
||||
#endif
|
||||
|
||||
#if __has_include(<ThinkingSDK/TDPresetProperties.h>)
|
||||
#import <ThinkingSDK/TDPresetProperties.h>
|
||||
#else
|
||||
#import "TDPresetProperties.h"
|
||||
#endif
|
||||
|
||||
#if __has_include(<ThinkingSDK/TDDeviceInfo.h>)
|
||||
#import <ThinkingSDK/TDDeviceInfo.h>
|
||||
#else
|
||||
#import "TDDeviceInfo.h"
|
||||
#endif
|
||||
@@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e385aa30cd049a34c9063fd5c45028e6
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
AddToEmbeddedBinaries: false
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user