Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fest(Segment): add all new endpoints to segment #1459

Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
e272fa0
add create audience action
kkupreeva Mar 1, 2022
c684925
try enable CI
kkupreeva Mar 1, 2022
612c74b
try fix
kkupreeva Mar 1, 2022
682ab31
return ci how it was
kkupreeva Mar 2, 2022
2ba19f2
add updateAudience, deleteAudience, trackEvent
kkupreeva Mar 2, 2022
cc0eecc
check workflow
kkupreeva Mar 2, 2022
e26685a
fix tests
kkupreeva Mar 2, 2022
36af31d
fix tests
kkupreeva Mar 2, 2022
7e1c10c
fix description
kkupreeva Mar 2, 2022
e8652c5
improve test
kkupreeva Mar 3, 2022
336d84b
fix labels and descriptions
kkupreeva Mar 3, 2022
e6562b3
generate types
kkupreeva Mar 3, 2022
3abb5c7
return workflows how it was before
kkupreeva Mar 3, 2022
33e6d2d
change destination name Talon One -> Talon.One
kkupreeva Mar 3, 2022
b7e48e6
review
kkupreeva Mar 15, 2022
295b63d
new files
kaatinga Mar 14, 2022
0df88fb
added 3 endpoints
kaatinga Mar 14, 2022
4b47f87
added generated files
kaatinga Mar 14, 2022
d95fad1
implemented 3 endppoints
kaatinga Mar 14, 2022
c83e0aa
tests
kaatinga Mar 15, 2022
cd7960f
fixed tests, added right json tags
kaatinga Mar 15, 2022
ab7c139
Merge branch 'main' into sc-7503-add-destination-endpoints-to-work-wi…
kaatinga Mar 15, 2022
6671232
updated models
kaatinga Mar 16, 2022
6d0bd80
updated test models
kaatinga Mar 16, 2022
cc20a80
update models
kaatinga Mar 16, 2022
7edca72
updated models
kaatinga Mar 16, 2022
a47c146
tests generated
kaatinga Mar 16, 2022
5e3a7ed
updated models
kaatinga Mar 16, 2022
cd1022f
tests generated
kaatinga Mar 16, 2022
d391a8e
Merge pull request #2 from talon-one/sc-7503-add-destination-endpoint…
kaatinga Mar 16, 2022
b7e7d31
Revert "Merge pull request #2 from talon-one/sc-7503-add-destination-…
kaatinga Mar 17, 2022
c66c811
Revert "Revert "Merge pull request #2 from talon-one/sc-7503-add-dest…
kaatinga Mar 17, 2022
ec2f8fa
added more endpoints and fixed some minor things
kaatinga Mar 17, 2022
c63ca9e
deleted an unnecessarily added file
kaatinga Mar 17, 2022
2ece421
updated snapshots, thank you @jinapark202
kaatinga Mar 18, 2022
687a4ac
Merge pull request #6 from talon-one/sc-7503-add-destination-endpoint…
kaatinga Mar 21, 2022
80066b4
Merge branch 'segmentio:main' into main
kaatinga Mar 21, 2022
4285efc
Merge branch 'segmentio:main' into main
kkupreeva Mar 23, 2022
b0bba6d
Merge branch 'segmentio:main' into main
kaatinga Apr 5, 2022
c04ab5d
Merge branch 'segmentio:main' into main
kaatinga May 2, 2022
c3b7c5a
Merge branch 'segmentio:main' into main
kaatinga May 5, 2022
98e55b3
Merge branch 'segmentio:main' into main
kkupreeva May 12, 2022
aa361c2
Merge branch 'segmentio:main' into main
kkupreeva May 30, 2022
3562b82
Merge branch 'segmentio:main' into main
kkupreeva Jun 17, 2022
e5ea929
Merge branch 'segmentio:main' into main
kkupreeva Jun 23, 2022
c3f4f42
add updateCustomerProfileV2 action
kkupreeva Jul 6, 2022
47f0956
add default mapping
kkupreeva Jul 6, 2022
29bbb75
integrationId -> integration ID
kkupreeva Jul 6, 2022
5f487cb
new update customer session destination for talon.one
kaatinga Jul 12, 2022
e875ad2
Merge pull request #10 from talon-one/sc-9770-adjust-talon-one-segmen…
kaatinga Jul 12, 2022
de73d63
fixed tests, review
kaatinga Jul 14, 2022
d3153ca
added choices for attributesInfo
kaatinga Jul 14, 2022
390e6f1
reused attributesInfo constant from t1-properties.ts
kaatinga Jul 14, 2022
d9a844b
updated test by cardItems array
kaatinga Jul 14, 2022
110db63
updated test by cardItems array
kaatinga Jul 14, 2022
6807790
generated types
kaatinga Jul 14, 2022
bdbd6c7
fixed unit tests
kaatinga Jul 14, 2022
5a51c55
fixed a typo
kaatinga Jul 15, 2022
dbdf252
Merge branch 'segmentio:main' into main
kkupreeva Jul 18, 2022
2311cc4
review
kaatinga Jul 18, 2022
1ff7796
Merge branch 'segmentio:main' into main
kkupreeva Jul 27, 2022
454e77c
Merge branch 'segmentio:main' into main
kaatinga Aug 2, 2022
fc2630a
deleted destination to update multiple attributes fro multiple custom…
kaatinga Aug 2, 2022
68a9e4d
Merge pull request #11 from talon-one/sc-12648-remove-destination-act…
kaatinga Aug 3, 2022
24ce049
Merge branch 'segmentio:main' into main
kkupreeva Jun 21, 2023
0826d2f
Merge branch 'segmentio:main' into main
kkupreeva Jul 27, 2023
faba700
Add new talon-integration endpoints to segment
rubyjohn93 Jul 28, 2023
dcbd38f
Merge branch 'segmentio:main' into sc-25493-add-all-new-endpoints-to-…
rubyjohn93 Aug 1, 2023
bcbe966
Mark old endpoints as deprecated in title and description
rubyjohn93 Aug 16, 2023
2420124
Fix PR comments from docs team
rubyjohn93 Aug 18, 2023
086c894
Fix casing
rubyjohn93 Aug 18, 2023
b5e26e9
Fix PR comments
rubyjohn93 Aug 22, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,23 @@ Object {
}
`;

exports[`Testing snapshot for actions-talon-one destination: trackEventV2 action - all fields 1`] = `
Object {
"customerProfileId": "e)TF!ogVx#Nvh4",
"eventAttributes": Object {
"testType": "e)TF!ogVx#Nvh4",
},
"eventType": "e)TF!ogVx#Nvh4",
}
`;

exports[`Testing snapshot for actions-talon-one destination: trackEventV2 action - required fields 1`] = `
Object {
"customerProfileId": "e)TF!ogVx#Nvh4",
"eventType": "e)TF!ogVx#Nvh4",
}
`;

exports[`Testing snapshot for actions-talon-one destination: updateAudience action - all fields 1`] = `
Object {
"audienceName": "y73nLJ!",
Expand Down Expand Up @@ -135,6 +152,29 @@ Object {
}
`;

exports[`Testing snapshot for actions-talon-one destination: updateCustomerProfileV3 action - all fields 1`] = `
Object {
"attributes": Object {
"testType": "GeWo@^$JGyRkK",
},
"audiencesChanges": Object {
"adds": Array [
525191390167040,
],
"deletes": Array [
525191390167040,
],
},
"runRuleEngine": false,
}
`;

exports[`Testing snapshot for actions-talon-one destination: updateCustomerProfileV3 action - required fields 1`] = `
Object {
"audiencesChanges": Object {},
}
`;

exports[`Testing snapshot for actions-talon-one destination: updateCustomerProfilesAudiences action - all fields 1`] = `
Object {
"data": Array [
Expand Down Expand Up @@ -203,3 +243,55 @@ Object {
"customerSession": Object {},
}
`;

exports[`Testing snapshot for actions-talon-one destination: updateCustomerSessionV2 action - all fields 1`] = `
Object {
"additionalCosts": Object {
"testType": "J(4saNJrsRd8Z]iG%36t",
},
"attributes": Object {
"testType": "J(4saNJrsRd8Z]iG%36t",
},
"cartItems": Array [
Object {
"additionalCosts": Object {
"testType": "J(4saNJrsRd8Z]iG%36t",
},
"attributes": Object {
"testType": "J(4saNJrsRd8Z]iG%36t",
},
"category": "J(4saNJrsRd8Z]iG%36t",
"height": "J(4saNJrsRd8Z]iG%36t",
"length": "J(4saNJrsRd8Z]iG%36t",
"name": "J(4saNJrsRd8Z]iG%36t",
"position": "J(4saNJrsRd8Z]iG%36t",
"price": 89572104743157.77,
"quantity": 89572104743157.77,
"remainingQuantity": "J(4saNJrsRd8Z]iG%36t",
"returnedQuantity": "J(4saNJrsRd8Z]iG%36t",
"sku": "J(4saNJrsRd8Z]iG%36t",
"weight": "J(4saNJrsRd8Z]iG%36t",
},
],
"couponCodes": Array [
"J(4saNJrsRd8Z]iG%36t",
],
"identifiers": Array [
"J(4saNJrsRd8Z]iG%36t",
],
"loyaltyCards": Array [
"J(4saNJrsRd8Z]iG%36t",
],
"profileId": "J(4saNJrsRd8Z]iG%36t",
"referralCode": "J(4saNJrsRd8Z]iG%36t",
"state": "cancelled",
}
`;

exports[`Testing snapshot for actions-talon-one destination: updateCustomerSessionV2 action - required fields 1`] = `
Object {
"identifiers": Array [
"J(4saNJrsRd8Z]iG%36t",
],
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import updateCustomerProfilesAudiences from './updateCustomerProfilesAudiences'
import trackEvent from './trackEvent'
import updateCustomerProfileV2 from './updateCustomerProfileV2'
import updateCustomerSession from './updateCustomerSession'
import trackEventV2 from './trackEventV2'
import updateCustomerSessionV2 from './updateCustomerSessionV2'
import updateCustomerProfileV3 from './updateCustomerProfileV3'

const destination: DestinationDefinition<Settings> = {
name: 'Talon.One (Actions)',
Expand Down Expand Up @@ -53,10 +56,13 @@ const destination: DestinationDefinition<Settings> = {
updateAudience,
deleteAudience,
updateCustomerProfile,
updateCustomerProfileV2,
updateCustomerProfileV3,
updateCustomerProfilesAudiences,
trackEvent,
updateCustomerProfileV2,
updateCustomerSession
trackEventV2,
updateCustomerSession,
updateCustomerSessionV2
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,12 @@ export const cartItems: InputField = {
}
}
}

export const identifier: InputField = {
label: 'Identifier',
description:
'Session custom identifier that you can set limits on or use inside your rules. For example, you can use IP addresses as identifiers to potentially identify devices and limit discounts abuse in case of customers creating multiple accounts.',
type: 'string',
multiple: true,
required: false
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import { attribute, customerProfileId } from '../t1-properties'
const TARGET_EVENT_TYPE = 'string'

const action: ActionDefinition<Settings, Payload> = {
title: 'Track Event',
description: 'This records a custom event in Talon.One.',
title: '[Deprecated] Track event',
description: `This records a custom event in Talon.One.

**Important:** This endpoint is deprecated. Use the current **Track event** endpoint instead.`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: `This records a custom event in Talon.One.
**Important:** This endpoint is deprecated. Use the current **Track event** endpoint instead.`,
description: `This records a custom event in Talon.One. **Important:** This Action is deprecated. Use the **Track event** Action instead.`,

fields: {
customerProfileId: {
...customerProfileId,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Testing snapshot for TalonOne's trackEventV2 destination action: all fields 1`] = `
Object {
"customerProfileId": "@*g0]#jUfAqZ28L86&D",
"eventAttributes": Object {
"testType": "@*g0]#jUfAqZ28L86&D",
},
"eventType": "@*g0]#jUfAqZ28L86&D",
}
`;

exports[`Testing snapshot for TalonOne's trackEventV2 destination action: required fields 1`] = `
Object {
"customerProfileId": "@*g0]#jUfAqZ28L86&D",
"eventType": "@*g0]#jUfAqZ28L86&D",
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import nock from 'nock'
import { createTestIntegration } from '@segment/actions-core'
import Destination from '../../index'

const testDestination = createTestIntegration(Destination)

describe('TalonOne.trackEventV2', () => {
it('misses customer profile ID', async () => {
try {
await testDestination.testAction('trackEventV2', {
settings: {
apiKey: 'some_api_key',
deployment: 'https://internal.europe-west1.talon.one'
}
})
} catch (err) {
expect(err.message).toContain("The root value is missing the required field 'customerProfileId'.")
}
})

it('misses event type', async () => {
try {
await testDestination.testAction('trackEvenV2', {
settings: {
apiKey: 'some_api_key',
deployment: 'https://internal.europe-west1.talon.one'
},
mapping: {
customerProfileId: 'some_customer_profile_id'
}
})
} catch (err) {
expect(err.message).toContain("The root value is missing the required field 'eventType'.")
}
})

it('should work', async () => {
nock('https://integration.talon.one')
.put('/segment/v2/events?skipNonExistingAttributes=true', {
customerProfileId: 'some_customer_profile_id',
eventType: 'event_type',
eventAttributes: {
favoriteProduct: 'fruits',
isDogLover: true,
stringAttribute: 'test',
booleanAttribute: 'true',
numberAttribute: '12345'
}
})
.matchHeader('Authorization', 'ApiKey-v1 some_api_key')
.matchHeader('destination-hostname', 'https://something.europe-west1.talon.one')
.reply(200)

await testDestination.testAction('trackEventV2', {
settings: {
apiKey: 'some_api_key',
deployment: 'https://something.europe-west1.talon.one'
},
mapping: {
customerProfileId: 'some_customer_profile_id',
skipNonExistingAttributes: true,
eventType: 'event_type',
attributes: {
favoriteProduct: 'fruits',
isDogLover: true,
stringAttribute: 'test',
booleanAttribute: 'true',
numberAttribute: '12345'
}
}
})
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { createTestEvent, createTestIntegration } from '@segment/actions-core'
import { generateTestData } from '../../../../lib/test-data'
import destination from '../../index'
import nock from 'nock'

const testDestination = createTestIntegration(destination)
const actionSlug = 'trackEventV2'
const destinationSlug = 'TalonOne'
const seedName = `${destinationSlug}#${actionSlug}`

describe(`Testing snapshot for ${destinationSlug}'s ${actionSlug} destination action:`, () => {
it('required fields', async () => {
const action = destination.actions[actionSlug]
const [eventData, settingsData] = generateTestData(seedName, destination, action, true)

nock(/.*/).persist().get(/.*/).reply(200)
nock(/.*/).persist().post(/.*/).reply(200)
nock(/.*/).persist().put(/.*/).reply(200)

const event = createTestEvent({
properties: eventData
})

const responses = await testDestination.testAction(actionSlug, {
event: event,
mapping: event.properties,
settings: settingsData,
auth: undefined
})

const request = responses[0].request
const rawBody = await request.text()

try {
const json = JSON.parse(rawBody)
expect(json).toMatchSnapshot()
return
} catch (err) {
expect(rawBody).toMatchSnapshot()
}

expect(request.headers).toMatchSnapshot()
})

it('all fields', async () => {
const action = destination.actions[actionSlug]
const [eventData, settingsData] = generateTestData(seedName, destination, action, false)

nock(/.*/).persist().get(/.*/).reply(200)
nock(/.*/).persist().post(/.*/).reply(200)
nock(/.*/).persist().put(/.*/).reply(200)

const event = createTestEvent({
properties: eventData
})

const responses = await testDestination.testAction(actionSlug, {
event: event,
mapping: event.properties,
settings: settingsData,
auth: undefined
})

const request = responses[0].request
const rawBody = await request.text()

try {
const json = JSON.parse(rawBody)
expect(json).toMatchSnapshot()
return
} catch (err) {
expect(rawBody).toMatchSnapshot()
}
})
})

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

Loading