|
| 1 | +import type { AudienceDestinationDefinition } from '@segment/actions-core' |
| 2 | +import type { Settings } from './generated-types' |
| 3 | + |
| 4 | +// For an example audience destination, refer to webhook-audiences. The Readme section is under 'Audience Support' |
| 5 | +const destination: AudienceDestinationDefinition<Settings> = { |
| 6 | + name: 'Bing Ads Audiences', |
| 7 | + slug: 'actions-bing-ads-audiences', |
| 8 | + mode: 'cloud', |
| 9 | + |
| 10 | + authentication: { |
| 11 | + scheme: 'oauth2', |
| 12 | + fields: {} |
| 13 | + // testAuthentication: (request) => { |
| 14 | + // // Return a request that tests/validates the user's credentials. |
| 15 | + // // If you do not have a way to validate the authentication fields safely, |
| 16 | + // // you can remove the `testAuthentication` function, though discouraged. |
| 17 | + // }, |
| 18 | + // refreshAccessToken: async (request, { auth }) => { |
| 19 | + // // Return a request that refreshes the access_token if the API supports it |
| 20 | + // const res = await request('https://www.example.com/oauth/refresh', { |
| 21 | + // method: 'POST', |
| 22 | + // body: new URLSearchParams({ |
| 23 | + // refresh_token: auth.refreshToken, |
| 24 | + // client_id: auth.clientId, |
| 25 | + // client_secret: auth.clientSecret, |
| 26 | + // grant_type: 'refresh_token' |
| 27 | + // }) |
| 28 | + // }) |
| 29 | + |
| 30 | + // return { accessToken: res?.data?.access_token } |
| 31 | + // } |
| 32 | + }, |
| 33 | + extendRequest({ auth }) { |
| 34 | + return { |
| 35 | + headers: { |
| 36 | + authorization: `Bearer ${auth?.accessToken}` |
| 37 | + } |
| 38 | + } |
| 39 | + }, |
| 40 | + |
| 41 | + audienceFields: {}, |
| 42 | + |
| 43 | + audienceConfig: { |
| 44 | + mode: { |
| 45 | + type: 'synced', // Indicates that the audience is synced on some schedule; update as necessary |
| 46 | + full_audience_sync: false // If true, we send the entire audience. If false, we just send the delta. |
| 47 | + } |
| 48 | + |
| 49 | + // Get/Create are optional and only needed if you need to create an audience before sending events/users. |
| 50 | + // createAudience: async (request, createAudienceInput) => { |
| 51 | + // // Create an audience through the destination's API |
| 52 | + // // Segment will save this externalId for subsequent calls; the externalId is used to keep track of the audience in our database |
| 53 | + // return {externalId: ''} |
| 54 | + // }, |
| 55 | + |
| 56 | + // getAudience: async (request, getAudienceInput) => { |
| 57 | + // // Right now, `getAudience` will mostly serve as a check to ensure the audience still exists in the destination |
| 58 | + // return {externalId: ''} |
| 59 | + // } |
| 60 | + }, |
| 61 | + |
| 62 | + // onDelete: async (request, { settings, payload }) => { |
| 63 | + // // Return a request that performs a GDPR delete for the provided Segment userId or anonymousId |
| 64 | + // // provided in the payload. If your destination does not support GDPR deletion you should not |
| 65 | + // // implement this function and should remove it completely. |
| 66 | + // }, |
| 67 | + |
| 68 | + actions: {} |
| 69 | +} |
| 70 | + |
| 71 | +export default destination |
0 commit comments