Skip to content

Conversation

@samtstern
Copy link
Contributor

@samtstern samtstern commented Jun 30, 2021

Description

Fixes #3536

Scenarios Tested

I created a simple function and triggered it in the Emulators UI:

const functions = require("firebase-functions");

exports.helloWorld = functions.auth.user().onCreate(async (user, ctx) => {
  console.log(JSON.stringify(ctx, undefined, 2));
});

The logs are correct:

>  {
>    "eventId": "d01d812f-03b5-4731-98c2-d539f4cb606f",
>    "eventType": "google.firebase.auth.user.create",
>    "resource": {
>      "service": "firebaseauth.googleapis.com",
>      "name": "projects/demo-project-12345"
>    },
>    "params": {},
>    "timestamp": "2021-06-30T13:45:49.161Z"
>  }

I also deployed a function to production to see the behavior and here is the context payload:

{
  "eventId":"2bcd79bb-dd0d-45b7-85f7-1a51b0b00e5a",
  "eventType":"google.firebase.auth.user.create",
  "notSupported":{},
  "resource":{
    "service":"firebaseauth.googleapis.com",
    "name":"projects/fir-dumpster"
  },
  "timestamp":"2021-07-01T16:51:17.729Z",
  "params":{}
} 

Sample Commands

N/A

@samtstern samtstern requested a review from yuchenshi June 30, 2021 13:48
@google-cla google-cla bot added the cla: yes Manual indication that this has passed CLA. label Jun 30, 2021
eventId: uuid.v4(),
eventType: `providers/firebase.auth/eventTypes/user.${action}`,
resource: {
name: `projects/${this.projectId}`,
Copy link
Member

Choose a reason for hiding this comment

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

Shall this include the user id? I'm not sure what the production behavior actually is though

Copy link
Contributor Author

@samtstern samtstern Jul 1, 2021

Choose a reason for hiding this comment

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

I was just following the docs here, but I will deploy a function quickly to confirm:
https://firebase.google.com/docs/reference/functions/cloud_functions_.eventcontext#resource

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the description with a production payload.

@samtstern samtstern merged commit 0e882aa into master Jul 1, 2021
devpeerapong pushed a commit to devpeerapong/firebase-tools that referenced this pull request Dec 14, 2021
@bkendall bkendall deleted the ss-fix-3536 branch March 18, 2022 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Manual indication that this has passed CLA.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incomplete event context when creating a new user

2 participants