3.1.0 • Published 8 months ago

@nuskin/mobile-logging v3.1.0

Weekly downloads
-
License
-
Repository
-
Last release
8 months ago

Mobile Logger Package

  • This package will allow you to add custom logging in your React Native mobile application and send these logs to DataDog and Firebase all at once.

Install and setup

  • In a terminal, cd into the apps/{project-name} directory and run yarn add @nuskin/mobile-logging.

  • Locate the top-level file index.js, insert the following code, replacing DD_CLIENT_TOKEN with your app's DataDog client token, CI_ENVIRONMENT_NAME with the app environment (ex: test, prod), and DD_RUM_APPLICATION_ID with your DataDog RUM App Id:

import { initLogger } from '@ns/mobile-logging';
//
// INSERT BELOW
initLogger(DD_CLIENT_TOKEN, CI_ENVIRONMENT_NAME, DD_RUM_APPLICATION_ID);
//
//
AppRegistry.registerComponent(appName, () => App);

IMPORTANT INFORMATION:

  • Please note that this package will send information to Firebase ONLY if you have already setup React Native Firebase for your app according to the instructions under 'Getting Started' here: https://rnfirebase.io/
  • This package has a peer dependency for @datadog/mobile-react-native and @react-native-firebase/analytics and @react-native-firebase/crashlytics. Make sure the app versions of these packages match those in this package or you will encounter issues.

Usage

  • Anywhere within your app you would like to add logging, be sure to import Logger from @nuskin/mobile-logging
import { Logger } from '@nuskin/mobile-logging';
  • Use the following labels to indicate the kind of log being put in (note the colors listed - console will use these colors when logging output):

    • Debug (logs locally)
      • Accepts params message (string - required) and context (object - optional)
      • White/Default Terminal
    • Info (logs locally)
      • Accepts params message (string - required) and context (object - optional)
      • Cyan
    • Warning (will be pushed to DataDog and Firebase)
      • Accepts params message (string - required) and context (object - optional)
      • Yellow
    • Error (logs locally and will be pushed to DataDog and Firebase Crashlytics)
      • Accepts params message (string - required), component (string - required), error (error - required), context (object - optional)
      • Red
    • Event (Will be pushed to DataDog and Firebase ONLY)
      • Accepts params event (string - required), component (string - optional), context (object - optional)
  • then add the logging as follows ():

Logger.<log-type>(params);

Example Usage:

Logger.error('Third party resource failed to return data', 'Home.tsx', error, {
    market: 'US',
    productId: 'us12345'
});

Example Output:

3.1.0

8 months ago

3.0.0

8 months ago

2.0.0

8 months ago

1.1.3-1

8 months ago

1.1.3-0

8 months ago

1.1.1

10 months ago

1.1.2

10 months ago

1.1.1-test.0

10 months ago

1.1.2-test.0

10 months ago

1.1.0

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.6-test.0

1 year ago

1.0.5-0

2 years ago

1.0.6-0

2 years ago

1.0.5

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

3 years ago

1.0.4

2 years ago

1.0.3

2 years ago

0.0.7

3 years ago

0.0.7-test.3

3 years ago

0.0.7-test.2

3 years ago

0.0.7-test.1

3 years ago

0.0.7-test.0

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago