Merge pull request #383 from microsoft/joasante/semantic-extensions
Add userId and userAdvertisingId setting capabilities to semantic context
This commit is contained in:
Коммит
5a5a730e63
|
@ -118,11 +118,9 @@ typedef NS_ENUM(NSInteger, ODWSessionState)
|
|||
eventProperties:(ODWEventProperties *)properties;
|
||||
|
||||
/*!
|
||||
@brief Get a pointer to the semantic context for this ODWLogger
|
||||
@return A pointer to the semantic context
|
||||
Semantic context for this ODWLogger
|
||||
*/
|
||||
-(ODWSemanticContext*)getSemanticContext;
|
||||
|
||||
@property (NS_NONATOMIC_IOSONLY, readonly, strong, nonnull) ODWSemanticContext* semanticContext;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -12,9 +12,10 @@ using namespace MAT;
|
|||
@implementation ODWLogger
|
||||
{
|
||||
ILogger* _wrappedLogger;
|
||||
ODWSemanticContext* semanticContext;
|
||||
}
|
||||
|
||||
@synthesize semanticContext = _semanticContext;
|
||||
|
||||
-(instancetype)initWithILogger:(ILogger*)logger
|
||||
{
|
||||
self = [super init];
|
||||
|
@ -24,7 +25,7 @@ using namespace MAT;
|
|||
{
|
||||
NSLog(@"Logger initialized successfully");
|
||||
}
|
||||
semanticContext = [[ODWSemanticContext alloc] initWithISemanticContext:_wrappedLogger->GetSemanticContext()];
|
||||
_semanticContext = [[ODWSemanticContext alloc] initWithISemanticContext:_wrappedLogger->GetSemanticContext()];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -205,9 +206,4 @@ using namespace MAT;
|
|||
}
|
||||
}
|
||||
|
||||
-(ODWSemanticContext*) getSemanticContext
|
||||
{
|
||||
return semanticContext;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -8,11 +8,23 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@interface ODWSemanticContext : NSObject
|
||||
|
||||
/*!
|
||||
@brief Specfies an application id to be included with every event
|
||||
@brief Specifies an application id to be included with every event
|
||||
@param appId A string that contains an application identifier
|
||||
*/
|
||||
-(void)setAppId:(NSString *)appId;
|
||||
|
||||
/*!
|
||||
@brief Specifies a unique user id to be included with every event
|
||||
@param userId A string that contains the unique user identifier.
|
||||
*/
|
||||
-(void)setUserId:(nonnull NSString *)userId;
|
||||
|
||||
/*!
|
||||
@brief Specifies a unique user advertising id to be included with every event
|
||||
@param userAdvertisingId AA string that contains the unique user advertising identifier.
|
||||
*/
|
||||
-(void)setUserAdvertisingId:(nonnull NSString *)userAdvertisingId;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
|
|
@ -25,4 +25,16 @@ using namespace MAT;
|
|||
_wrappedSemanticContext->SetAppId(strAppId);
|
||||
}
|
||||
|
||||
-(void)setUserId:(nonnull NSString *)userId
|
||||
{
|
||||
std::string strUserId = std::string([userId UTF8String]);
|
||||
_wrappedSemanticContext->SetUserId(strUserId);
|
||||
}
|
||||
|
||||
-(void)setUserAdvertisingId:(nonnull NSString *)userAdvertisingId
|
||||
{
|
||||
std::string strUserAdvertisingId = std::string([userAdvertisingId UTF8String]);
|
||||
_wrappedSemanticContext->SetUserAdvertisingId(strUserAdvertisingId);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -38,7 +38,9 @@ int main(int argc, char** argv){
|
|||
|
||||
[logger2 logEventWithEventProperties: event2];
|
||||
|
||||
[[logger2 getSemanticContext] setAppId:@"MyAppId"];
|
||||
[[logger2 semanticContext] setAppId:@"MyAppId"];
|
||||
[[logger2 semanticContext] setUserId:@"m:1010101010101010"];
|
||||
[[logger2 semanticContext] setUserAdvertisingId:@"p:00000000-0000-0000-0000-000000000000"];
|
||||
ODWEventProperties* event3 = [[ODWEventProperties alloc] initWithName:@"SemanticContext_ObjC_Event"];
|
||||
[logger2 logEventWithEventProperties: event3];
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче