Adds VS App Center analytics + crash reporting

Currently tracks install, refresh, and update app events.
This commit is contained in:
Riley Testut
2020-03-31 14:31:34 -07:00
parent cd89741827
commit 193ca28c98
71 changed files with 3548 additions and 314 deletions

View File

@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#import <Foundation/Foundation.h>
#import "MSAbstractLog.h"
#import "MSAppCenter.h"
#import "MSAppCenterErrors.h"
#import "MSChannelGroupProtocol.h"
#import "MSChannelProtocol.h"
#import "MSConstants.h"
#import "MSCustomProperties.h"
#import "MSDevice.h"
#import "MSEnable.h"
#import "MSLog.h"
#import "MSLogWithProperties.h"
#import "MSLogger.h"
#import "MSService.h"
#import "MSServiceAbstract.h"
#import "MSWrapperLogger.h"
#import "MSWrapperSdk.h"

View File

@@ -0,0 +1,13 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#ifndef MS_ABSTRACT_LOG_H
#define MS_ABSTRACT_LOG_H
#import <Foundation/Foundation.h>
@interface MSAbstractLog : NSObject
@end
#endif

View File

@@ -0,0 +1,223 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#import <Foundation/Foundation.h>
#import "MSConstants.h"
@class MSWrapperSdk;
#if !TARGET_OS_TV
@class MSCustomProperties;
#endif
@interface MSAppCenter : NSObject
/**
* Returns the singleton instance of MSAppCenter.
*/
+ (instancetype)sharedInstance;
/**
* Configure the SDK with an application secret.
*
* @param appSecret A unique and secret key used to identify the application.
*
* @discussion This may be called only once per application process lifetime.
*/
+ (void)configureWithAppSecret:(NSString *)appSecret;
/**
* Configure the SDK.
*
* @discussion This may be called only once per application process lifetime.
*/
+ (void)configure;
/**
* Configure the SDK with an application secret and an array of services to start.
*
* @param appSecret A unique and secret key used to identify the application.
* @param services Array of services to start.
*
* @discussion This may be called only once per application process lifetime.
*/
+ (void)start:(NSString *)appSecret withServices:(NSArray<Class> *)services;
/**
* Start the SDK with an array of services.
*
* @param services Array of services to start.
*
* @discussion This may be called only once per application process lifetime.
*/
+ (void)startWithServices:(NSArray<Class> *)services;
/**
* Start a service.
*
* @param service A service to start.
*
* @discussion This may be called only once per service per application process lifetime.
*/
+ (void)startService:(Class)service;
/**
* Configure the SDK with an array of services to start from a library. This will not start the service at application level, it will enable
* the service only for the library.
*
* @param services Array of services to start.
*/
+ (void)startFromLibraryWithServices:(NSArray<Class> *)services;
/**
* Check whether the SDK has already been configured or not.
*
* @return YES if configured, NO otherwise.
*/
+ (BOOL)isConfigured;
/**
* Check whether app is running in App Center Test Cloud.
*
* @return true if running in App Center Test Cloud, false otherwise.
*/
+ (BOOL)isRunningInAppCenterTestCloud;
/**
* Change the base URL (schema + authority + port only) used to communicate with the backend.
*
* @param logUrl Base URL to use for backend communication.
*/
+ (void)setLogUrl:(NSString *)logUrl;
/**
* Enable or disable the SDK as a whole. In addition to AppCenter resources, it will also enable or disable all registered services.
* The state is persisted in the device's storage across application launches.
*
* @param isEnabled YES to enable, NO to disable.
*
* @see isEnabled
*/
+ (void)setEnabled:(BOOL)isEnabled;
/**
* Check whether the SDK is enabled or not as a whole.
*
* @return YES if enabled, NO otherwise.
*
* @see setEnabled:
*/
+ (BOOL)isEnabled;
/**
* Get log level.
*
* @return Log level.
*/
+ (MSLogLevel)logLevel;
/**
* Set log level.
*
* @param logLevel The log level.
*/
+ (void)setLogLevel:(MSLogLevel)logLevel;
/**
* Set log level handler.
*
* @param logHandler Handler.
*/
+ (void)setLogHandler:(MSLogHandler)logHandler;
/**
* Set wrapper SDK information to use when building device properties. This is intended in case you are building a SDK that uses the App
* Center SDK under the hood, e.g. our Xamarin SDK or ReactNative SDk.
*
* @param wrapperSdk Wrapper SDK information.
*/
+ (void)setWrapperSdk:(MSWrapperSdk *)wrapperSdk;
#if !TARGET_OS_TV
/**
* Set the custom properties.
*
* @param customProperties Custom properties object.
*/
+ (void)setCustomProperties:(MSCustomProperties *)customProperties;
#endif
/**
* Check whether the application delegate forwarder is enabled or not.
*
* @return YES if enabled, NO otherwise.
*
* @discussion The application delegate forwarder forwards messages that target your application delegate methods via swizzling to the SDK.
* It simplifies the SDK integration but may not be suitable to any situations. For
* instance it should be disabled if you or one of your third party SDK is doing message forwarding on the application delegate. Message
* forwarding usually implies the implementation of @see NSObject#forwardingTargetForSelector: or @see NSObject#forwardInvocation: methods.
* To disable the application delegate forwarder just add the `AppCenterAppDelegateForwarderEnabled` tag to your Info .plist file and set it
* to `0`. Then you will have to forward any application delegate needed by the SDK manually.
*/
+ (BOOL)isAppDelegateForwarderEnabled;
/**
* Get unique installation identifier.
*
* @return Unique installation identifier.
*/
+ (NSUUID *)installId;
/**
* Detect if a debugger is attached to the app process. This is only invoked once on app startup and can not detect
* if the debugger is being attached during runtime!
*
* @return BOOL if the debugger is attached.
*/
+ (BOOL)isDebuggerAttached;
/**
* Get the current version of AppCenter SDK.
*
* @return The current version of AppCenter SDK.
*/
+ (NSString *)sdkVersion;
/**
* Set the maximum size of the internal storage. This method must be called before App Center is started. This method is only intended for
* applications.
*
* @param sizeInBytes Maximum size of the internal storage in bytes. This will be rounded up to the nearest multiple of a SQLite page size
* (default is 4096 bytes). Values below 20,480 bytes (20 KiB) will be ignored.
*
* @param completionHandler Callback that is invoked when the database size has been set. The `BOOL` parameter is `YES` if changing the size
* is successful, and `NO` otherwise. This parameter can be null.
*
* @discussion This only sets the maximum size of the database, but App Center modules might store additional data.
* The value passed to this method is not persisted on disk. The default maximum database size is 10485760 bytes (10 MiB).
*/
+ (void)setMaxStorageSize:(long)sizeInBytes completionHandler:(void (^)(BOOL))completionHandler;
/**
* Set the user identifier.
*
* @param userId User identifier.
*
* @discussion Set the user identifier for logs sent for the default target token when the secret passed in @c
* MSAppCenter:start:withServices: contains "target={targetToken}".
*
* For App Center backend the user identifier maximum length is 256 characters.
*
* AppCenter must be configured or started before this API can be used.
*/
+ (void)setUserId:(NSString *)userId;
/**
* Set country code to use when building device properties.
*
* @param countryCode The two-letter ISO country code. @see https://www.iso.org/obp/ui/#search for more information.
*/
+ (void)setCountryCode:(NSString *)countryCode;
@end

