Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { AudienceDestinationDefinition } from '@segment/actions-core'
import type { Settings, AudienceSettings } from './generated-types'
import syncAudience from './syncAudience'

const destination: AudienceDestinationDefinition<Settings, AudienceSettings> = {
name: 'Dotdigital Audiences',
slug: 'actions-dotdigital-audiences',
mode: 'cloud',
authentication: {
scheme: 'basic',
fields: {
api_host: {
label: 'Region',
description: 'The region your account is in',
type: 'string',
choices: [
{ value: 'https://r1-api.dotdigital.com', label: 'r1' },
{ value: 'https://r2-api.dotdigital.com', label: 'r2' },
{ value: 'https://r3-api.dotdigital.com', label: 'r3' }
],
default: 'https://r1-api.dotdigital.com',
required: true
},
username: {
label: 'Username',
description: 'Your Dotdigital username',
type: 'string',
required: true
},
password: {
label: 'Password',
description: 'Your Dotdigital password.',
type: 'password',
required: true
}
},
testAuthentication: async (request, { settings }) => {
return await request(`${settings.api_host}/v2/data-fields/`)
}
},
extendRequest({ settings }) {
return {
headers: { Authorization: `Basic ${btoa(settings.username + ':' + settings.password)}`, 'x-ddg-integration-token': '7d1e8cff-4856-4f45-93d3-dac7377a53c2'},
responseType: 'json'
}
},
audienceFields: {
audienceName: {
label: 'Dotdigital List Name',
description: 'A Dotdigital list name',
type: 'string',
required: true
}
},
audienceConfig: {
mode: {
type: 'synced',
full_audience_sync: false
},
async createAudience(_request, _createAudienceInput) {
return { externalId: "test" }
},
async getAudience(_request, _getAudienceInput) {

return { externalId: "test" }
}
},
actions: {
syncAudience
}
}

export default destination

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import type { ActionDefinition } from '@segment/actions-core'
import type { Settings } from '../generated-types'
import type { Payload } from './generated-types'

const action: ActionDefinition<Settings, Payload> = {
title: 'Sync Audience',
description: 'Sync Segment Engage Audience to a Dotdigital List',
defaultSubscription: 'type = "identify" or type = "track"',
fields: {
segment_computation_action: {
label: 'Segment Computation Action',
description:
"Hidden field used to verify that the payload is generated by an Audience. Payloads not containing computation_class = 'audience' or 'journey_step' will be dropped before the perform() fuction call.",
type: 'string',
unsafe_hidden: true,
required: true,
default: {
'@path': '$.context.personas.computation_class'
},
choices: [
{ label: 'audience', value: 'audience' },
{ label: 'journey_step', value: 'journey_step' }
]
},
computation_key: {
label: 'Audience Computation Key',
description: "Segment's friendly name for the Audience",
type: 'string',
required: true,
default: {
'@path': '$.context.personas.computation_key'
}
},
external_audience_id: {
type: 'string',
label: 'Audience ID',
description: 'Unique Audience Identifier returned by the createAudience() function call.',
required: true,
unsafe_hidden: false,
default: {
'@path': '$.context.personas.external_audience_id'
}
},
emailIdentifier: {
label: 'Email address',
description: "The Contact's email address.",
type: 'string',
format: 'email',
default: {
'@if': {
exists: { '@path': '$.traits.email' },
then: { '@path': '$.traits.email' },
else: { '@path': '$.properties.email' }
}
}
},
mobileNumberIdentifier: {
label: 'Mobile Number',
description: "The Contact's mobile number.",
type: 'string',
default: {
'@if': {
exists: { '@path': '$.traits.phone' },
then: { '@path': '$.traits.phone' },
else: { '@path': '$.properties.phone' }
}
}
},
traits_or_props: {
label: 'Traits or properties object',
description: 'A computed object for track and identify events. This field should not need to be edited.',
type: 'object',
required: true,
unsafe_hidden: true,
default: {
'@if': {
exists: { '@path': '$.properties' },
then: { '@path': '$.properties' },
else: { '@path': '$.traits' }
}
}
},
dataFields: {
label: 'Data Fields',
description: `An object containing key/value pairs for data fields assigned to this Contact. Custom Data Fields must already be defined in Dotdigital.`,
type: 'object',
required: false,
disabledInputMethods: ['literal', 'variable', 'function', 'freeform', 'enrichment'],
defaultObjectUI: 'keyvalue:only',
additionalProperties: false,
dynamic: true
},
enable_batching: {
type: 'boolean',
label: 'Batch events',
description: 'Batching not supported.',
required: true,
default: false,
unsafe_hidden: true
}
},
perform: async (_request) => {
return
}
}

export default action
1 change: 1 addition & 0 deletions packages/destination-actions/src/destinations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ register('695d30cdac2addbdcc3baf7f', './memora')
register('697088b36245ed59c958d615', './rokt-capi')
register('69708853c934696ffa66b6ef', './qualified')
register('69708875e5073cee011f9be2', './jimo-cloud')
register('698085f267252abcf3254a52', './dotdigital-audiences')

function register(id: MetadataId, destinationPath: string) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
Expand Down
Loading