Repository: firebase/functions-samples Branch: main Commit: a6ae4cbd3cf2 Files: 660 Total size: 1.1 MB Directory structure: gitextract_tgieqsqq/ ├── .github/ │ ├── ISSUE_TEMPLATE/ │ │ ├── bug_report.md │ │ ├── config.yml │ │ └── docs.md │ └── workflows/ │ ├── test_node.yml │ ├── test_node_1st_gen.yml │ └── test_python.yml ├── .gitignore ├── .opensource/ │ └── project.json ├── CONTRIBUTING.md ├── LICENSE ├── Node/ │ ├── README.md │ ├── alerts-to-discord/ │ │ ├── .gitignore │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.js │ │ ├── index.js │ │ └── package.json │ ├── app-distribution-feedback-to-jira/ │ │ ├── .eslintrc │ │ ├── .gitignore │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.cjs │ │ ├── .gitignore │ │ ├── index.js │ │ └── package.json │ ├── call-vertex-remote-config-server/ │ │ ├── README.md │ │ ├── client/ │ │ │ ├── README.md │ │ │ ├── config.ts │ │ │ ├── index.html │ │ │ ├── main.ts │ │ │ ├── package.json │ │ │ ├── vite-env.d.ts │ │ │ └── vite.config.js │ │ ├── firebase.json │ │ └── functions/ │ │ ├── index.js │ │ └── package.json │ ├── delete-unused-accounts-cron/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.js │ │ ├── index.js │ │ └── package.json │ ├── fcm-notifications/ │ │ ├── .gitignore │ │ ├── README.md │ │ ├── database.rules.json │ │ ├── firebase.json │ │ ├── functions/ │ │ │ ├── .eslintrc.cjs │ │ │ ├── .gitignore │ │ │ ├── index.js │ │ │ └── package.json │ │ └── public/ │ │ ├── firebase-messaging-sw.js │ │ ├── index.html │ │ ├── main.css │ │ └── main.js │ ├── instrument-with-opentelemetry/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.js │ │ ├── index.js │ │ ├── package.json │ │ ├── timer.js │ │ └── tracing.js │ ├── pnpm-workspace.yaml │ ├── quickstarts/ │ │ ├── auth-blocking-functions/ │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── .eslintrc.js │ │ │ ├── .gitignore │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── callable-functions/ │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── .eslintrc.js │ │ │ ├── .gitignore │ │ │ ├── index.js │ │ │ ├── package.json │ │ │ └── sanitizer.js │ │ ├── callable-functions-streaming/ │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ ├── functions/ │ │ │ │ ├── .eslintrc.js │ │ │ │ ├── .gitignore │ │ │ │ ├── index.js │ │ │ │ └── package.json │ │ │ └── website/ │ │ │ └── index.html │ │ ├── custom-events/ │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── .eslintrc.js │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── firestore-sync-auth/ │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ ├── firestore.indexes.json │ │ │ ├── firestore.rules │ │ │ └── functions/ │ │ │ ├── .eslintrc.js │ │ │ ├── .gitignore │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── genkit-helloworld/ │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── .eslintrc.js │ │ │ ├── .gitignore │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── https-time-server/ │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── .eslintrc.js │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── monitor-cloud-logging/ │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── .eslintrc.js │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── pubsub-helloworld/ │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── .eslintrc.js │ │ │ ├── .gitignore │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── testlab-matrix-completed/ │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── .eslintrc.js │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── thumbnails/ │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── .eslintrc.js │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── uppercase-firestore/ │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ ├── firestore.indexes.json │ │ │ ├── firestore.rules │ │ │ └── functions/ │ │ │ ├── .eslintrc.js │ │ │ ├── .gitignore │ │ │ ├── index.js │ │ │ └── package.json │ │ └── uppercase-rtdb/ │ │ ├── README.md │ │ ├── database.rules.json │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.js │ │ ├── index.js │ │ └── package.json │ ├── remote-config-diff/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.js │ │ ├── index.js │ │ └── package.json │ ├── remote-config-server-with-vertex/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── index.js │ │ └── package.json │ ├── taskqueues-backup-images/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.js │ │ ├── index.js │ │ └── package.json │ ├── test-functions-jest/ │ │ ├── .gitignore │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.js │ │ ├── .gitignore │ │ ├── index.js │ │ ├── index.test.js │ │ └── package.json │ ├── test-functions-jest-ts/ │ │ ├── .gitignore │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.js │ │ ├── .gitignore │ │ ├── jest.config.js │ │ ├── package.json │ │ ├── src/ │ │ │ ├── __test__/ │ │ │ │ └── index.test.ts │ │ │ └── index.ts │ │ ├── tsconfig.dev.json │ │ └── tsconfig.json │ ├── test-functions-mocha/ │ │ ├── .gitignore │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.js │ │ ├── .gitignore │ │ ├── index.js │ │ ├── index.test.js │ │ └── package.json │ ├── testlab-to-slack/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.js │ │ ├── index.js │ │ └── package.json │ └── youtube/ │ ├── README.md │ ├── firebase.json │ └── functions/ │ ├── index.ts │ ├── package.json │ └── tsconfig.json ├── Node-1st-gen/ │ ├── README.md │ ├── assistant-say-number/ │ │ ├── README.md │ │ ├── action.json │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── authenticated-json-api/ │ │ ├── README.md │ │ ├── database.rules.json │ │ ├── firebase.json │ │ ├── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── index.js │ │ │ └── package.json │ │ └── public/ │ │ ├── index.html │ │ ├── main.css │ │ └── main.js │ ├── authorized-https-endpoint/ │ │ ├── README.md │ │ ├── firebase.json │ │ ├── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── index.js │ │ │ └── package.json │ │ └── public/ │ │ ├── index.html │ │ ├── main.css │ │ └── main.js │ ├── bigquery-import/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── child-count/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── convert-images/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── coupon-on-purchase/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── delete-old-child-nodes/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── delete-unused-accounts-cron/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── developer-motivator/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── email-confirmation/ │ │ ├── README.md │ │ ├── database.rules.json │ │ ├── firebase.json │ │ ├── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── index.js │ │ │ └── package.json │ │ └── public/ │ │ ├── index.html │ │ ├── main.css │ │ └── main.js │ ├── exif-images/ │ │ ├── README.md │ │ ├── database.rules.json │ │ ├── firebase.json │ │ ├── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── index.js │ │ │ └── package.json │ │ └── public/ │ │ ├── index.html │ │ ├── main.css │ │ └── main.js │ ├── fcm-notifications/ │ │ ├── README.md │ │ ├── database.rules.json │ │ ├── firebase.json │ │ ├── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── index.js │ │ │ └── package.json │ │ └── public/ │ │ ├── firebase-messaging-sw.js │ │ ├── index.html │ │ ├── main.css │ │ └── main.js │ ├── ffmpeg-convert-audio/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── fulltext-search/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── fulltext-search-firestore/ │ │ ├── README.md │ │ ├── firebase.json │ │ ├── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── .gitignore │ │ │ ├── elastic.js │ │ │ ├── index.js │ │ │ ├── package.json │ │ │ └── typesense.js │ │ └── public/ │ │ ├── index.html │ │ └── index.js │ ├── github-to-slack/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── google-sheet-sync/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── image-maker/ │ │ ├── .gitignore │ │ ├── README.md │ │ ├── firebase.json │ │ ├── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── clock.js │ │ │ ├── index.js │ │ │ ├── package.json │ │ │ ├── ray.js │ │ │ └── sparkline.js │ │ └── public/ │ │ └── index.html │ ├── instagram-auth/ │ │ ├── .gitignore │ │ ├── README.md │ │ ├── database.rules.json │ │ ├── firebase.json │ │ ├── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── main.css │ │ └── public/ │ │ ├── index.html │ │ ├── main.css │ │ ├── main.js │ │ └── popup.html │ ├── lastmodified-tracking/ │ │ ├── README.md │ │ ├── database.rules.json │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── limit-children/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── linkedin-auth/ │ │ ├── .gitignore │ │ ├── README.md │ │ ├── database.rules.json │ │ ├── firebase.json │ │ ├── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── main.css │ │ └── public/ │ │ ├── index.html │ │ ├── main.css │ │ ├── main.js │ │ └── popup.html │ ├── message-translation/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── minimal-webhook/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── moderate-images/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── okta-auth/ │ │ ├── .gitignore │ │ ├── README.md │ │ ├── firebase.json │ │ ├── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── public/ │ │ │ └── index.html │ │ └── setup.js │ ├── paypal/ │ │ ├── .gitignore │ │ ├── README.md │ │ ├── firebase.json │ │ ├── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── index.js │ │ │ └── package.json │ │ └── public/ │ │ ├── cancel.html │ │ ├── error.html │ │ ├── index.html │ │ ├── main.css │ │ └── success.html │ ├── presence-firestore/ │ │ ├── README.md │ │ ├── firebase.json │ │ ├── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── index.js │ │ │ └── package.json │ │ └── public/ │ │ ├── index.html │ │ └── index.js │ ├── publish-model/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── quickstarts/ │ │ ├── auth-blocking-functions/ │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── .eslintrc.js │ │ │ ├── .gitignore │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── big-ben/ │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ ├── functions/ │ │ │ │ ├── .eslintrc.json │ │ │ │ ├── index.js │ │ │ │ └── package.json │ │ │ └── public/ │ │ │ ├── script.js │ │ │ └── style.css │ │ ├── email-users/ │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ ├── functions/ │ │ │ │ ├── .eslintrc.json │ │ │ │ ├── index.js │ │ │ │ └── package.json │ │ │ └── public/ │ │ │ ├── index.html │ │ │ ├── main.css │ │ │ └── main.js │ │ ├── https-time-server/ │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── multicodebase-hellos/ │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ ├── js/ │ │ │ │ ├── .eslintrc.js │ │ │ │ ├── .gitignore │ │ │ │ ├── index.js │ │ │ │ └── package.json │ │ │ └── ts/ │ │ │ ├── .eslintrc.js │ │ │ ├── .gitignore │ │ │ ├── package.json │ │ │ ├── src/ │ │ │ │ └── index.ts │ │ │ ├── tsconfig.dev.json │ │ │ └── tsconfig.json │ │ ├── pubsub-helloworld/ │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── runtime-options/ │ │ │ ├── .gitignore │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── .eslintrc.js │ │ │ ├── .gitignore │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── taskqueues-backup-images/ │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── testlab-matrix-completed/ │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── .gitignore │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── thumbnails/ │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── uppercase-firestore/ │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ ├── firestore.indexes.json │ │ │ ├── firestore.rules │ │ │ └── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── .gitignore │ │ │ ├── index.js │ │ │ └── package.json │ │ └── uppercase-rtdb/ │ │ ├── README.md │ │ ├── database.rules.json │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ ├── package.json │ │ └── test/ │ │ ├── test.offline.js │ │ └── test.online.js │ ├── remote-config-diff/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── spotify-auth/ │ │ ├── README.md │ │ ├── database.rules.json │ │ ├── firebase.json │ │ ├── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── main.css │ │ └── public/ │ │ ├── index.html │ │ ├── main.css │ │ ├── main.js │ │ └── popup.html │ ├── stripe/ │ │ ├── README.md │ │ ├── firebase.json │ │ ├── firestore.rules │ │ ├── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── index.js │ │ │ └── package.json │ │ └── public/ │ │ ├── index.html │ │ └── javascript/ │ │ └── app.js │ ├── survey-app-update/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── template-handlebars/ │ │ ├── README.md │ │ ├── firebase.json │ │ ├── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── firebaseUser.js │ │ │ ├── index.js │ │ │ ├── package.json │ │ │ └── views/ │ │ │ ├── layouts/ │ │ │ │ └── main.handlebars │ │ │ └── user.handlebars │ │ └── public/ │ │ └── main.css │ ├── testlab-to-slack/ │ │ ├── .gitignore │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .gitignore │ │ ├── index.js │ │ └── package.json │ ├── text-moderation/ │ │ ├── README.md │ │ ├── firebase.json │ │ ├── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── index.js │ │ │ └── package.json │ │ ├── public/ │ │ │ ├── index.html │ │ │ ├── main.css │ │ │ └── main.js │ │ └── security.rules.json │ ├── url-shortener/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .eslintrc.json │ │ ├── index.js │ │ └── package.json │ ├── user-data-cleanup/ │ │ ├── README.md │ │ └── doc/ │ │ ├── auto_rules_extraction.md │ │ └── design.md │ ├── username-password-auth/ │ │ ├── README.md │ │ ├── database.rules.json │ │ ├── firebase.json │ │ ├── functions/ │ │ │ ├── .eslintrc.json │ │ │ ├── index.js │ │ │ └── package.json │ │ └── public/ │ │ ├── index.html │ │ ├── main.css │ │ └── main.js │ ├── vision-annotate-images/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── .gitignore │ │ ├── eslint.config.js │ │ ├── package.json │ │ ├── src/ │ │ │ └── index.ts │ │ └── tsconfig.json │ └── youtube/ │ ├── README.md │ ├── firebase.json │ └── functions/ │ ├── .eslintrc.json │ ├── index.js │ └── package.json ├── Python/ │ ├── .gitignore │ ├── README.md │ ├── alerts-to-discord/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── main.py │ │ └── requirements.txt │ ├── delete-unused-accounts-cron/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── main.py │ │ └── requirements.txt │ ├── fcm-notifications/ │ │ ├── .gitignore │ │ ├── README.md │ │ ├── database.rules.json │ │ ├── firebase.json │ │ ├── functions/ │ │ │ ├── .gitignore │ │ │ ├── main.py │ │ │ └── requirements.txt │ │ └── public/ │ │ ├── firebase-messaging-sw.js │ │ ├── index.html │ │ ├── main.css │ │ └── main.js │ ├── http-flask/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── main.py │ │ └── requirements.txt │ ├── post-signup-event/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── main.py │ │ └── requirements.txt │ ├── pyfmt.py │ ├── pyproject.toml │ ├── quickstarts/ │ │ ├── auth-blocking-functions/ │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── main.py │ │ │ └── requirements.txt │ │ ├── callable-functions/ │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── main.py │ │ │ └── requirements.txt │ │ ├── custom-events/ │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── main.py │ │ │ └── requirements.txt │ │ ├── firestore-sync-auth/ │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── main.py │ │ │ └── requirements.txt │ │ ├── https-time-server/ │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── main.py │ │ │ └── requirements.txt │ │ ├── monitor-cloud-logging/ │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── main.py │ │ │ └── requirements.txt │ │ ├── pubsub-helloworld/ │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── main.py │ │ │ └── requirements.txt │ │ ├── uppercase-firestore/ │ │ │ ├── README.md │ │ │ ├── firebase.json │ │ │ └── functions/ │ │ │ ├── main.py │ │ │ └── requirements.txt │ │ └── uppercase-rtdb/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── main.py │ │ └── requirements.txt │ ├── remote-config-diff/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── main.py │ │ └── requirements.txt │ ├── requirements.txt │ ├── taskqueues-backup-images/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── main.py │ │ └── requirements.txt │ ├── testlab-to-slack/ │ │ ├── README.md │ │ ├── firebase.json │ │ └── functions/ │ │ ├── main.py │ │ └── requirements.txt │ └── thumbnails/ │ ├── README.md │ ├── firebase.json │ └── functions/ │ ├── main.py │ └── requirements.txt ├── README.md ├── community.md ├── package-lock.json ├── package.json └── tsconfig.template.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/ISSUE_TEMPLATE/bug_report.md ================================================ --- name: Bug report about: Report an issue with a specific sample title: '[BUG] in sample: ' labels: 'type: bug' assignees: '' --- ### Which sample has a bug? **Sample name or URL where you found the bug** ### How to reproduce the issue **Failing Function code used (if you modified the sample)** **Steps to set up and reproduce** ### Debug output **Errors in the [console logs](https://console.firebase.google.com/project/_/functions/logs?search=&severity=DEBUG)** **Screenshots** ### Expected behavior ### Actual behavior ================================================ FILE: .github/ISSUE_TEMPLATE/config.yml ================================================ # Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # https://docs.github.com/en/free-pro-team@latest/github/building-a-strong-community/configuring-issue-templates-for-your-repository#configuring-the-template-chooser blank_issues_enabled: false contact_links: - name: Propose a new sample, or get help setting up a sample url: https://github.com/firebase/functions-samples/discussions about: Informal help and discussion about the samples in this repository. - name: Issues with the Firebase platform url: https://firebase.google.com/support about: Report issues with Firebase services to Firebase support. ================================================ FILE: .github/ISSUE_TEMPLATE/docs.md ================================================ --- name: Documentation issue about: Are a sample's docs incorrect or unclear? title: '[DOCS] for sample: ' labels: '' assignees: '' --- ### Which sample? **Sample name or URL** **Link to closest heading** ### What is the issue with this sample's docs? ================================================ FILE: .github/workflows/test_node.yml ================================================ # Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. name: 2nd Gen CI Tests on: pull_request: paths: - 'Node/**' - 'package.json' - 'package-lock.json' - 'pnpm-workspace.yaml' - 'pnpm-lock.yaml' - 'tsconfig.template.json' push: branches: - main paths: - 'Node/**' - 'package.json' - 'package-lock.json' - 'pnpm-workspace.yaml' - 'pnpm-lock.yaml' - 'tsconfig.template.json' env: CI: true jobs: unit: runs-on: ubuntu-latest strategy: matrix: node-version: # The latest Node version for 2nd gen # https://cloud.google.com/functions/docs/runtime-support#node.js - 22.x steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - name: Cache npm uses: actions/cache@v4 with: path: ~/.npm key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }} - run: npm install - run: npm run bootstrap-2nd-gen - run: npm run lint-2nd-gen - run: npm run compile-2nd-gen - run: npm run test-2nd-gen ================================================ FILE: .github/workflows/test_node_1st_gen.yml ================================================ # Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. name: 1st Gen CI Tests on: pull_request: paths: - 'Node-1st-gen/**' - 'package.json' - 'package-lock.json' - 'pnpm-workspace.yaml' - 'pnpm-lock.yaml' - 'tsconfig.template.json' push: branches: - main paths: - 'Node-1st-gen/**' - 'package.json' - 'package-lock.json' - 'pnpm-workspace.yaml' - 'pnpm-lock.yaml' - 'tsconfig.template.json' env: CI: true jobs: unit: runs-on: ubuntu-latest strategy: matrix: node-version: # The latest Node version for 1st gen # https://cloud.google.com/functions/docs/runtime-support#node.js - 20.x steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - name: Cache npm uses: actions/cache@v4 with: path: ~/.npm key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }} - run: npm install - run: npm run bootstrap-1st-gen - run: npm run lint-1st-gen - run: npm run compile-1st-gen - run: npm run test-1st-gen ================================================ FILE: .github/workflows/test_python.yml ================================================ # Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. name: CI Tests on: pull_request: paths: - 'Python/**' push: branches: - main paths: - 'Python/**' env: CI: true jobs: unit: runs-on: ubuntu-latest strategy: matrix: python-version: - "3.10" - "3.11" steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies working-directory: ./Python run: pip install -r requirements.txt - name: Lint working-directory: ./Python run: python pyfmt.py --check_only --exclude "**/venv/**/*.py" **/*.py ================================================ FILE: .gitignore ================================================ .idea **/node_modules/* **/.firebase **/.firebaserc **/.runtimeconfig.json */npm-debug.log lerna-debug.log *~ service-account-credentials.json **/package-lock.json # keep the root package-lock so that tools are consistent !/package-lock.json **/ui-debug.log **/database-debug.log **/firebase-debug.log **/pubsub-debug.log **/tsconfig-compile.json yarn.lock **/.DS_Store ================================================ FILE: .opensource/project.json ================================================ { "name": "Cloud Functions Samples", "type": "sample", "platforms": [ "Admin", "Node" ], "content": "README.md", "pages": { "quickstarts/big-ben/README.md": "Quickstart: HTTP Trigger + Hosting", "quickstarts/email-users/README.md": "Quickstart: Auth Trigger", "quickstarts/pubsub-helloworld/README.md": "Quickstart: PubSub Trigger", "quickstarts/thumbnails/README.md": "Quickstart: Cloud Storage Trigger", "quickstarts/time-server/README.md": "Quickstart: HTTP Trigger", "quickstarts/uppercase/README.md": "Quickstart: RTDB Trigger", "quickstarts/uppercase-firestore/README.md": "Quickstart: Firestore Trigger" }, "related": [ "firebase/firebase-functions" ] } ================================================ FILE: CONTRIBUTING.md ================================================ # Contributing to the Firebase Cloud Functions Templates Library We'd love for you to contribute to our source code and to make the Firebase Cloud Functions Templates Library even better than it is today! Here are the guidelines we'd like you to follow: - [Code of Conduct](#coc) - [Question or Problem?](#question) - [Issues and Bugs](#issue) - [Feature Requests](#feature) - [Submission Guidelines](#submit) - [Signing the CLA](#cla) ## Code of Conduct As contributors and maintainers of the Firebase functions-samples project, we pledge to respect everyone who contributes by posting issues, updating documentation, submitting pull requests, providing feedback in comments, and any other activities. Communication through any of Firebase's channels (GitHub, StackOverflow, Twitter, etc.) must be constructive and never resort to personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct. We promise to extend courtesy and respect to everyone involved in this project regardless of gender, gender identity, sexual orientation, disability, age, race, ethnicity, religion, or level of experience. We expect anyone contributing to the project to do the same. If any member of the community violates this code of conduct, the maintainers of this project may take action, removing issues, comments, and PRs or blocking accounts as deemed appropriate. If you are subject to or witness unacceptable behavior, or have any other concerns, please drop us a line at [Firebase support](https://firebase.google.com/support). ## Got a Question or Problem? - To report specific problems with the samples in this repository, file an [issue](#issue). - If you have questions about a sample in this repository, try opening a [discussion](https://github.com/firebase/functions-samples/discussions). - For general Cloud Functions for Firebase questions, please ask on [StackOverflow][stackoverflow] and use the `firebase` tag. - If you have a problem specific to your Firebase project, or would like to report an issue with Firebase itself, contact [Firebase support](https://firebase.google.com/support). ## Found an Issue? If you find a bug in the source code or a mistake in the documentation, you can help us by submitting an issue to our [GitHub Repository][github]. Even better, you can submit a Pull Request with a fix. See [below](#submit) for some guidelines. ## Submission Guidelines ### Submitting an Issue Before you submit your issue search the archive in case your question was already answered. Help us to maximize the effort we can spend fixing issues and adding new features by not reporting duplicate issues. The more information you can provide in an issue, the faster we can resolve it. Issues that don't make an attempt to follow the issue template will likely be closed. ### New samples Given the maintenance cost of the large number of samples that are already in this repository, we are unlikely to add new samples. However, if you have an idea for a sample and would like to discuss it with others, take a look at the ["ideas" section of this repository's discussions](https://github.com/firebase/functions-samples/discussions?discussions_q=category%3AIdeas). Pull Requests that contain new samples will only be considered if they meet the following criteria: - Solve a common use-case for Cloud Functions for Firebase with minimal non-Firebase setup required - Thoroughly documented - Thoroughly tested - Simple enough to be maintained alongside all other samples in the repository If your Pull Request isn't accepted, consider hosting it in your own GitHub repository, and adding it to our [list of community-built extensions](./community.md)! ## Signing the CLA Contributions to this project must be accompanied by a Contributor License Agreement (CLA). You (or your employer) retain the copyright to your contribution; this simply gives us permission to use and redistribute your contributions as part of the project. Head over to to see your current agreements on file or to sign a new one. You generally only need to submit a CLA once, so if you've already submitted one (even if it was for a different project), you probably don't need to do it again. Please sign our [Contributor License Agreement][google-cla] (CLA) before sending pull requests. For any code changes to be accepted, the CLA must be signed. It's a quick process, we promise! [github]: https://github.com/firebase/functions-samples [google-cla]: https://cla.developers.google.com [js-style-guide]: http://google.github.io/styleguide/javascriptguide.xml [py-style-guide]: http://google.github.io/styleguide/pyguide.html [jsbin]: http://jsbin.com/ [stackoverflow]: http://stackoverflow.com/questions/tagged/firebase [global-gitignore]: https://help.github.com/articles/ignoring-files/#create-a-global-gitignore ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2016 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: Node/README.md ================================================ # Node.js (2nd gen) samples This folder contains examples for 2nd gen Node.js functions. See a description of all samples in this folder in the [root README](../README.md). ================================================ FILE: Node/alerts-to-discord/.gitignore ================================================ # Don't accidentally push Discord Webhook URL to prod functions/.env ================================================ FILE: Node/alerts-to-discord/README.md ================================================ # Quickstart: Send Firebase Alerts to Discord This quickstart demonstrates how to trigger a function based on a Firebase Alert, and send information about the alert to a channel in a Discord server. Screen Shot 2022-04-29 at 11 12 12 AM ## Set up and Deploy ### Discord Webhook URL The sample uses [Discord Webhooks](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks) to send alerts to a Discord channel. You'll need to create a Webhook and hook it up the function by [creating an environment variable](https://firebase.google.com/docs/functions/config-env#env-variables): 1. Follow the "MAKING A WEBHOOK" instructions in the [Discord docs](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks). 1. Copy the Webhook URL 1. Create a `.env` file in the `functions` directory 1. Add the `DISCORD_WEBHOOK_URL` variable and set it to your Webhook URL: ```bash DISCORD_WEBHOOK_URL="" ``` ### Deploy Deploy functions using the Firebase CLI: ```bash $ firebase deploy ``` ## License © Google, 2022. Licensed under an [Apache-2](../../../LICENSE) license. ================================================ FILE: Node/alerts-to-discord/firebase.json ================================================ { "functions": { "codebase": "alerts-to-discord", "predeploy": [ "npm --prefix \"$RESOURCE_DIR\" run lint" ] } } ================================================ FILE: Node/alerts-to-discord/functions/.eslintrc.js ================================================ /** * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ module.exports = { root: true, env: { es2017: true, node: true, }, extends: [ "eslint:recommended", "google", ], rules: { quotes: ["error", "double"], }, }; ================================================ FILE: Node/alerts-to-discord/functions/index.js ================================================ /** * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // [START v2import] const { onNewFatalIssuePublished, } = require("firebase-functions/alerts/crashlytics"); const { onNewTesterIosDevicePublished, } = require("firebase-functions/alerts/appDistribution"); const { onThresholdAlertPublished, } = require("firebase-functions/alerts/performance"); const logger = require("firebase-functions/logger"); // [END v2import] /** * Posts a message to Discord with Discord's Webhook API * * @param {string} botName - The bot username to display * @param {string} messageBody - The message to post (Discord MarkDown) */ async function postMessageToDiscord(botName, messageBody) { const webhookUrl = process.env.DISCORD_WEBHOOK_URL; if (!webhookUrl) { throw new Error( "No webhook URL found. Set the Discord Webhook URL before deploying. Learn more about Discord webhooks here: https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks", ); } return fetch(webhookUrl, { method: "POST", headers: {"Content-Type": "application/json"}, body: JSON.stringify( // Here's what the Discord API supports in the payload: // https://discord.com/developers/docs/resources/webhook#execute-webhook-jsonform-params { content: messageBody, username: botName, }, ), }); } // [START v2Alerts] /** * function triggered by Crashlytics that publishes a message * to Discord whenever a new fatal issue occurs. */ // [START v2CrashlyticsAlertTrigger] exports.postfatalissuetodiscord = onNewFatalIssuePublished(async (event) => { // [END v2CrashlyticsAlertTrigger] // [START v2CrashlyticsEventPayload] // construct a helpful message to send to Discord const appId = event.appId; const {id, title, subtitle, appVersion} = event.data.payload.issue; const message = ` 🚨 New fatal issue for ${appId} in version ${appVersion} 🚨 **${title}** ${subtitle} id: \`${id}\` `; // [END v2CrashlyticsEventPayload] try { // [START v2SendToDiscord] const response = await postMessageToDiscord("Crashlytics Bot", message); if (response.ok) { logger.info( `Posted fatal Crashlytics alert ${id} for ${appId} to Discord`, event.data.payload, ); } else { throw new Error(`Discord returned status code ${response.status}`); } // [END v2SendToDiscord] } catch (error) { logger.error( `Unable to post fatal Crashlytics alert ${id} for ${appId} to Discord`, error, ); } }); /** * function triggered by App Distribution that publishes a message * to Discord whenever a new iOS tester device is registered. */ // [START v2AppDistributionAlertTrigger] exports.postnewduuidtodiscord = onNewTesterIosDevicePublished(async (event) => { // [END v2AppDistributionAlertTrigger] // [START v2AppDistributionEventPayload] // construct a helpful message to send to Discord const appId = event.appId; const { testerDeviceIdentifier, testerDeviceModelName, testerEmail, testerName, } = event.data.payload; const message = ` 📱 New iOS device registered by ${testerName} <${testerEmail}> for ${appId} UDID **${testerDeviceIdentifier}** for ${testerDeviceModelName} `; // [END v2AppDistributionEventPayload] try { // [START v2SendNewTesterIosDeviceToDiscord] const response = await postMessageToDiscord("AppDistribution Bot", message); if (response.ok) { logger.info( `Posted iOS device registration alert for ${testerEmail} to Discord`, ); } else { throw new Error(`Discord returned status code ${response.status}`); } // [END v2SendNewTesterIosDeviceToDiscord] } catch (error) { logger.error( `Unable to post iOS device registration for ${testerEmail} to Discord`, error, ); } }); // [END v2Alerts] /** * Function triggered by Firebase Performance Monitoring that publishes * a message to Discord whenever a performance threshold alert is fired. */ // [START v2PerformanceAlertTrigger] exports.postperformancealerttodiscord = onThresholdAlertPublished( async (event) => { // [END v2PerformanceAlertTrigger] // [START v2PerformanceEventPayload] // construct a helpful message to send to Discord const appId = event.appId; const { eventName, metricType, eventType, numSamples, thresholdValue, thresholdUnit, conditionPercentile, appVersion, violationValue, violationUnit, investigateUri, } = event.data.payload; const message = ` ⚠️ Performance Alert for ${metricType} of ${eventType}: **${eventName}** ⚠️ App id: ${appId} Alert condition: ${thresholdValue} ${thresholdUnit} Percentile (if applicable): ${conditionPercentile} App version (if applicable): ${appVersion} Violation: ${violationValue} ${violationUnit} Number of samples checked: ${numSamples} **Investigate more:** ${investigateUri} `; // [END v2PerformanceEventPayload] try { // [START v2SendPerformanceAlertToDiscord] const response = await postMessageToDiscord( "Firebase Performance Bot", message); if (response.ok) { logger.info( `Posted Firebase Performance alert ${eventName} to Discord`, event.data.payload, ); } else { throw new Error(`Discord returned status code ${response.status}`); } // [END v2SendPerformanceAlertToDiscord] } catch (error) { logger.error( `Unable to post Firebase Performance alert ${eventName} to Discord`, error, ); } }); // [END v2Alerts] ================================================ FILE: Node/alerts-to-discord/functions/package.json ================================================ { "name": "alerts-to-discord", "description": "Send a message to Discord when an alert is received from Firebase", "scripts": { "lint": "eslint .", "serve": "firebase emulators:start --only functions", "shell": "firebase functions:shell", "start": "npm run shell", "deploy": "firebase deploy --only functions", "logs": "firebase functions:log", "compile": "cp ../../../tsconfig.template.json ./tsconfig-compile.json && tsc --project tsconfig-compile.json" }, "engines": { "node": "22" }, "main": "index.js", "dependencies": { "firebase-admin": "^13.0.2", "firebase-functions": "7.0.0" }, "devDependencies": { "@types/node": "^17.0.45", "eslint": "^8.57.1", "eslint-config-google": "^0.14.0", "firebase-functions-test": "^3.4.0" }, "private": true } ================================================ FILE: Node/app-distribution-feedback-to-jira/.eslintrc ================================================ module.exports = { root: true, env: { es2017: true, node: true, }, extends: [ "eslint:recommended", "google", ], rules: { quotes: ["error", "double"], }, }; ================================================ FILE: Node/app-distribution-feedback-to-jira/.gitignore ================================================ # Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* firebase-debug.log* firebase-debug.*.log* # Firebase cache .firebase/ # Firebase config # Uncomment this if you'd like others to create their own Firebase project. # For a team working on the same Firebase project(s), it is recommended to leave # it commented so all members can deploy to the same project(s) in .firebaserc. # .firebaserc # Runtime data pids *.pid *.seed *.pid.lock # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # nyc test coverage .nyc_output # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # Bower dependency directory (https://bower.io/) bower_components # node-waf configuration .lock-wscript # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release # Dependency directories node_modules/ # Optional npm cache directory .npm # Optional eslint cache .eslintcache # Optional REPL history .node_repl_history # Output of 'npm pack' *.tgz # Yarn Integrity file .yarn-integrity # dotenv environment variables file .env ================================================ FILE: Node/app-distribution-feedback-to-jira/README.md ================================================ # Send in-app feedback to Jira This [code](functions/index.js) demonstrates how to use a Firebase Cloud Function triggered by an [in-app feedback Firebase Alert from App Distribution](https://firebase.google.com/docs/functions/beta/reference/firebase-functions.alerts.appdistribution.inappfeedbackpayload), and stores the feedback details (including screenshot) in Jira. You can customize this code to work with your own Jira configuration (eg on-premise support, custom issue types, etc). ## Quickstart This sample code uses Jira's built-in APIs to create issues for in-app tester feedback. For simplicity it uses [basic authorization](https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/). 1. [Generate an API token](https://id.atlassian.com/manage-profile/security/api-tokens) via your Jira profile. Note: If the tester who files feedback does not have a Jira account, the user who generates this token will be marked as the issue's reporter. 2. This [code](functions/index.js) uses [parameterized configuration](https://firebase.google.com/docs/functions/config-env#params) to prompt for the required configuratio. To start the process, run: ```bash $ firebase deploy ``` This will store the `API_TOKEN` using [Google Cloud Secret Manager](https://cloud.google.com/secret-manager) and the remaining settings in an `.env` file which will contain the following variables, customized to your Jira project: ```bash JIRA_URI="" PROJECT_KEY="" ISSUE_TYPE_ID="" ISSUE_LABEL="