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

Update CloudEvent types #1089

Merged
merged 2 commits into from May 2, 2022
Merged

Update CloudEvent types #1089

merged 2 commits into from May 2, 2022

Conversation

TheIronDev
Copy link
Contributor

Updates to exported CloudEvent Types

This commit makes several updates to the exported CloudEvent types.

  • Fixed NPE issue with attempting to grab storageBucket from a null firebase config
  • Billing types include a notificationType
  • Crashlytics have more documentation on fields
  • Storage has an exported StorageEvent which includes the bucket.
  • Storage function api references StorageEvent to better match to expected output.
  • Updated more signatures to optionally expect a bucket.

Description

Code sample

This commit makes several updates to the exported CloudEvent types.

* Billing types include a notificationType
  * [Link](https://github.com/googleapis/google-cloudevents/blob/main/proto/google/events/firebase/firebasealerts/v1/cloud_event_payload.proto#L132-L133)
* Crashlytics have more documentation on fields
* Storage has an exported `StorageEvent` which includes the bucket.
* Storage function api references `StorageEvent` to better match to expected output.
Updated more signatures to optionally expect a bucket.
@@ -382,7 +389,7 @@ export function getOptsAndBucket(
bucket = bucketOrOpts;
opts = {};
} else {
bucket = bucketOrOpts.bucket || firebaseConfig().storageBucket;
bucket = bucketOrOpts.bucket || firebaseConfig()?.storageBucket;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the NPE culprit. firebaseConfig() is nullable, so attempting to access storageBucket throw an exception.

@taeold taeold changed the title Tystark.more type fixes Update CloudEvent types May 1, 2022
principalEmail: string;
/** The type of the notification, e.g. upgrade, downgrade */
notificationType: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

oh nice catch, I think I missed this field and meant to add it a while ago 🤦‍♂️

bucket: string;
}

export type StorageEvent = CloudEvent<StorageObjectData, WithBucket>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh interesting, I didn't realize that storage also uses custom extension attributes.

@TheIronDev TheIronDev merged commit 1aa1865 into master May 2, 2022
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.

None yet

2 participants