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 @@ -299,11 +299,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,6 +182,7 @@ const action: ActionDefinition<Settings, Payload> = {
referrer,
min_id_length,
library,
library2,
...rest
} = omit(payload, revenueKeys)
const properties = rest as AmplitudeEvent
Expand All @@ -194,7 +195,7 @@ const action: ActionDefinition<Settings, Payload> = {
if (library === 'analytics.js' && !properties.platform) {
properties.platform = 'Web'
}

if (time && dayjs.utc(time).isValid()) {
properties.time = dayjs.utc(time).valueOf()
}
Expand Down Expand Up @@ -222,7 +223,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,6 +223,7 @@ const action: ActionDefinition<Settings, Payload> = {
userAgentData,
min_id_length,
library,
library2,
setOnce,
setAlways,
add,
Expand Down Expand Up @@ -271,7 +272,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,6 +234,7 @@ const action: ActionDefinition<Settings, Payload> = {
referrer,
min_id_length,
library,
library2,
...rest
} = omit(payload, revenueKeys)
const properties = rest as AmplitudeEvent
Expand Down Expand Up @@ -276,7 +277,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 +289,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