Cookies Type
Define a type to represent custom cookies in the cookies settings window.
Cookie
Interface
ts
import type { CookieLifecycleParams } from './module.types'
/**
* Define an interface for custom cookies in the cookies settings window.
*/
export interface Cookie {
/**
* Name by which the browser will identify the cookie.
* A name without spaces or special characters is recommended.
*/
name: string
/**
* Title or long name with which the cookie will be displayed in its description section.
*/
title?: string
/**
* Text that will be shown in the settings window to describe the cookie.
* It is possible to specify HTML code.
*/
description?: string
/**
* Initial state of the cookie checkbox.
*/
checked?: boolean
/**
* Allows to interact or not with the checkbox.
*/
disabled?: boolean
/**
* Only applicable to a cookie associated with Google Analytics.
* Determines whether data collection is activated before the user has accepted or rejected cookies.
*/
onLoad?: boolean
/**
* Only applicable to a cookie associated with Google Analytics.
* Google Analytics code for global site tag (gtag.js).
*/
code?: string
/**
* Function that will be executed when the cookie is accepted or rejected.
* The function will receive an object with the following properties:
* - lifecycle: 'first-load' | 'load' | 'accept' | 'reject'
* - cookie: Cookie
* - status: boolean
* - path: string
* @param arg
*/
manageFunction?: (arg: CookieLifecycleParams) => void | Promise<void>
/**
* Define this property if the cookie is a parent of other cookies.
* So when the parent cookie is accepted, all its children will be accepted too.
* If the parent cookie is rejected, all its children will be rejected too.
*/
cookies?: Array<Omit<Cookie, 'title' | 'description' | 'cookies'>>
}
CookiesStatus
Interface
ts
/**
* Define a type to represent the status of custom cookies.
*/
export interface CookiesStatus {
/**
* Status of each custom cookie, identified by their respective names.
* The values are boolean flags indicating whether the cookie is accepted or rejected.
*/
[key: string]: {
status: boolean
parent?: Cookie
} & Cookie
}