View File

@@ -0,0 +1,41 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#ifndef MS_APP_CENTER_ERRORS_H
#define MS_APP_CENTER_ERRORS_H
#import <Foundation/Foundation.h>
#define MS_APP_CENTER_BASE_DOMAIN @"com.Microsoft.AppCenter."
NS_ASSUME_NONNULL_BEGIN
#pragma mark - Domain
static NSString *const kMSACErrorDomain = MS_APP_CENTER_BASE_DOMAIN @"ErrorDomain";
#pragma mark - General
// Error codes.
NS_ENUM(NSInteger){MSACLogInvalidContainerErrorCode = 1, MSACCanceledErrorCode = 2, MSACDisabledErrorCode = 3};
// Error descriptions.
static NSString const *kMSACLogInvalidContainerErrorDesc = @"Invalid log container.";
static NSString const *kMSACCanceledErrorDesc = @"The operation was canceled.";
static NSString const *kMSACDisabledErrorDesc = @"The service is disabled.";
#pragma mark - Connection
// Error codes.
NS_ENUM(NSInteger){MSACConnectionPausedErrorCode = 100, MSACConnectionHttpErrorCode = 101};
// Error descriptions.
static NSString const *kMSACConnectionHttpErrorDesc = @"An HTTP error occured.";
static NSString const *kMSACConnectionPausedErrorDesc = @"Canceled, connection paused with log deletion.";
// Error user info keys.
static NSString const *kMSACConnectionHttpCodeErrorKey = @"MSACConnectionHttpCode";
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,83 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#ifndef MS_CHANNEL_GROUP_PROTOCOL_H
#define MS_CHANNEL_GROUP_PROTOCOL_H
#import <Foundation/Foundation.h>
#import "MSChannelProtocol.h"
NS_ASSUME_NONNULL_BEGIN
@class MSChannelUnitConfiguration;
@protocol MSIngestionProtocol;
@protocol MSChannelUnitProtocol;
/**
* `MSChannelGroupProtocol` represents a kind of channel that contains constituent MSChannelUnit objects. When an operation from the
* `MSChannelProtocol` is performed on the group, that operation should be propagated to its constituent MSChannelUnit objects.
*/
@protocol MSChannelGroupProtocol <MSChannelProtocol>
/**
* Initialize a channel unit with the given configuration.
*
* @param configuration channel configuration.
*
* @return The added `MSChannelUnitProtocol`. Use this object to enqueue logs.
*/
- (id<MSChannelUnitProtocol>)addChannelUnitWithConfiguration:(MSChannelUnitConfiguration *)configuration;
/**
* Initialize a channel unit with the given configuration.
*
* @param configuration channel configuration.
* @param ingestion The alternative ingestion object
*
* @return The added `MSChannelUnitProtocol`. Use this object to enqueue logs.
*/
- (id<MSChannelUnitProtocol>)addChannelUnitWithConfiguration:(MSChannelUnitConfiguration *)configuration
withIngestion:(nullable id<MSIngestionProtocol>)ingestion;
/**
* Change the base URL (schema + authority + port only) used to communicate with the backend.
*
* @param logUrl base URL to use for backend communication.
*/
- (void)setLogUrl:(NSString *)logUrl;
/**
* Set the app secret.
*
* @param appSecret The app secret.
*/
- (void)setAppSecret:(NSString *)appSecret;
/**
* Set the maximum size of the internal storage. This method must be called before App Center is started.
*
* @discussion The default maximum database size is 10485760 bytes (10 MiB).
*
* @param sizeInBytes Maximum size of the internal storage in bytes. This will be rounded up to the nearest multiple of a SQLite page size
* (default is 4096 bytes). Values below 24576 bytes (24 KiB) will be ignored.
* @param completionHandler Callback that is invoked when the database size has been set. The `BOOL` parameter is `YES` if changing the size
* is successful, and `NO` otherwise.
*/
- (void)setMaxStorageSize:(long)sizeInBytes completionHandler:(nullable void (^)(BOOL))completionHandler;
/**
* Return a channel unit instance for the given groupId.
*
* @param groupId The group ID for a channel unit.
*
* @return A channel unit instance or `nil`.
*/
- (id<MSChannelUnitProtocol>)channelUnitForGroupId:(NSString *)groupId;
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,63 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#ifndef MS_CHANNEL_PROTOCOL_H
#define MS_CHANNEL_PROTOCOL_H
#import <Foundation/Foundation.h>
#import "MSEnable.h"
NS_ASSUME_NONNULL_BEGIN
@protocol MSChannelDelegate;
/**
* `MSChannelProtocol` contains the essential operations of a channel. Channels are broadly responsible for enqueuing logs to be sent to the
* backend and/or stored on disk.
*/
@protocol MSChannelProtocol <NSObject, MSEnable>
/**
* Add delegate.
*
* @param delegate delegate.
*/
- (void)addDelegate:(id<MSChannelDelegate>)delegate;
/**
* Remove delegate.
*
* @param delegate delegate.
*/
- (void)removeDelegate:(id<MSChannelDelegate>)delegate;
/**
* Pause operations, logs will be stored but not sent.
*
* @param identifyingObject Object used to identify the pause request.
*
* @discussion A paused channel doesn't forward logs to the ingestion. The identifying object used to pause the channel can be any unique
* object. The same identifying object must be used to call resume. For simplicity if the caller is the one owning the channel then @c self
* can be used as identifying object.
*
* @see resumeWithIdentifyingObject:
*/
- (void)pauseWithIdentifyingObject:(id<NSObject>)identifyingObject;
/**
* Resume operations, logs can be sent again.
*
* @param identifyingObject Object used to passed to the pause method.
*
* @discussion The channel only resume when all the outstanding identifying objects have been resumed.
*
* @see pauseWithIdentifyingObject:
*/
- (void)resumeWithIdentifyingObject:(id<NSObject>)identifyingObject;
@end
NS_ASSUME_NONNULL_END
#endif

