Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use logger class and send App Check dummy token in header #8591

Merged
merged 2 commits into from
Oct 23, 2024

Conversation

hsubox76
Copy link
Contributor

App Check's getToken() should never throw, but in case of an error getting a valid App Check token, it fills in the "token" field with a standard dummy token, and adds an "error" field. The backend needs to receive these dummy tokens in the header so the developer can track failed requests. Right now we just don't send them. This change sends the dummy token, and logs a warning if an error is found.

I also realized I forgot to include the standard logger API in VertexAI so I added it. This is a wrapper around console used across all products that adds a product name prefix and also enables the global setLogLevel() to apply to any console messages called through this wrapper.

Copy link

changeset-bot bot commented Oct 23, 2024

🦋 Changeset detected

Latest commit: 9e8ef56

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@firebase/vertexai Patch
firebase Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@hsubox76 hsubox76 marked this pull request as ready for review October 23, 2024 17:21
@hsubox76 hsubox76 requested review from a team as code owners October 23, 2024 17:21
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Oct 23, 2024

Size Analysis Report 1

Affected Products

  • @firebase/vertexai

    • ArraySchema

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size4.54 kB4.61 kB+70 B (+1.5%)
      size-with-ext-deps22.4 kB22.4 kB+28 B (+0.1%)

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • BlockReason

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size2.45 kB2.52 kB+70 B (+2.9%)
      size-with-ext-deps20.3 kB20.3 kB+28 B (+0.1%)

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • BooleanSchema

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size4.54 kB4.61 kB+70 B (+1.5%)
      size-with-ext-deps22.4 kB22.4 kB+28 B (+0.1%)

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • ChatSession

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size14.5 kB14.7 kB+127 B (+0.9%)
      size-with-ext-deps33.1 kB33.2 kB+87 B (+0.3%)

      Dependency

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      variables

      25 dependencies

      BlockReason
      DEFAULT_API_VERSION
      DEFAULT_BASE_URL
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      LANGUAGE_TAG
      PACKAGE_VERSION
      POSSIBLE_ROLES
      SILENT_ERROR
      SchemaType
      Task
      VALID_PARTS_PER_ROLE
      VALID_PART_FIELDS
      VALID_PREVIOUS_CONTENT_ROLES
      VERTEX_TYPE
      badFinishReasons
      name
      responseLineRE
      version

      26 dependencies

      BlockReason
      DEFAULT_API_VERSION
      DEFAULT_BASE_URL
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      LANGUAGE_TAG
      PACKAGE_VERSION
      POSSIBLE_ROLES
      SILENT_ERROR
      SchemaType
      Task
      VALID_PARTS_PER_ROLE
      VALID_PART_FIELDS
      VALID_PREVIOUS_CONTENT_ROLES
      VERTEX_TYPE
      badFinishReasons
      logger
      name
      responseLineRE
      version

      + logger

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • FinishReason

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size2.45 kB2.52 kB+70 B (+2.9%)
      size-with-ext-deps20.3 kB20.3 kB+28 B (+0.1%)

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • FunctionCallingMode

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size2.46 kB2.53 kB+70 B (+2.8%)
      size-with-ext-deps20.3 kB20.3 kB+28 B (+0.1%)

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • GenerativeModel

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size17.0 kB17.2 kB+127 B (+0.7%)
      size-with-ext-deps35.6 kB35.7 kB+87 B (+0.2%)

      Dependency

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      variables

      25 dependencies

      BlockReason
      DEFAULT_API_VERSION
      DEFAULT_BASE_URL
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      LANGUAGE_TAG
      PACKAGE_VERSION
      POSSIBLE_ROLES
      SILENT_ERROR
      SchemaType
      Task
      VALID_PARTS_PER_ROLE
      VALID_PART_FIELDS
      VALID_PREVIOUS_CONTENT_ROLES
      VERTEX_TYPE
      badFinishReasons
      name
      responseLineRE
      version

      26 dependencies

      BlockReason
      DEFAULT_API_VERSION
      DEFAULT_BASE_URL
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      LANGUAGE_TAG
      PACKAGE_VERSION
      POSSIBLE_ROLES
      SILENT_ERROR
      SchemaType
      Task
      VALID_PARTS_PER_ROLE
      VALID_PART_FIELDS
      VALID_PREVIOUS_CONTENT_ROLES
      VERTEX_TYPE
      badFinishReasons
      logger
      name
      responseLineRE
      version

      + logger

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • HarmBlockMethod

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size2.45 kB2.52 kB+70 B (+2.9%)
      size-with-ext-deps20.3 kB20.3 kB+28 B (+0.1%)

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • HarmBlockThreshold

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size2.46 kB2.53 kB+70 B (+2.8%)
      size-with-ext-deps20.3 kB20.3 kB+28 B (+0.1%)

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • HarmCategory

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size2.45 kB2.52 kB+70 B (+2.9%)
      size-with-ext-deps20.3 kB20.3 kB+28 B (+0.1%)

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • HarmProbability

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size2.45 kB2.52 kB+70 B (+2.9%)
      size-with-ext-deps20.3 kB20.3 kB+28 B (+0.1%)

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • HarmSeverity

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size2.45 kB2.52 kB+70 B (+2.9%)
      size-with-ext-deps20.3 kB20.3 kB+28 B (+0.1%)

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • IntegerSchema

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size4.54 kB4.61 kB+70 B (+1.5%)
      size-with-ext-deps22.4 kB22.4 kB+28 B (+0.1%)

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • NumberSchema

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size4.54 kB4.61 kB+70 B (+1.5%)
      size-with-ext-deps22.4 kB22.4 kB+28 B (+0.1%)

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • ObjectSchema

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size4.54 kB4.61 kB+70 B (+1.5%)
      size-with-ext-deps22.4 kB22.4 kB+28 B (+0.1%)

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • POSSIBLE_ROLES

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size2.50 kB2.57 kB+70 B (+2.8%)
      size-with-ext-deps20.3 kB20.4 kB+28 B (+0.1%)

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • Schema

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size4.54 kB4.61 kB+70 B (+1.5%)
      size-with-ext-deps22.4 kB22.4 kB+28 B (+0.1%)

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • SchemaType

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size2.45 kB2.52 kB+70 B (+2.9%)
      size-with-ext-deps20.3 kB20.3 kB+28 B (+0.1%)

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • StringSchema

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size4.54 kB4.61 kB+70 B (+1.5%)
      size-with-ext-deps22.4 kB22.4 kB+28 B (+0.1%)

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • VertexAIError

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size2.76 kB2.83 kB+70 B (+2.5%)
      size-with-ext-deps20.6 kB20.6 kB+28 B (+0.1%)

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • getGenerativeModel

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size17.2 kB17.3 kB+127 B (+0.7%)
      size-with-ext-deps35.7 kB35.8 kB+87 B (+0.2%)

      Dependency

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      variables

      25 dependencies

      BlockReason
      DEFAULT_API_VERSION
      DEFAULT_BASE_URL
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      LANGUAGE_TAG
      PACKAGE_VERSION
      POSSIBLE_ROLES
      SILENT_ERROR
      SchemaType
      Task
      VALID_PARTS_PER_ROLE
      VALID_PART_FIELDS
      VALID_PREVIOUS_CONTENT_ROLES
      VERTEX_TYPE
      badFinishReasons
      name
      responseLineRE
      version

      26 dependencies

      BlockReason
      DEFAULT_API_VERSION
      DEFAULT_BASE_URL
      DEFAULT_LOCATION
      FinishReason
      FunctionCallingMode
      HarmBlockMethod
      HarmBlockThreshold
      HarmCategory
      HarmProbability
      HarmSeverity
      LANGUAGE_TAG
      PACKAGE_VERSION
      POSSIBLE_ROLES
      SILENT_ERROR
      SchemaType
      Task
      VALID_PARTS_PER_ROLE
      VALID_PART_FIELDS
      VALID_PREVIOUS_CONTENT_ROLES
      VERTEX_TYPE
      badFinishReasons
      logger
      name
      responseLineRE
      version

      + logger

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

    • getVertexAI

      Size

      TypeBase (1f1ba3f)Merge (109f9be)Diff
      size2.63 kB2.70 kB+70 B (+2.7%)
      size-with-ext-deps27.8 kB27.8 kB+28 B (+0.1%)

      External Dependency

      ModuleBase (1f1ba3f)Merge (109f9be)Diff
      @firebase/logger

      Logger

      + Logger

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/UBv7ZDZUTI.html

Copy link
Contributor

@DellaBitta DellaBitta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you can drop the base64 import.

@google-oss-bot
Copy link
Contributor

Size Report 1

Affected Products

  • @firebase/vertexai

    TypeBase (1f1ba3f)Merge (109f9be)Diff
    browser28.7 kB28.9 kB+169 B (+0.6%)
    main29.5 kB29.7 kB+206 B (+0.7%)
    module28.7 kB28.9 kB+169 B (+0.6%)
  • firebase

    TypeBase (1f1ba3f)Merge (109f9be)Diff
    firebase-vertexai.js22.1 kB23.9 kB+1.79 kB (+8.1%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/XlkrP2gxLe.html

@hsubox76
Copy link
Contributor Author

Looks like you can drop the base64 import.

Thanks, got it.

@hsubox76 hsubox76 merged commit 4db3d3e into main Oct 23, 2024
38 of 39 checks passed
@hsubox76 hsubox76 deleted the ch-appcheck-token-fix branch October 23, 2024 21:12
@google-oss-bot google-oss-bot mentioned this pull request Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants