Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import { createHash } from 'crypto'
import { IntegrationError, RetryableError } from '@segment/actions-core'
import type { RequestClient } from '@segment/actions-core'
import { CRITEO_AUDIENCES_API_VERSION } from './versioning-info'

const BASE_API_URL = 'https://api.criteo.com/2023-10'
const BASE_API_URL = `https://api.criteo.com/${CRITEO_AUDIENCES_API_VERSION}`

export const hash = (value: string | undefined): string | undefined => {
if (value === undefined) return
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** CRITEO_AUDIENCES_API_VERSION
* Criteo audience segments base API version.
* API reference: https://developers.criteo.com/marketing-solutions/v2023.10/docs/welcome-to-criteo
*/

export const CRITEO_AUDIENCES_API_VERSION = '2023-10'
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { KLAVIYO_REVISION_DATE } from './versioning-info'

export const API_URL = 'https://a.klaviyo.com/api'
export const REVISION_DATE = '2025-01-15'
export const REVISION_DATE = KLAVIYO_REVISION_DATE
export const COUNTRY_CODES = [
{ label: 'AD - Andorra', value: 'AD' },
{ label: 'AE - United Arab Emirates', value: 'AE' },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** KLAVIYO_REVISION_DATE
* Klaviyo API revision date.
* API reference: https://developers.klaviyo.com/en/reference/api_overview
*/
export const KLAVIYO_REVISION_DATE = '2025-01-15'
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { LAUNCHDARKLY_AUDIENCES_API_VERSION } from './versioning-info'

export const CONSTANTS = {
LD_CLIENT_SDK_BASE_URL: 'https://clientsdk.launchdarkly.com',
LD_API_BASE_URL: 'https://app.launchdarkly.com/api/v2',
LD_API_BASE_URL: `https://app.launchdarkly.com/api/${LAUNCHDARKLY_AUDIENCES_API_VERSION}`,

LD_API_CUSTOM_AUDIENCE_ENDPOINT: '/segment-targets/segment-audiences',
ADD: 'ADD',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** LAUNCHDARKLY_AUDIENCES_API_VERSION
* LaunchDarkly API version.
* API reference: https://launchdarkly.com/docs/api/segments
*/
export const LAUNCHDARKLY_AUDIENCES_API_VERSION = 'v2'
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ActionDefinition, IntegrationError } from '@segment/actions-core'
import type { Settings } from '../generated-types'
import { getEndpointByRegion } from '../regional-endpoints'
import type { Payload } from './generated-types'
import { MOENGAGE_API_VERSION } from '../versioning-info'

const action: ActionDefinition<Settings, Payload> = {
title: 'Identify User',
Expand Down Expand Up @@ -105,7 +106,7 @@ const action: ActionDefinition<Settings, Payload> = {

const endpoint = getEndpointByRegion(settings.region)

return request(`${endpoint}/v1/integrations/segment?appId=${settings.api_id}`, {
return request(`${endpoint}/${MOENGAGE_API_VERSION}/integrations/segment?appId=${settings.api_id}`, {
method: 'post',
json: event,
headers: {
Expand All @@ -115,4 +116,4 @@ const action: ActionDefinition<Settings, Payload> = {
}
}

export default action
export default action
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Settings } from './generated-types'
import trackEvent from './trackEvent'
import identifyUser from './identifyUser'
import { getEndpointByRegion } from './regional-endpoints'
import { MOENGAGE_API_VERSION } from './versioning-info'

const destination: DestinationDefinition<Settings> = {
name: 'Moengage (Actions)',
Expand Down Expand Up @@ -57,7 +58,7 @@ const destination: DestinationDefinition<Settings> = {
},
testAuthentication: (request, { settings }) => {
const endpoint = getEndpointByRegion(settings.region)
return request(`${endpoint}/v1/integrations/segment/auth?appId=${settings.api_id}`, {
return request(`${endpoint}/${MOENGAGE_API_VERSION}/integrations/segment/auth?appId=${settings.api_id}`, {
method: 'get',
headers: {
authorization: `Basic ${Buffer.from(`${settings.api_id}:${settings.api_key}`).toString('base64')}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ActionDefinition, IntegrationError } from '@segment/actions-core'
import type { Settings } from '../generated-types'
import type { Payload } from './generated-types'
import { getEndpointByRegion } from '../regional-endpoints'
import { MOENGAGE_API_VERSION } from '../versioning-info'

const action: ActionDefinition<Settings, Payload> = {
title: 'Track Event',
Expand Down Expand Up @@ -82,14 +83,15 @@ const action: ActionDefinition<Settings, Payload> = {
default: {
'@path': '$.properties'
}
},
},
update_existing_only: {
label: 'Update Existing Users Only',
type: 'boolean',
description: 'If set to true, events from the Segment will only trigger updates for users who already exist in Moengage.',
description:
'If set to true, events from the Segment will only trigger updates for users who already exist in Moengage.',
required: false,
default: false
},
}
},
perform: async (request, { payload, settings }) => {
if (!settings.api_id || !settings.api_key) {
Expand All @@ -109,12 +111,11 @@ const action: ActionDefinition<Settings, Payload> = {
properties: payload.properties,
timestamp: payload.timestamp,
update_existing_only: payload.update_existing_only || false

}

const endpoint = getEndpointByRegion(settings.region)

return request(`${endpoint}/v1/integrations/segment?appId=${settings.api_id}`, {
return request(`${endpoint}/${MOENGAGE_API_VERSION}/integrations/segment?appId=${settings.api_id}`, {
method: 'post',
json: event,
headers: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** MOENGAGE_API_VERSION
* MoEngage integrations API version.
* Private API
*/
export const MOENGAGE_API_VERSION = 'v1'
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { DestinationDefinition } from '@segment/actions-core'
import { InvalidAuthenticationError } from '@segment/actions-core'
import type { Settings } from './generated-types'
import { OPTIMIZELY_FEATURE_EXPERIMENTATION_DELETE_API_VERSION } from './versioning-info'

import trackEvent from './trackEvent'

Expand Down Expand Up @@ -47,16 +48,19 @@ const destination: DestinationDefinition<Settings> = {
throw new InvalidAuthenticationError('Access Token is required for user deletion.')
}

return request('https://api.optimizely.com/v2/subject-access-requests', {
method: 'post',
headers: { Authorization: `Bearer ${settings?.accessToken}` },
json: {
data_type: 'visitor',
identifier: settings.accountId,
identifier_type: 'dcp_id',
request_type: 'delete'
return request(
`https://api.optimizely.com/${OPTIMIZELY_FEATURE_EXPERIMENTATION_DELETE_API_VERSION}/subject-access-requests`,
{
method: 'post',
headers: { Authorization: `Bearer ${settings?.accessToken}` },
json: {
data_type: 'visitor',
identifier: settings.accountId,
identifier_type: 'dcp_id',
request_type: 'delete'
}
}
})
)
},

actions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { Payload } from './generated-types'
import { ProjectConfig } from '../types'
import { buildVisitorAttributes, getEventId, getEventKeys, isValidJson } from './functions'
import dayjs from '../../../lib/dayjs'
import { OPTIMIZELY_FEATURE_EXPERIMENTATION_TRACK_API_VERSION } from '../versioning-info'

const action: ActionDefinition<Settings, Payload> = {
title: 'Track Event',
Expand Down Expand Up @@ -155,7 +156,7 @@ const action: ActionDefinition<Settings, Payload> = {
})
}

return await request('https://logx.optimizely.com/v1/events', {
return await request(`https://logx.optimizely.com/${OPTIMIZELY_FEATURE_EXPERIMENTATION_TRACK_API_VERSION}/events`, {
method: 'POST',
json: {
account_id: dataFile.accountId,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** OPTIMIZELY_FEATURE_EXPERIMENTATION_DELETE_API_VERSION
* Optimizely Feature Experimentation GDPR delete API version.
* API reference: https://docs.developers.optimizely.com/web-experimentation/reference/update_sar_request_by_post
*/
export const OPTIMIZELY_FEATURE_EXPERIMENTATION_DELETE_API_VERSION = 'v2'

/** OPTIMIZELY_FEATURE_EXPERIMENTATION_TRACK_API_VERSION
* Optimizely Feature Experimentation track events API version.
* API reference: https://docs.developers.optimizely.com/experimentation-data/reference/post_events
*/
export const OPTIMIZELY_FEATURE_EXPERIMENTATION_TRACK_API_VERSION = 'v1'
Loading