View File

@@ -0,0 +1,170 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#import <Foundation/Foundation.h>
/**
* Log Levels
*/
typedef NS_ENUM(NSUInteger, MSLogLevel) {
/**
* Logging will be very chatty
*/
MSLogLevelVerbose = 2,
/**
* Debug information will be logged
*/
MSLogLevelDebug = 3,
/**
* Information will be logged
*/
MSLogLevelInfo = 4,
/**
* Errors and warnings will be logged
*/
MSLogLevelWarning = 5,
/**
* Errors will be logged
*/
MSLogLevelError = 6,
/**
* Only critical errors will be logged
*/
MSLogLevelAssert = 7,
/**
* Logging is disabled
*/
MSLogLevelNone = 99
};
typedef NSString * (^MSLogMessageProvider)(void);
typedef void (^MSLogHandler)(MSLogMessageProvider messageProvider, MSLogLevel logLevel, NSString *tag, const char *file,
const char *function, uint line);
/**
* Channel priorities, check the kMSPriorityCount if you add a new value.
* The order matters here! Values NEED to range from low priority to high priority.
*/
typedef NS_ENUM(NSInteger, MSPriority) { MSPriorityBackground, MSPriorityDefault, MSPriorityHigh };
static short const kMSPriorityCount = MSPriorityHigh + 1;
/**
* The priority by which the modules are initialized.
* MSPriorityMax is reserved for only 1 module and this needs to be Crashes.
* Crashes needs to be initialized first to catch crashes in our other SDK Modules (which will hopefully never happen) and to avoid losing
* any log at crash time.
*/
typedef NS_ENUM(NSInteger, MSInitializationPriority) {
MSInitializationPriorityDefault = 500,
MSInitializationPriorityHigh = 750,
MSInitializationPriorityMax = 999
};
/**
* Enum with the different HTTP status codes.
*/
typedef NS_ENUM(NSInteger, MSHTTPCodesNo) {
// Invalid
MSHTTPCodesNo0XXInvalidUnknown = 0,
// Informational
MSHTTPCodesNo1XXInformationalUnknown = 1,
MSHTTPCodesNo100Continue = 100,
MSHTTPCodesNo101SwitchingProtocols = 101,
MSHTTPCodesNo102Processing = 102,
// Success
MSHTTPCodesNo2XXSuccessUnknown = 2,
MSHTTPCodesNo200OK = 200,
MSHTTPCodesNo201Created = 201,
MSHTTPCodesNo202Accepted = 202,
MSHTTPCodesNo203NonAuthoritativeInformation = 203,
MSHTTPCodesNo204NoContent = 204,
MSHTTPCodesNo205ResetContent = 205,
MSHTTPCodesNo206PartialContent = 206,
MSHTTPCodesNo207MultiStatus = 207,
MSHTTPCodesNo208AlreadyReported = 208,
MSHTTPCodesNo209IMUsed = 209,
// Redirection
MSHTTPCodesNo3XXSuccessUnknown = 3,
MSHTTPCodesNo300MultipleChoices = 300,
MSHTTPCodesNo301MovedPermanently = 301,
MSHTTPCodesNo302Found = 302,
MSHTTPCodesNo303SeeOther = 303,
MSHTTPCodesNo304NotModified = 304,
MSHTTPCodesNo305UseProxy = 305,
MSHTTPCodesNo306SwitchProxy = 306,
MSHTTPCodesNo307TemporaryRedirect = 307,
MSHTTPCodesNo308PermanentRedirect = 308,
// Client error
MSHTTPCodesNo4XXSuccessUnknown = 4,
MSHTTPCodesNo400BadRequest = 400,
MSHTTPCodesNo401Unauthorised = 401,
MSHTTPCodesNo402PaymentRequired = 402,
MSHTTPCodesNo403Forbidden = 403,
MSHTTPCodesNo404NotFound = 404,
MSHTTPCodesNo405MethodNotAllowed = 405,
MSHTTPCodesNo406NotAcceptable = 406,
MSHTTPCodesNo407ProxyAuthenticationRequired = 407,
MSHTTPCodesNo408RequestTimeout = 408,
MSHTTPCodesNo409Conflict = 409,
MSHTTPCodesNo410Gone = 410,
MSHTTPCodesNo411LengthRequired = 411,
MSHTTPCodesNo412PreconditionFailed = 412,
MSHTTPCodesNo413RequestEntityTooLarge = 413,
MSHTTPCodesNo414RequestURITooLong = 414,
MSHTTPCodesNo415UnsupportedMediaType = 415,
MSHTTPCodesNo416RequestedRangeNotSatisfiable = 416,
MSHTTPCodesNo417ExpectationFailed = 417,
MSHTTPCodesNo418IamATeapot = 418,
MSHTTPCodesNo419AuthenticationTimeout = 419,
MSHTTPCodesNo420MethodFailureSpringFramework = 420,
MSHTTPCodesNo420EnhanceYourCalmTwitter = 4200,
MSHTTPCodesNo422UnprocessableEntity = 422,
MSHTTPCodesNo423Locked = 423,
MSHTTPCodesNo424FailedDependency = 424,
MSHTTPCodesNo424MethodFailureWebDaw = 4240,
MSHTTPCodesNo425UnorderedCollection = 425,
MSHTTPCodesNo426UpgradeRequired = 426,
MSHTTPCodesNo428PreconditionRequired = 428,
MSHTTPCodesNo429TooManyRequests = 429,
MSHTTPCodesNo431RequestHeaderFieldsTooLarge = 431,
MSHTTPCodesNo444NoResponseNginx = 444,
MSHTTPCodesNo449RetryWithMicrosoft = 449,
MSHTTPCodesNo450BlockedByWindowsParentalControls = 450,
MSHTTPCodesNo451RedirectMicrosoft = 451,
MSHTTPCodesNo451UnavailableForLegalReasons = 4510,
MSHTTPCodesNo494RequestHeaderTooLargeNginx = 494,
MSHTTPCodesNo495CertErrorNginx = 495,
MSHTTPCodesNo496NoCertNginx = 496,
MSHTTPCodesNo497HTTPToHTTPSNginx = 497,
MSHTTPCodesNo499ClientClosedRequestNginx = 499,
// Server error
MSHTTPCodesNo5XXSuccessUnknown = 5,
MSHTTPCodesNo500InternalServerError = 500,
MSHTTPCodesNo501NotImplemented = 501,
MSHTTPCodesNo502BadGateway = 502,
MSHTTPCodesNo503ServiceUnavailable = 503,
MSHTTPCodesNo504GatewayTimeout = 504,
MSHTTPCodesNo505HTTPVersionNotSupported = 505,
MSHTTPCodesNo506VariantAlsoNegotiates = 506,
MSHTTPCodesNo507InsufficientStorage = 507,
MSHTTPCodesNo508LoopDetected = 508,
MSHTTPCodesNo509BandwidthLimitExceeded = 509,
MSHTTPCodesNo510NotExtended = 510,
MSHTTPCodesNo511NetworkAuthenticationRequired = 511,
MSHTTPCodesNo522ConnectionTimedOut = 522,
MSHTTPCodesNo598NetworkReadTimeoutErrorUnknown = 598,
MSHTTPCodesNo599NetworkConnectTimeoutErrorUnknown = 599
};

