Skip to content

Commit fe4d452

Browse files
authored
add support for snake_case for contentAssetId in Adobe Heartbeat (#692)
* add support for snake_case for contentAssetId in Adobe Heartbeat * prefer camelCase over snake_case instead
1 parent c480d0d commit fe4d452

File tree

5 files changed

+64
-17
lines changed

5 files changed

+64
-17
lines changed

.vscode/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Launch Chrome",
9+
"type": "chrome",
10+
"request": "launch",
11+
"url": "http://localhost:8080/"
12+
},
13+
]
14+
}

integrations/adobe-analytics/HISTORY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
1.16.6 / 2022-07-26
2+
===================
3+
* Drop support for `assetId` for `StandardVideoMetadata`
4+
* Add support for `content_asset_id` for `StandardVideoMetadata`
5+
16
1.16.5 / 2022-02-15
27
===================
38
* Bump @segment/trample to ^0.2.1.

integrations/adobe-analytics/lib/index.js

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,23 +1497,30 @@ function createStandardVideoMetadata(track, mediaObj) {
14971497
var props = track.properties();
14981498
var metaKeys = videoAnalytics.MediaHeartbeat.VideoMetadataKeys;
14991499
var stdVidMeta = {};
1500-
var segAdbMap = {
1501-
program: metaKeys.SHOW,
1502-
season: metaKeys.SEASON,
1503-
episode: metaKeys.EPISODE,
1504-
assetId: metaKeys.ASSET_ID,
1505-
contentAssetId: metaKeys.ASSET_ID,
1506-
genre: metaKeys.GENRE,
1507-
airdate: metaKeys.FIRST_AIR_DATE,
1508-
publisher: metaKeys.ORIGINATOR,
1509-
channel: metaKeys.NETWORK,
1510-
rating: metaKeys.RATING
1511-
};
1500+
var adbSegMap = {}
1501+
adbSegMap[metaKeys.SHOW] = ["program"],
1502+
adbSegMap[metaKeys.SEASON] = ["season"],
1503+
adbSegMap[metaKeys.EPISODE] = ["episode"],
1504+
adbSegMap[metaKeys.ASSET_ID] = ["contentAssetId", "content_asset_id"],
1505+
adbSegMap[metaKeys.GENRE] = ["genre"],
1506+
adbSegMap[metaKeys.FIRST_AIR_DATE] = ["airdate"],
1507+
adbSegMap[metaKeys.ORIGINATOR] = ["publisher"],
1508+
adbSegMap[metaKeys.NETWORK] = ["channel"],
1509+
adbSegMap[metaKeys.RATING] = ["rating"]
1510+
1511+
// Iterate over each Adobe property and check our props to see if the corresponding Segment property exists.
1512+
for (var adbProp in adbSegMap) {
1513+
for (var i = 0; i < adbSegMap[adbProp].length; i++) {
1514+
var segProp = adbSegMap[adbProp][i];
1515+
if (props[segProp]) {
1516+
stdVidMeta[adbProp] = props[segProp];
1517+
break;
1518+
}
1519+
}
15121520

1513-
// eslint-disable-next-line
1514-
for (var prop in segAdbMap) {
1515-
// If the property exists on the Segment object, set the Adobe metadata key to that value.
1516-
stdVidMeta[segAdbMap[prop]] = props[prop] || 'no ' + segAdbMap[prop];
1521+
if (!stdVidMeta[adbProp]) {
1522+
stdVidMeta[adbProp] = 'no ' + adbProp
1523+
}
15171524
}
15181525

15191526
mediaObj.setValue(

integrations/adobe-analytics/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@segment/analytics.js-integration-adobe-analytics",
33
"description": "The Adobe Analytics analytics.js integration.",
4-
"version": "1.16.5",
4+
"version": "1.16.6",
55
"keywords": [
66
"analytics.js",
77
"analytics.js-integration",

integrations/adobe-analytics/test/index.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,27 @@ describe('Adobe Analytics', function() {
16541654
);
16551655
});
16561656

1657+
it('should prefer camelCase over snake_case for contentAssetId', function() {
1658+
var contentAssetIdValue = 'Good Value';
1659+
analytics.track('Video Playback Started', {
1660+
session_id: sessionId,
1661+
channel: 'Black Mesa',
1662+
video_player: 'Transit Announcement System',
1663+
playhead: 5,
1664+
content_asset_id: 'wrong value',
1665+
contentAssetId: contentAssetIdValue,
1666+
title: 'Half-Life',
1667+
total_length: 1260,
1668+
livestream: false
1669+
});
1670+
1671+
analytics.equal(
1672+
contentAssetIdValue,
1673+
adobeAnalytics.mediaHeartbeats[sessionId].heartbeat._aaPlugin
1674+
._videoMetadata['a.media.asset']
1675+
);
1676+
});
1677+
16571678
it('should call trackPause when a video is paused', function() {
16581679
analytics.track('Video Playback Started', {
16591680
session_id: sessionId,

0 commit comments

Comments
 (0)