Path: blob/main/website/docs/Advanced/UserProfile.md
1028 views
UserProfile
UserProfiles are "saved state" of a User that can be restored to later resume a session.
UserProfiles enable you to capture the full browser state of a user after performing a series of activities. You might use this to:
resume the state of a "logged-in" user
accumulate "usage" behavior for an ongoing profile
share browser profiles between Agent instances running on different machines
Constructor
This "state" is not instantiated, but retrieved from an Agent instance: agent.exportUserProfile().
State is stored for all domains (origins) that are loaded into a window at the time of export. The exported state is JSON with additional type information for IndexedDB complex objects.
When you restore a UserProfile, SecretAgent will restore the Cookies, Dom Storage and IndexedDB records for all domains that are included in the state.
Properties
cookies
Cookies for all loaded "origins" for the browsing session.
Type: Cookie[]
deviceProfile
An object containing hardware device properties emulated in this userProfile like memory and gpu information.
Type: object
deviceMemory
number
. The amount of memory specified for this machinewebGlParameters
object
. Key value of WebGlParameters to override (ie, { 37445: 'WebGl Vendor' })videoDevice
object { deviceId: string, groupId: string }
. A video device to emulate if none is present, such as on a headless server.
storage
An object with a key for each "security origin" of a page, and value all the associated DomStorage.
A DomStorage
object contains: {#dom-storage}
localStorage
[key,value][]
. Thewindow.localStorage
entries for a given domain.sessionStorage
[key,value][]
. Thewindow.sessionStorage
entries for a given domain.indexedDB
IndexedDB[]
. An array of theindexedDB
databases for a given domain with records stored as typeson.
Type: object { [origin: string]: DomStorage }
key
string
. The "security origin" of a page or iFrame as defined by Chrome.value DomStorage. The
DomStorage
entry for the given origin.
userAgentString
The user agent used in this profile. Many sites that track user fingerprint information track the useragent information and expect it to remain the same. You can still override this (eg, to update a browser version) by overriding the userAgent
parameter when constructing a new Agent
.