diff --git a/packages/analytics/lib/index.d.ts b/packages/analytics/lib/index.d.ts index b6b1a43e..33822c3e 100644 --- a/packages/analytics/lib/index.d.ts +++ b/packages/analytics/lib/index.d.ts @@ -40,6 +40,14 @@ export namespace Analytics { * * @note 100 characters is the maximum length for param key names. * + * #### Example + * + * ```js + * await analytics().logEvent('product_view', { + * id: '1234', + * }); + * ``` + * * @param name Event name must not conflict with any Reserved Events. * @param params Parameters to be sent and displayed with the event. */ @@ -51,6 +59,13 @@ export namespace Analytics { * * @note Analytics collection is enabled by default. * + * #### Example + * + * ```js + * // Disable collection + * await analytics().setAnalyticsCollectionEnabled(false); + * ``` + * * @param enabled A boolean value representing whether Analytics collection is enabled or disabled. */ setAnalyticsCollectionEnabled(enabled: boolean): Promise; @@ -62,6 +77,12 @@ export namespace Analytics { * always sent as your current class name. For example on Android it will always * show as 'MainActivity' if you do not specify it. * + * #### Example + * + * ```js + * await analytics().setCurrentScreen('ProductScreen', 'ProductScreen'); + * ``` + * * @param screenName A screen name, e.g. Product. * @param screenClassOverride On Android, React Native runs in a single activity called * 'MainActivity'. Setting this parameter overrides the default name shown on logs. @@ -71,6 +92,13 @@ export namespace Analytics { /** * Sets the minimum engagement time required before starting a session. * + * #### Example + * + * ```js + * // 20 seconds + * await analytics().setMinimumSessionDuration(20000); + * ``` + * * @param milliseconds The default value is 10000 (10 seconds). */ setMinimumSessionDuration(milliseconds: number): Promise; @@ -78,6 +106,13 @@ export namespace Analytics { /** * Sets the duration of inactivity that terminates the current session. * + * #### Example + * + * ```js + * // 20 minutes + * await analytics().setMinimumSessionDuration(900000); + * ``` + * * @param milliseconds The default value is 1800000 (30 minutes). */ setSessionTimeoutDuration(milliseconds: number): Promise; @@ -85,6 +120,14 @@ export namespace Analytics { /** * Gives a user a unique identification. * + * #### Example + * + * ```js + * // Set User + * await analytics().setUserId('123456789'); + * // Remove User + * await analytics().setUserId(null); + * ``` * * @param id Set to null to remove a previously assigned id from analytics events */ @@ -93,6 +136,12 @@ export namespace Analytics { /** * Sets a key/value pair of data on the current user. * + * #### Example + * + * ```js + * await analytics().setUserProperty('account_type', 'gold'); + * ``` + * * @param name A user property identifier. * @param value Set to null to remove a previously assigned id from analytics events. */ @@ -101,6 +150,15 @@ export namespace Analytics { /** * Sets multiple key/value pair of data on the current user. * + * #### Example + * + * ```js + * await analytics().setUserProperties({ + * account_type: 'gold', + * account_name: 'Gold Badge', + * }); + * ``` + * * @react-native-firebase * @param properties Set a property value to null to remove it. */ @@ -108,6 +166,12 @@ export namespace Analytics { /** * Clears all analytics data for this instance from the device and resets the app instance ID. + * + * #### Example + * + * ```js + * await analytics().resetAnalyticsData(); + * ``` */ resetAnalyticsData(): Promise; } diff --git a/packages/analytics/lib/index.js.flow b/packages/analytics/lib/index.js.flow index 81afb74c..c4695292 100644 --- a/packages/analytics/lib/index.js.flow +++ b/packages/analytics/lib/index.js.flow @@ -26,6 +26,14 @@ export interface Module extends ReactNativeFirebaseModule { * * @note 100 characters is the maximum length for param key names. * + * #### Example + * + * ```js + * await analytics().logEvent('product_view', { + * id: '1234', + * }); + * ``` + * * @param name Event name must not conflict with any Reserved Events. * @param params Parameters to be sent and displayed with the event. */ @@ -37,6 +45,13 @@ export interface Module extends ReactNativeFirebaseModule { * * @note Analytics collection is enabled by default. * + * #### Example + * + * ```js + * // Disable collection + * await analytics().setAnalyticsCollectionEnabled(false); + * ``` + * * @param enabled A boolean value representing whether Analytics collection is enabled or disabled. */ setAnalyticsCollectionEnabled(enabled: boolean): Promise; @@ -48,6 +63,12 @@ export interface Module extends ReactNativeFirebaseModule { * always sent as your current class name. For example on Android it will always * show as 'MainActivity' if you do not specify it. * + * #### Example + * + * ```js + * await analytics().setCurrentScreen('ProductScreen', 'ProductScreen'); + * ``` + * * @param screenName A screen name, e.g. Product. * @param screenClassOverride On Android, React Native runs in a single activity called * 'MainActivity'. Setting this parameter overrides the default name shown on logs. @@ -57,6 +78,13 @@ export interface Module extends ReactNativeFirebaseModule { /** * Sets the minimum engagement time required before starting a session. * + * #### Example + * + * ```js + * // 20 seconds + * await analytics().setMinimumSessionDuration(20000); + * ``` + * * @param milliseconds The default value is 10000 (10 seconds). */ setMinimumSessionDuration(milliseconds: number): Promise; @@ -64,6 +92,13 @@ export interface Module extends ReactNativeFirebaseModule { /** * Sets the duration of inactivity that terminates the current session. * + * #### Example + * + * ```js + * // 20 minutes + * await analytics().setMinimumSessionDuration(900000); + * ``` + * * @param milliseconds The default value is 1800000 (30 minutes). */ setSessionTimeoutDuration(milliseconds: number): Promise; @@ -71,6 +106,14 @@ export interface Module extends ReactNativeFirebaseModule { /** * Gives a user a unique identification. * + * #### Example + * + * ```js + * // Set User + * await analytics().setUserId('123456789'); + * // Remove User + * await analytics().setUserId(null); + * ``` * * @param id Set to null to remove a previously assigned id from analytics events */ @@ -79,6 +122,12 @@ export interface Module extends ReactNativeFirebaseModule { /** * Sets a key/value pair of data on the current user. * + * #### Example + * + * ```js + * await analytics().setUserProperty('account_type', 'gold'); + * ``` + * * @param name A user property identifier. * @param value Set to null to remove a previously assigned id from analytics events. */ @@ -87,6 +136,15 @@ export interface Module extends ReactNativeFirebaseModule { /** * Sets multiple key/value pair of data on the current user. * + * #### Example + * + * ```js + * await analytics().setUserProperties({ + * account_type: 'gold', + * account_name: 'Gold Badge', + * }); + * ``` + * * @react-native-firebase * @param properties Set a property value to null to remove it. */ @@ -94,6 +152,12 @@ export interface Module extends ReactNativeFirebaseModule { /** * Clears all analytics data for this instance from the device and resets the app instance ID. + * + * #### Example + * + * ```js + * await analytics().resetAnalyticsData(); + * ``` */ resetAnalyticsData(): Promise; }