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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,41 @@ export const eventSchema: Record<string, InputField> = {
}
},
platform: {
label: 'Platform',
label: 'HIDDEN: Platform',
type: 'string',
unsafe_hidden: true,
description:
'Platform of the device. If using analytics.js to send events from a Browser and no if no Platform value is provided, the value "Web" will be sent.',
'Hidden: Platform of the device. If using analytics.js to send events from a Browser and no if no Platform value is provided, the value "Web" will be sent.',
default: {
'@path': '$.context.device.type'
}
},
platform2: {
label: 'Platform Settings',
type: 'object',
description: 'Specifies the "platform" value to send to Amplitude. Select "Use Mapping" to set the value using the "Platform Mapping" field. "Legacy Behaviour" sets the value to "iOS", "Android" or "Web" based on values in the Segment event payload.',
defaultObjectUI: 'keyvalue',
properties: {
behavior: {
label: 'Behavior',
description: 'Configure how to set the platform value.',
type: 'string',
choices: [
{ label: 'Auto', value: 'auto' },
{ label: 'Use Mapping', value: 'use_mapping' }
]
},
mapping: {
label: 'Platform Mapping',
description: 'The platform value to send to Amplitude. Only used when the "Behavior" field is set to "Use Mapping".',
type: 'string'
}
},
default: {
behavior: 'auto',
mapping: { '@path': '$.context.device.type' }
}
},
os_name: {
label: 'OS Name',
type: 'string',
Expand Down Expand Up @@ -299,11 +326,39 @@ export const eventSchema: Record<string, InputField> = {
'Amplitude will deduplicate subsequent events sent with this ID we have already seen before within the past 7 days. Amplitude recommends generating a UUID or using some combination of device ID, user ID, event type, event ID, and time.'
},
library: {
label: 'Library',
// hiding this field as it was the value from the field was never used correctly and has created confusion with users.
label: 'HIDDEN: Library',
type: 'string',
description: 'The name of the library that generated the event.',
description: 'HIDDEN: The name of the library that generated the event.',
unsafe_hidden: true,
default: {
'@path': '$.context.library.name'
}
},
library2: {
label: 'Library Settings',
type: 'object',
description: 'Specifies the "library" value to send to Amplitude. Select "Use Mapping" to set the value from the "Library Mapping" field. "Legacy Behaviour" sets the value to "segment".',
defaultObjectUI: 'keyvalue',
properties: {
behavior: {
label: 'Behavior',
description: 'Configure how to set the library value.',
type: 'string',
choices: [
{ label: 'Auto', value: 'auto' },
{ label: 'Use Mapping', value: 'use_mapping' }
],
},
mapping: {
label: 'Library Mapping',
description: 'The library value to send to Amplitude. Only used when the "Behavior" field is set to "Use Mapping".',
type: 'string'
}
},
default: {
behavior: 'use_mapping',
mapping: { '@path': '$.context.library.name' }
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,25 @@ const action: ActionDefinition<Settings, Payload> = {
referrer,
min_id_length,
library,
library2,
platform2,
...rest
} = omit(payload, revenueKeys)
const properties = rest as AmplitudeEvent
let options

if (properties.platform) {
properties.platform = properties.platform.replace(/ios/i, 'iOS').replace(/android/i, 'Android')
}
if(platform2?.behavior !== 'use_mapping') {
// auto behavior
if (properties.platform) {
properties.platform = properties.platform.replace(/ios/i, 'iOS').replace(/android/i, 'Android')
}

if (library === 'analytics.js' && !properties.platform) {
properties.platform = 'Web'
if (library === 'analytics.js' && !properties.platform) {
properties.platform = 'Web'
}
}
else {
properties.platform = platform2?.mapping
}

if (time && dayjs.utc(time).isValid()) {
Expand Down Expand Up @@ -222,7 +230,7 @@ const action: ActionDefinition<Settings, Payload> = {
...(includeRawUserAgent && { user_agent: userAgent }),
// Make sure any top-level properties take precedence over user-agent properties
...removeUndefined(properties),
library: 'segment'
library: library2?.behavior === 'use_mapping' ? library2.mapping : 'segment'
}
]

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -223,20 +223,28 @@ const action: ActionDefinition<Settings, Payload> = {
userAgentData,
min_id_length,
library,
library2,
setOnce,
setAlways,
add,
platform2,
...rest
} = omit(payload, revenueKeys)
const properties = rest as AmplitudeEvent
let options

if (properties.platform) {
properties.platform = properties.platform.replace(/ios/i, 'iOS').replace(/android/i, 'Android')
}
if(platform2?.behavior !== 'use_mapping') {
// auto behavior
if (properties.platform) {
properties.platform = properties.platform.replace(/ios/i, 'iOS').replace(/android/i, 'Android')
}

if (library === 'analytics.js' && !properties.platform) {
properties.platform = 'Web'
if (library === 'analytics.js' && !properties.platform) {
properties.platform = 'Web'
}
}
else {
properties.platform = platform2?.mapping
}

if (time && dayjs.utc(time).isValid()) {
Expand Down Expand Up @@ -271,7 +279,7 @@ const action: ActionDefinition<Settings, Payload> = {
...(includeRawUserAgent && { user_agent: userAgent }),
// Make sure any top-level properties take precedence over user-agent properties
...removeUndefined(properties),
library: 'segment'
library: library2?.behavior === 'use_mapping' ? library2.mapping : 'segment'
}
]

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,25 @@ const action: ActionDefinition<Settings, Payload> = {
referrer,
min_id_length,
library,
library2,
platform2,
...rest
} = omit(payload, revenueKeys)
const properties = rest as AmplitudeEvent
let options

if (properties.platform) {
properties.platform = properties.platform.replace(/ios/i, 'iOS').replace(/android/i, 'Android')
}
if(platform2?.behavior !== 'use_mapping') {
// auto behavior
if (properties.platform) {
properties.platform = properties.platform.replace(/ios/i, 'iOS').replace(/android/i, 'Android')
}

if (library === 'analytics.js' && !properties.platform) {
properties.platform = 'Web'
if (library === 'analytics.js' && !properties.platform) {
properties.platform = 'Web'
}
}
else {
properties.platform = platform2?.mapping
}

if (time && dayjs.utc(time).isValid()) {
Expand Down Expand Up @@ -276,7 +284,7 @@ const action: ActionDefinition<Settings, Payload> = {
...removeUndefined(properties),
// Conditionally track revenue with main event
...(products.length && trackRevenuePerProduct ? {} : getRevenueProperties(payload)),
library: 'segment'
library: library2?.behavior === 'use_mapping' ? library2.mapping : 'segment'
}
]

Expand All @@ -288,7 +296,7 @@ const action: ActionDefinition<Settings, Payload> = {
event_properties: product,
event_type: 'Product Purchased',
insert_id: properties.insert_id ? `${properties.insert_id}-${events.length + 1}` : undefined,
library: 'segment'
library: library2?.behavior === 'use_mapping' ? library2.mapping : 'segment'
})
}

Expand Down
Loading