@adobe/alloy 2.20.0-alpha.0 → 2.20.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/libEs5/components/LegacyMediaAnalytics/createMediaAnalyticsTracker.js +42 -42
- package/libEs5/components/LegacyMediaAnalytics/createMediaHelper.js +163 -157
- package/libEs5/components/LegacyMediaAnalytics/media/constants.js +20 -20
- package/libEs5/components/MediaCollection/{createMediaRequestPayload.js → constants/eventTypes.js} +9 -13
- package/libEs5/components/MediaCollection/createHeartbeatEngine.js +12 -4
- package/libEs5/components/MediaCollection/createMediaEventManager.js +21 -31
- package/libEs5/components/MediaCollection/createMediaSessionCacheManager.js +10 -10
- package/libEs5/components/MediaCollection/createUpdateMediaSessionState.js +3 -7
- package/libEs5/components/MediaCollection/index.js +12 -6
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/utils/validation/index.js +6 -1
- package/{libEs6/components/MediaCollection/createMediaRequestPayload.js → libEs5/utils/validation/matchesRegexpValidator.js} +10 -14
- package/libEs6/components/LegacyMediaAnalytics/createMediaAnalyticsTracker.js +22 -22
- package/libEs6/components/LegacyMediaAnalytics/createMediaHelper.js +163 -150
- package/libEs6/components/LegacyMediaAnalytics/media/constants.js +10 -10
- package/libEs6/components/MediaCollection/constants/eventTypes.js +21 -0
- package/libEs6/components/MediaCollection/createHeartbeatEngine.js +11 -4
- package/libEs6/components/MediaCollection/createMediaEventManager.js +23 -30
- package/libEs6/components/MediaCollection/createMediaSessionCacheManager.js +10 -10
- package/libEs6/components/MediaCollection/createUpdateMediaSessionState.js +2 -8
- package/libEs6/components/MediaCollection/index.js +12 -6
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/utils/validation/index.js +6 -1
- package/libEs6/utils/validation/matchesRegexpValidator.js +17 -0
- package/package.json +2 -2
- package/libEs5/components/MediaCollection/mediaConstants/mediaEvents.js +0 -13
- package/libEs6/components/MediaCollection/mediaConstants/mediaEvents.js +0 -9
|
@@ -11,163 +11,176 @@ governing permissions and limitations under the License.
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { number, objectOf, string } from "../../utils/validation";
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
name: string().nonEmpty(),
|
|
25
|
-
length: number().required(),
|
|
26
|
-
streamType: string().nonEmpty(),
|
|
27
|
-
contentType: string().nonEmpty()
|
|
28
|
-
});
|
|
29
|
-
try {
|
|
30
|
-
const result = validate(mediaObject);
|
|
31
|
-
const sessionDetails = {
|
|
32
|
-
name: result.name,
|
|
33
|
-
friendlyName: result.friendlyName,
|
|
34
|
-
length: result.length,
|
|
35
|
-
streamType: result.streamType,
|
|
36
|
-
contentType: result.contentType
|
|
37
|
-
};
|
|
38
|
-
return {
|
|
39
|
-
sessionDetails
|
|
14
|
+
export default (({
|
|
15
|
+
logger
|
|
16
|
+
}) => {
|
|
17
|
+
const createMediaObject = (friendlyName, name, length, contentType, streamType) => {
|
|
18
|
+
const mediaObject = {
|
|
19
|
+
friendlyName,
|
|
20
|
+
name,
|
|
21
|
+
length,
|
|
22
|
+
streamType,
|
|
23
|
+
contentType
|
|
40
24
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
25
|
+
const validate = objectOf({
|
|
26
|
+
friendlyName: string().nonEmpty(),
|
|
27
|
+
name: string().nonEmpty(),
|
|
28
|
+
length: number().required(),
|
|
29
|
+
streamType: string().nonEmpty(),
|
|
30
|
+
contentType: string().nonEmpty()
|
|
31
|
+
});
|
|
32
|
+
try {
|
|
33
|
+
const result = validate(mediaObject);
|
|
34
|
+
const sessionDetails = {
|
|
35
|
+
name: result.name,
|
|
36
|
+
friendlyName: result.friendlyName,
|
|
37
|
+
length: result.length,
|
|
38
|
+
streamType: result.streamType,
|
|
39
|
+
contentType: result.contentType
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
sessionDetails
|
|
43
|
+
};
|
|
44
|
+
} catch (error) {
|
|
45
|
+
logger.warn(`An error occurred while creating the Media Object.`, error);
|
|
46
|
+
return {};
|
|
47
|
+
}
|
|
50
48
|
};
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
try {
|
|
57
|
-
const result = validator(adBreakObject);
|
|
58
|
-
const advertisingPodDetails = {
|
|
59
|
-
friendlyName: result.friendlyName,
|
|
60
|
-
offset: result.offset,
|
|
61
|
-
index: result.index
|
|
62
|
-
};
|
|
63
|
-
return {
|
|
64
|
-
advertisingPodDetails
|
|
49
|
+
const createAdBreakObject = (name, position, startTime) => {
|
|
50
|
+
const adBreakObject = {
|
|
51
|
+
friendlyName: name,
|
|
52
|
+
offset: position,
|
|
53
|
+
index: startTime
|
|
65
54
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
55
|
+
const validator = objectOf({
|
|
56
|
+
friendlyName: string().nonEmpty(),
|
|
57
|
+
offset: number(),
|
|
58
|
+
index: number()
|
|
59
|
+
});
|
|
60
|
+
try {
|
|
61
|
+
const result = validator(adBreakObject);
|
|
62
|
+
const advertisingPodDetails = {
|
|
63
|
+
friendlyName: result.friendlyName,
|
|
64
|
+
offset: result.offset,
|
|
65
|
+
index: result.index
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
advertisingPodDetails
|
|
69
|
+
};
|
|
70
|
+
} catch (error) {
|
|
71
|
+
logger.warn(`An error occurred while creating the Ad Break Object.`, error);
|
|
72
|
+
return {};
|
|
73
|
+
}
|
|
76
74
|
};
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
try {
|
|
84
|
-
const result = validator(adObject);
|
|
85
|
-
const advertisingDetails = {
|
|
86
|
-
friendlyName: result.friendlyName,
|
|
87
|
-
name: result.name,
|
|
88
|
-
podPosition: result.podPosition,
|
|
89
|
-
length: result.length
|
|
75
|
+
const createAdObject = (name, id, position, length) => {
|
|
76
|
+
const adObject = {
|
|
77
|
+
friendlyName: name,
|
|
78
|
+
name: id,
|
|
79
|
+
podPosition: position,
|
|
80
|
+
length
|
|
90
81
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
82
|
+
const validator = objectOf({
|
|
83
|
+
friendlyName: string().nonEmpty(),
|
|
84
|
+
name: string().nonEmpty(),
|
|
85
|
+
podPosition: number(),
|
|
86
|
+
length: number()
|
|
87
|
+
});
|
|
88
|
+
try {
|
|
89
|
+
const result = validator(adObject);
|
|
90
|
+
const advertisingDetails = {
|
|
91
|
+
friendlyName: result.friendlyName,
|
|
92
|
+
name: result.name,
|
|
93
|
+
podPosition: result.podPosition,
|
|
94
|
+
length: result.length
|
|
95
|
+
};
|
|
96
|
+
return {
|
|
97
|
+
advertisingDetails
|
|
98
|
+
};
|
|
99
|
+
} catch (error) {
|
|
100
|
+
logger.warn(`An error occurred while creating the Advertising Object.`, error);
|
|
101
|
+
return {};
|
|
102
|
+
}
|
|
104
103
|
};
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
try {
|
|
112
|
-
const result = validator(chapterDetailsObject);
|
|
113
|
-
const chapterDetails = {
|
|
114
|
-
friendlyName: result.friendlyName,
|
|
115
|
-
offset: result.offset,
|
|
116
|
-
index: result.index,
|
|
117
|
-
length: result.length
|
|
118
|
-
};
|
|
119
|
-
return {
|
|
120
|
-
chapterDetails
|
|
104
|
+
const createChapterObject = (name, position, length, startTime) => {
|
|
105
|
+
const chapterDetailsObject = {
|
|
106
|
+
friendlyName: name,
|
|
107
|
+
offset: position,
|
|
108
|
+
length,
|
|
109
|
+
index: startTime
|
|
121
110
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
111
|
+
const validator = objectOf({
|
|
112
|
+
friendlyName: string().nonEmpty(),
|
|
113
|
+
offset: number(),
|
|
114
|
+
length: number(),
|
|
115
|
+
index: number()
|
|
116
|
+
});
|
|
117
|
+
try {
|
|
118
|
+
const result = validator(chapterDetailsObject);
|
|
119
|
+
const chapterDetails = {
|
|
120
|
+
friendlyName: result.friendlyName,
|
|
121
|
+
offset: result.offset,
|
|
122
|
+
index: result.index,
|
|
123
|
+
length: result.length
|
|
124
|
+
};
|
|
125
|
+
return {
|
|
126
|
+
chapterDetails
|
|
127
|
+
};
|
|
128
|
+
} catch (error) {
|
|
129
|
+
logger.warn(`An error occurred while creating the Chapter Object.`, error);
|
|
130
|
+
return {};
|
|
131
|
+
}
|
|
130
132
|
};
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
export const createQoEObject = (bitrate, droppedFrames, fps, startupTime) => {
|
|
147
|
-
const qoeObject = {
|
|
148
|
-
bitrate,
|
|
149
|
-
droppedFrames,
|
|
150
|
-
fps,
|
|
151
|
-
startupTime
|
|
133
|
+
const createStateObject = stateName => {
|
|
134
|
+
const STATE_NAME_REGEX = "^[a-zA-Z0-9_]{1,64}$";
|
|
135
|
+
const validator = string().matches(STATE_NAME_REGEX, "This is not a valid state name.");
|
|
136
|
+
try {
|
|
137
|
+
const result = validator(stateName);
|
|
138
|
+
const stateDetails = {
|
|
139
|
+
name: result
|
|
140
|
+
};
|
|
141
|
+
return {
|
|
142
|
+
stateDetails
|
|
143
|
+
};
|
|
144
|
+
} catch (error) {
|
|
145
|
+
logger.warn(`An error occurred while creating the State Object.`, error);
|
|
146
|
+
return {};
|
|
147
|
+
}
|
|
152
148
|
};
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
try {
|
|
160
|
-
const result = validator(qoeObject);
|
|
161
|
-
const qoeDetails = {
|
|
162
|
-
bitrate: result.bitrate,
|
|
163
|
-
droppedFrames: result.droppedFrames,
|
|
164
|
-
fps: result.fps,
|
|
165
|
-
startupTime: result.startupTime
|
|
166
|
-
};
|
|
167
|
-
return {
|
|
168
|
-
qoeDetails
|
|
149
|
+
const createQoEObject = (bitrate, droppedFrames, fps, startupTime) => {
|
|
150
|
+
const qoeObject = {
|
|
151
|
+
bitrate,
|
|
152
|
+
droppedFrames,
|
|
153
|
+
fps,
|
|
154
|
+
startupTime
|
|
169
155
|
};
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
156
|
+
const validator = objectOf({
|
|
157
|
+
bitrate: number(),
|
|
158
|
+
droppedFrames: number(),
|
|
159
|
+
fps: number(),
|
|
160
|
+
startupTime: number()
|
|
161
|
+
});
|
|
162
|
+
try {
|
|
163
|
+
const result = validator(qoeObject);
|
|
164
|
+
const qoeDetails = {
|
|
165
|
+
bitrate: result.bitrate,
|
|
166
|
+
droppedFrames: result.droppedFrames,
|
|
167
|
+
fps: result.fps,
|
|
168
|
+
startupTime: result.startupTime
|
|
169
|
+
};
|
|
170
|
+
return {
|
|
171
|
+
qoeDetails
|
|
172
|
+
};
|
|
173
|
+
} catch (error) {
|
|
174
|
+
logger.warn(`An error occurred while creating the QOE Object.`, error);
|
|
175
|
+
return {};
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
return {
|
|
179
|
+
createMediaObject,
|
|
180
|
+
createAdBreakObject,
|
|
181
|
+
createAdObject,
|
|
182
|
+
createChapterObject,
|
|
183
|
+
createStateObject,
|
|
184
|
+
createQoEObject
|
|
185
|
+
};
|
|
186
|
+
});
|
|
@@ -10,11 +10,11 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
export const
|
|
13
|
+
export const MEDIA_TYPE = {
|
|
14
14
|
Video: "video",
|
|
15
15
|
Audio: "audio"
|
|
16
16
|
};
|
|
17
|
-
export const
|
|
17
|
+
export const STREAM_TYPE = {
|
|
18
18
|
VOD: "vod",
|
|
19
19
|
Live: "live",
|
|
20
20
|
Linear: "linear",
|
|
@@ -22,14 +22,14 @@ export const StreamType = {
|
|
|
22
22
|
Audiobook: "audiobook",
|
|
23
23
|
AOD: "aod"
|
|
24
24
|
};
|
|
25
|
-
export const
|
|
25
|
+
export const PLAYER_STATE = {
|
|
26
26
|
FullScreen: "fullScreen",
|
|
27
27
|
ClosedCaption: "closedCaptioning",
|
|
28
28
|
Mute: "mute",
|
|
29
29
|
PictureInPicture: "pictureInPicture",
|
|
30
30
|
InFocus: "inFocus"
|
|
31
31
|
};
|
|
32
|
-
export const
|
|
32
|
+
export const EVENT = {
|
|
33
33
|
/**
|
|
34
34
|
* Constant defining event type for AdBreak start
|
|
35
35
|
*/
|
|
@@ -91,19 +91,19 @@ export const Event = {
|
|
|
91
91
|
*/
|
|
92
92
|
StateEnd: "stateEnd"
|
|
93
93
|
};
|
|
94
|
-
export const
|
|
94
|
+
export const MEDIA_EVENTS = {
|
|
95
95
|
SessionStart: "sessionStart",
|
|
96
96
|
SessionEnd: "sessionEnd",
|
|
97
97
|
SessionComplete: "sessionComplete",
|
|
98
98
|
Play: "play",
|
|
99
99
|
Pause: "pauseStart",
|
|
100
|
-
...
|
|
100
|
+
...EVENT
|
|
101
101
|
};
|
|
102
|
-
export const
|
|
102
|
+
export const MEDIA_OBJECT_KEYS = {
|
|
103
103
|
MediaResumed: "media.resumed",
|
|
104
104
|
GranularAdTracking: "media.granularadtracking"
|
|
105
105
|
};
|
|
106
|
-
export const
|
|
106
|
+
export const VIDEO_METADATA_KEYS = {
|
|
107
107
|
Show: "a.media.show",
|
|
108
108
|
Season: "a.media.season",
|
|
109
109
|
Episode: "a.media.episode",
|
|
@@ -122,7 +122,7 @@ export const VideoMetadataKeys = {
|
|
|
122
122
|
Feed: "a.media.feed",
|
|
123
123
|
StreamFormat: "a.media.format"
|
|
124
124
|
};
|
|
125
|
-
export const
|
|
125
|
+
export const AUDIO_METADATA_KEYS = {
|
|
126
126
|
Artist: "a.media.artist",
|
|
127
127
|
Album: "a.media.album",
|
|
128
128
|
Label: "a.media.label",
|
|
@@ -130,7 +130,7 @@ export const AudioMetadataKeys = {
|
|
|
130
130
|
Station: "a.media.station",
|
|
131
131
|
Publisher: "a.media.publisher"
|
|
132
132
|
};
|
|
133
|
-
export const
|
|
133
|
+
export const AD_METADATA_KEYS = {
|
|
134
134
|
Advertiser: "a.media.ad.advertiser",
|
|
135
135
|
CampaignId: "a.media.ad.campaign",
|
|
136
136
|
CreativeId: "a.media.ad.creative",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
export default {
|
|
13
|
+
PAUSE: "media.pauseStart",
|
|
14
|
+
PLAY: "media.play",
|
|
15
|
+
BUFFERING: "media.buffering",
|
|
16
|
+
AD_START: "media.adStart",
|
|
17
|
+
SESSION_END: "media.sessionEnd",
|
|
18
|
+
SESSION_START: "media.sessionStart",
|
|
19
|
+
SESSION_COMPLETE: "media.sessionComplete",
|
|
20
|
+
PING: "media.ping"
|
|
21
|
+
};
|
|
@@ -11,6 +11,12 @@ governing permissions and limitations under the License.
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import toInteger from "../../utils/toInteger";
|
|
14
|
+
import MediaEvent from "./constants/eventTypes";
|
|
15
|
+
const ACTION = "ping";
|
|
16
|
+
const getCurrentInterval = playerSession => {
|
|
17
|
+
const currentTime = Date.now();
|
|
18
|
+
return Math.abs(currentTime - playerSession.latestTriggeredEvent) / 1000;
|
|
19
|
+
};
|
|
14
20
|
export default (({
|
|
15
21
|
config,
|
|
16
22
|
mediaEventManager,
|
|
@@ -21,18 +27,18 @@ export default (({
|
|
|
21
27
|
sessionId,
|
|
22
28
|
onBeforeMediaEvent
|
|
23
29
|
}) => {
|
|
24
|
-
const currentTime = Date.now();
|
|
25
30
|
const {
|
|
26
31
|
mainPingInterval
|
|
27
32
|
} = config.mediaCollection;
|
|
28
33
|
const playerSession = mediaSessionCacheManager.getSession(playerId);
|
|
29
|
-
|
|
34
|
+
const currentInterval = getCurrentInterval(playerSession);
|
|
35
|
+
if (currentInterval > mainPingInterval) {
|
|
30
36
|
const {
|
|
31
37
|
playhead,
|
|
32
38
|
qoeDataDetails
|
|
33
39
|
} = onBeforeMediaEvent(playerId);
|
|
34
40
|
const xdm = {
|
|
35
|
-
eventType:
|
|
41
|
+
eventType: MediaEvent.PING,
|
|
36
42
|
mediaCollection: {
|
|
37
43
|
playhead: toInteger(playhead),
|
|
38
44
|
sessionID: sessionId,
|
|
@@ -45,7 +51,8 @@ export default (({
|
|
|
45
51
|
}
|
|
46
52
|
});
|
|
47
53
|
return mediaEventManager.trackMediaEvent({
|
|
48
|
-
event
|
|
54
|
+
event,
|
|
55
|
+
action: ACTION
|
|
49
56
|
}).then(() => {
|
|
50
57
|
mediaSessionCacheManager.updateLastTriggeredEventTS({
|
|
51
58
|
playerId
|
|
@@ -11,11 +11,11 @@ governing permissions and limitations under the License.
|
|
|
11
11
|
*/
|
|
12
12
|
/* eslint-disable import/no-restricted-paths */
|
|
13
13
|
|
|
14
|
-
import MediaEvents from "./
|
|
15
|
-
import createMediaRequestPayload from "./createMediaRequestPayload";
|
|
14
|
+
import MediaEvents from "./constants/eventTypes";
|
|
16
15
|
import createMediaRequest from "./createMediaRequest";
|
|
17
16
|
import injectTimestamp from "../Context/injectTimestamp";
|
|
18
|
-
import {
|
|
17
|
+
import { toInteger } from "../../utils";
|
|
18
|
+
import { createDataCollectionRequestPayload } from "../../utils/request";
|
|
19
19
|
export default (({
|
|
20
20
|
config,
|
|
21
21
|
eventManager,
|
|
@@ -26,14 +26,13 @@ export default (({
|
|
|
26
26
|
createMediaEvent({
|
|
27
27
|
options
|
|
28
28
|
}) {
|
|
29
|
+
const event = eventManager.createEvent();
|
|
29
30
|
const {
|
|
30
|
-
xdm = {}
|
|
31
|
-
} = options;
|
|
32
|
-
const event = {
|
|
33
31
|
xdm
|
|
34
|
-
};
|
|
32
|
+
} = options;
|
|
35
33
|
const timestamp = injectTimestamp(() => new Date());
|
|
36
|
-
timestamp(
|
|
34
|
+
timestamp(xdm);
|
|
35
|
+
event.setUserXdm(xdm);
|
|
37
36
|
return event;
|
|
38
37
|
},
|
|
39
38
|
createMediaSession(options) {
|
|
@@ -43,14 +42,17 @@ export default (({
|
|
|
43
42
|
version
|
|
44
43
|
} = config.mediaCollection;
|
|
45
44
|
const event = eventManager.createEvent();
|
|
45
|
+
const {
|
|
46
|
+
sessionDetails
|
|
47
|
+
} = options.xdm.mediaCollection;
|
|
46
48
|
event.setUserXdm(options.xdm);
|
|
47
49
|
event.mergeXdm({
|
|
48
50
|
eventType: MediaEvents.SESSION_START,
|
|
49
51
|
mediaCollection: {
|
|
50
52
|
sessionDetails: {
|
|
51
|
-
playerName:
|
|
52
|
-
channel:
|
|
53
|
-
appVersion:
|
|
53
|
+
playerName: sessionDetails.playerName || playerName,
|
|
54
|
+
channel: sessionDetails.channel || channel,
|
|
55
|
+
appVersion: sessionDetails.appVersion || version
|
|
54
56
|
}
|
|
55
57
|
}
|
|
56
58
|
});
|
|
@@ -71,24 +73,14 @@ export default (({
|
|
|
71
73
|
} = onBeforeMediaEvent({
|
|
72
74
|
playerId
|
|
73
75
|
});
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
return event;
|
|
82
|
-
}
|
|
83
|
-
return deepAssign(event, {
|
|
84
|
-
xdm: {
|
|
85
|
-
mediaCollection: {
|
|
86
|
-
playhead: toInteger(playhead),
|
|
87
|
-
qoeDataDetails,
|
|
88
|
-
sessionID
|
|
89
|
-
}
|
|
76
|
+
event.mergeXdm({
|
|
77
|
+
mediaCollection: {
|
|
78
|
+
playhead: toInteger(playhead),
|
|
79
|
+
qoeDataDetails,
|
|
80
|
+
sessionID
|
|
90
81
|
}
|
|
91
82
|
});
|
|
83
|
+
return event;
|
|
92
84
|
},
|
|
93
85
|
trackMediaSession({
|
|
94
86
|
event,
|
|
@@ -101,15 +93,16 @@ export default (({
|
|
|
101
93
|
});
|
|
102
94
|
},
|
|
103
95
|
trackMediaEvent({
|
|
104
|
-
event
|
|
96
|
+
event,
|
|
97
|
+
action
|
|
105
98
|
}) {
|
|
106
|
-
const
|
|
107
|
-
const mediaRequestPayload = createMediaRequestPayload();
|
|
99
|
+
const mediaRequestPayload = createDataCollectionRequestPayload();
|
|
108
100
|
const request = createMediaRequest({
|
|
109
101
|
mediaRequestPayload,
|
|
110
102
|
action
|
|
111
103
|
});
|
|
112
104
|
mediaRequestPayload.addEvent(event);
|
|
105
|
+
event.finalize();
|
|
113
106
|
return consent.awaitConsent().then(() => {
|
|
114
107
|
return sendEdgeNetworkRequest({
|
|
115
108
|
request
|
|
@@ -19,30 +19,30 @@ export default (() => {
|
|
|
19
19
|
playerId,
|
|
20
20
|
heartbeatId
|
|
21
21
|
}) => {
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
22
|
+
const sessionDetails = mediaSessionCache[playerId];
|
|
23
|
+
if (!sessionDetails) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
sessionDetails.heartbeatId = heartbeatId;
|
|
27
27
|
};
|
|
28
28
|
const stopHeartbeat = ({
|
|
29
29
|
playerId
|
|
30
30
|
}) => {
|
|
31
|
-
const
|
|
32
|
-
if (!
|
|
31
|
+
const sessionDetails = mediaSessionCache[playerId];
|
|
32
|
+
if (!sessionDetails) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
clearInterval(
|
|
36
|
-
|
|
35
|
+
clearInterval(sessionDetails.heartbeatId);
|
|
36
|
+
sessionDetails.heartbeatId = null;
|
|
37
37
|
};
|
|
38
38
|
const updateLastTriggeredEventTS = ({
|
|
39
39
|
playerId
|
|
40
40
|
}) => {
|
|
41
|
-
const
|
|
42
|
-
if (!
|
|
41
|
+
const sessionDetails = mediaSessionCache[playerId];
|
|
42
|
+
if (!sessionDetails) {
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
sessionDetails.latestTriggeredEvent = Date.now();
|
|
46
46
|
};
|
|
47
47
|
const storeSession = ({
|
|
48
48
|
playerId,
|
|
@@ -10,20 +10,14 @@ OF ANY KIND, either express or implied. See the License for the specific languag
|
|
|
10
10
|
governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import MediaEvents from "./
|
|
13
|
+
import MediaEvents from "./constants/eventTypes";
|
|
14
14
|
export default (({
|
|
15
15
|
mediaSessionCacheManager
|
|
16
16
|
}) => {
|
|
17
17
|
return ({
|
|
18
18
|
playerId,
|
|
19
|
-
|
|
19
|
+
eventType
|
|
20
20
|
}) => {
|
|
21
|
-
if (!playerId) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const {
|
|
25
|
-
eventType
|
|
26
|
-
} = xdm;
|
|
27
21
|
if (eventType === MediaEvents.SESSION_COMPLETE || eventType === MediaEvents.SESSION_END) {
|
|
28
22
|
mediaSessionCacheManager.stopHeartbeat({
|
|
29
23
|
playerId
|
|
@@ -118,26 +118,32 @@ const createMediaCollection = ({
|
|
|
118
118
|
options
|
|
119
119
|
});
|
|
120
120
|
const {
|
|
121
|
-
playerId
|
|
121
|
+
playerId,
|
|
122
|
+
xdm
|
|
122
123
|
} = options;
|
|
124
|
+
const eventType = xdm.eventType;
|
|
125
|
+
const action = eventType.split(".")[1];
|
|
123
126
|
const {
|
|
124
127
|
onBeforeMediaEvent,
|
|
125
128
|
sessionPromise
|
|
126
129
|
} = mediaSessionCacheManager.getSession(playerId);
|
|
127
130
|
sessionPromise.then(result => {
|
|
128
|
-
|
|
131
|
+
mediaEventManager.augmentMediaEvent({
|
|
129
132
|
event,
|
|
130
133
|
playerId,
|
|
131
134
|
onBeforeMediaEvent,
|
|
132
135
|
sessionID: result.sessionId
|
|
133
136
|
});
|
|
134
137
|
return mediaEventManager.trackMediaEvent({
|
|
135
|
-
event
|
|
138
|
+
event,
|
|
139
|
+
action
|
|
136
140
|
}).then(() => {
|
|
137
141
|
updateMediaSessionState({
|
|
138
142
|
playerId,
|
|
139
|
-
|
|
143
|
+
eventType
|
|
140
144
|
});
|
|
145
|
+
}).catch(error => {
|
|
146
|
+
logger.warn(`The Media Event of type ${action} failed.`, error);
|
|
141
147
|
});
|
|
142
148
|
});
|
|
143
149
|
}
|
|
@@ -151,8 +157,8 @@ createMediaCollection.configValidators = objectOf({
|
|
|
151
157
|
channel: string().nonEmpty().required(),
|
|
152
158
|
playerName: string().nonEmpty().required(),
|
|
153
159
|
version: string(),
|
|
154
|
-
mainPingInterval: number().minimum(10).maximum(
|
|
155
|
-
adPingInterval: number().minimum(10).maximum(
|
|
160
|
+
mainPingInterval: number().minimum(10).maximum(50).default(10),
|
|
161
|
+
adPingInterval: number().minimum(10).maximum(50).default(10)
|
|
156
162
|
}).noUnknownFields()
|
|
157
163
|
});
|
|
158
164
|
export default createMediaCollection;
|