PersistDataValueSettingsBuilder
public class PersistDataValueSettingsBuilder : TransformationSettingsBuilder
Builder for creating a PersistDataValue transformation that stores a value from the dispatch payload
(or a constant) into the data layer with a configurable expiry and update policy.
Example usage:
let settings = PersistDataValueSettingsBuilder(id: "persist-user-id")
.persistFrom(.key("user_id"), to: .key("persisted_user_id"))
.setExpiryPolicy(.forever)
.setUpdatePolicy(.keepFirstValue)
.setScope(.afterCollectors)
.build()
-
Creates a new builder for a
PersistDataValuetransformation with the given uniqueid.Declaration
Swift
public init(id: String)Parameters
idA unique identifier for this transformation instance.
-
Configures the transformation to persist a constant value to a specified destination of the data layer.
This method sets up the transformation to store a fixed value at the specified destination path in the data layer. The value will be persisted according to the configured expiry and update policy settings. If not specified, defaults to
.sessionexpiry and.allowUpdatepolicy.Declaration
Swift
public func persistConstant(_ constant: DataInput, to destination: ReferenceContainer) -> SelfParameters
constantThe constant value to be persisted.
destinationA
ReferenceContainerspecifying where in the data layer to store the value. Can be a simple key or a nested path.Return Value
The builder instance for method chaining.
-
Configures the transformation to persist a value from the
Dispatchpayload to a specified destination of the data layer.This method sets up the transformation to copy a value from an existing location in the payload (specified by the input
ReferenceContainer) to the specified destination path in the data layer. The value will be persisted according to the configured expiry and update policy settings. If not specified, defaults to.sessionexpiry and.allowUpdatepolicy.Declaration
Swift
public func persistFrom(_ input: ReferenceContainer, to destination: ReferenceContainer) -> SelfParameters
inputA
ReferenceContainerspecifying the source location in the ‘Dispatch’ payload from which to read the value to be persisted.destinationA
ReferenceContainerspecifying where in the data layer to store the value. Can be a simple key or a nested path.Return Value
The builder instance for method chaining.
-
Sets the expiry policy for the persisted data.
This method configures how long the persisted value should remain in the data store before it expires and is automatically removed. The expiry policy determines the lifecycle of the stored data.
If not called, the default expiry policy of
.sessionwill be used.Declaration
Swift
public func setExpiryPolicy(_ expiryPolicy: ExpiryPolicy) -> SelfParameters
expiryPolicyThe
ExpiryPolicyto apply to the persisted data. Common values include.session(expires when the session ends),.forever(never expires), or.duration(timeFrame)for custom time-based expiry.Return Value
The builder instance for method chaining.
-
Sets the update policy for the persisted data.
This method configures how the transformation should behave when attempting to persist data to a destination that already contains a value. The update policy determines whether existing values can be overwritten or should be preserved.
If not called, the default update policy of
.allowUpdatewill be used.Declaration
Swift
public func setUpdatePolicy(_ updatePolicy: UpdatePolicy) -> SelfParameters
updatePolicyThe
UpdatePolicypolicy to apply when the destination already contains data. Use.allowUpdateto overwrite existing values, or.keepFirstValueto preserve existing values and skip the persistence operation.Return Value
The builder instance for method chaining.
-
Builds a
DataObjectfrom the current builder state. Writes whatever properties have been set to the configuration DataObject.Declaration
Swift
override public func build() -> DataObject
View on GitHub