import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller"; import { BaseController } from "@metamask/base-controller"; import type { Messenger } from "@metamask/messenger"; import type { AnalyticsDataRegulationControllerMethodActions } from "./AnalyticsDataRegulationController-method-action-types.mjs"; import type { AnalyticsDataRegulationServiceActions } from "./AnalyticsDataRegulationService.mjs"; import { DATA_DELETE_RESPONSE_STATUSES } from "./types.mjs"; import type { DeleteRegulationResponse, DeleteRegulationStatus } from "./types.mjs"; /** * The name of the {@link AnalyticsDataRegulationController}, used to namespace the * controller's actions and events and to namespace the controller's state data * when composed with other controllers. */ export declare const controllerName = "AnalyticsDataRegulationController"; /** * Describes the shape of the state object for {@link AnalyticsDataRegulationController}. */ export type AnalyticsDataRegulationControllerState = { /** * Indicates if data has been recorded since the last deletion request. */ hasCollectedDataSinceDeletionRequest: boolean; /** * Segment's data deletion regulation ID. * The ID returned by the Segment delete API which allows checking the status of the deletion request. */ deleteRegulationId?: string; /** * Segment's data deletion regulation creation timestamp. * The timestamp (in milliseconds since epoch) when the deletion request was created. */ deleteRegulationTimestamp?: number; }; /** * Returns default values for AnalyticsDataRegulationController state. * * @returns Default state */ export declare function getDefaultAnalyticsDataRegulationControllerState(): AnalyticsDataRegulationControllerState; /** * Returns the state of the {@link AnalyticsDataRegulationController}. */ export type AnalyticsDataRegulationControllerGetStateAction = ControllerGetStateAction; /** * Actions that {@link AnalyticsDataRegulationControllerMessenger} exposes to other consumers. */ export type AnalyticsDataRegulationControllerActions = AnalyticsDataRegulationControllerGetStateAction | AnalyticsDataRegulationControllerMethodActions; /** * Actions from other messengers that {@link AnalyticsDataRegulationControllerMessenger} calls. */ type AllowedActions = AnalyticsDataRegulationServiceActions; /** * Event emitted when a data deletion task is created. */ export type DataDeletionTaskCreatedEvent = { type: `${typeof controllerName}:dataDeletionTaskCreated`; payload: [DeleteRegulationResponse]; }; /** * Event emitted when the data recording flag is updated. */ export type DataRecordingFlagUpdatedEvent = { type: `${typeof controllerName}:dataRecordingFlagUpdated`; payload: [boolean]; }; /** * Event emitted when the state of the {@link AnalyticsDataRegulationController} changes. */ export type AnalyticsDataRegulationControllerStateChangeEvent = ControllerStateChangeEvent; /** * Events that {@link AnalyticsDataRegulationControllerMessenger} exposes to other consumers. */ export type AnalyticsDataRegulationControllerEvents = AnalyticsDataRegulationControllerStateChangeEvent | DataDeletionTaskCreatedEvent | DataRecordingFlagUpdatedEvent; /** * Events from other messengers that {@link AnalyticsDataRegulationControllerMessenger} subscribes to. */ type AllowedEvents = never; /** * The messenger restricted to actions and events accessed by * {@link AnalyticsDataRegulationController}. */ export type AnalyticsDataRegulationControllerMessenger = Messenger; /** * The options that AnalyticsDataRegulationController takes. */ export type AnalyticsDataRegulationControllerOptions = { /** * Initial controller state. */ state?: Partial; /** * Messenger used to communicate with BaseController and other controllers. */ messenger: AnalyticsDataRegulationControllerMessenger; /** * Analytics ID used for data deletion requests. */ analyticsId: string; }; /** * The AnalyticsDataRegulationController manages analytics privacy and GDPR/CCPA data deletion functionality. * It communicates with Segment's Regulations API via a proxy to create and monitor data deletion requests. * * This controller follows the MetaMask controller pattern and integrates with the * messenger system to allow other controllers and components to manage data deletion tasks. */ export declare class AnalyticsDataRegulationController extends BaseController { #private; /** * Constructs an AnalyticsDataRegulationController instance. * * @param options - Controller options * @param options.state - Initial controller state. Use `getDefaultAnalyticsDataRegulationControllerState()` for defaults. * @param options.messenger - Messenger used to communicate with BaseController * @param options.analyticsId - Analytics ID used for data deletion requests */ constructor({ state, messenger, analyticsId, }: AnalyticsDataRegulationControllerOptions); /** * Creates a new delete regulation for the user. * This is necessary to respect the GDPR and CCPA regulations. * * @returns Promise containing the status of the request with regulateId * @throws Error if analytics ID is missing or if the service call fails */ createDataDeletionTask(): Promise<{ status: typeof DATA_DELETE_RESPONSE_STATUSES.Success; regulateId: string; }>; /** * Check the latest delete regulation status. * * @returns Promise containing the timestamp, delete status and collected data flag */ checkDataDeleteStatus(): Promise; /** * Update the data recording flag if needed. * This method should be called after tracking events to ensure * the data recording flag is properly updated for data deletion workflows. * * The flag can only be set to `true` (indicating data has been collected). * It cannot be explicitly set to `false` - it is only reset to `false` when * a new deletion task is created via `createDataDeletionTask`. * */ updateDataRecordingFlag(): void; } export {}; //# sourceMappingURL=AnalyticsDataRegulationController.d.mts.map