تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
تتيح لك إضافة Delete User Data (delete-user-data) حذف بيانات المستخدم عند حذفه من مشروعك على Firebase. يمكنك ضبط هذه الإضافة لحذف بيانات المستخدمين من أيّ من الخدمات التالية أو جميعها: Cloud Firestore أو Realtime Database أو Cloud Storage. يتم ربط كل عملية تشغيل للإضافة لحذف البيانات بمعرّف UserId الخاص بالمستخدم.
هذه الإضافة مفيدة لاحترام خصوصية المستخدمين واستيفاء متطلبات الامتثال. ومع ذلك، لا يضمن استخدام هذه الإضافة الامتثال للوائح التنظيمية الحكومية والمتعلقة بالمجال.
لا تحذف هذه الإضافة البيانات إلا من Cloud Firestore وRealtime Database وCloud Storage. إذا كنت تخزِّن بيانات المستخدمين في مكان آخر، عليك أيضًا حذف بيانات المستخدمين من هذه المصادر عند حذفهم.
تثبيت الإضافة
لتثبيت الإضافة، اتّبِع الخطوات الواردة في صفحة تثبيت إضافة Firebase. باختصار، نفِّذ أحد الإجراءات التالية:
أثناء تثبيت الإضافة، سيُطلب منك تحديد عدد من مَعلمات الإعداد:
موقع "وظائف السحابة الإلكترونية":
اختَر الموقع الجغرافي الذي تريد نشر الدوال التي تم إنشاؤها لهذه الإضافة فيه. عادةً ما تريد موقعًا جغرافيًا قريبًا من قاعدة البيانات. للحصول على مساعدة في اختيار موقع جغرافي، يُرجى الرجوع إلى دليل اختيار الموقع الجغرافي.
مسارات Cloud Firestore:
ما هي المسارات في مثيل Cloud Firestore الذي يحتوي على بيانات المستخدمين؟ اترك الحقل فارغًا إذا كنت لا تستخدم Cloud Firestore. أدخِل المسارات الكاملة مفصولة بفواصل. يمكنك تمثيل معرّف المستخدم المحذوف باستخدام {UID}. على سبيل المثال، إذا كان لديك المجموعتان users وadmins، وكانت كل مجموعة تحتوي على مستندات تتضمّن رقم تعريف المستخدم كأرقام تعريف للمستندات، يمكنك إدخال users/{UID},admins/{UID}.
وضع الحذف في Cloud Firestore:
(لا ينطبق إلا في حال استخدام المَعلمة Cloud Firestore paths). كيف تريد حذف مستندات Cloud Firestore؟ لحذف المستندات في المجموعات الفرعية أيضًا، اضبط هذه المَعلمة على recursive.
مثيل Realtime Database:
من أي مثيل لقاعدة بيانات الوقت الفعلي تريد حذف بيانات المستخدم؟
موقع Realtime Database:
(لا ينطبق ذلك إلا إذا قدّمت المَعلمة Realtime Database instance). من أي موقع جغرافي في Realtime Database تريد حذف بيانات المستخدم؟
مسارات Realtime Database:
ما هي المسارات في مثيل Realtime Database التي تحتوي على بيانات المستخدمين؟ اترك الحقل فارغًا إذا كنت لا تستخدم Realtime Database. أدخِل المسارات الكاملة مفصولة بفواصل. يمكنك تمثيل معرّف المستخدم المحذوف باستخدام {UID}. على سبيل المثال: users/{UID},admins/{UID}.
مسارات Cloud Storage:
أين يتم تخزين بيانات المستخدمين في Google Cloud Storage؟ اترك هذا الحقل فارغًا إذا كنت لا تستخدم Cloud Storage. أدخِل المسارات الكاملة للملفات أو الدلائل في حِزم Storage، مفصولة بفواصل. استخدِم {UID} لتمثيل معرّف المستخدم المحذوف، واستخدِم {DEFAULT} لتمثيل حزمة التخزين التلقائية.
في ما يلي سلسلة من الأمثلة:
لحذف جميع الملفات في الحزمة التلقائية باستخدام نظام تسمية الملفات {UID}-pic.png، أدخِل {DEFAULT}/{UID}-pic.png.
لحذف جميع الملفات في حزمة أخرى باسم my-app-logs باستخدام نظام تسمية الملفات {UID}-logs.txt، أدخِل {DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt.
لحذف دليل يحمل تصنيف معرّف المستخدم وجميع ملفاته (مثل media/{UID})، أدخِل {DEFAULT}/{UID}-pic.png,my-app-logs/{UID}-logs.txt,{DEFAULT}/media/{UID}.
اكتشاف البيانات المراد حذفها
تستخدم هذه الإضافة بعض الآليات لاكتشاف البيانات المراد حذفها. يجب ضبط هذه الآليات بشكلٍ صريح لكي تحذف الإضافة البيانات. لن تحذف الإضافة سوى البيانات التي تم ضبطها صراحةً على الحذف استنادًا إلى الآليات المتوفّرة.
يجب الانتباه إلى الاختلافات التالية في السلوك بين كل خدمة:
Cloud Firestore: السلوك التلقائي هو حذف مستند بشكل سطحي (لن يتم حذف المجموعات الفرعية). لحذف جميع المجموعات الفرعية لمستند بشكل متكرّر، اضبط خيار "وضع حذف Cloud Firestore" على "متكرّر".
Realtime Database: سيتم حذف جميع البيانات في العقدة المحدّدة.
مساحة التخزين: في حال تحديد مسار دليل، سيتم حذف جميع الملفات والمجلدات الفرعية.
حسب المسار
عند ضبط مسارات Cloud Firestore وRealtime Database وCloud Storage، من الممكن تحديد متغيّر UID في المسارات سيتم استبداله برقم تعريف المستخدم (UID) الذي تمت مصادقته. عند حذف مستخدم، ستحذف الإضافة جميع البيانات التي تم إدخالها في مسارات معيّنة باستخدام معرّف المستخدم الفريد هذا، على سبيل المثال:
لتفعيل الإضافة كي تكتشف تلقائيًا مستندات Firestore المطلوب حذفها، اضبط مَعلمة الإعداد "تفعيل الاكتشاف التلقائي" على "نعم".
تعمل ميزة "الاكتشاف التلقائي" من خلال الانتقال تلقائيًا إلى قاعدة البيانات للعثور على المجموعات والمستندات التي يجب حذفها وفقًا لإعداداتك. تحدّد الإضافة هذه المجموعات والمستندات باستخدام المنهجية التالية:
أولاً، يعثر الامتداد على جميع المجموعات الجذرية في قاعدة البيانات. إذا تطابق رقم تعريف المجموعة مع رقم تعريف المستخدم، يتم حذف المجموعة بأكملها (يكون الحذف إما متكررًا أو سطحيًا، وذلك حسب إعدادات الإضافة في "وضع حذف Cloud Firestore").
ثانيًا، إذا لم يتطابق معرّف المجموعة، ستحاول الإضافة تحديد مستند وحذفه إذا كان معرّف المستند يطابق المعرّف الفريد للمستخدم.
أخيرًا، لكل مستند:
أ. إذا كان عمق البحث الحالي (انظر أدناه) أقل من أو يساوي عمق البحث الذي تم ضبطه، سيتم تكرار العملية لجميع المجموعات الفرعية للمستند الحالي.
ب. في حال ضبط حقول البحث، ستتحقّق الإضافة ممّا إذا كانت الحقول المقدَّمة تطابق المعرّف الفريد للمستخدم. في حال العثور على تطابق، سيتم حذف المستند.
متوسط عدد الصفحات المشاهَدة بعد البحث
توفّر الإضافة قيمة قابلة للضبط لعمق البحث (القيمة التلقائية هي 3). لن يتم تنفيذ عملية الانتقال إلا إذا كان عمق البحث الحالي أقل من أو يساوي عمق البحث الذي تم ضبطه. يعتمد عمق البحث الحالي على عمق المجموعة الحالية أو المجموعة الرئيسية للمستندات، على سبيل المثال
لن تحذف هذه الإضافة تلقائيًا معرّفات المستخدمين المخزّنة في المصفوفات أو الخرائط، ولن تبحث عن البيانات التي تمّت فهرستها حسب معرّف المستخدم والمخزّنة في المجموعات الفرعية المتداخلة بشكل كبير بعد العمق المحدّد أعلاه.
تاريخ التعديل الأخير: 2025-07-25 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-07-25 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],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."]]