Skip to content

Commit d9246b9

Browse files
Copilotabhandage
andcommitted
Add 8 more destinations to centralized versioning-info.ts
Added: - amazon-conversions-api (v2 profiles, v1 events) - dotdigital (v2) - posthog (v0) - qualtrics (v3) - reddit-conversions-api (v2.0) - snap-conversions-api (v3) - userpilot (v1) - sendgrid (v3) Co-authored-by: abhandage <174417010+abhandage@users.noreply.github.com>
1 parent 5867bd2 commit d9246b9

File tree

11 files changed

+75
-20
lines changed

11 files changed

+75
-20
lines changed

packages/destination-actions/src/destinations/amazon-conversions-api/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Region } from './types'
66
import { defaultValues, InvalidAuthenticationError } from '@segment/actions-core'
77
import { getAuthToken } from './utils'
88
import trackConversion from './trackConversion'
9+
import { AMAZON_CONVERSIONS_API_PROFILES_VERSION } from '../versioning-info'
910

1011
const destination: DestinationDefinition<Settings> = {
1112
name: 'Amazon Conversions Api',
@@ -40,7 +41,7 @@ const destination: DestinationDefinition<Settings> = {
4041
throw new InvalidAuthenticationError('Please authenticate via Oauth before enabling the destination.')
4142
}
4243

43-
return await request<RefreshTokenResponse>(`${settings.region}/v2/profiles`, {
44+
return await request<RefreshTokenResponse>(`${settings.region}/${AMAZON_CONVERSIONS_API_PROFILES_VERSION}/profiles`, {
4445
method: 'GET',
4546
headers: {
4647
'Content-Type': 'application/json'

packages/destination-actions/src/destinations/amazon-conversions-api/trackConversion/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import type {
2222
} from '../types'
2323
import { MatchKeyTypeV1, Region, ConversionTypeV2 } from '../types'
2424
import type { Payload } from './generated-types'
25+
import { AMAZON_CONVERSIONS_API_EVENTS_VERSION } from '../../versioning-info'
2526

2627
/**
2728
* Helper function to validate if a string value exists and is not empty
@@ -142,7 +143,7 @@ export async function sendEventsRequest<ImportConversionEventsResponse>(
142143
// Ensure eventData is always an array
143144
const events = Array.isArray(eventData) ? eventData : [eventData]
144145

145-
return await request<ImportConversionEventsResponse>(`${settings.region}/events/v1`, {
146+
return await request<ImportConversionEventsResponse>(`${settings.region}/events/${AMAZON_CONVERSIONS_API_EVENTS_VERSION}`, {
146147
method: 'POST',
147148
json: {
148149
eventData: events,

packages/destination-actions/src/destinations/dotdigital/api/resources/dd-campaign-api.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { DynamicFieldResponse, ModifiedResponse, RequestClient } from '@segment/
22
import type { Settings } from '../../generated-types'
33
import DDApi from '../dd-api'
44
import { Campaign, sendCampaignPayload } from '../types'
5+
import { DOTDIGITAL_API_VERSION } from '../../../versioning-info'
56

67
/**
78
* Class representing the Dotdigital Campaign API.
@@ -19,7 +20,7 @@ class DDCampaignApi extends DDApi {
1920
* @returns {Promise<object>} A promise that resolves to the response of the update operation.
2021
*/
2122
async getCampaignsPaging(select = 1000, skip = 0) {
22-
return await this.get('/v2/campaigns', { select, skip })
23+
return await this.get(`/${DOTDIGITAL_API_VERSION}/campaigns`, { select, skip })
2324
}
2425

2526
/**
@@ -71,10 +72,10 @@ class DDCampaignApi extends DDApi {
7172
contactIDs: [contactId],
7273
sendDate: sendDate
7374
}
74-
let endpoint = `/v2/campaigns/send`
75+
let endpoint = `/${DOTDIGITAL_API_VERSION}/campaigns/send`
7576

7677
if (sendTimeOptimised) {
77-
endpoint = `/v2/campaigns/send-time-optimised`
78+
endpoint = `/${DOTDIGITAL_API_VERSION}/campaigns/send-time-optimised`
7879
delete sendCampaignPayload.sendDate
7980
}
8081

packages/destination-actions/src/destinations/posthog/identify/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { ActionDefinition } from '@segment/actions-core'
22
import type { Settings } from '../generated-types'
33
import type { Payload } from './generated-types'
44
import type { IdentifyEvent } from '../types'
5+
import { POSTHOG_API_VERSION } from '../../versioning-info'
56

67
const action: ActionDefinition<Settings, Payload> = {
78
title: 'Identify',
@@ -37,7 +38,7 @@ const action: ActionDefinition<Settings, Payload> = {
3738
}
3839
},
3940
perform: (request, {payload, settings}) => {
40-
const url = `${settings.endpoint}/i/v0/e/`
41+
const url = `${settings.endpoint}/i/${POSTHOG_API_VERSION}/e/`
4142
const headers = {
4243
'Content-Type': 'application/json'
4344
}

packages/destination-actions/src/destinations/qualtrics/qualtricsApiClient.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { RequestClient } from '@segment/actions-core'
2+
import { QUALTRICS_API_VERSION } from '../versioning-info'
23

34
export type SupportedMethods = 'get' | 'post'
45

@@ -131,36 +132,36 @@ export default class QualtricsApiClient {
131132
}
132133

133134
public async whoaAmI(): Promise<WhoAmiResponse> {
134-
const endpoint = `/API/v3/whoami`
135+
const endpoint = `/API/${QUALTRICS_API_VERSION}/whoami`
135136
return (await this.makeRequest(endpoint, 'get')).result as WhoAmiResponse
136137
}
137138

138139
public async listDirectories(): Promise<ListDirectoriesResponse> {
139-
const endpoint = `/API/v3/directories/`
140+
const endpoint = `/API/${QUALTRICS_API_VERSION}/directories/`
140141
return (await this.makeRequest(endpoint, 'get')).result as ListDirectoriesResponse
141142
}
142143

143144
public async createDirectoryContact(
144145
directoryId: string,
145146
body: CreateDirectoryContactRequest
146147
): Promise<CreateDirectoryContactResponse> {
147-
const endpoint = `/API/v3/directories/${directoryId}/contacts`
148+
const endpoint = `/API/${QUALTRICS_API_VERSION}/directories/${directoryId}/contacts`
148149
return (await this.makeRequest(endpoint, 'post', body)).result as CreateDirectoryContactResponse
149150
}
150151

151152
public async createContactTransaction(
152153
directoryId: string,
153154
body: CreateContactTransactionRequest
154155
): Promise<CreateContactTransactionResponse> {
155-
const endpoint = `/API/v3/directories/${directoryId}/transactions`
156+
const endpoint = `/API/${QUALTRICS_API_VERSION}/directories/${directoryId}/transactions`
156157
return (await this.makeRequest(endpoint, 'post', body)).result as CreateContactTransactionResponse
157158
}
158159

159160
public async searchDirectoryForContact(
160161
directoryId: string,
161162
body: SearchDirectoryForContactRequest
162163
): Promise<SearchDirectoryContactResponse[]> {
163-
const endpoint = `/API/v3/directories/${directoryId}/contacts/search`
164+
const endpoint = `/API/${QUALTRICS_API_VERSION}/directories/${directoryId}/contacts/search`
164165
const filterBody = this.createFilterBody(body)
165166
if (!filterBody) {
166167
return []

packages/destination-actions/src/destinations/reddit-conversions-api/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Settings } from './generated-types'
33
import type { RedditConversionsTestAuthenticationError } from './types'
44
import standardEvent from './standardEvent'
55
import customEvent from './customEvent'
6+
import { REDDIT_CONVERSIONS_API_VERSION } from '../versioning-info'
67

78
const destination: DestinationDefinition<Settings> = {
89
name: 'Reddit Conversions API',
@@ -35,7 +36,7 @@ const destination: DestinationDefinition<Settings> = {
3536
},
3637
testAuthentication: async (request, { settings }) => {
3738
try {
38-
return await request(`https://ads-api.reddit.com/api/v2.0/conversions/events/${settings.ad_account_id}`, {
39+
return await request(`https://ads-api.reddit.com/api/v${REDDIT_CONVERSIONS_API_VERSION}/conversions/events/${settings.ad_account_id}`, {
3940
method: 'POST',
4041
headers: {
4142
Authorization: `Bearer ${settings.conversion_token}`

packages/destination-actions/src/destinations/reddit-conversions-api/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
DatapProcessingOptions
1212
} from './types'
1313
import { processHashing } from '../../lib/hashing-utils'
14+
import { REDDIT_CONVERSIONS_API_VERSION } from '../versioning-info'
1415

1516
type EventMetadataType = StandardEvent['event_metadata'] | CustomEvent['event_metadata']
1617
type ProductsType = StandardEvent['products'] | CustomEvent['products']
@@ -21,7 +22,7 @@ type ScreenDimensionsType = StandardEvent['screen_dimensions'] | CustomEvent['sc
2122

2223
export async function send(request: RequestClient, settings: Settings, payload: StandardEvent[] | CustomEvent[]) {
2324
const data = createRedditPayload(payload, settings)
24-
return request(`https://ads-api.reddit.com/api/v2.0/conversions/events/${settings.ad_account_id}`, {
25+
return request(`https://ads-api.reddit.com/api/v${REDDIT_CONVERSIONS_API_VERSION}/conversions/events/${settings.ad_account_id}`, {
2526
method: 'POST',
2627
headers: { Authorization: `Bearer ${settings.conversion_token}` },
2728
json: JSON.parse(JSON.stringify(data))

packages/destination-actions/src/destinations/sendgrid/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { DestinationDefinition } from '@segment/actions-core'
22
import type { Settings } from './generated-types'
33
import { GLOBAL_ENDPOINT, EU_ENDPOINT } from './sendgrid-properties'
4+
import { SENDGRID_API_VERSION } from '../versioning-info'
45

56
import updateUserProfile from './updateUserProfile'
67

@@ -37,7 +38,7 @@ const destination: DestinationDefinition<Settings> = {
3738
},
3839
testAuthentication: (request, { settings }) => {
3940
const endpoint = settings?.endpoint || GLOBAL_ENDPOINT
40-
return request(`${endpoint}/v3/user/account`)
41+
return request(`${endpoint}/${SENDGRID_API_VERSION}/user/account`)
4142
}
4243
},
4344

packages/destination-actions/src/destinations/snap-conversions-api/reportConversionEvent/snap-capi-v3.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
smartHash
1515
} from './utils'
1616
import { processHashing } from '../../../lib/hashing-utils'
17+
import { SNAP_CONVERSIONS_API_VERSION } from '../../versioning-info'
1718

1819
const CURRENCY_ISO_4217_CODES = new Set([
1920
'USD',
@@ -687,7 +688,7 @@ const buildRequestURL = (settings: Settings, action_source: string | undefined,
687688
})()
688689
)
689690

690-
return `https://tr.snapchat.com/v3/${appOrPixelID}/events?access_token=${authToken}`
691+
return `https://tr.snapchat.com/${SNAP_CONVERSIONS_API_VERSION}/${appOrPixelID}/events?access_token=${authToken}`
691692
}
692693

693694
const validatePayload = (payload: ReturnType<typeof buildPayloadData>) => {

packages/destination-actions/src/destinations/userpilot/request-utils.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { Payload as TrackPayload } from './trackEvent/generated-types'
44
import type { Payload as GroupPayload } from './identifyCompany/generated-types'
55

66
import { RequestOptions } from '@segment/actions-core'
7+
import { USERPILOT_API_VERSION } from '../versioning-info'
78

89
const baseURL = 'https://analytex.userpilot.io/'
910

@@ -14,7 +15,7 @@ interface RequestParams {
1415

1516
export const getDeleteRequestParams = (settings: Settings, userId: string): RequestParams => {
1617
return {
17-
url: `${validateEndpoint(settings.endpoint)}v1/users`,
18+
url: `${validateEndpoint(settings.endpoint)}${USERPILOT_API_VERSION}/users`,
1819
options: {
1920
method: 'DELETE',
2021
json: { users: [userId] }
@@ -24,7 +25,7 @@ export const getDeleteRequestParams = (settings: Settings, userId: string): Requ
2425

2526
export const getValidationParams = (settings: Settings): RequestParams => {
2627
return {
27-
url: `${validateEndpoint(settings.endpoint)}v1/validate`,
28+
url: `${validateEndpoint(settings.endpoint)}${USERPILOT_API_VERSION}/validate`,
2829
options: {
2930
method: 'GET'
3031
}
@@ -35,7 +36,7 @@ export const getIdentifyRequestParams = (settings: Settings, payload: IdentifyPa
3536
const { traits, userId } = payload
3637

3738
return {
38-
url: `${validateEndpoint(settings.endpoint)}v1/identify`,
39+
url: `${validateEndpoint(settings.endpoint)}${USERPILOT_API_VERSION}/identify`,
3940
options: {
4041
method: 'POST',
4142
json: {
@@ -50,7 +51,7 @@ export const getCompanyIdentifyRequestParams = (settings: Settings, payload: Gro
5051
const { traits, groupId } = payload
5152

5253
return {
53-
url: `${validateEndpoint(settings.endpoint)}v1/companies/identify`,
54+
url: `${validateEndpoint(settings.endpoint)}${USERPILOT_API_VERSION}/companies/identify`,
5455
options: {
5556
method: 'POST',
5657
json: {
@@ -64,7 +65,7 @@ export const getCompanyIdentifyRequestParams = (settings: Settings, payload: Gro
6465
export const getTrackEventParams = (settings: Settings, payload: TrackPayload): RequestParams => {
6566
const { userId, name, properties } = payload
6667
return {
67-
url: `${validateEndpoint(settings.endpoint)}v1/track`,
68+
url: `${validateEndpoint(settings.endpoint)}${USERPILOT_API_VERSION}/track`,
6869
options: {
6970
method: 'POST',
7071
json: {

0 commit comments

Comments
 (0)