diff --git a/lib/modules/analytics/index.js b/lib/modules/analytics/index.js index 3cba2d47..39ad9bc9 100644 --- a/lib/modules/analytics/index.js +++ b/lib/modules/analytics/index.js @@ -122,7 +122,12 @@ export default class Analytics extends ModuleBase { * Sets the user ID property. * @param id */ - setUserId(id: string): void { + setUserId(id: string | null): void { + if (id !== null && !isString(id)) { + throw new Error( + 'analytics.setUserId(): The supplied userId must be a string value or null.' + ); + } getNativeModule(this).setUserId(id); } @@ -131,17 +136,28 @@ export default class Analytics extends ModuleBase { * @param name * @param value */ - setUserProperty(name: string, value: string): void { + setUserProperty(name: string, value: string | null): void { + if (value !== null && !isString(value)) { + throw new Error( + 'analytics.setUserProperty(): The supplied property must be a string value or null.' + ); + } getNativeModule(this).setUserProperty(name, value); } /** - * Sets a user property to a given value. + * Sets multiple user properties to the supplied values. * @RNFirebaseSpecific * @param object */ setUserProperties(object: Object): void { Object.keys(object).forEach(property => { + const value = object[property]; + if (value !== null && !isString(value)) { + throw new Error( + `analytics.setUserProperties(): The property with name '${property}' must be a string value or null.` + ); + } getNativeModule(this).setUserProperty(property, object[property]); }); }