Skip to content

Commit 009164e

Browse files
* refactored _build_audience helper so channel_type is handled consistently — maps ios/android/amazon/web → *_channel, falls back to generic channel when omitted/unrecognized
* gave channel_type a default: $.context.device.type and kept it a free string * added a User-Agent header unit test * added batch test for customEvents (was missing) * dropped the BROWSER/serve.ts commit * commented index.ts env-var defaults
1 parent ce7fb7d commit 009164e

5 files changed

Lines changed: 39 additions & 9 deletions

File tree

packages/destination-actions/src/destinations/airship/customEvents/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ const action: ActionDefinition<Settings, Payload> = {
2525
},
2626
channel_type: {
2727
label: 'Channel Type',
28-
description: 'The Airship audience key for the channel type (e.g. android_channel, ios_channel, amazon_channel, web_channel). If omitted, the generic channel key is used and Airship will resolve the type, which may introduce a slight delay.',
28+
description:
29+
'The device type for the Channel ID (e.g. ios, android, amazon, web). Defaults to the device type from the event. If omitted or unrecognized, the generic channel key is used and Airship resolves the type, which may introduce a slight delay.',
2930
type: 'string',
30-
required: false
31+
required: false,
32+
default: {
33+
'@path': '$.context.device.type'
34+
}
3135
},
3236
name: {
3337
label: 'Name',

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ const destination: DestinationDefinition<Settings> = {
2424
label: 'Access Token',
2525
description: 'Create in the Airship Go dashboard in Settings->Partner Integrations->Segment',
2626
type: 'password',
27-
default: process.env.DEFAULT_ACCESS_TOKEN,
27+
// default: process.env.DEFAULT_ACCESS_TOKEN,
2828
required: true
2929
},
3030
app_key: {
3131
label: 'App Key',
3232
description: 'The App Key identifies the Airship Project to which API requests are made.',
3333
type: 'password',
34-
default: process.env.DEFAULT_APP_KEY,
34+
// default: process.env.DEFAULT_APP_KEY,
3535
required: true
3636
},
3737
endpoint: {

packages/destination-actions/src/destinations/airship/manageTags/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ const action: ActionDefinition<Settings, Payload> = {
2424
},
2525
channel_type: {
2626
label: 'Channel Type',
27-
description: 'The Airship audience key for the channel type (e.g. android_channel, ios_channel, amazon_channel). If omitted, the generic channel key is used and Airship will resolve the type, which may introduce a slight delay.',
27+
description:
28+
'The device type for the Channel ID (e.g. ios, android, amazon, web). Defaults to the device type from the event. If omitted or unrecognized, the generic channel key is used and Airship resolves the type, which may introduce a slight delay.',
2829
type: 'string',
29-
required: false
30+
required: false,
31+
default: {
32+
'@path': '$.context.device.type'
33+
}
3034
},
3135
tags: {
3236
label: 'Tag Name',

packages/destination-actions/src/destinations/airship/setAttributes/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ const action: ActionDefinition<Settings, Payload> = {
2626
},
2727
channel_type: {
2828
label: 'Channel Type',
29-
description: 'The Airship audience key for the channel type (e.g. android_channel, ios_channel, amazon_channel, web_channel). If omitted, the generic channel key is used and Airship will resolve the type, which may introduce a slight delay.',
29+
description:
30+
'The device type for the Channel ID (e.g. ios, android, amazon, web). Defaults to the device type from the event. If omitted or unrecognized, the generic channel key is used and Airship resolves the type, which may introduce a slight delay.',
3031
type: 'string',
31-
required: false
32+
required: false,
33+
default: {
34+
'@path': '$.context.device.type'
35+
}
3236
},
3337
occurred: {
3438
label: 'Occurred',

packages/destination-actions/src/destinations/airship/utilities.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,26 @@ export function map_endpoint(region: string) {
232232
}
233233
}
234234

235+
function _channel_type_to_key(channel_type: string): string {
236+
const map: Record<string, string> = {
237+
ios: 'ios_channel',
238+
android: 'android_channel',
239+
amazon: 'amazon_channel',
240+
web: 'web_channel'
241+
}
242+
return map[channel_type.toLowerCase()] ?? 'channel'
243+
}
244+
245+
// Builds the audience identifier object used to target a user, shared across all actions.
246+
// - named_user_id -> { named_user_id }
247+
// - channel_id with channel_type -> platform-specific key, e.g. { ios_channel } (Airship resolves
248+
// the channel directly)
249+
// - channel_id without channel_type -> generic { channel } (Airship resolves the type server-side)
250+
// Used as the `user` object for custom events and the `audience` object for attributes and tags.
235251
function _build_audience(payload: { named_user_id?: string; channel_id?: string; channel_type?: string }): object {
236252
if (payload.channel_id) {
237-
return { [payload.channel_type ?? 'channel']: payload.channel_id }
253+
const key = payload.channel_type ? _channel_type_to_key(payload.channel_type) : 'channel'
254+
return { [key]: payload.channel_id }
238255
}
239256
if (payload.named_user_id) {
240257
return { named_user_id: payload.named_user_id }
@@ -433,6 +450,7 @@ function _extract_country_language(locale: string): string[] {
433450

434451
export const _private = {
435452
_build_audience,
453+
_channel_type_to_key,
436454
_build_custom_event_object,
437455
_build_attributes_object,
438456
_build_attribute,

0 commit comments

Comments
 (0)