Skip to content

Commit cda80e1

Browse files
Copilotabhandage
andcommitted
Add 6 more destinations to centralized versioning-info.ts
Added: - aampe (v1) - livelike-cloud (v1) - sendgrid-audiences (v3) - ms-bing-capi (v1) - snap-audiences (v1) - reddit-audiences (v1 auth, v3 ads) Co-authored-by: abhandage <174417010+abhandage@users.noreply.github.com>
1 parent e392940 commit cda80e1

File tree

11 files changed

+67
-21
lines changed

11 files changed

+67
-21
lines changed
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
import { AAMPE_API_VERSION } from '../versioning-info'
12

2-
export const SingaporeURL = 'https://ingestion-service-asia-southeast1-toqowp62ka-as.a.run.app/v1/'
3-
export const GermanyURL = 'https://ingestion-service-europe-west3-toqowp62ka-ey.a.run.app/v1/'
4-
export const FranceURL = 'https://ingestion-service-europe-west9-toqowp62ka-ey.a.run.app/v1/'
3+
export const SingaporeURL = `https://ingestion-service-asia-southeast1-toqowp62ka-as.a.run.app/${AAMPE_API_VERSION}/`
4+
export const GermanyURL = `https://ingestion-service-europe-west3-toqowp62ka-ey.a.run.app/${AAMPE_API_VERSION}/`
5+
export const FranceURL = `https://ingestion-service-europe-west9-toqowp62ka-ey.a.run.app/${AAMPE_API_VERSION}/`
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export const apiBaseUrl = 'https://cf-blast.livelikecdn.com/api/v1'
1+
import { LIVELIKE_CLOUD_API_VERSION } from '../versioning-info'
2+
3+
export const apiBaseUrl = `https://cf-blast.livelikecdn.com/api/${LIVELIKE_CLOUD_API_VERSION}`

packages/destination-actions/src/destinations/ms-bing-capi/sendEvent/constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export const API_URL = `https://capi.uet.microsoft.com/v1/`
1+
import { MS_BING_CAPI_API_VERSION } from '../versioning-info'
2+
3+
export const API_URL = `https://capi.uet.microsoft.com/${MS_BING_CAPI_API_VERSION}/`
24

