From bb1d0ffc9cd7433639ca9d293decf0de40c7b0ad Mon Sep 17 00:00:00 2001 From: Mickey Mokotov Date: Sun, 6 Jun 2021 17:13:10 +0300 Subject: [PATCH] fixed [bug] method setScreenName is no longer supported. For alternative methods see https://firebase.googleblog.com/2020/08/google-analytics-manual-screen-view.html --- README.md | 16 +--------------- ios/Plugin/Plugin.m | 1 - ios/Plugin/Plugin.swift | 19 ------------------- src/definitions.ts | 4 ---- src/web.ts | 13 ------------- 5 files changed, 1 insertion(+), 52 deletions(-) diff --git a/README.md b/README.md index 7ed4694..6ac1b3c 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,6 @@ git checkout -b firebase-analytics | setUserId | ✅ | ✅ | ✅ | | setUserProperty | ✅ | ✅ | ✅ | | getAppInstanceId | ✅ | ✅ | ❌ | -| setScreenName | ✅ | ✅ | ❌ | | reset | ✅ | ✅ | ✅ | | logEvent | ✅ | ✅ | ✅ | | setCollectionEnabled | ✅ | ✅ | ✅ | @@ -163,19 +162,6 @@ FirebaseAnalytics.setUserProperty({ */ FirebaseAnalytics.getAppInstanceId(); -/** - * Platform: Android/iOS - * Sets the current screen name, which specifies the current visual context in your app. - * @param screenName - name of the current screen to track - * nameOverride - name of the screen class to override - * @returns instanceId - individual instance id value - * https://firebase.google.com/docs/analytics/screenviews - */ -FirebaseAnalytics.setScreenName({ - screenName: "login", - nameOverride: "LoginScreen", -}); - /** * Platform: Web/Android/iOS * Clears all analytics data for this app from the device and resets the app instance id. @@ -307,7 +293,7 @@ If you were previously using the `capacitor-analytics` package from npm 2. on android's _MainActivity.java_ change the import path from `io.stewan.capacitor.analytics.AnalyticsPlugin;` to `com.getcapacitor.community.firebaseanalytics.FirebaseAnalytics;` 3. public api changes - `instance()` is now `getAppInstanceId()` - - `setScreen()` is now `setScreenName()` + - `setScreenName()` removed, see https://firebase.googleblog.com/2020/08/google-analytics-manual-screen-view.html - `setUserID()` is now `setUserId()` - `setUserProp()` us now `setUserProperty()` diff --git a/ios/Plugin/Plugin.m b/ios/Plugin/Plugin.m index c37e131..6c6b6de 100644 --- a/ios/Plugin/Plugin.m +++ b/ios/Plugin/Plugin.m @@ -5,7 +5,6 @@ CAP_PLUGIN_METHOD(setUserId, CAPPluginReturnPromise); CAP_PLUGIN_METHOD(setUserProperty, CAPPluginReturnPromise); CAP_PLUGIN_METHOD(getAppInstanceId, CAPPluginReturnPromise); - CAP_PLUGIN_METHOD(setScreenName, CAPPluginReturnPromise); CAP_PLUGIN_METHOD(reset, CAPPluginReturnPromise); CAP_PLUGIN_METHOD(logEvent, CAPPluginReturnPromise); CAP_PLUGIN_METHOD(setCollectionEnabled, CAPPluginReturnPromise); diff --git a/ios/Plugin/Plugin.swift b/ios/Plugin/Plugin.swift index 80d297a..5c7b12d 100644 --- a/ios/Plugin/Plugin.swift +++ b/ios/Plugin/Plugin.swift @@ -58,26 +58,7 @@ public class FirebaseAnalytics: CAPPlugin { "instanceId": instanceId ]) } - - - /// Sets the current screen name, which specifies the current visual context in your app. - /// - Parameter call: screenName - the activity to which the screen name and class name apply. - /// nameOverride - the name of the current screen. Set to null to clear the current screen name. - @objc func setScreenName(_ call: CAPPluginCall) { - if !call.hasOption("screenName") { - call.error("screenName property is missing") - return - } - - let screenName = call.getString("screenName") - let nameOverride = call.getString("nameOverride") ?? nil - DispatchQueue.main.async { - Analytics.setScreenName(screenName, screenClass: nameOverride) - } - call.success() - } - /// Clears all analytics data for this app from the device and resets the app instance id. @objc func reset(_ call: CAPPluginCall) { diff --git a/src/definitions.ts b/src/definitions.ts index f46c0f8..7f64ad5 100644 --- a/src/definitions.ts +++ b/src/definitions.ts @@ -9,10 +9,6 @@ export interface FirebaseAnalyticsPlugin { setUserId(options: { userId: string }): Promise; setUserProperty(options: { name: string; value: string }): Promise; getAppInstanceId(): Promise<{ instanceId: string }>; - setScreenName(options: { - screenName: string; - nameOverride?: string; - }): Promise; reset(): Promise; logEvent(options: { name: string; params: object }): Promise; setCollectionEnabled(options: { enabled: boolean }): Promise; diff --git a/src/web.ts b/src/web.ts index 2da1056..535c8b0 100644 --- a/src/web.ts +++ b/src/web.ts @@ -105,19 +105,6 @@ export class FirebaseAnalyticsWeb extends WebPlugin return new Promise((resolve, _reject) => resolve); } - /** - * Sets the current screen name, which specifies the current visual context in your app. - * @param options - screenName: the activity to which the screen name and class name apply. - * nameOverride: the name of the current screen. Set to null to clear the current screen name. - * Platform: Android/iOS - */ - setScreenName(_options: { - screenName: string; - nameOverride: string; - }): Promise { - return new Promise((resolve, _reject) => resolve); - } - /** * Clears all analytics data for this app from the device and resets the app instance id. * Platform: Android/iOS