release 2.0.0

This commit is contained in:
Aliaksei Nestsiarovich
2020-06-08 22:14:06 +03:00
commit a5bdc83170
81 changed files with 10985 additions and 0 deletions

13
ios/AppMetrica.h Normal file
View File

@@ -0,0 +1,13 @@
/*
* Version for React Native
* © 2020 YANDEX
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://yandex.com/legal/appmetrica_sdk_agreement/
*/
#import <React/RCTBridgeModule.h>
@interface AppMetrica : NSObject <RCTBridgeModule>
@end

114
ios/AppMetrica.m Normal file
View File

@@ -0,0 +1,114 @@
/*
* Version for React Native
* © 2020 YANDEX
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://yandex.com/legal/appmetrica_sdk_agreement/
*/
#import "AppMetrica.h"
#import "AppMetricaUtils.h"
static NSString *const kYMMReactNativeExceptionName = @"ReactNativeException";
@implementation AppMetrica
@synthesize methodQueue = _methodQueue;
RCT_EXPORT_MODULE()
RCT_EXPORT_METHOD(activate:(NSDictionary *)configDict)
{
[YMMYandexMetrica activateWithConfiguration:[AppMetricaUtils configurationForDictionary:configDict]];
}
RCT_EXPORT_METHOD(getLibraryApiLevel)
{
// It does nothing for iOS
}
RCT_EXPORT_METHOD(getLibraryVersion:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
{
resolve([YMMYandexMetrica libraryVersion]);
}
RCT_EXPORT_METHOD(pauseSession)
{
[YMMYandexMetrica pauseSession];
}
RCT_EXPORT_METHOD(reportAppOpen:(NSString *)deeplink)
{
[YMMYandexMetrica handleOpenURL:[NSURL URLWithString:deeplink]];
}
RCT_EXPORT_METHOD(reportError:(NSString *)message) {
NSException *exception = [[NSException alloc] initWithName:message reason:nil userInfo:nil];
[YMMYandexMetrica reportError:message exception:exception onFailure:NULL];
}
RCT_EXPORT_METHOD(reportEvent:(NSString *)eventName:(NSDictionary *)attributes)
{
if (attributes == nil) {
[YMMYandexMetrica reportEvent:eventName onFailure:^(NSError *error) {
NSLog(@"error: %@", [error localizedDescription]);
}];
} else {
[YMMYandexMetrica reportEvent:eventName parameters:attributes onFailure:^(NSError *error) {
NSLog(@"error: %@", [error localizedDescription]);
}];
}
}
RCT_EXPORT_METHOD(reportReferralUrl:(NSString *)referralUrl)
{
[YMMYandexMetrica reportReferralUrl:[NSURL URLWithString:referralUrl]];
}
RCT_EXPORT_METHOD(requestAppMetricaDeviceID:(RCTResponseSenderBlock)listener)
{
YMMAppMetricaDeviceIDRetrievingBlock completionBlock = ^(NSString *_Nullable appMetricaDeviceID, NSError *_Nullable error) {
listener(@[[self wrap:appMetricaDeviceID], [self wrap:[AppMetricaUtils stringFromRequestDeviceIDError:error]]]);
};
[YMMYandexMetrica requestAppMetricaDeviceIDWithCompletionQueue:nil completionBlock:completionBlock];
}
RCT_EXPORT_METHOD(resumeSession)
{
[YMMYandexMetrica resumeSession];
}
RCT_EXPORT_METHOD(sendEventsBuffer)
{
[YMMYandexMetrica sendEventsBuffer];
}
RCT_EXPORT_METHOD(setLocation:(NSDictionary *)locationDict)
{
[YMMYandexMetrica setLocation:[AppMetricaUtils locationForDictionary:locationDict]];
}
RCT_EXPORT_METHOD(setLocationTracking:(BOOL)enabled)
{
[YMMYandexMetrica setLocationTracking:enabled];
}
RCT_EXPORT_METHOD(setStatisticsSending:(BOOL)enabled)
{
[YMMYandexMetrica setStatisticsSending:enabled];
}
RCT_EXPORT_METHOD(setUserProfileID:(NSString *)userProfileID)
{
[YMMYandexMetrica setUserProfileID:userProfileID];
}
- (NSObject *)wrap:(NSObject *)value
{
if (value == nil) {
return [NSNull null];
}
return value;
}
@end

View File

@@ -0,0 +1,286 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
216E37E423ABB07000694F71 /* AppMetricaUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 216E37E323ABB07000694F71 /* AppMetricaUtils.m */; };
B3E7B58A1CC2AC0600A0062D /* AppMetrica.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* AppMetrica.m */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
58B511D91A9E6C8500147676 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "include/$(PRODUCT_NAME)";
dstSubfolderSpec = 16;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
134814201AA4EA6300B7C361 /* libAppMetrica.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAppMetrica.a; sourceTree = BUILT_PRODUCTS_DIR; };
216E37E223ABAFE400694F71 /* AppMetricaUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppMetricaUtils.h; sourceTree = "<group>"; };
216E37E323ABB07000694F71 /* AppMetricaUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppMetricaUtils.m; sourceTree = "<group>"; };
B3E7B5881CC2AC0600A0062D /* AppMetrica.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppMetrica.h; sourceTree = "<group>"; };
B3E7B5891CC2AC0600A0062D /* AppMetrica.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppMetrica.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
58B511D81A9E6C8500147676 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
134814211AA4EA7D00B7C361 /* Products */ = {
isa = PBXGroup;
children = (
134814201AA4EA6300B7C361 /* libAppMetrica.a */,
);
name = Products;
sourceTree = "<group>";
};
58B511D21A9E6C8500147676 = {
isa = PBXGroup;
children = (
216E37E323ABB07000694F71 /* AppMetricaUtils.m */,
216E37E223ABAFE400694F71 /* AppMetricaUtils.h */,
B3E7B5881CC2AC0600A0062D /* AppMetrica.h */,
B3E7B5891CC2AC0600A0062D /* AppMetrica.m */,
134814211AA4EA7D00B7C361 /* Products */,
);
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
58B511DA1A9E6C8500147676 /* AppMetrica */ = {
isa = PBXNativeTarget;
buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "AppMetrica" */;
buildPhases = (
58B511D71A9E6C8500147676 /* Sources */,
58B511D81A9E6C8500147676 /* Frameworks */,
58B511D91A9E6C8500147676 /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = AppMetrica;
productName = RCTDataManager;
productReference = 134814201AA4EA6300B7C361 /* libAppMetrica.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
58B511D31A9E6C8500147676 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0920;
ORGANIZATIONNAME = Facebook;
TargetAttributes = {
58B511DA1A9E6C8500147676 = {
CreatedOnToolsVersion = 6.1.1;
};
};
};
buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "AppMetrica" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = 58B511D21A9E6C8500147676;
productRefGroup = 58B511D21A9E6C8500147676;
projectDirPath = "";
projectRoot = "";
targets = (
58B511DA1A9E6C8500147676 /* AppMetrica */,
);
};
/* End PBXProject section */
/* Begin PBXSourcesBuildPhase section */
58B511D71A9E6C8500147676 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B3E7B58A1CC2AC0600A0062D /* AppMetrica.m in Sources */,
216E37E423ABB07000694F71 /* AppMetricaUtils.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
58B511ED1A9E6C8500147676 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
};
name = Debug;
};
58B511EE1A9E6C8500147676 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
};
name = Release;
};
58B511F01A9E6C8500147676 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(PROJECT_DIR)/../../../ios/Frameworks",
"$(PROJECT_DIR)/../../../ios",
);
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../../React/**",
"$(SRCROOT)/../../react-native/React/**",
);
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = AppMetrica;
SKIP_INSTALL = YES;
};
name = Debug;
};
58B511F11A9E6C8500147676 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(PROJECT_DIR)/../../../ios/Frameworks",
"$(PROJECT_DIR)/../../../ios",
);
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../../../React/**",
"$(SRCROOT)/../../react-native/React/**",
);
LIBRARY_SEARCH_PATHS = "$(inherited)";
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = AppMetrica;
SKIP_INSTALL = YES;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "AppMetrica" */ = {
isa = XCConfigurationList;
buildConfigurations = (
58B511ED1A9E6C8500147676 /* Debug */,
58B511EE1A9E6C8500147676 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "AppMetrica" */ = {
isa = XCConfigurationList;
buildConfigurations = (
58B511F01A9E6C8500147676 /* Debug */,
58B511F11A9E6C8500147676 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 58B511D31A9E6C8500147676 /* Project object */;
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:AppMetrica.xcodeproj">
</FileRef>
</Workspace>

18
ios/AppMetricaUtils.h Normal file
View File

@@ -0,0 +1,18 @@
/*
* Version for React Native
* © 2020 YANDEX
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://yandex.com/legal/appmetrica_sdk_agreement/
*/
#import <CoreLocation/CoreLocation.h>
#import <YandexMobileMetrica/YandexMobileMetrica.h>
@interface AppMetricaUtils : NSObject
+ (YMMYandexMetricaConfiguration *)configurationForDictionary:(NSDictionary *)configDict;
+ (CLLocation *)locationForDictionary:(NSDictionary *)locationDict;
+ (NSString *)stringFromRequestDeviceIDError:(NSError *)error;
@end

113
ios/AppMetricaUtils.m Normal file
View File

@@ -0,0 +1,113 @@
/*
* Version for React Native
* © 2020 YANDEX
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://yandex.com/legal/appmetrica_sdk_agreement/
*/
#import "AppMetricaUtils.h"
@implementation AppMetricaUtils
+ (YMMYandexMetricaConfiguration *)configurationForDictionary:(NSDictionary *)configDict
{
NSString *apiKey = configDict[@"apiKey"];
YMMYandexMetricaConfiguration *configuration = [[YMMYandexMetricaConfiguration alloc] initWithApiKey:apiKey];
if (configDict[@"appVersion"] != nil) {
configuration.appVersion = configDict[@"appVersion"];
}
if (configDict[@"crashReporting"] != nil) {
configuration.crashReporting = [configDict[@"crashReporting"] boolValue];
}
if (configDict[@"activationAsSessionStart"] != nil) {
configuration.handleActivationAsSessionStart = [configDict[@"activationAsSessionStart"] boolValue];
}
if (configDict[@"firstActivationAsUpdate"] != nil) {
configuration.handleFirstActivationAsUpdate = [configDict[@"firstActivationAsUpdate"] boolValue];
}
if (configDict[@"location"] != nil) {
configuration.location = [self locationForDictionary:configDict[@"location"]];
}
if (configDict[@"locationTracking"] != nil) {
configuration.locationTracking = [configDict[@"locationTracking"] boolValue];
}
if (configDict[@"logs"] != nil) {
configuration.logs = [configDict[@"logs"] boolValue];
}
if (configDict[@"preloadInfo"] != nil) {
configuration.preloadInfo = [[self class] preloadInfoForDictionary:configDict[@"preloadInfo"]];
}
if (configDict[@"sessionsAutoTracking"] != nil) {
configuration.sessionsAutoTracking = [configDict[@"sessionsAutoTracking"] boolValue];
}
if (configDict[@"sessionTimeout"] != nil) {
configuration.sessionTimeout = [configDict[@"sessionTimeout"] unsignedIntegerValue];
}
if (configDict[@"statisticsSending"] != nil) {
configuration.statisticsSending = [configDict[@"statisticsSending"] boolValue];
}
return configuration;
}
+ (CLLocation *)locationForDictionary:(NSDictionary *)locationDict
{
if (locationDict == nil) {
return nil;
}
NSNumber *latitude = locationDict[@"latitude"];
NSNumber *longitude = locationDict[@"longitude"];
NSNumber *altitude = locationDict[@"altitude"];
NSNumber *horizontalAccuracy = locationDict[@"accuracy"];
NSNumber *verticalAccuracy = locationDict[@"verticalAccuracy"];
NSNumber *course = locationDict[@"course"];
NSNumber *speed = locationDict[@"speed"];
NSNumber *timestamp = locationDict[@"timestamp"];
NSDate *locationDate = timestamp != nil ? [NSDate dateWithTimeIntervalSince1970:timestamp.doubleValue] : [NSDate date];
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(latitude.doubleValue, longitude.doubleValue);
CLLocation *location = [[CLLocation alloc] initWithCoordinate:coordinate
altitude:altitude.doubleValue
horizontalAccuracy:horizontalAccuracy.doubleValue
verticalAccuracy:verticalAccuracy.doubleValue
course:course.doubleValue
speed:speed.doubleValue
timestamp:locationDate];
return location;
}
+ (YMMYandexMetricaPreloadInfo *)preloadInfoForDictionary:(NSDictionary *)preloadInfoDict
{
if (preloadInfoDict == nil) {
return nil;
}
NSString *trackingId = preloadInfoDict[@"trackingId"];
YMMYandexMetricaPreloadInfo *preloadInfo = [[YMMYandexMetricaPreloadInfo alloc] initWithTrackingIdentifier:trackingId];
NSDictionary *additionalInfo = preloadInfoDict[@"additionalInfo"];
if (additionalInfo != nil) {
for (NSString *key in additionalInfo) {
[preloadInfo setAdditionalInfo:additionalInfo[key] forKey:key];
}
}
return preloadInfo;
}
+ (NSString *)stringFromRequestDeviceIDError:(NSError *)error
{
if (error == nil) {
return nil;
}
if ([error.domain isEqualToString:NSURLErrorDomain]) {
return @"NETWORK";
}
return @"UNKNOWN";
}
@end