From 9b2a5d5a740cf209c87921a63da3585ec852182c Mon Sep 17 00:00:00 2001 From: Tiago Boldt Sousa Date: Tue, 27 Feb 2024 14:30:20 +0000 Subject: [PATCH 1/3] wip kevel audience --- .../kevel-audience/generated-types.ts | 8 ++ .../src/destinations/kevel-audience/index.ts | 36 ++++++ .../syncAudience/__tests__/index.test.ts | 103 ++++++++++++++++++ .../syncAudience/generated-types.ts | 0 .../kevel-audience/syncAudience/index.ts | 69 ++++++++++++ .../generated-types.ts | 0 .../{kevel => kevel-userdb}/index.ts | 0 .../syncAudience/__tests__/index.test.ts | 12 +- .../syncAudience/generated-types.ts | 22 ++++ .../syncAudience/index.ts | 0 .../syncTraits/__tests__/index.test.ts | 0 .../syncTraits/generated-types.ts | 0 .../syncTraits/index.ts | 0 13 files changed, 242 insertions(+), 8 deletions(-) create mode 100644 packages/destination-actions/src/destinations/kevel-audience/generated-types.ts create mode 100644 packages/destination-actions/src/destinations/kevel-audience/index.ts create mode 100644 packages/destination-actions/src/destinations/kevel-audience/syncAudience/__tests__/index.test.ts rename packages/destination-actions/src/destinations/{kevel => kevel-audience}/syncAudience/generated-types.ts (100%) create mode 100644 packages/destination-actions/src/destinations/kevel-audience/syncAudience/index.ts rename packages/destination-actions/src/destinations/{kevel => kevel-userdb}/generated-types.ts (100%) rename packages/destination-actions/src/destinations/{kevel => kevel-userdb}/index.ts (100%) rename packages/destination-actions/src/destinations/{kevel => kevel-userdb}/syncAudience/__tests__/index.test.ts (89%) create mode 100644 packages/destination-actions/src/destinations/kevel-userdb/syncAudience/generated-types.ts rename packages/destination-actions/src/destinations/{kevel => kevel-userdb}/syncAudience/index.ts (100%) rename packages/destination-actions/src/destinations/{kevel => kevel-userdb}/syncTraits/__tests__/index.test.ts (100%) rename packages/destination-actions/src/destinations/{kevel => kevel-userdb}/syncTraits/generated-types.ts (100%) rename packages/destination-actions/src/destinations/{kevel => kevel-userdb}/syncTraits/index.ts (100%) diff --git a/packages/destination-actions/src/destinations/kevel-audience/generated-types.ts b/packages/destination-actions/src/destinations/kevel-audience/generated-types.ts new file mode 100644 index 0000000000..b12328e1d9 --- /dev/null +++ b/packages/destination-actions/src/destinations/kevel-audience/generated-types.ts @@ -0,0 +1,8 @@ +// Generated file. DO NOT MODIFY IT BY HAND. + +export interface Settings { + /** + * Your Kevel Audience Domain + */ + audienceDomain: string +} diff --git a/packages/destination-actions/src/destinations/kevel-audience/index.ts b/packages/destination-actions/src/destinations/kevel-audience/index.ts new file mode 100644 index 0000000000..e6c6a8cc1b --- /dev/null +++ b/packages/destination-actions/src/destinations/kevel-audience/index.ts @@ -0,0 +1,36 @@ +import type { DestinationDefinition } from '@segment/actions-core' +import type { Settings } from './generated-types' + +import syncAudience from './syncAudience' + +const destination: DestinationDefinition = { + name: 'Kevel Audience (Actions)', + slug: 'actions-kevel-audience', + description: + 'Send Segment user profiles and Segment Audiences to Kevel Audience. Only users with a Segment userId will be synced.', + mode: 'cloud', + + authentication: { + scheme: 'custom', + fields: { + audienceDomain: { + label: 'Kevel Audience Domain', + description: 'Your Kevel Audience Domain', + type: 'string', + required: true + } + } + }, + extendRequest() { + return { + headers: { + 'Content-Type': 'application/json' + } + } + }, + actions: { + syncAudience + } +} + +export default destination diff --git a/packages/destination-actions/src/destinations/kevel-audience/syncAudience/__tests__/index.test.ts b/packages/destination-actions/src/destinations/kevel-audience/syncAudience/__tests__/index.test.ts new file mode 100644 index 0000000000..7667ac9b46 --- /dev/null +++ b/packages/destination-actions/src/destinations/kevel-audience/syncAudience/__tests__/index.test.ts @@ -0,0 +1,103 @@ +import nock from 'nock' +import { createTestEvent, createTestIntegration } from '@segment/actions-core' +import Destination from '../../index' + +const testDestination = createTestIntegration(Destination) + +const goodTrackEvent = createTestEvent({ + type: 'track', + userId: 'uid1', + context: { + personas: { + computation_class: 'audience', + computation_key: 'kevel_segment_test_name' + }, + traits: { + email: 'test@email.com' + } + }, + properties: { + audience_key: 'kevel_segment_test_name', + kevel_segment_test_name: true + } +}) + +const goodIdentifyEvent = createTestEvent({ + type: 'identify', + userId: 'uid1', + context: { + personas: { + computation_class: 'audience', + computation_key: 'kevel_segment_test_name' + } + }, + traits: { + audience_key: 'kevel_segment_test_name', + kevel_segment_test_name: true + }, + properties: undefined +}) + +const badEvent = createTestEvent({ + userId: 'uid1', + context: { + personas: { + computation_key: 'kevel_segment_test_name' + }, + traits: { + email: 'test@email.com' + } + }, + properties: { + audience_key: 'kevel_segment_test_name', + kevel_segment_test_name: true + } +}) + +describe('Kevel.syncAudience', () => { + it('should not throw an error if the audience creation succeed - track', async () => { + const payload = {} + const audienceDomain = 'domain.audience.kevel.com' + const baseUrl = `https://${audienceDomain}/event-tracker` // TODO Tracker + + nock(baseUrl).post(`${baseUrl}`, payload).reply(200) + + await expect( + testDestination.testAction('syncAudience', { + event: goodTrackEvent, + settings: { + audienceDomain: 'domain.audience.kevel.com' + }, + useDefaultMappings: true + }) + ).resolves.not.toThrowError() + }) + + it('should not throw an error if the audience creation succeed - track', async () => { + const payload = {} + const networkId1 = 'networkId1' + const baseUrl = `https://e-${networkId1}.adzerk.net/udb/${networkId1}` + + nock(baseUrl).post(`/`, payload).reply(200) + + await expect( + testDestination.testAction('syncAudience', { + event: goodIdentifyEvent, + settings: { + networkId: networkId1, + apiKey: 'apiKey1' + }, + useDefaultMappings: true + }) + ).resolves.not.toThrowError() + }) + + it('should throw an error if audience creation event missing mandatory field', async () => { + await expect( + testDestination.testAction('syncAudience', { + event: badEvent, + useDefaultMappings: true + }) + ).rejects.toThrowError("The root value is missing the required field 'segment_computation_action'") + }) +}) diff --git a/packages/destination-actions/src/destinations/kevel/syncAudience/generated-types.ts b/packages/destination-actions/src/destinations/kevel-audience/syncAudience/generated-types.ts similarity index 100% rename from packages/destination-actions/src/destinations/kevel/syncAudience/generated-types.ts rename to packages/destination-actions/src/destinations/kevel-audience/syncAudience/generated-types.ts diff --git a/packages/destination-actions/src/destinations/kevel-audience/syncAudience/index.ts b/packages/destination-actions/src/destinations/kevel-audience/syncAudience/index.ts new file mode 100644 index 0000000000..484b2ddcc5 --- /dev/null +++ b/packages/destination-actions/src/destinations/kevel-audience/syncAudience/index.ts @@ -0,0 +1,69 @@ +import type { ActionDefinition } from '@segment/actions-core' +import type { Settings } from '../generated-types' +import type { Payload } from './generated-types' + +const action: ActionDefinition = { + title: 'Sync Audience to Kevel Audience', + description: 'Sync a Segment Engage Audience to a Kevel Audience. Only users with a Segment userId will be synced.', + defaultSubscription: 'type = "track" or type = "identify"', + fields: { + segment_computation_key: { + label: 'Segment Audience Key', + description: 'Segment Audience name to which user identifier should be added or removed', + type: 'string', + unsafe_hidden: true, + required: true, + default: { + '@path': '$.context.personas.computation_key' + } + }, + segment_computation_action: { + label: 'Segment Computation Action', + description: + "Segment computation class used to determine if input event is from an Engage Audience'. Value must be = 'audience'.", + type: 'string', + unsafe_hidden: true, + required: true, + default: { + '@path': '$.context.personas.computation_class' + }, + choices: [{ label: 'audience', value: 'audience' }] + }, + segment_user_id: { + label: 'User ID', + description: "The user's unique ID", + type: 'string', + unsafe_hidden: true, + required: true, + default: { '@path': '$.userId' } + }, + 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' } + } + } + } + }, + perform: async (request, data) => { + const settings = data.settings + + const baseUrl = `https://${settings.audienceDomain}/` // TODO event tracker + + const payload = data.payload + + return request(`${baseUrl}`, { + json: payload, + method: 'POST' + }) + } +} + +export default action diff --git a/packages/destination-actions/src/destinations/kevel/generated-types.ts b/packages/destination-actions/src/destinations/kevel-userdb/generated-types.ts similarity index 100% rename from packages/destination-actions/src/destinations/kevel/generated-types.ts rename to packages/destination-actions/src/destinations/kevel-userdb/generated-types.ts diff --git a/packages/destination-actions/src/destinations/kevel/index.ts b/packages/destination-actions/src/destinations/kevel-userdb/index.ts similarity index 100% rename from packages/destination-actions/src/destinations/kevel/index.ts rename to packages/destination-actions/src/destinations/kevel-userdb/index.ts diff --git a/packages/destination-actions/src/destinations/kevel/syncAudience/__tests__/index.test.ts b/packages/destination-actions/src/destinations/kevel-userdb/syncAudience/__tests__/index.test.ts similarity index 89% rename from packages/destination-actions/src/destinations/kevel/syncAudience/__tests__/index.test.ts rename to packages/destination-actions/src/destinations/kevel-userdb/syncAudience/__tests__/index.test.ts index 0b027ec2b2..033c139763 100644 --- a/packages/destination-actions/src/destinations/kevel/syncAudience/__tests__/index.test.ts +++ b/packages/destination-actions/src/destinations/kevel-userdb/syncAudience/__tests__/index.test.ts @@ -56,13 +56,11 @@ const badEvent = createTestEvent({ describe('Kevel.syncAudience', () => { it('should not throw an error if the audience creation succeed - track', async () => { - const userId = 'uid1' + const payload = {} const networkId1 = 'networkId1' const baseUrl = `https://e-${networkId1}.adzerk.net/udb/${networkId1}` - nock(baseUrl) - .post(`/interests?userKey=${userId}`, JSON.stringify(['kevel_segment_test_name'])) - .reply(200) + nock(baseUrl).post(`/`, payload).reply(200) await expect( testDestination.testAction('syncAudience', { @@ -77,13 +75,11 @@ describe('Kevel.syncAudience', () => { }) it('should not throw an error if the audience creation succeed - track', async () => { - const userId = 'uid1' + const payload = {} const networkId1 = 'networkId1' const baseUrl = `https://e-${networkId1}.adzerk.net/udb/${networkId1}` - nock(baseUrl) - .post(`/interests?userKey=${userId}`, JSON.stringify(['kevel_segment_test_name'])) - .reply(200) + nock(baseUrl).post(`/`, payload).reply(200) await expect( testDestination.testAction('syncAudience', { diff --git a/packages/destination-actions/src/destinations/kevel-userdb/syncAudience/generated-types.ts b/packages/destination-actions/src/destinations/kevel-userdb/syncAudience/generated-types.ts new file mode 100644 index 0000000000..4277d10241 --- /dev/null +++ b/packages/destination-actions/src/destinations/kevel-userdb/syncAudience/generated-types.ts @@ -0,0 +1,22 @@ +// Generated file. DO NOT MODIFY IT BY HAND. + +export interface Payload { + /** + * Segment Audience name to which user identifier should be added or removed + */ + segment_computation_key: string + /** + * Segment computation class used to determine if input event is from an Engage Audience'. Value must be = 'audience'. + */ + segment_computation_action: string + /** + * The user's unique ID + */ + segment_user_id: string + /** + * A computed object for track and identify events. This field should not need to be edited. + */ + traits_or_props: { + [k: string]: unknown + } +} diff --git a/packages/destination-actions/src/destinations/kevel/syncAudience/index.ts b/packages/destination-actions/src/destinations/kevel-userdb/syncAudience/index.ts similarity index 100% rename from packages/destination-actions/src/destinations/kevel/syncAudience/index.ts rename to packages/destination-actions/src/destinations/kevel-userdb/syncAudience/index.ts diff --git a/packages/destination-actions/src/destinations/kevel/syncTraits/__tests__/index.test.ts b/packages/destination-actions/src/destinations/kevel-userdb/syncTraits/__tests__/index.test.ts similarity index 100% rename from packages/destination-actions/src/destinations/kevel/syncTraits/__tests__/index.test.ts rename to packages/destination-actions/src/destinations/kevel-userdb/syncTraits/__tests__/index.test.ts diff --git a/packages/destination-actions/src/destinations/kevel/syncTraits/generated-types.ts b/packages/destination-actions/src/destinations/kevel-userdb/syncTraits/generated-types.ts similarity index 100% rename from packages/destination-actions/src/destinations/kevel/syncTraits/generated-types.ts rename to packages/destination-actions/src/destinations/kevel-userdb/syncTraits/generated-types.ts diff --git a/packages/destination-actions/src/destinations/kevel/syncTraits/index.ts b/packages/destination-actions/src/destinations/kevel-userdb/syncTraits/index.ts similarity index 100% rename from packages/destination-actions/src/destinations/kevel/syncTraits/index.ts rename to packages/destination-actions/src/destinations/kevel-userdb/syncTraits/index.ts From 1b76809c45501005e2066816470bdb65a6536201 Mon Sep 17 00:00:00 2001 From: Tiago Boldt Sousa Date: Tue, 27 Feb 2024 14:30:20 +0000 Subject: [PATCH 2/3] kevel audience plugin --- .../kevel-audience/generated-types.ts | 28 ++++++ .../src/destinations/kevel-audience/index.ts | 67 ++++++++++++++ .../syncAudience/__tests__/index.test.ts | 89 +++++++++++++++++++ .../syncAudience/generated-types.ts | 14 +++ .../kevel-audience/syncAudience/index.ts | 54 +++++++++++ .../generated-types.ts | 0 .../{kevel => kevel-userdb}/index.ts | 6 +- .../syncAudience/__tests__/index.test.ts | 2 +- .../syncAudience/generated-types.ts | 0 .../syncAudience/index.ts | 3 +- .../syncTraits/__tests__/index.test.ts | 0 .../syncTraits/generated-types.ts | 0 .../syncTraits/index.ts | 2 +- 13 files changed, 259 insertions(+), 6 deletions(-) create mode 100644 packages/destination-actions/src/destinations/kevel-audience/generated-types.ts create mode 100644 packages/destination-actions/src/destinations/kevel-audience/index.ts create mode 100644 packages/destination-actions/src/destinations/kevel-audience/syncAudience/__tests__/index.test.ts create mode 100644 packages/destination-actions/src/destinations/kevel-audience/syncAudience/generated-types.ts create mode 100644 packages/destination-actions/src/destinations/kevel-audience/syncAudience/index.ts rename packages/destination-actions/src/destinations/{kevel => kevel-userdb}/generated-types.ts (100%) rename packages/destination-actions/src/destinations/{kevel => kevel-userdb}/index.ts (83%) rename packages/destination-actions/src/destinations/{kevel => kevel-userdb}/syncAudience/__tests__/index.test.ts (99%) rename packages/destination-actions/src/destinations/{kevel => kevel-userdb}/syncAudience/generated-types.ts (100%) rename packages/destination-actions/src/destinations/{kevel => kevel-userdb}/syncAudience/index.ts (94%) rename packages/destination-actions/src/destinations/{kevel => kevel-userdb}/syncTraits/__tests__/index.test.ts (100%) rename packages/destination-actions/src/destinations/{kevel => kevel-userdb}/syncTraits/generated-types.ts (100%) rename packages/destination-actions/src/destinations/{kevel => kevel-userdb}/syncTraits/index.ts (94%) diff --git a/packages/destination-actions/src/destinations/kevel-audience/generated-types.ts b/packages/destination-actions/src/destinations/kevel-audience/generated-types.ts new file mode 100644 index 0000000000..180d052370 --- /dev/null +++ b/packages/destination-actions/src/destinations/kevel-audience/generated-types.ts @@ -0,0 +1,28 @@ +// Generated file. DO NOT MODIFY IT BY HAND. + +export interface Settings { + /** + * Your Kevel Audience Domain. Example: "cdp.yourdomain.com". + */ + audienceDomain: string + /** + * The Kevel Audience User ID Type to use. Example: "crm". + */ + userIdType: string + /** + * The Kevel Audience client ID to identify the event. Example: "brand-name". + */ + clientId: string + /** + * The Kevel Audience site ID to identify the event. Example: "segment-app". + */ + siteId: string + /** + * The Kevel Audience API Key to authorize the requests. Get yours from your Customer Success representative. + */ + apiKey: string + /** + * The type of event to send to Kevel Audience. Example: "segmentSync". + */ + eventType: string +} diff --git a/packages/destination-actions/src/destinations/kevel-audience/index.ts b/packages/destination-actions/src/destinations/kevel-audience/index.ts new file mode 100644 index 0000000000..4360948d8e --- /dev/null +++ b/packages/destination-actions/src/destinations/kevel-audience/index.ts @@ -0,0 +1,67 @@ +import type { DestinationDefinition } from '@segment/actions-core' +import type { Settings } from './generated-types' + +import syncAudience from './syncAudience' + +const destination: DestinationDefinition = { + name: 'Kevel Audience (Actions)', + slug: 'actions-kevel-audience', + description: + 'Send Segment user profiles and Segment Audiences to Kevel Audience. Only users with a Segment userId will be synced.', + mode: 'cloud', + + authentication: { + scheme: 'custom', + fields: { + audienceDomain: { + label: 'Kevel Audience Domain', + description: 'Your Kevel Audience Domain. Example: "cdp.yourdomain.com".', + type: 'string', + required: true + }, + userIdType: { + label: 'Kevel Audience user ID Type to map Segment ID to', + description: 'The Kevel Audience User ID Type to use. Example: "crm".', + type: 'string', + required: true + }, + clientId: { + label: 'Kevel Audience client ID', + description: 'The Kevel Audience client ID to identify the event. Example: "brand-name".', + type: 'string', + required: true + }, + siteId: { + label: 'Kevel Audience site ID', + description: 'The Kevel Audience site ID to identify the event. Example: "segment-app".', + type: 'string', + required: true + }, + apiKey: { + label: 'Kevel Audience API Key', + description: + 'The Kevel Audience API Key to authorize the requests. Get yours from your Customer Success representative.', + type: 'string', + required: true + }, + eventType: { + label: 'Event Type', + description: 'The type of event to send to Kevel Audience. Example: "segmentSync".', + type: 'string', + required: true + } + } + }, + extendRequest() { + return { + headers: { + 'Content-Type': 'application/json' + } + } + }, + actions: { + syncAudience + } +} + +export default destination diff --git a/packages/destination-actions/src/destinations/kevel-audience/syncAudience/__tests__/index.test.ts b/packages/destination-actions/src/destinations/kevel-audience/syncAudience/__tests__/index.test.ts new file mode 100644 index 0000000000..fcd42dc401 --- /dev/null +++ b/packages/destination-actions/src/destinations/kevel-audience/syncAudience/__tests__/index.test.ts @@ -0,0 +1,89 @@ +import nock from 'nock' +import { createTestEvent, createTestIntegration } from '@segment/actions-core' +import Destination from '../../index' + +const testDestination = createTestIntegration(Destination) + +const goodTrackEvent = createTestEvent({ + type: 'track', + userId: 'uid1', + context: { + personas: { + computation_class: 'audience', + computation_key: 'kevel_segment_test_name' + }, + traits: { + email: 'test@email.com' + } + }, + properties: { + audience_key: 'kevel_segment_test_name', + kevel_segment_test_name: true + } +}) + +const goodIdentifyEvent = createTestEvent({ + type: 'identify', + userId: 'uid1', + context: { + personas: { + computation_class: 'audience', + computation_key: 'kevel_segment_test_name' + } + }, + traits: { + audience_key: 'kevel_segment_test_name', + kevel_segment_test_name: true + }, + properties: undefined +}) + +describe('Kevel.syncAudience', () => { + it('should not throw an error if the audience creation succeed - track', async () => { + const baseUrl = 'https://tr.domain.brand.com/' + + nock(baseUrl) + .post('/events/server', (body) => body.customData.kevel_segment_test_name === true) + .reply(200) + + console.log(nock.activeMocks()) + + await expect( + testDestination.testAction('syncAudience', { + event: goodTrackEvent, + settings: { + audienceDomain: 'domain.brand.com', + userIdType: 'email_sha256', + apiKey: 'api_key', + clientId: 'client_id', + siteId: 'site_id', + eventType: 'segmentSync' + }, + useDefaultMappings: true + }) + ).resolves.not.toThrowError() + }) + + it('should not throw an error if the audience creation succeed - identify', async () => { + const baseUrl = 'https://tr.domain.brand.com' + + nock(baseUrl) + .post('/events/server', (body) => body.customData.kevel_segment_test_name === true) + .reply(200) + + await expect( + testDestination.testAction('syncAudience', { + event: goodIdentifyEvent, + settings: { + audienceDomain: 'domain.brand.com', + userIdType: 'email_sha256', + apiKey: 'api_key', + clientId: 'client_id', + siteId: 'site_id', + eventType: 'segmentSync' + }, + useDefaultMappings: true + }) + ).resolves.not.toThrowError() + }) +}) diff --git a/packages/destination-actions/src/destinations/kevel-audience/syncAudience/generated-types.ts b/packages/destination-actions/src/destinations/kevel-audience/syncAudience/generated-types.ts new file mode 100644 index 0000000000..9961472af7 --- /dev/null +++ b/packages/destination-actions/src/destinations/kevel-audience/syncAudience/generated-types.ts @@ -0,0 +1,14 @@ +// Generated file. DO NOT MODIFY IT BY HAND. + +export interface Payload { + /** + * The user's unique ID + */ + segment_user_id: string + /** + * A computed object for track and identify events. This field should not need to be edited. + */ + traits_or_props: { + [k: string]: unknown + } +} diff --git a/packages/destination-actions/src/destinations/kevel-audience/syncAudience/index.ts b/packages/destination-actions/src/destinations/kevel-audience/syncAudience/index.ts new file mode 100644 index 0000000000..f3eb5c8666 --- /dev/null +++ b/packages/destination-actions/src/destinations/kevel-audience/syncAudience/index.ts @@ -0,0 +1,54 @@ +import type { ActionDefinition } from '@segment/actions-core' +import type { Settings } from '../generated-types' +import type { Payload } from './generated-types' + +const action: ActionDefinition = { + title: 'Sync Audience to Kevel Audience', + description: 'Sync a Segment Engage Audience to a Kevel Audience. Only users with a Segment userId will be synced.', + defaultSubscription: 'type = "track" or type = "identify"', + fields: { + segment_user_id: { + label: 'User ID', + description: "The user's unique ID", + type: 'string', + unsafe_hidden: true, + required: true, + default: { '@path': '$.userId' } + }, + 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' } + } + } + } + }, + perform: async (request, data) => { + const baseUrl = `https://tr.${data.settings.audienceDomain}/events/server` // TODO event tracker + const payload = { + clientId: data.settings.clientId, + siteId: data.settings.siteId, + type: 'custom', + customType: data.settings.eventType, + user: { + type: data.settings.userIdType, + id: data.payload.segment_user_id + }, + customData: data.payload.traits_or_props + } + + return request(`${baseUrl}`, { + json: payload, + method: 'POST' + }) + } +} + +export default action diff --git a/packages/destination-actions/src/destinations/kevel/generated-types.ts b/packages/destination-actions/src/destinations/kevel-userdb/generated-types.ts similarity index 100% rename from packages/destination-actions/src/destinations/kevel/generated-types.ts rename to packages/destination-actions/src/destinations/kevel-userdb/generated-types.ts diff --git a/packages/destination-actions/src/destinations/kevel/index.ts b/packages/destination-actions/src/destinations/kevel-userdb/index.ts similarity index 83% rename from packages/destination-actions/src/destinations/kevel/index.ts rename to packages/destination-actions/src/destinations/kevel-userdb/index.ts index fd12a664db..7367e894cc 100644 --- a/packages/destination-actions/src/destinations/kevel/index.ts +++ b/packages/destination-actions/src/destinations/kevel-userdb/index.ts @@ -6,10 +6,10 @@ import syncAudience from './syncAudience' import syncTraits from './syncTraits' const destination: DestinationDefinition = { - name: 'Kevel (Actions)', - slug: 'actions-kevel', + name: 'Kevel UserDB (Actions)', + slug: 'actions-kevel-userdb', description: - 'Send Segment user profiles and Segment Audiences to Kevel. Only users with a Segment userId will be synced.', + 'Send Segment user profiles and Segment Audiences to Kevel UserDB. Only users with a Segment userId will be synced.', mode: 'cloud', authentication: { diff --git a/packages/destination-actions/src/destinations/kevel/syncAudience/__tests__/index.test.ts b/packages/destination-actions/src/destinations/kevel-userdb/syncAudience/__tests__/index.test.ts similarity index 99% rename from packages/destination-actions/src/destinations/kevel/syncAudience/__tests__/index.test.ts rename to packages/destination-actions/src/destinations/kevel-userdb/syncAudience/__tests__/index.test.ts index 0b027ec2b2..16c5d9b032 100644 --- a/packages/destination-actions/src/destinations/kevel/syncAudience/__tests__/index.test.ts +++ b/packages/destination-actions/src/destinations/kevel-userdb/syncAudience/__tests__/index.test.ts @@ -76,7 +76,7 @@ describe('Kevel.syncAudience', () => { ).resolves.not.toThrowError() }) - it('should not throw an error if the audience creation succeed - track', async () => { + it('should not throw an error if the audience creation succeed - identify', async () => { const userId = 'uid1' const networkId1 = 'networkId1' const baseUrl = `https://e-${networkId1}.adzerk.net/udb/${networkId1}` diff --git a/packages/destination-actions/src/destinations/kevel/syncAudience/generated-types.ts b/packages/destination-actions/src/destinations/kevel-userdb/syncAudience/generated-types.ts similarity index 100% rename from packages/destination-actions/src/destinations/kevel/syncAudience/generated-types.ts rename to packages/destination-actions/src/destinations/kevel-userdb/syncAudience/generated-types.ts diff --git a/packages/destination-actions/src/destinations/kevel/syncAudience/index.ts b/packages/destination-actions/src/destinations/kevel-userdb/syncAudience/index.ts similarity index 94% rename from packages/destination-actions/src/destinations/kevel/syncAudience/index.ts rename to packages/destination-actions/src/destinations/kevel-userdb/syncAudience/index.ts index 59bee19d7b..e916618b0d 100644 --- a/packages/destination-actions/src/destinations/kevel/syncAudience/index.ts +++ b/packages/destination-actions/src/destinations/kevel-userdb/syncAudience/index.ts @@ -4,7 +4,8 @@ import type { Payload } from './generated-types' const action: ActionDefinition = { title: 'Sync Audience', - description: 'Sync a Segment Engage Audience to a Kevel Segment. Only users with a Segment userId will be synced.', + description: + 'Sync a Segment Engage Audience to a Kevel UserDB Interest. Only users with a Segment userId will be synced.', defaultSubscription: 'type = "track" or type = "identify"', fields: { segment_computation_key: { diff --git a/packages/destination-actions/src/destinations/kevel/syncTraits/__tests__/index.test.ts b/packages/destination-actions/src/destinations/kevel-userdb/syncTraits/__tests__/index.test.ts similarity index 100% rename from packages/destination-actions/src/destinations/kevel/syncTraits/__tests__/index.test.ts rename to packages/destination-actions/src/destinations/kevel-userdb/syncTraits/__tests__/index.test.ts diff --git a/packages/destination-actions/src/destinations/kevel/syncTraits/generated-types.ts b/packages/destination-actions/src/destinations/kevel-userdb/syncTraits/generated-types.ts similarity index 100% rename from packages/destination-actions/src/destinations/kevel/syncTraits/generated-types.ts rename to packages/destination-actions/src/destinations/kevel-userdb/syncTraits/generated-types.ts diff --git a/packages/destination-actions/src/destinations/kevel/syncTraits/index.ts b/packages/destination-actions/src/destinations/kevel-userdb/syncTraits/index.ts similarity index 94% rename from packages/destination-actions/src/destinations/kevel/syncTraits/index.ts rename to packages/destination-actions/src/destinations/kevel-userdb/syncTraits/index.ts index 7c51e40c92..d413b00a2a 100644 --- a/packages/destination-actions/src/destinations/kevel/syncTraits/index.ts +++ b/packages/destination-actions/src/destinations/kevel-userdb/syncTraits/index.ts @@ -4,7 +4,7 @@ import type { Payload } from './generated-types' const action: ActionDefinition = { title: 'Sync Traits', - description: 'Sync user profile traits from Segment to Kevel', + description: 'Sync user profile traits from Segment to Kevel UserDB', defaultSubscription: 'type = "identify"', fields: { segment_user_id: { From d9dc4f437ceb2cf39de71c339335f67e4b04f8f4 Mon Sep 17 00:00:00 2001 From: Tiago Boldt Sousa Date: Mon, 4 Mar 2024 22:25:54 +0000 Subject: [PATCH 3/3] update documentation for kevel integrations --- .../src/destinations/kevel-audience/generated-types.ts | 2 +- .../src/destinations/kevel-audience/index.ts | 10 +++++----- .../__tests__/index.test.ts | 8 +++----- .../generated-types.ts | 0 .../{syncAudience => syncKevelAudience}/index.ts | 5 +++-- .../src/destinations/kevel-userdb/index.ts | 2 +- .../destinations/kevel-userdb/syncAudience/index.ts | 2 +- .../src/destinations/kevel-userdb/syncTraits/index.ts | 3 ++- 8 files changed, 16 insertions(+), 16 deletions(-) rename packages/destination-actions/src/destinations/kevel-audience/{syncAudience => syncKevelAudience}/__tests__/index.test.ts (92%) rename packages/destination-actions/src/destinations/kevel-audience/{syncAudience => syncKevelAudience}/generated-types.ts (100%) rename packages/destination-actions/src/destinations/kevel-audience/{syncAudience => syncKevelAudience}/index.ts (79%) diff --git a/packages/destination-actions/src/destinations/kevel-audience/generated-types.ts b/packages/destination-actions/src/destinations/kevel-audience/generated-types.ts index 180d052370..12b8fa4b51 100644 --- a/packages/destination-actions/src/destinations/kevel-audience/generated-types.ts +++ b/packages/destination-actions/src/destinations/kevel-audience/generated-types.ts @@ -2,7 +2,7 @@ export interface Settings { /** - * Your Kevel Audience Domain. Example: "cdp.yourdomain.com". + * Your Kevel Audience root subdomain. Example: "cdp.yourdomain.com". */ audienceDomain: string /** diff --git a/packages/destination-actions/src/destinations/kevel-audience/index.ts b/packages/destination-actions/src/destinations/kevel-audience/index.ts index 4360948d8e..e5ee3b54ab 100644 --- a/packages/destination-actions/src/destinations/kevel-audience/index.ts +++ b/packages/destination-actions/src/destinations/kevel-audience/index.ts @@ -1,13 +1,13 @@ import type { DestinationDefinition } from '@segment/actions-core' import type { Settings } from './generated-types' -import syncAudience from './syncAudience' +import syncKevelAudience from './syncKevelAudience' const destination: DestinationDefinition = { name: 'Kevel Audience (Actions)', slug: 'actions-kevel-audience', description: - 'Send Segment user profiles and Segment Audiences to Kevel Audience. Only users with a Segment userId will be synced.', + "Share Segment user attributes and Segment Audiences from `track` and `identify` events to Kevel Audience using Kevel Audience tracking events and sharing data as `customFields`. By configuring Kevel Audience user attributes, this data can then be made available on the user's profile. Only users with a Segment userId will be synced.", mode: 'cloud', authentication: { @@ -15,12 +15,12 @@ const destination: DestinationDefinition = { fields: { audienceDomain: { label: 'Kevel Audience Domain', - description: 'Your Kevel Audience Domain. Example: "cdp.yourdomain.com".', + description: 'Your Kevel Audience root subdomain. Example: "cdp.yourdomain.com".', type: 'string', required: true }, userIdType: { - label: 'Kevel Audience user ID Type to map Segment ID to', + label: 'Kevel Audience user ID Type to map your Segment ID to', description: 'The Kevel Audience User ID Type to use. Example: "crm".', type: 'string', required: true @@ -60,7 +60,7 @@ const destination: DestinationDefinition = { } }, actions: { - syncAudience + syncKevelAudience } } diff --git a/packages/destination-actions/src/destinations/kevel-audience/syncAudience/__tests__/index.test.ts b/packages/destination-actions/src/destinations/kevel-audience/syncKevelAudience/__tests__/index.test.ts similarity index 92% rename from packages/destination-actions/src/destinations/kevel-audience/syncAudience/__tests__/index.test.ts rename to packages/destination-actions/src/destinations/kevel-audience/syncKevelAudience/__tests__/index.test.ts index fcd42dc401..d49dc326ae 100644 --- a/packages/destination-actions/src/destinations/kevel-audience/syncAudience/__tests__/index.test.ts +++ b/packages/destination-actions/src/destinations/kevel-audience/syncKevelAudience/__tests__/index.test.ts @@ -38,7 +38,7 @@ const goodIdentifyEvent = createTestEvent({ properties: undefined }) -describe('Kevel.syncAudience', () => { +describe('KevelAuddience.syncKevelAudience', () => { it('should not throw an error if the audience creation succeed - track', async () => { const baseUrl = 'https://tr.domain.brand.com/' @@ -46,10 +46,8 @@ describe('Kevel.syncAudience', () => { .post('/events/server', (body) => body.customData.kevel_segment_test_name === true) .reply(200) - console.log(nock.activeMocks()) - await expect( - testDestination.testAction('syncAudience', { + testDestination.testAction('syncKevelAudience', { event: goodTrackEvent, settings: { audienceDomain: 'domain.brand.com', @@ -72,7 +70,7 @@ describe('Kevel.syncAudience', () => { .reply(200) await expect( - testDestination.testAction('syncAudience', { + testDestination.testAction('syncKevelAudience', { event: goodIdentifyEvent, settings: { audienceDomain: 'domain.brand.com', diff --git a/packages/destination-actions/src/destinations/kevel-audience/syncAudience/generated-types.ts b/packages/destination-actions/src/destinations/kevel-audience/syncKevelAudience/generated-types.ts similarity index 100% rename from packages/destination-actions/src/destinations/kevel-audience/syncAudience/generated-types.ts rename to packages/destination-actions/src/destinations/kevel-audience/syncKevelAudience/generated-types.ts diff --git a/packages/destination-actions/src/destinations/kevel-audience/syncAudience/index.ts b/packages/destination-actions/src/destinations/kevel-audience/syncKevelAudience/index.ts similarity index 79% rename from packages/destination-actions/src/destinations/kevel-audience/syncAudience/index.ts rename to packages/destination-actions/src/destinations/kevel-audience/syncKevelAudience/index.ts index f3eb5c8666..39144bb51f 100644 --- a/packages/destination-actions/src/destinations/kevel-audience/syncAudience/index.ts +++ b/packages/destination-actions/src/destinations/kevel-audience/syncKevelAudience/index.ts @@ -3,8 +3,9 @@ import type { Settings } from '../generated-types' import type { Payload } from './generated-types' const action: ActionDefinition = { - title: 'Sync Audience to Kevel Audience', - description: 'Sync a Segment Engage Audience to a Kevel Audience. Only users with a Segment userId will be synced.', + title: 'Sync with Kevel Audience', + description: + "Share Segment user attributes and Segment Audiences from `track` and `identify` events to Kevel Audience using Kevel Audience tracking events and sharing data as `customFields`. By configuring Kevel Audience user attributes, this data can then be made available on the user's profile. Only users with a Segment userId will be synced.", defaultSubscription: 'type = "track" or type = "identify"', fields: { segment_user_id: { diff --git a/packages/destination-actions/src/destinations/kevel-userdb/index.ts b/packages/destination-actions/src/destinations/kevel-userdb/index.ts index 7367e894cc..8160660bb6 100644 --- a/packages/destination-actions/src/destinations/kevel-userdb/index.ts +++ b/packages/destination-actions/src/destinations/kevel-userdb/index.ts @@ -9,7 +9,7 @@ const destination: DestinationDefinition = { name: 'Kevel UserDB (Actions)', slug: 'actions-kevel-userdb', description: - 'Send Segment user profiles and Segment Audiences to Kevel UserDB. Only users with a Segment userId will be synced.', + 'Send Segment user profiles and Segment Audiences to Kevel UserDB for campaign targeting. Only users with a Segment userId will be synced.', mode: 'cloud', authentication: { diff --git a/packages/destination-actions/src/destinations/kevel-userdb/syncAudience/index.ts b/packages/destination-actions/src/destinations/kevel-userdb/syncAudience/index.ts index e916618b0d..86b4ddd44e 100644 --- a/packages/destination-actions/src/destinations/kevel-userdb/syncAudience/index.ts +++ b/packages/destination-actions/src/destinations/kevel-userdb/syncAudience/index.ts @@ -5,7 +5,7 @@ import type { Payload } from './generated-types' const action: ActionDefinition = { title: 'Sync Audience', description: - 'Sync a Segment Engage Audience to a Kevel UserDB Interest. Only users with a Segment userId will be synced.', + 'Sync a Segment Engage Audience to a Kevel UserDB Interest. Only users with a Segment userId will be synced. Read the [documentation for more details](https://dev.kevel.com/reference/add-interest-to-user).', defaultSubscription: 'type = "track" or type = "identify"', fields: { segment_computation_key: { diff --git a/packages/destination-actions/src/destinations/kevel-userdb/syncTraits/index.ts b/packages/destination-actions/src/destinations/kevel-userdb/syncTraits/index.ts index d413b00a2a..1c4dfbd7c4 100644 --- a/packages/destination-actions/src/destinations/kevel-userdb/syncTraits/index.ts +++ b/packages/destination-actions/src/destinations/kevel-userdb/syncTraits/index.ts @@ -4,7 +4,8 @@ import type { Payload } from './generated-types' const action: ActionDefinition = { title: 'Sync Traits', - description: 'Sync user profile traits from Segment to Kevel UserDB', + description: + 'Sync user profile traits and segments from Segment to Kevel UserDB using `customProperties`. Read the [documentation for more details](https://dev.kevel.com/reference/set-custom-properties-alternative).', defaultSubscription: 'type = "identify"', fields: { segment_user_id: {