Merge pull request #383 from microsoft/joasante/semantic-extensions

Add userId and userAdvertisingId setting capabilities to semantic context
This commit is contained in:
Joseph Asante 2020-05-21 14:17:09 -07:00 коммит произвёл GitHub
Родитель e4962f6b74 78a702b434
Коммит 5a5a730e63
5 изменённых файлов: 33 добавлений и 13 удалений

Просмотреть файл

@ -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];