View File

@@ -0,0 +1,70 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#ifndef MS_CUSTOM_PROPERTIES_H
#define MS_CUSTOM_PROPERTIES_H
#import <Foundation/Foundation.h>
/**
* Custom properties builder.
* Collects multiple properties to send in one log.
*/
@interface MSCustomProperties : NSObject
/**
* Set the specified property value with the specified key.
* If the properties previously contained a property for the key, the old value is replaced.
*
* @param key Key with which the specified value is to be set.
* @param value Value to be set with the specified key.
*
* @return This instance.
*/
- (instancetype)setString:(NSString *)value forKey:(NSString *)key;
/**
* Set the specified property value with the specified key.
* If the properties previously contained a property for the key, the old value is replaced.
*
* @param key Key with which the specified value is to be set.
* @param value Value to be set with the specified key.
*
* @return This instance.
*/
- (instancetype)setNumber:(NSNumber *)value forKey:(NSString *)key;
/**
* Set the specified property value with the specified key.
* If the properties previously contained a property for the key, the old value is replaced.
*
* @param key Key with which the specified value is to be set.
* @param value Value to be set with the specified key.
*
* @return This instance.
*/
- (instancetype)setBool:(BOOL)value forKey:(NSString *)key;
/**
* Set the specified property value with the specified key.
* If the properties previously contained a property for the key, the old value is replaced.
*
* @param key Key with which the specified value is to be set.
* @param value Value to be set with the specified key.
*
* @return This instance.
*/
- (instancetype)setDate:(NSDate *)value forKey:(NSString *)key;
/**
* Clear the property for the specified key.
*
* @param key Key whose mapping is to be cleared.
*
* @return This instance.
*/
- (instancetype)clearPropertyForKey:(NSString *)key;
@end
#endif

