Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Dengan ekstensi Hapus Data Pengguna (delete-user-data), Anda dapat menghapus data pengguna saat pengguna tersebut dihapus dari project Firebase. Anda dapat mengonfigurasi ekstensi ini untuk menghapus data pengguna dari salah satu atau semua penyimpanan berikut: Cloud Firestore, Realtime Database, atau Cloud Storage. Setiap pemicu ekstensi untuk menghapus data terikat pada UserId pengguna.
Ekstensi ini berguna untuk menjaga privasi pengguna dan memenuhi persyaratan kepatuhan. Namun, penggunaan ekstensi ini tidak menjamin bahwa Anda mematuhi peraturan pemerintah atau industri.
Ekstensi ini hanya menghapus data dari Cloud Firestore, Realtime Database, dan Cloud Storage. Jika Anda menyimpan data pengguna di tempat lain, Anda juga harus menghapus data pengguna dari sumber tersebut saat menghapus pengguna.
Menginstal ekstensi
Untuk menginstal ekstensi, ikuti langkah-langkah di halaman Menginstal Firebase Extension. Singkatnya, lakukan salah satu langkah berikut:
Selama penginstalan ekstensi, Anda akan diminta untuk menentukan sejumlah parameter konfigurasi:
Lokasi Cloud Functions:
Pilih lokasi tempat Anda ingin men-deploy fungsi yang dibuat untuk ekstensi ini. Sebaiknya pilih lokasi yang dekat dengan database Anda. Untuk mendapatkan bantuan dalam memilih lokasi, baca panduan memilih lokasi.
Jalur Cloud Firestore:
Jalur mana yang berisi data pengguna di instance Cloud Firestore Anda? Biarkan kosong jika Anda tidak menggunakan Cloud Firestore. Masukkan jalur lengkap yang dipisahkan dengan koma. Anda dapat menandakan User ID pengguna yang dihapus dengan {UID}. Misalnya, jika Anda memiliki koleksi users dan admins, dan setiap koleksi memiliki dokumen dengan User-ID sebagai ID dokumen, Anda dapat memasukkan users/{UID},admins/{UID}.
Mode hapus Cloud Firestore:
(Hanya berlaku jika Anda menggunakan parameter Cloud Firestore paths.) Bagaimana Anda ingin menghapus dokumen Cloud Firestore? Untuk juga menghapus dokumen yang berada di subkoleksi, tetapkan parameter ini ke recursive.
Instance Realtime Database:
Dari instance Realtime Database mana Anda ingin menghapus data pengguna?
Lokasi Realtime Database:
(Hanya berlaku jika Anda memberikan parameter Realtime Database instance.) Dari lokasi Realtime Database mana Anda ingin menghapus data pengguna?
Jalur-jalur Realtime Database:
Jalur mana yang berisi data pengguna di instance Realtime Database Anda? Biarkan kosong jika Anda tidak menggunakan Realtime Database. Masukkan jalur lengkap yang dipisahkan dengan koma. Anda dapat menandakan User ID pengguna yang dihapus dengan {UID}. Contoh: users/{UID},admins/{UID}.
Jalur Cloud Storage:
Di mana dalam Google Cloud Storage Anda menyimpan data pengguna? Biarkan kosong jika Anda tidak menggunakan Cloud Storage. Masukkan jalur lengkap ke file atau direktori di bucket Storage Anda yang dipisahkan dengan koma. Gunakan {UID} untuk menandakan User ID pengguna yang dihapus, dan gunakan {DEFAULT} untuk menandakan bucket Storage default Anda.
Berikut ini rangkaian contohnya:
Untuk menghapus semua file dalam bucket default dengan skema penamaan file {UID}-pic.png, masukkan {DEFAULT}/{UID}-pic.png.
Untuk juga menghapus semua file dalam bucket lain yang disebut my-app-logs dengan skema penamaan file {UID}-logs.txt, masukkan {DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt.
Untuk juga menghapus direktori berlabel ID Pengguna dan semua filenya (seperti media/{UID}), masukkan {DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt,{DEFAULT}/media/{UID}.
Menemukan data untuk dihapus
Ada beberapa mekanisme yang digunakan ekstensi ini untuk menemukan data yang akan dihapus. Mekanisme ini harus dikonfigurasi secara eksplisit agar ekstensi dapat menghapus data. Ekstensi hanya akan menghapus data yang secara eksplisit dikonfigurasi untuk dihapus berdasarkan mekanisme yang diberikan.
Perhatikan perbedaan perilaku berikut di antara setiap layanan:
Cloud Firestore: perilaku default-nya adalah menghapus dokumen secara dangkal (sub-koleksi tidak akan dihapus). Untuk menghapus semua subkoleksi dokumen secara rekursif, tetapkan opsi "Mode hapus Cloud Firestore" ke "Rekursif".
Realtime Database: semua data di node yang ditentukan akan dihapus.
Penyimpanan: jika jalur direktori ditentukan, semua file dan subdirektori akan dihapus.
Menurut jalur
Saat mengonfigurasi jalur Cloud Firestore, Realtime Database & Cloud Storage, Anda dapat menentukan variabel UID di jalur yang akan diganti dengan UID pengguna terautentikasi. Saat pengguna dihapus, ekstensi akan menghapus semua data yang terkait dengan UID tersebut pada jalur tertentu, misalnya:
Jalur Cloud Firestore: users/{UID},admins/{UID}
Jalur Realtime Database: likes/{UID}
Jalur Cloud Storage: {DEFAULT}/uploads/{UID},{DEFAULT}/avatars/{UID}.jpeg
Penemuan Otomatis (Cloud Firestore)
Agar ekstensi dapat otomatis menemukan dokumen Firestore yang akan dihapus, tetapkan parameter konfigurasi "Enable auto discovery" ke "Yes".
Penemuan otomatis bekerja dengan menjelajahi database secara otomatis untuk menemukan koleksi dan dokumen yang harus dihapus sesuai dengan konfigurasi Anda. Ekstensi mengidentifikasi koleksi dan dokumen tersebut dengan metodologi berikut:
Pertama, ekstensi akan menemukan semua koleksi root di database. Jika ID koleksi cocok dengan UID pengguna, seluruh koleksi akan dihapus (penghapusan bersifat rekursif atau dangkal, bergantung pada konfigurasi ekstensi untuk "mode hapus Cloud Firestore").
Kedua, jika ID koleksi tidak cocok, ekstensi akan mencoba mengidentifikasi dan menghapus dokumen jika ID dokumennya cocok dengan ID UID pengguna.
Terakhir, untuk setiap dokumen:
a. Jika kedalaman penelusuran saat ini (lihat di bawah) kurang dari atau sama dengan kedalaman penelusuran yang dikonfigurasi, proses akan diulang untuk semua subkoleksi dokumen saat ini.
b. Jika kolom penelusuran telah dikonfigurasi, ekstensi akan memeriksa apakah kolom yang diberikan cocok dengan UID pengguna. Jika kecocokan ditemukan, dokumen akan dihapus.
Kedalaman Penelusuran
Ekstensi ini menawarkan nilai kedalaman penelusuran yang dapat dikonfigurasi (default-nya adalah 3). Traversal hanya akan dijalankan jika kedalaman penelusuran saat ini kurang dari atau sama dengan kedalaman penelusuran yang dikonfigurasi. Kedalaman penelusuran saat ini didasarkan pada kedalaman koleksi saat ini atau koleksi induk dokumen, misalnya
Ekstensi ini TIDAK akan otomatis menghapus UID yang disimpan dalam array atau peta, dan tidak akan menelusuri data yang terkait dengan ID pengguna yang disimpan dalam subkoleksi bertingkat yang dalam setelah kedalaman yang ditentukan di atas.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-04 UTC."],[],[],null,["\u003cbr /\u003e\n\nThe Delete User Data extension (`delete-user-data`) lets you delete a user's data when the user is deleted from your Firebase project. You can configure this extension to delete user data from any or all of the following: Cloud Firestore, Realtime Database, or Cloud Storage. Each trigger of the extension to delete data is keyed to the user's `UserId`.\n| **Note:** To use this extension, you need to manage your users with Firebase Authentication.\n\nThis extension is useful for respecting user privacy and fulfilling compliance requirements. However, using this extension does not guarantee compliance with government and industry regulations.\n\nPrerequisites\n\n- You must use [Firebase Authentication](https://firebase.google.com/docs/auth) to manage your users.\n\n- This extension only deletes data from [Cloud Firestore](https://firebase.google.com/docs/firestore), [Realtime Database](https://firebase.google.com/docs/database), and [Cloud Storage](https://firebase.google.com/docs/storage). If you store user data elsewhere, you should also delete user data from those sources when you delete users.\n\nInstall the extension\n\nTo install the extension, follow the steps on the [Install Firebase Extension](https://firebase.google.com/docs/extensions/install-extensions) page. In summary, do one of the following:\n\n- **Firebase console:** Click the following button:\n\n [Install the Delete User Data extension](https://console.firebase.google.com/project/_/extensions/install?ref=firebase%2Fdelete-user-data)\n- **CLI:** Run the following command:\n\n firebase ext:install firebase/delete-user-data --project=\u003cvar translate=\"no\"\u003eprojectId-or-alias\u003c/var\u003e\n\nDuring the installation of the extension, you will be prompted to specify a number of configuration parameters:\n\n- **Cloud Functions location:**\n\n Select the location of where you want to deploy the functions created for this extension. You usually want a location close to your database. For help selecting a location, refer to the [location selection guide](https://firebase.google.com/docs/functions/locations).\n- **Cloud Firestore paths:**\n\n Which paths in your Cloud Firestore instance contain user data? Leave empty if you don't use Cloud Firestore. Enter the full paths, separated by commas. You can represent the User ID of the deleted user with `{UID}`. For example, if you have the collections `users` and `admins`, and each collection has documents with the User ID as document IDs, then you can enter `users/{UID},admins/{UID}`.\n- **Cloud Firestore delete mode:**\n\n (Only applicable if you use the `Cloud Firestore paths` parameter.) How do you want to delete Cloud Firestore documents? To also delete documents in subcollections, set this parameter to `recursive`.\n- **Realtime Database instance:**\n\n From which Realtime Database instance do you want to delete user data?\n- **Realtime Database location:**\n\n (Only applicable if you provided the `Realtime Database instance` parameter.) From which Realtime Database location do you want to delete user data?\n- **Realtime Database paths:**\n\n Which paths in your Realtime Database instance contain user data? Leave empty if you don't use Realtime Database. Enter the full paths, separated by commas. You can represent the User ID of the deleted user with `{UID}`. For example: `users/{UID},admins/{UID}`.\n- **Cloud Storage paths:**\n\n Where in Google Cloud Storage do you store user data? Leave empty if you don't use Cloud Storage. Enter the full paths to files or directories in your Storage buckets, separated by commas. Use `{UID}` to represent the User ID of the deleted user, and use `{DEFAULT}` to represent your default Storage bucket.\n\n Here's a series of examples:\n - To delete all the files in your default bucket with the file naming scheme `{UID}-pic.png`, enter `{DEFAULT}/{UID}-pic.png`.\n - To also delete all the files in another bucket called `my-app-logs` with the file naming scheme `{UID}-logs.txt`, enter `{DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt`.\n - To *also* delete a User ID-labeled directory and all its files (like `media/{UID}`), enter `{DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt,{DEFAULT}/media/{UID}`.\n\nDiscovering data for deletion\n\nThere are a few mechanisms that this extension uses to discover data for deletion. These mechanisms have to be explicitly configured for the extension to delete data. The extension will only delete data that is explicitly configured to delete based on the mechanisms provided.\n\nBe aware of the following behavioral differences between each service:\n\n- Cloud Firestore: the default behavior is to shallow delete a document (sub-collections will not be deleted). To recursively delete all sub-collections of a document, set the \"Cloud Firestore delete mode\" option to \"Recursive\".\n- Realtime Database: all data at the specified node will be deleted.\n- Storage: if a directory path is specified, all files and sub-directories will be deleted.\n\nBy path\n\nWhen configuring the Cloud Firestore, Realtime Database \\& Cloud Storage paths, it's possible to define a `UID` variable in the paths which will be replaced with the authenticated user's UID. When a user is deleted, the extension will delete all data keyed on that UID at the given paths, for example:\n\n- Cloud Firestore path(s): `users/{UID},admins/{UID}`\n- Realtime Database path(s): `likes/{UID}`\n- Cloud Storage path(s): `{DEFAULT}/uploads/{UID},{DEFAULT}/avatars/{UID}.jpeg`\n\nAuto Discovery (Cloud Firestore)\n\nTo enable the extension to automatically discover Firestore documents to delete, set the \"Enable auto discovery\" configuration parameter to \"Yes\".\n\nAuto-discovery works by automatically traversing the database to find collections and documents which should be deleted according to your configuration. The extension identifies those collections and documents with the following methodology:\n\n1. First, the extension finds all root collections in the database. If a collection's ID matches that of the user's UID, the entire collection is deleted (deletion is either recursive or shallow, depending on the extensions's configuration for \"Cloud Firestore delete mode\").\n2. Secondly, if the collection ID does not match, the extension will attempt to identify and delete a document if its document ID matches that of the user's UID.\n3. Finally, for each document: a. If the current search depth (see below) is less than or equal to the configured search depth, the process will be repeated for all of the current document's sub-collections. b. If search fields have been configured, the extension will check if the provided fields match the user's UID. If a match is found, the document will be deleted.\n\nSearch Depth\n\nThe extension offers a configurable search depth value (defaulting to 3). Traversal will only be executed if the current search depth is less than or equal to the configured search depth. The current search depth is based on the depth of the current collection or documents parent collection, for example \n\n /users = 1\n /users/\u003cdocument-id\u003e = 1\n /users/\u003cdocument-id\u003e/comments = 2\n /users/\u003cdocument-id\u003e/comments/\u003cdocument-id\u003e = 2\n\nThis extension will NOT automatically delete UIDs stored in arrays or maps, and it will not search for data keyed by user ID stored in deeply nested subcollections past the depth specified above.\n| **Note:** with large databases, traversal-based discovery may incur many reads and deletions since it reads all documents in the corresponding collections. Please be aware of Cloud Firestore billing prices and how this might impact you. Auto discovery is completely optional."]]