IngestIdentityWorkflowUtils
type IngestIdentityWorkflowUtils = {
deleteCustomData: (identifier, key) => Promise<void>;
getTraitGroups: (identifier) => Promise<Record<string, WorkflowTrait[]>>;
readCustomData: <T>(identifier, key) => Promise<T | null>;
setTraitGroup: (identifier, groupId, traits) => Promise<void>;
writeCustomData: (identifier, key, value) => Promise<void>;
};Properties
deleteCustomData
deleteCustomData: (identifier, key) => Promise<void>;Delete an item of custom data previously written by this app against a user or session.
Parameters
| Parameter | Type | Description |
|---|---|---|
identifier | WorkflowUserIdentifier | The user or session to delete the data against. |
key | string | The key to delete. Must be a non-empty string of less than 1000 characters. |
Returns
Promise<void>
Example
await utils.identity.deleteCustomData(identity, 'user-profile')getTraitGroups
getTraitGroups: (identifier) => Promise<Record<string, WorkflowTrait[]>>;Retrieves all trait groups for the specified identity, as a record of trait arrays keyed by group ID.
Parameters
| Parameter | Type | Description |
|---|---|---|
identifier | WorkflowUserIdentifier | The user or session whose trait groups should be fetched. |
Returns
Promise<Record<string, WorkflowTrait[]>>
Example
const groups = await utils.identity.getTraitGroups(identity)
readCustomData
readCustomData: <T>(identifier, key) => Promise<T | null>;Read an item of previously-stored custom data against a user or session. Data written by this app is visible to every brand of the org.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
| Parameter | Type | Description |
|---|---|---|
identifier | WorkflowUserIdentifier | The user or session to read the data against. |
key | string | The key to read. Must be a non-empty string of less than 1000 characters. |
Returns
Promise<T | null>
Example
const userProfile: { name: string } | null = await utils.identity.readCustomData(identity, 'user-profile')
setTraitGroup
setTraitGroup: (identifier, groupId, traits) => Promise<void>;Replace the traits for a group on a given identity. Any traits previously stored under this group ID are overwritten entirely. Traits written by this app are visible to every brand of the org.
Constraints:
groupIdmust be a non-empty string up to 64 characters.- Each trait
keymust be a non-empty string up to 128 characters. - The serialized trait-groups blob for this identity must not exceed 256 kB.
Parameters
| Parameter | Type | Description |
|---|---|---|
identifier | WorkflowUserIdentifier | The user or session to assign the traits to. |
groupId | string | A non-empty string identifying the trait group. Must be no longer than 64 characters. |
traits | WorkflowTrait[] | The traits to assign. |
Returns
Promise<void>
Example
await utils.identity.setTraitGroup(identity, 'preferences', [{ key: 'plan:pro' }])
writeCustomData
writeCustomData: (identifier, key, value) => Promise<void>;Write an item of custom data against a user or session. Data is stored in this app's own space and is visible to every brand of the org.
Parameters
| Parameter | Type | Description |
|---|---|---|
identifier | WorkflowUserIdentifier | The user or session to write the data against. |
key | string | The key to write the data against. Must be a non-empty string of less than 1000 characters. |
value | NonNullable<unknown> | The value to write. Must be non-null and less than 32kb when stringified. |
Returns
Promise<void>
Example
await utils.identity.writeCustomData(identity, 'user-profile', { name: 'Joe Blogs' })