View File

@@ -0,0 +1,96 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#ifndef MS_DEVICE_H
#define MS_DEVICE_H
#import <Foundation/Foundation.h>
#import "MSWrapperSdk.h"
@interface MSDevice : MSWrapperSdk
/*
* Name of the SDK. Consists of the name of the SDK and the platform, e.g. "appcenter.ios", "appcenter.android"
*/
@property(nonatomic, copy, readonly) NSString *sdkName;
/*
* Version of the SDK in semver format, e.g. "1.2.0" or "0.12.3-alpha.1".
*/
@property(nonatomic, copy, readonly) NSString *sdkVersion;
/*
* Device model (example: iPad2,3).
*/
@property(nonatomic, copy, readonly) NSString *model;
/*
* Device manufacturer (example: HTC).
*/
@property(nonatomic, copy, readonly) NSString *oemName;
/*
* OS name (example: iOS).
*/
@property(nonatomic, copy, readonly) NSString *osName;
/*
* OS version (example: 9.3.0).
*/
@property(nonatomic, copy, readonly) NSString *osVersion;
/*
* OS build code (example: LMY47X). [optional]
*/
@property(nonatomic, copy, readonly) NSString *osBuild;
/*
* API level when applicable like in Android (example: 15). [optional]
*/
@property(nonatomic, copy, readonly) NSNumber *osApiLevel;
/*
* Language code (example: en_US).
*/
@property(nonatomic, copy, readonly) NSString *locale;
/*
* The offset in minutes from UTC for the device time zone, including daylight savings time.
*/
@property(nonatomic, readonly, strong) NSNumber *timeZoneOffset;
/*
* Screen size of the device in pixels (example: 640x480).
*/
@property(nonatomic, copy, readonly) NSString *screenSize;
/*
* Application version name, e.g. 1.1.0
*/
@property(nonatomic, copy, readonly) NSString *appVersion;
/*
* Carrier name (for mobile devices). [optional]
*/
@property(nonatomic, copy, readonly) NSString *carrierName;
/*
* Carrier country code (for mobile devices). [optional]
*/
@property(nonatomic, copy, readonly) NSString *carrierCountry;
/*
* The app's build number, e.g. 42.
*/
@property(nonatomic, copy, readonly) NSString *appBuild;
/*
* The bundle identifier, package identifier, or namespace, depending on what the individual plattforms use, .e.g com.microsoft.example.
* [optional]
*/
@property(nonatomic, copy, readonly) NSString *appNamespace;
@end
#endif