35
export const CURRENCY_ISO_CODES = new Set([
46
'AED',
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { REDDIT_AUDIENCES_AUTH_API_VERSION, REDDIT_AUDIENCES_ADS_API_VERSION } from '../versioning-info'
2+
3+
export const REDDIT_AUTH_BASE_URL = `https://www.reddit.com/api/${REDDIT_AUDIENCES_AUTH_API_VERSION}`
4+
export const REDDIT_ADS_BASE_URL = `https://ads-api.reddit.com/api/${REDDIT_AUDIENCES_ADS_API_VERSION}`

packages/destination-actions/src/destinations/reddit-audiences/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { defaultValues, AudienceDestinationDefinition } from '@segment/actions-c
22
import type { Settings, AudienceSettings } from './generated-types'
33
import syncAudience from './syncAudience'
44
import { CreateAudienceReq, CreateAudienceResp } from './types'
5+
import { REDDIT_AUTH_BASE_URL, REDDIT_ADS_BASE_URL } from './constants'
56

67
const destination: AudienceDestinationDefinition<Settings, AudienceSettings> = {
78
name: 'Reddit Audiences',
@@ -20,7 +21,7 @@ const destination: AudienceDestinationDefinition<Settings, AudienceSettings> = {
2021
refreshAccessToken: async (request, { auth }) => {
2122
const authToken = Buffer.from(`${auth.clientId}:${auth.clientSecret}`).toString('base64')
2223

23-
const res = await request('https://www.reddit.com/api/v1/access_token', {
24+
const res = await request(`${REDDIT_AUTH_BASE_URL}/access_token`, {
2425
method: 'POST',
2526
headers: {
2627
Authorization: `Basic ${authToken}`,
@@ -59,7 +60,7 @@ const destination: AudienceDestinationDefinition<Settings, AudienceSettings> = {
5960
},
6061
async createAudience(request, createAudienceInput) {
6162
const response = await request<CreateAudienceResp>(
62-
`https://ads-api.reddit.com/api/v3/ad_accounts/${createAudienceInput.settings.ad_account_id}/custom_audiences`,
63+
`${REDDIT_ADS_BASE_URL}/ad_accounts/${createAudienceInput.settings.ad_account_id}/custom_audiences`,
6364
{
6465
method: 'POST',
6566
headers: {

packages/destination-actions/src/destinations/reddit-audiences/syncAudience/functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function getColumns(payloads: Payload[]): Columns {
8989
}
9090

9191
async function updateAudience(request: RequestClient, json: UpdateAudienceReq, audienceid: string) {
92-
return await request<UpdateAudienceReq>(`https://ads-api.reddit.com/api/v3/custom_audiences/${audienceid}/users`, {
92+
return await request<UpdateAudienceReq>(`${REDDIT_ADS_BASE_URL}/custom_audiences/${audienceid}/users`, {
9393
method: 'PATCH',
9494
json
9595
})
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1+
import { SENDGRID_AUDIENCES_API_VERSION } from '../versioning-info'
2+
13
export const MAX_BATCH_SIZE = 100
24

3-
export const GET_LIST_URL = 'https://api.sendgrid.com/v3/marketing/lists'
5+
export const GET_LIST_URL = `https://api.sendgrid.com/${SENDGRID_AUDIENCES_API_VERSION}/marketing/lists`
46

5-
export const CREATE_LIST_URL = 'https://api.sendgrid.com/v3/marketing/lists'
7+
export const CREATE_LIST_URL = `https://api.sendgrid.com/${SENDGRID_AUDIENCES_API_VERSION}/marketing/lists`
68

7-
export const UPSERT_CONTACTS_URL = 'https://api.sendgrid.com/v3/marketing/contacts'
9+
export const UPSERT_CONTACTS_URL = `https://api.sendgrid.com/${SENDGRID_AUDIENCES_API_VERSION}/marketing/contacts`
810

9-
export const REMOVE_CONTACTS_FROM_LIST_URL =
10-
'https://api.sendgrid.com/v3/marketing/lists/{list_id}/contacts?contact_ids={contact_ids}'
11+
export const REMOVE_CONTACTS_FROM_LIST_URL = `https://api.sendgrid.com/${SENDGRID_AUDIENCES_API_VERSION}/marketing/lists/{list_id}/contacts?contact_ids={contact_ids}`
1112

1213
export const MAX_CHUNK_SIZE_REMOVE = 100
1314

14-
export const GET_CONTACT_BY_EMAIL_URL = 'https://api.sendgrid.com/v3/marketing/contacts/search/emails'
15+
export const GET_CONTACT_BY_EMAIL_URL = `https://api.sendgrid.com/${SENDGRID_AUDIENCES_API_VERSION}/marketing/contacts/search/emails`
1516

16-
export const SEARCH_CONTACTS_URL = 'https://api.sendgrid.com/v3/marketing/contacts/search'
17+
export const SEARCH_CONTACTS_URL = `https://api.sendgrid.com/${SENDGRID_AUDIENCES_API_VERSION}/marketing/contacts/search`
1718

1819
export const MAX_CHUNK_SIZE_SEARCH = 50
1920

20-
export const GET_CUSTOM_FIELDS_URL = 'https://api.sendgrid.com/v3/marketing/field_definitions'
21+
export const GET_CUSTOM_FIELDS_URL = `https://api.sendgrid.com/${SENDGRID_AUDIENCES_API_VERSION}/marketing/field_definitions`
2122

2223
export const E164_REGEX = /^\+[1-9]\d{1,14}$/
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { SNAP_AUDIENCES_API_VERSION } from '../versioning-info'
2+
13
export const ACCESS_TOKEN_URL = 'https://accounts.snapchat.com/login/oauth2/access_token'
24

3-
export const DEFAULT_RETENTION_DAYS = 9999
5+
export const DEFAULT_RETENTION_DAYS = 9999
6+
export const SNAP_AUDIENCES_BASE_URL = `https://adsapi.snapchat.com/${SNAP_AUDIENCES_API_VERSION}`

packages/destination-actions/src/destinations/snap-audiences/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { AudienceDestinationDefinition, defaultValues, IntegrationError } from '
22
import type { Settings, AudienceSettings } from './generated-types'
33
import syncAudience from './syncAudience'
44
import { CreateAudienceReq, RefreshTokenResponse, SnapAudienceResponse } from './types'
5-
import { ACCESS_TOKEN_URL, DEFAULT_RETENTION_DAYS } from './constants'
5+
import { ACCESS_TOKEN_URL, DEFAULT_RETENTION_DAYS, SNAP_AUDIENCES_BASE_URL } from './constants'
66

77
const destination: AudienceDestinationDefinition<Settings, AudienceSettings> = {
88
name: 'Snap Audiences (Actions)',
@@ -140,7 +140,7 @@ const destination: AudienceDestinationDefinition<Settings, AudienceSettings> = {
140140
]
141141
}
142142

143-
const response = await request<SnapAudienceResponse>(`https://adsapi.snapchat.com/v1/adaccounts/${ad_account_id}/segments`, {
143+
const response = await request<SnapAudienceResponse>(`${SNAP_AUDIENCES_BASE_URL}/adaccounts/${ad_account_id}/segments`, {
144144
method: 'POST',
145145
json
146146
})
@@ -149,7 +149,7 @@ const destination: AudienceDestinationDefinition<Settings, AudienceSettings> = {
149149
},
150150

151151
getAudience: async (request, { externalId }) => {
152-
const response = await request<SnapAudienceResponse>(`https://adsapi.snapchat.com/v1/segments/${externalId}`, {
152+
const response = await request<SnapAudienceResponse>(`${SNAP_AUDIENCES_BASE_URL}/segments/${externalId}`, {
153153
method: 'GET'
154154
})
155155

packages/destination-actions/src/destinations/snap-audiences/syncAudience/functions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { processHashing } from '../../../lib/hashing-utils'
33
import { RequestClient, MultiStatusResponse } from '@segment/actions-core'
44
import { PayloadWithIndex, AddRemoveUsersJSON, SchemaType, OperationType } from './types'
55
import { SCHEMA_TYPES } from './constants'
6+
import { SNAP_AUDIENCES_BASE_URL } from '../constants'
67

78
export async function send(request: RequestClient, payload: Payload[]) {
89
const payloads: PayloadWithIndex[] = payload.map((p, index) => ({ ...p, index }))
@@ -44,7 +45,7 @@ export async function send(request: RequestClient, payload: Payload[]) {
4445
}
4546
)
4647

47-
const url = `https://adsapi.snapchat.com/v1/segments/${external_audience_id}/users`
48+
const url = `${SNAP_AUDIENCES_BASE_URL}/segments/${external_audience_id}/users`
4849
await Promise.all(Object.entries(batches)
4950
.filter(([, batch]) => batch.opPayloads.length > 0)
5051
.map(async ([, batch]) => {

0 commit comments

Comments
 (0)