From 093abb5f55aec8f925bd58200a23547c700a8495 Mon Sep 17 00:00:00 2001 From: markxoe Date: Tue, 16 Feb 2021 12:40:01 +0100 Subject: [PATCH 1/2] solve Promis resolve warnings --- src/web.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/web.ts b/src/web.ts index ba0404c..109de2c 100644 --- a/src/web.ts +++ b/src/web.ts @@ -289,7 +289,7 @@ export class FirebaseAnalyticsWeb extends WebPlugin document.getElementById(scripts[0]) && document.getElementById(scripts[1]) ) { - return resolve(); + return resolve(undefined); } await this.loadScript(firebaseAppScript.key, firebaseAppScript.src); @@ -297,7 +297,7 @@ export class FirebaseAnalyticsWeb extends WebPlugin firebaseAnalyticsScript.key, firebaseAnalyticsScript.src ); - resolve(); + resolve(undefined); }); } From 7ad288bdc9713b15e540254e5cffd379f63b7b20 Mon Sep 17 00:00:00 2001 From: markxoe Date: Tue, 16 Feb 2021 12:41:58 +0100 Subject: [PATCH 2/2] fix(#49): setUserId accept null too --- src/definitions.ts | 2 +- src/web.ts | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/definitions.ts b/src/definitions.ts index f46c0f8..7c15d16 100644 --- a/src/definitions.ts +++ b/src/definitions.ts @@ -6,7 +6,7 @@ declare module "@capacitor/core" { export interface FirebaseAnalyticsPlugin { initializeFirebase(options: FirebaseInitOptions): Promise; - setUserId(options: { userId: string }): Promise; + setUserId(options: { userId: string | null }): Promise; setUserProperty(options: { name: string; value: string }): Promise; getAppInstanceId(): Promise<{ instanceId: string }>; setScreenName(options: { diff --git a/src/web.ts b/src/web.ts index 109de2c..3176b77 100644 --- a/src/web.ts +++ b/src/web.ts @@ -68,7 +68,7 @@ export class FirebaseAnalyticsWeb extends WebPlugin * @param options - userId: unique identifier of the user to log * Platform: Web/Android/iOS */ - setUserId(options: { userId: string }): Promise { + setUserId(options: { userId: string | null }): Promise { return new Promise(async (resolve, reject) => { await this.ready; @@ -77,12 +77,12 @@ export class FirebaseAnalyticsWeb extends WebPlugin return; } - const { userId } = options || { userId: undefined }; + let { userId } = options || { userId: "" }; - if (!userId) { - reject("userId property is missing"); - return; - } + if (userId == undefined) + reject("userId property should be string or null"); + + if (userId == null) userId = ""; this.analyticsRef.setUserId(userId); resolve(); @@ -104,7 +104,10 @@ export class FirebaseAnalyticsWeb extends WebPlugin return; } - const { name, value } = options || { name: undefined, value: undefined }; + const { name, value } = options || { + name: undefined, + value: undefined, + }; if (!name) { reject("name property is missing");