View File

@@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#ifndef MS_ENABLE_H
#define MS_ENABLE_H
#import <Foundation/Foundation.h>
/**
* Protocol to define an instance that can be enabled/disabled.
*/
@protocol MSEnable <NSObject>
@required
/**
* Enable/disable this instance and delete data on disabled state.
*
* @param isEnabled A boolean value set to YES to enable the instance or NO to disable it.
* @param deleteData A boolean value set to YES to delete data or NO to keep it.
*/
- (void)setEnabled:(BOOL)isEnabled andDeleteDataOnDisabled:(BOOL)deleteData;
@end
#endif

View File

@@ -0,0 +1,73 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#ifndef MS_LOG_H
#define MS_LOG_H
#import <Foundation/Foundation.h>
@class MSDevice;
@protocol MSLog <NSObject>
/**
* Log type.
*/
@property(nonatomic, copy) NSString *type;
/**
* Log timestamp.
*/
@property(nonatomic, strong) NSDate *timestamp;
/**
* A session identifier is used to correlate logs together. A session is an abstract concept in the API and is not necessarily an analytics
* session, it can be used to only track crashes.
*/
@property(nonatomic, copy) NSString *sid;
/**
* Optional distribution group ID value.
*/
@property(nonatomic, copy) NSString *distributionGroupId;
/**
* Optional user identifier.
*/
@property(nonatomic, copy) NSString *userId;
/**
* Device properties associated to this log.
*/
@property(nonatomic, strong) MSDevice *device;
/**
* Transient object tag. For example, a log can be tagged with a transmission target. We do this currently to prevent properties being
* applied retroactively to previous logs by comparing their tags.
*/
@property(nonatomic, strong) NSObject *tag;
/**
* Checks if the object's values are valid.
*
* @return YES, if the object is valid.
*/
- (BOOL)isValid;
/**
* Adds a transmission target token that this log should be sent to.
*
* @param token The transmission target token.
*/
- (void)addTransmissionTargetToken:(NSString *)token;
/**
* Gets all transmission target tokens that this log should be sent to.
*
* @returns Collection of transmission target tokens that this log should be sent to.
*/
- (NSSet *)transmissionTargetTokens;
@end
#endif

