mobile-center
Advanced tools
Comparing version 0.8.1 to 0.9.0
@@ -1,15 +0,17 @@ | ||
let Platform = require('react-native').Platform; | ||
let RNMobileCenter = require("react-native").NativeModules.RNMobileCenter; | ||
const RNMobileCenter = require('react-native').NativeModules.RNMobileCenter; | ||
const MobileCenterLog = require('mobile-center/mobile-center-log'); | ||
let MobileCenter = { | ||
const logTag = 'MobileCenter'; | ||
const MobileCenter = { | ||
// By design, these constants match both the iOS SDK values in MSContants.h and the standard Android values in android.util.Log | ||
LogLevelVerbose: 2, // Logging will be very chatty | ||
LogLevelDebug: 3, // Debug information will be logged | ||
LogLevelInfo: 4, // Information will be logged | ||
LogLevelWarning: 5, // Errors and warnings will be logged | ||
LogLevelError: 6, // Errors will be logged | ||
LogLevelAssert: 7, // Only critical errors will be logged | ||
LogLevelNone: 99, // Logging is disabled | ||
LogLevelVerbose: MobileCenterLog.LogLevelVerbose, // Logging will be very chatty | ||
LogLevelDebug: MobileCenterLog.LogLevelDebug, // Debug information will be logged | ||
LogLevelInfo: MobileCenterLog.LogLevelInfo, // Information will be logged | ||
LogLevelWarning: MobileCenterLog.LogLevelWarning, // Errors and warnings will be logged | ||
LogLevelError: MobileCenterLog.LogLevelError, // Errors will be logged | ||
LogLevelAssert: MobileCenterLog.LogLevelAssert, // Only critical errors will be logged | ||
LogLevelNone: MobileCenterLog.LogLevelNone, // Logging is disabled | ||
// async - returns a Promise | ||
@@ -21,3 +23,3 @@ getLogLevel() { | ||
// async - returns a Promise | ||
setLogLevel(logLevel){ | ||
setLogLevel(logLevel) { | ||
return RNMobileCenter.setLogLevel(logLevel); | ||
@@ -43,23 +45,49 @@ }, | ||
setCustomProperties(properties) { | ||
// Android ReadableMap doesn't support Date type, so pass Dates as a Map Object to work around that | ||
if (Platform.OS === 'android') { | ||
let newProperties = {}; | ||
Object.keys(properties).forEach((key) => { | ||
let value = properties[key]; | ||
if (value instanceof Date) { | ||
newProperties[key] = { | ||
// RNDate name should be in sync with the matching Java code | ||
"RNDate": value.toISOString() | ||
}; | ||
} | ||
else { | ||
newProperties[key] = value; | ||
} | ||
}); | ||
properties = newProperties; | ||
if (properties instanceof MobileCenter.CustomProperties) { | ||
return RNMobileCenter.setCustomProperties(properties); | ||
} else { | ||
const type = Object.prototype.toString.apply(properties); | ||
MobileCenterLog.error(logTag, `SetCustomProperties: Invalid type, expected CustomProperties but got ${type}.`); | ||
} | ||
return RNMobileCenter.setCustomProperties(properties); | ||
} | ||
}; | ||
MobileCenter.CustomProperties = class { | ||
set(key, value) { | ||
if (typeof key === 'string') { | ||
const valueType = typeof value; | ||
switch (valueType) { | ||
case 'string': | ||
case 'number': | ||
case 'boolean': | ||
this[key] = { type: valueType, value }; | ||
break; | ||
case 'object': | ||
if (value instanceof Date) { | ||
this[key] = { type: 'date-time', value: value.getTime() }; | ||
} else { | ||
MobileCenterLog.error(logTag, 'CustomProperties: Invalid value type, expected string|number|boolean|Date.'); | ||
} | ||
break; | ||
default: | ||
MobileCenterLog.error(logTag, 'CustomProperties: Invalid value type, expected string|number|boolean|Date.'); | ||
} | ||
} else { | ||
MobileCenterLog.error(logTag, 'CustomProperties: Invalid key type, expected string.'); | ||
} | ||
return this; | ||
} | ||
clear(key) { | ||
if (typeof key === 'string') { | ||
this[key] = { type: 'clear' }; | ||
} else { | ||
MobileCenterLog.error(logTag, 'CustomProperties: Invalid key type, expected string.'); | ||
} | ||
return this; | ||
} | ||
}; | ||
module.exports = MobileCenter; |
{ | ||
"name": "mobile-center", | ||
"version": "0.8.1", | ||
"version": "0.9.0", | ||
"description": "Node module that contains common functionality needed to mobile-center-* modules", | ||
@@ -19,5 +19,5 @@ "main": "MobileCenter.js", | ||
}, | ||
"homepage": "https://github.com/microsoft/mobile-center-sdk-react-native#readme", | ||
"homepage": "https://github.com/Microsoft/mobile-center-sdk-react-native/blob/master/mobile-center/README.md", | ||
"dependencies": { | ||
"mobile-center-link-scripts": "0.8.1" | ||
"mobile-center-link-scripts": "0.9.0" | ||
}, | ||
@@ -32,3 +32,14 @@ "rnpm": { | ||
} | ||
}, | ||
"devDependencies": { | ||
"babel-eslint": "^7.2.3", | ||
"eslint": "^4.5.0", | ||
"eslint-config-airbnb": "^15.1.0", | ||
"eslint-plugin-import": "^2.7.0", | ||
"eslint-plugin-jsx-a11y": "^6.0.2", | ||
"eslint-plugin-react": "^7.2.1" | ||
}, | ||
"scripts": { | ||
"lint": "eslint ." | ||
} | ||
} |
@@ -1,12 +0,11 @@ | ||
var rnpmlink = require('mobile-center-link-scripts'); | ||
var package = require('./../package.json'); | ||
const rnpmlink = require('mobile-center-link-scripts'); | ||
return rnpmlink.ios.initMobileCenterConfig().then(function (file) { | ||
var code = ' [RNMobileCenter register]; // Initialize Mobile Center ' | ||
return rnpmlink.ios.initMobileCenterConfig().then(() => { | ||
const code = ' [RNMobileCenter register]; // Initialize Mobile Center '; | ||
return rnpmlink.ios.initInAppDelegate('#import <RNMobileCenter/RNMobileCenter.h>', code); | ||
}).then(function (file) { | ||
console.log('Added code to initialize iOS Mobile Center SDK in ' + file); | ||
}).then((file) => { | ||
console.log(`Added code to initialize iOS Mobile Center SDK in ${file}`); | ||
return rnpmlink.ios.addPodDeps([ | ||
{ pod: 'RNMobileCenterShared', version: '0.8.1' } | ||
]).catch(function (e) { | ||
{ pod: 'RNMobileCenterShared', version: '0.9.0' } | ||
]).catch((e) => { | ||
console.log(` | ||
@@ -17,5 +16,5 @@ Could not install dependencies using CocoaPods. | ||
Error Reason - ${e.message} | ||
`) | ||
`); | ||
return Promise.resolve(); | ||
}) | ||
}); | ||
}); |
@@ -1,6 +0,5 @@ | ||
var rnpmlink = require('mobile-center-link-scripts'); | ||
const rnpmlink = require('mobile-center-link-scripts'); | ||
console.log('Configuring Mobile Center'); | ||
return rnpmlink.android.initMobileCenterConfig(true).then(function (file) { | ||
}); | ||
return rnpmlink.android.initMobileCenterConfig(true); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
31114
17
359
1
4
6
2
+ Addedmobile-center-link-scripts@0.9.0(transitive)
- Removedmobile-center-link-scripts@0.8.1(transitive)