View File

@@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#ifndef MS_LOG_WITH_PROPERTIES_H
#define MS_LOG_WITH_PROPERTIES_H
#import <Foundation/Foundation.h>
#import "MSAbstractLog.h"
@interface MSLogWithProperties : MSAbstractLog
/**
* Additional key/value pair parameters. [optional]
*/
@property(nonatomic, strong) NSDictionary<NSString *, NSString *> *properties;
@end
#endif

View File

@@ -0,0 +1,44 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#import <Foundation/Foundation.h>
#import "MSConstants.h"
#define MSLog(_level, _tag, _message) \
[MSLogger logMessage:_message level:_level tag:_tag file:__FILE__ function:__PRETTY_FUNCTION__ line:__LINE__]
#define MSLogAssert(tag, format, ...) \
MSLog(MSLogLevelAssert, tag, (^{ \
return [NSString stringWithFormat:(format), ##__VA_ARGS__]; \
}))
#define MSLogError(tag, format, ...) \
MSLog(MSLogLevelError, tag, (^{ \
return [NSString stringWithFormat:(format), ##__VA_ARGS__]; \
}))
#define MSLogWarning(tag, format, ...) \
MSLog(MSLogLevelWarning, tag, (^{ \
return [NSString stringWithFormat:(format), ##__VA_ARGS__]; \
}))
#define MSLogInfo(tag, format, ...) \
MSLog(MSLogLevelInfo, tag, (^{ \
return [NSString stringWithFormat:(format), ##__VA_ARGS__]; \
}))
#define MSLogDebug(tag, format, ...) \
MSLog(MSLogLevelDebug, tag, (^{ \
return [NSString stringWithFormat:(format), ##__VA_ARGS__]; \
}))
#define MSLogVerbose(tag, format, ...) \
MSLog(MSLogLevelVerbose, tag, (^{ \
return [NSString stringWithFormat:(format), ##__VA_ARGS__]; \
}))
@interface MSLogger : NSObject
+ (void)logMessage:(MSLogMessageProvider)messageProvider
level:(MSLogLevel)loglevel
tag:(NSString *)tag
file:(const char *)file
function:(const char *)function
line:(uint)line;
@end

View File

@@ -0,0 +1,35 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#ifndef MS_SERVICE_H
#define MS_SERVICE_H
#import <Foundation/Foundation.h>
/**
* Protocol declaring service logic.
*/
@protocol MSService <NSObject>
/**
* Enable or disable this service.
* The state is persisted in the device's storage across application launches.
*
* @param isEnabled Whether this service is enabled or not.
*
* @see isEnabled
*/
+ (void)setEnabled:(BOOL)isEnabled;
/**
* Indicates whether this service is enabled.
*
* @return `YES` if this service is enabled, `NO` if it is not.
*
* @see setEnabled:
*/
+ (BOOL)isEnabled;
@end
#endif

View File

@@ -0,0 +1,55 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#ifndef MS_SERVICE_ABSTRACT_H
#define MS_SERVICE_ABSTRACT_H
#import <Foundation/Foundation.h>
#import "MSService.h"
@protocol MSChannelGroupProtocol;
/**
* Abstraction of services common logic.
* This class is intended to be subclassed only not instantiated directly.
*/
@interface MSServiceAbstract : NSObject <MSService>
/**
* The flag indicates whether the service is started from application or not.
*/
@property(nonatomic, assign) BOOL startedFromApplication;
/**
* Start this service with a channel group. Also sets the flag that indicates that a service has been started.
*
* @param channelGroup channel group used to persist and send logs.
* @param appSecret app secret for the SDK.
* @param token default transmission target token for this service.
* @param fromApplication indicates whether the service started from an application or not.
*/
- (void)startWithChannelGroup:(id<MSChannelGroupProtocol>)channelGroup
appSecret:(NSString *)appSecret
transmissionTargetToken:(NSString *)token
fromApplication:(BOOL)fromApplication;
/**
* Update configuration when the service requires to start again. This method should only be called if the service is started from libraries
* and then is being started from an application.
*
* @param appSecret app secret for the SDK.
* @param token default transmission target token for this service.
*/
- (void)updateConfigurationWithAppSecret:(NSString *)appSecret transmissionTargetToken:(NSString *)token;
/**
* Checks if the service needs the application secret.
*
* @return `YES` if the application secret is required, `NO` otherwise.
*/
- (BOOL)isAppSecretRequired;
@end
#endif

View File

@@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#import <Foundation/Foundation.h>
#import "MSConstants.h"
/**
* This is a utility for producing App Center style log messages. It is only intended for use by App Center services and wrapper SDKs of App
* Center.
*/
@interface MSWrapperLogger : NSObject
+ (void)MSWrapperLog:(MSLogMessageProvider)message tag:(NSString *)tag level:(MSLogLevel)level;
@end

View File

@@ -0,0 +1,59 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#ifndef MS_WRAPPER_SDK_H
#define MS_WRAPPER_SDK_H
#import <Foundation/Foundation.h>
@interface MSWrapperSdk : NSObject
/*
* Version of the wrapper SDK. When the SDK is embedding another base SDK (for example Xamarin.Android wraps Android), the Xamarin specific
* version is populated into this field while sdkVersion refers to the original Android SDK. [optional]
*/
@property(nonatomic, copy, readonly) NSString *wrapperSdkVersion;
/*
* Name of the wrapper SDK (examples: Xamarin, Cordova). [optional]
*/
@property(nonatomic, copy, readonly) NSString *wrapperSdkName;
/*
* Version of the wrapper technology framework (Xamarin runtime version or ReactNative or Cordova etc...). [optional]
*/
@property(nonatomic, copy, readonly) NSString *wrapperRuntimeVersion;
/*
* Label that is used to identify application code 'version' released via Live Update beacon running on device.
*/
@property(nonatomic, copy, readonly) NSString *liveUpdateReleaseLabel;
/*
* Identifier of environment that current application release belongs to, deployment key then maps to environment like Production, Staging.
*/
@property(nonatomic, copy, readonly) NSString *liveUpdateDeploymentKey;
/*
* Hash of all files (ReactNative or Cordova) deployed to device via LiveUpdate beacon. Helps identify the Release version on device or need
* to download updates in future
*/
@property(nonatomic, copy, readonly) NSString *liveUpdatePackageHash;
- (instancetype)initWithWrapperSdkVersion:(NSString *)wrapperSdkVersion
wrapperSdkName:(NSString *)wrapperSdkName
wrapperRuntimeVersion:(NSString *)wrapperRuntimeVersion
liveUpdateReleaseLabel:(NSString *)liveUpdateReleaseLabel
liveUpdateDeploymentKey:(NSString *)liveUpdateDeploymentKey
liveUpdatePackageHash:(NSString *)liveUpdatePackageHash;
/**
* Checks if the object's values are valid.
*
* @return YES, if the object is valid.
*/
- (BOOL)isValid;
@end
#endif