@adobe/alloy 2.19.1-beta.0 → 2.20.0-alpha.0
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 +272 -0
- package/libEs5/components/LegacyMediaAnalytics/createMediaHelper.js +182 -0
- package/libEs5/components/LegacyMediaAnalytics/index.js +48 -0
- package/libEs5/components/LegacyMediaAnalytics/media/constants.js +154 -0
- package/libEs5/components/LegacyMediaAnalytics/media/mediaKeysToXdmConverter.js +51 -0
- package/libEs5/components/MediaCollection/createHeartbeatEngine.js +55 -0
- package/libEs5/components/MediaCollection/createMediaEventManager.js +119 -0
- package/libEs5/components/MediaCollection/createMediaRequest.js +30 -0
- package/libEs5/components/MediaCollection/createMediaRequestPayload.js +29 -0
- package/libEs5/components/MediaCollection/createMediaSessionCacheManager.js +62 -0
- package/libEs5/components/MediaCollection/createUpdateMediaSessionState.js +35 -0
- package/libEs5/components/MediaCollection/index.js +159 -0
- package/libEs5/components/MediaCollection/mediaConstants/mediaEvents.js +13 -0
- package/libEs5/components/MediaCollection/validateMediaEventOptions.js +35 -0
- package/libEs5/components/MediaCollection/validateMediaSessionOptions.js +36 -0
- package/libEs5/constants/libraryVersion.js +1 -1
- package/libEs5/core/componentCreators.js +3 -1
- package/libEs5/core/edgeNetwork/injectSendEdgeNetworkRequest.js +1 -1
- package/libEs5/utils/request/createRequest.js +8 -1
- package/libEs5/utils/validation/createMaximumValidator.js +22 -0
- package/libEs5/utils/validation/index.js +5 -0
- package/libEs6/components/LegacyMediaAnalytics/createMediaAnalyticsTracker.js +276 -0
- package/libEs6/components/LegacyMediaAnalytics/createMediaHelper.js +173 -0
- package/libEs6/components/LegacyMediaAnalytics/index.js +45 -0
- package/libEs6/components/LegacyMediaAnalytics/media/constants.js +140 -0
- package/libEs6/components/LegacyMediaAnalytics/media/mediaKeysToXdmConverter.js +46 -0
- package/libEs6/components/MediaCollection/createHeartbeatEngine.js +57 -0
- package/libEs6/components/MediaCollection/createMediaEventManager.js +122 -0
- package/libEs6/components/MediaCollection/createMediaRequest.js +28 -0
- package/libEs6/components/MediaCollection/createMediaRequestPayload.js +26 -0
- package/libEs6/components/MediaCollection/createMediaSessionCacheManager.js +63 -0
- package/libEs6/components/MediaCollection/createUpdateMediaSessionState.js +36 -0
- package/libEs6/components/MediaCollection/index.js +158 -0
- package/libEs6/components/MediaCollection/mediaConstants/mediaEvents.js +9 -0
- package/libEs6/components/MediaCollection/validateMediaEventOptions.js +32 -0
- package/libEs6/components/MediaCollection/validateMediaSessionOptions.js +34 -0
- package/libEs6/constants/libraryVersion.js +1 -1
- package/libEs6/core/componentCreators.js +3 -1
- package/libEs6/core/edgeNetwork/injectSendEdgeNetworkRequest.js +1 -1
- package/libEs6/utils/request/createRequest.js +8 -1
- package/libEs6/utils/validation/createMaximumValidator.js +16 -0
- package/libEs6/utils/validation/index.js +5 -0
- package/package.json +2 -2
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _toInteger = require("../../utils/toInteger");
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
7
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var _default = function _default(_ref) {
|
|
17
|
+
var config = _ref.config,
|
|
18
|
+
mediaEventManager = _ref.mediaEventManager,
|
|
19
|
+
mediaSessionCacheManager = _ref.mediaSessionCacheManager;
|
|
20
|
+
return function (_ref2) {
|
|
21
|
+
var playerId = _ref2.playerId,
|
|
22
|
+
sessionId = _ref2.sessionId,
|
|
23
|
+
onBeforeMediaEvent = _ref2.onBeforeMediaEvent;
|
|
24
|
+
var currentTime = Date.now();
|
|
25
|
+
var mainPingInterval = config.mediaCollection.mainPingInterval;
|
|
26
|
+
var playerSession = mediaSessionCacheManager.getSession(playerId);
|
|
27
|
+
if (Math.abs(currentTime - playerSession.latestTriggeredEvent) / 1000 > mainPingInterval) {
|
|
28
|
+
var _onBeforeMediaEvent = onBeforeMediaEvent(playerId),
|
|
29
|
+
playhead = _onBeforeMediaEvent.playhead,
|
|
30
|
+
qoeDataDetails = _onBeforeMediaEvent.qoeDataDetails;
|
|
31
|
+
var xdm = {
|
|
32
|
+
eventType: "media.ping",
|
|
33
|
+
mediaCollection: {
|
|
34
|
+
playhead: (0, _toInteger.default)(playhead),
|
|
35
|
+
sessionID: sessionId,
|
|
36
|
+
qoeDataDetails: qoeDataDetails
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
var event = mediaEventManager.createMediaEvent({
|
|
40
|
+
options: {
|
|
41
|
+
xdm: xdm
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return mediaEventManager.trackMediaEvent({
|
|
45
|
+
event: event
|
|
46
|
+
}).then(function () {
|
|
47
|
+
mediaSessionCacheManager.updateLastTriggeredEventTS({
|
|
48
|
+
playerId: playerId
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return Promise.resolve();
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
exports.default = _default;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _mediaEvents = require("./mediaConstants/mediaEvents");
|
|
5
|
+
var _createMediaRequestPayload = require("./createMediaRequestPayload");
|
|
6
|
+
var _createMediaRequest = require("./createMediaRequest");
|
|
7
|
+
var _injectTimestamp = require("../Context/injectTimestamp");
|
|
8
|
+
var _utils = require("../../utils");
|
|
9
|
+
/*
|
|
10
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
11
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
|
|
15
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
+
governing permissions and limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
/* eslint-disable import/no-restricted-paths */
|
|
21
|
+
var _default = function _default(_ref) {
|
|
22
|
+
var config = _ref.config,
|
|
23
|
+
eventManager = _ref.eventManager,
|
|
24
|
+
consent = _ref.consent,
|
|
25
|
+
sendEdgeNetworkRequest = _ref.sendEdgeNetworkRequest;
|
|
26
|
+
return {
|
|
27
|
+
createMediaEvent: function createMediaEvent(_ref2) {
|
|
28
|
+
var options = _ref2.options;
|
|
29
|
+
var _options$xdm = options.xdm,
|
|
30
|
+
xdm = _options$xdm === void 0 ? {} : _options$xdm;
|
|
31
|
+
var event = {
|
|
32
|
+
xdm: xdm
|
|
33
|
+
};
|
|
34
|
+
var timestamp = (0, _injectTimestamp.default)(function () {
|
|
35
|
+
return new Date();
|
|
36
|
+
});
|
|
37
|
+
timestamp(event.xdm);
|
|
38
|
+
return event;
|
|
39
|
+
},
|
|
40
|
+
createMediaSession: function createMediaSession(options) {
|
|
41
|
+
var _config$mediaCollecti = config.mediaCollection,
|
|
42
|
+
playerName = _config$mediaCollecti.playerName,
|
|
43
|
+
channel = _config$mediaCollecti.channel,
|
|
44
|
+
version = _config$mediaCollecti.version;
|
|
45
|
+
var event = eventManager.createEvent();
|
|
46
|
+
event.setUserXdm(options.xdm);
|
|
47
|
+
event.mergeXdm({
|
|
48
|
+
eventType: _mediaEvents.default.SESSION_START,
|
|
49
|
+
mediaCollection: {
|
|
50
|
+
sessionDetails: {
|
|
51
|
+
playerName: options.xdm.mediaCollection.sessionDetails.playerName || playerName,
|
|
52
|
+
channel: options.xdm.mediaCollection.sessionDetails.channel || channel,
|
|
53
|
+
appVersion: options.xdm.mediaCollection.sessionDetails.appVersion || version
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return event;
|
|
58
|
+
},
|
|
59
|
+
augmentMediaEvent: function augmentMediaEvent(_ref3) {
|
|
60
|
+
var event = _ref3.event,
|
|
61
|
+
playerId = _ref3.playerId,
|
|
62
|
+
onBeforeMediaEvent = _ref3.onBeforeMediaEvent,
|
|
63
|
+
sessionID = _ref3.sessionID;
|
|
64
|
+
if (!playerId || !onBeforeMediaEvent) {
|
|
65
|
+
return event;
|
|
66
|
+
}
|
|
67
|
+
var _onBeforeMediaEvent = onBeforeMediaEvent({
|
|
68
|
+
playerId: playerId
|
|
69
|
+
}),
|
|
70
|
+
playhead = _onBeforeMediaEvent.playhead,
|
|
71
|
+
qoeDataDetails = _onBeforeMediaEvent.qoeDataDetails;
|
|
72
|
+
if (event.mergeXdm) {
|
|
73
|
+
event.mergeXdm({
|
|
74
|
+
mediaCollection: {
|
|
75
|
+
playhead: (0, _utils.toInteger)(playhead),
|
|
76
|
+
qoeDataDetails: qoeDataDetails
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return event;
|
|
80
|
+
}
|
|
81
|
+
return (0, _utils.deepAssign)(event, {
|
|
82
|
+
xdm: {
|
|
83
|
+
mediaCollection: {
|
|
84
|
+
playhead: (0, _utils.toInteger)(playhead),
|
|
85
|
+
qoeDataDetails: qoeDataDetails,
|
|
86
|
+
sessionID: sessionID
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
trackMediaSession: function trackMediaSession(_ref4) {
|
|
92
|
+
var event = _ref4.event,
|
|
93
|
+
playerId = _ref4.playerId,
|
|
94
|
+
onBeforeMediaEvent = _ref4.onBeforeMediaEvent;
|
|
95
|
+
return eventManager.sendEvent(event, {
|
|
96
|
+
playerId: playerId,
|
|
97
|
+
onBeforeMediaEvent: onBeforeMediaEvent
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
trackMediaEvent: function trackMediaEvent(_ref5) {
|
|
101
|
+
var event = _ref5.event;
|
|
102
|
+
var action = event.xdm.eventType.split(".")[1];
|
|
103
|
+
var mediaRequestPayload = (0, _createMediaRequestPayload.default)();
|
|
104
|
+
var request = (0, _createMediaRequest.default)({
|
|
105
|
+
mediaRequestPayload: mediaRequestPayload,
|
|
106
|
+
action: action
|
|
107
|
+
});
|
|
108
|
+
mediaRequestPayload.addEvent(event);
|
|
109
|
+
return consent.awaitConsent().then(function () {
|
|
110
|
+
return sendEdgeNetworkRequest({
|
|
111
|
+
request: request
|
|
112
|
+
}).then(function () {
|
|
113
|
+
return {};
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
exports.default = _default;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _request = require("../../utils/request");
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
7
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var _default = function _default(_ref) {
|
|
17
|
+
var mediaRequestPayload = _ref.mediaRequestPayload,
|
|
18
|
+
action = _ref.action;
|
|
19
|
+
return (0, _request.createRequest)({
|
|
20
|
+
payload: mediaRequestPayload,
|
|
21
|
+
edgeSubPath: "/va",
|
|
22
|
+
getAction: function getAction() {
|
|
23
|
+
return action;
|
|
24
|
+
},
|
|
25
|
+
getUseSendBeacon: function getUseSendBeacon() {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
exports.default = _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _request = require("../../utils/request");
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
7
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var _default = function _default() {
|
|
17
|
+
var content = {};
|
|
18
|
+
var payload = (0, _request.createRequestPayload)({
|
|
19
|
+
content: content,
|
|
20
|
+
addIdentity: (0, _request.createAddIdentity)(content),
|
|
21
|
+
hasIdentity: (0, _request.createHasIdentity)(content)
|
|
22
|
+
});
|
|
23
|
+
payload.addEvent = function (event) {
|
|
24
|
+
content.events = content.events || [];
|
|
25
|
+
content.events.push(event);
|
|
26
|
+
};
|
|
27
|
+
return payload;
|
|
28
|
+
};
|
|
29
|
+
exports.default = _default;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
/*
|
|
5
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
6
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
var _default = function _default() {
|
|
16
|
+
var mediaSessionCache;
|
|
17
|
+
var getSession = function getSession(playerId) {
|
|
18
|
+
return mediaSessionCache[playerId] || {};
|
|
19
|
+
};
|
|
20
|
+
var saveHeartbeat = function saveHeartbeat(_ref) {
|
|
21
|
+
var playerId = _ref.playerId,
|
|
22
|
+
heartbeatId = _ref.heartbeatId;
|
|
23
|
+
var mediaSession = mediaSessionCache[playerId];
|
|
24
|
+
if (!mediaSession) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
mediaSession.heartbeatId = heartbeatId;
|
|
28
|
+
};
|
|
29
|
+
var stopHeartbeat = function stopHeartbeat(_ref2) {
|
|
30
|
+
var playerId = _ref2.playerId;
|
|
31
|
+
var mediaSession = mediaSessionCache[playerId];
|
|
32
|
+
if (!mediaSession) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
clearInterval(mediaSession.heartbeatId);
|
|
36
|
+
mediaSession.heartbeatId = null;
|
|
37
|
+
};
|
|
38
|
+
var updateLastTriggeredEventTS = function updateLastTriggeredEventTS(_ref3) {
|
|
39
|
+
var playerId = _ref3.playerId;
|
|
40
|
+
var player = mediaSessionCache[playerId];
|
|
41
|
+
if (!player) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
player.latestTriggeredEvent = Date.now();
|
|
45
|
+
};
|
|
46
|
+
var storeSession = function storeSession(_ref4) {
|
|
47
|
+
var playerId = _ref4.playerId,
|
|
48
|
+
sessionDetails = _ref4.sessionDetails;
|
|
49
|
+
if (mediaSessionCache === undefined) {
|
|
50
|
+
mediaSessionCache = {};
|
|
51
|
+
}
|
|
52
|
+
mediaSessionCache[playerId] = sessionDetails;
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
getSession: getSession,
|
|
56
|
+
stopHeartbeat: stopHeartbeat,
|
|
57
|
+
updateLastTriggeredEventTS: updateLastTriggeredEventTS,
|
|
58
|
+
storeSession: storeSession,
|
|
59
|
+
saveHeartbeat: saveHeartbeat
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
exports.default = _default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _mediaEvents = require("./mediaConstants/mediaEvents");
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
7
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var _default = function _default(_ref) {
|
|
17
|
+
var mediaSessionCacheManager = _ref.mediaSessionCacheManager;
|
|
18
|
+
return function (_ref2) {
|
|
19
|
+
var playerId = _ref2.playerId,
|
|
20
|
+
xdm = _ref2.xdm;
|
|
21
|
+
if (!playerId) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
var eventType = xdm.eventType;
|
|
25
|
+
if (eventType === _mediaEvents.default.SESSION_COMPLETE || eventType === _mediaEvents.default.SESSION_END) {
|
|
26
|
+
mediaSessionCacheManager.stopHeartbeat({
|
|
27
|
+
playerId: playerId
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
mediaSessionCacheManager.updateLastTriggeredEventTS({
|
|
31
|
+
playerId: playerId
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.default = _default;
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _validation = require("../../utils/validation");
|
|
5
|
+
var _createMediaSessionCacheManager = require("./createMediaSessionCacheManager");
|
|
6
|
+
var _validateMediaEventOptions = require("./validateMediaEventOptions");
|
|
7
|
+
var _validateMediaSessionOptions = require("./validateMediaSessionOptions");
|
|
8
|
+
var _createMediaEventManager = require("./createMediaEventManager");
|
|
9
|
+
var _utils = require("../../utils");
|
|
10
|
+
var _createHeartbeatEngine = require("./createHeartbeatEngine");
|
|
11
|
+
var _createUpdateMediaSessionState = require("./createUpdateMediaSessionState");
|
|
12
|
+
/*
|
|
13
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
14
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
15
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
16
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
|
|
18
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
19
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
20
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
21
|
+
governing permissions and limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
var createMediaCollection = function createMediaCollection(_ref) {
|
|
25
|
+
var config = _ref.config,
|
|
26
|
+
logger = _ref.logger,
|
|
27
|
+
eventManager = _ref.eventManager,
|
|
28
|
+
sendEdgeNetworkRequest = _ref.sendEdgeNetworkRequest,
|
|
29
|
+
consent = _ref.consent;
|
|
30
|
+
var mediaSessionCacheManager = (0, _createMediaSessionCacheManager.default)({
|
|
31
|
+
config: config
|
|
32
|
+
});
|
|
33
|
+
var mediaEventManager = (0, _createMediaEventManager.default)({
|
|
34
|
+
config: config,
|
|
35
|
+
eventManager: eventManager,
|
|
36
|
+
logger: logger,
|
|
37
|
+
consent: consent,
|
|
38
|
+
sendEdgeNetworkRequest: sendEdgeNetworkRequest
|
|
39
|
+
});
|
|
40
|
+
var heartbeatTicker = (0, _createHeartbeatEngine.default)({
|
|
41
|
+
config: config,
|
|
42
|
+
mediaEventManager: mediaEventManager,
|
|
43
|
+
mediaSessionCacheManager: mediaSessionCacheManager
|
|
44
|
+
});
|
|
45
|
+
var updateMediaSessionState = (0, _createUpdateMediaSessionState.default)({
|
|
46
|
+
mediaSessionCacheManager: mediaSessionCacheManager
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
lifecycle: {
|
|
50
|
+
onBeforeEvent: function onBeforeEvent(_ref2) {
|
|
51
|
+
var playerId = _ref2.playerId,
|
|
52
|
+
onBeforeMediaEvent = _ref2.onBeforeMediaEvent,
|
|
53
|
+
_ref2$onResponse = _ref2.onResponse,
|
|
54
|
+
onResponse = _ref2$onResponse === void 0 ? _utils.noop : _ref2$onResponse;
|
|
55
|
+
onResponse(function (_ref3) {
|
|
56
|
+
var response = _ref3.response;
|
|
57
|
+
var sessionId = response.getPayloadsByType("media-analytics:new-session");
|
|
58
|
+
logger.info("Media session ID returned: ", sessionId);
|
|
59
|
+
if (sessionId.length > 0) {
|
|
60
|
+
if (playerId && onBeforeMediaEvent) {
|
|
61
|
+
var heartbeatId = setInterval(function () {
|
|
62
|
+
heartbeatTicker({
|
|
63
|
+
sessionId: sessionId[0].sessionId,
|
|
64
|
+
playerId: playerId,
|
|
65
|
+
onBeforeMediaEvent: onBeforeMediaEvent
|
|
66
|
+
});
|
|
67
|
+
}, 1000);
|
|
68
|
+
mediaSessionCacheManager.saveHeartbeat({
|
|
69
|
+
playerId: playerId,
|
|
70
|
+
heartbeatId: heartbeatId
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
sessionId: sessionId[0].sessionId
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
return {};
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
commands: {
|
|
82
|
+
createMediaSession: {
|
|
83
|
+
optionsValidator: function optionsValidator(options) {
|
|
84
|
+
return (0, _validateMediaSessionOptions.default)({
|
|
85
|
+
options: options
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
run: function run(options) {
|
|
89
|
+
var playerId = options.playerId,
|
|
90
|
+
onBeforeMediaEvent = options.onBeforeMediaEvent;
|
|
91
|
+
var event = mediaEventManager.createMediaSession(options);
|
|
92
|
+
mediaEventManager.augmentMediaEvent({
|
|
93
|
+
event: event,
|
|
94
|
+
playerId: playerId,
|
|
95
|
+
onBeforeMediaEvent: onBeforeMediaEvent
|
|
96
|
+
});
|
|
97
|
+
var sessionPromise = mediaEventManager.trackMediaSession({
|
|
98
|
+
event: event,
|
|
99
|
+
playerId: playerId,
|
|
100
|
+
onBeforeMediaEvent: onBeforeMediaEvent
|
|
101
|
+
});
|
|
102
|
+
mediaSessionCacheManager.storeSession({
|
|
103
|
+
playerId: playerId,
|
|
104
|
+
sessionDetails: {
|
|
105
|
+
sessionPromise: sessionPromise,
|
|
106
|
+
onBeforeMediaEvent: onBeforeMediaEvent,
|
|
107
|
+
latestTriggeredEvent: Date.now()
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
return sessionPromise;
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
sendMediaEvent: {
|
|
114
|
+
optionsValidator: function optionsValidator(options) {
|
|
115
|
+
return (0, _validateMediaEventOptions.default)({
|
|
116
|
+
options: options
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
run: function run(options) {
|
|
120
|
+
var event = mediaEventManager.createMediaEvent({
|
|
121
|
+
options: options
|
|
122
|
+
});
|
|
123
|
+
var playerId = options.playerId;
|
|
124
|
+
var _mediaSessionCacheMan = mediaSessionCacheManager.getSession(playerId),
|
|
125
|
+
onBeforeMediaEvent = _mediaSessionCacheMan.onBeforeMediaEvent,
|
|
126
|
+
sessionPromise = _mediaSessionCacheMan.sessionPromise;
|
|
127
|
+
sessionPromise.then(function (result) {
|
|
128
|
+
var finalEvent = mediaEventManager.augmentMediaEvent({
|
|
129
|
+
event: event,
|
|
130
|
+
playerId: playerId,
|
|
131
|
+
onBeforeMediaEvent: onBeforeMediaEvent,
|
|
132
|
+
sessionID: result.sessionId
|
|
133
|
+
});
|
|
134
|
+
return mediaEventManager.trackMediaEvent({
|
|
135
|
+
event: finalEvent
|
|
136
|
+
}).then(function () {
|
|
137
|
+
updateMediaSessionState({
|
|
138
|
+
playerId: playerId,
|
|
139
|
+
xdm: finalEvent.xdm
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
createMediaCollection.namespace = "Media Collection";
|
|
149
|
+
createMediaCollection.configValidators = (0, _validation.objectOf)({
|
|
150
|
+
mediaCollection: (0, _validation.objectOf)({
|
|
151
|
+
channel: (0, _validation.string)().nonEmpty().required(),
|
|
152
|
+
playerName: (0, _validation.string)().nonEmpty().required(),
|
|
153
|
+
version: (0, _validation.string)(),
|
|
154
|
+
mainPingInterval: (0, _validation.number)().minimum(10).maximum(60).default(10),
|
|
155
|
+
adPingInterval: (0, _validation.number)().minimum(10).maximum(60).default(10)
|
|
156
|
+
}).noUnknownFields()
|
|
157
|
+
});
|
|
158
|
+
var _default = createMediaCollection;
|
|
159
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _default = {
|
|
5
|
+
PAUSE: "media.pauseStart",
|
|
6
|
+
PLAY: "media.play",
|
|
7
|
+
BUFFERING: "media.buffering",
|
|
8
|
+
AD_START: "media.adStart",
|
|
9
|
+
SESSION_END: "media.sessionEnd",
|
|
10
|
+
SESSION_START: "media.sessionStart",
|
|
11
|
+
SESSION_COMPLETE: "media.sessionComplete"
|
|
12
|
+
};
|
|
13
|
+
exports.default = _default;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _validation = require("../../utils/validation");
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
7
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var _default = function _default(_ref) {
|
|
17
|
+
var options = _ref.options;
|
|
18
|
+
var validator = (0, _validation.anyOf)([(0, _validation.objectOf)({
|
|
19
|
+
playerId: (0, _validation.string)().required(),
|
|
20
|
+
xdm: (0, _validation.objectOf)({
|
|
21
|
+
eventType: (0, _validation.string)().required(),
|
|
22
|
+
mediaCollection: (0, _validation.objectOf)((0, _validation.anything)())
|
|
23
|
+
}).required()
|
|
24
|
+
}).required(), (0, _validation.objectOf)({
|
|
25
|
+
xdm: (0, _validation.objectOf)({
|
|
26
|
+
eventType: (0, _validation.string)().required(),
|
|
27
|
+
mediaCollection: (0, _validation.objectOf)({
|
|
28
|
+
playhead: (0, _validation.number)().integer().required(),
|
|
29
|
+
sessionID: (0, _validation.string)().required()
|
|
30
|
+
}).required()
|
|
31
|
+
}).required()
|
|
32
|
+
}).required()], "Error validating the sendMediaEvent command options.");
|
|
33
|
+
return validator(options);
|
|
34
|
+
};
|
|
35
|
+
exports.default = _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _validation = require("../../utils/validation");
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
7
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var _default = function _default(_ref) {
|
|
17
|
+
var options = _ref.options;
|
|
18
|
+
var sessionValidator = (0, _validation.anyOf)([(0, _validation.objectOf)({
|
|
19
|
+
playerId: (0, _validation.string)().required(),
|
|
20
|
+
onBeforeMediaEvent: (0, _validation.callback)().required(),
|
|
21
|
+
xdm: (0, _validation.objectOf)({
|
|
22
|
+
mediaCollection: (0, _validation.objectOf)({
|
|
23
|
+
sessionDetails: (0, _validation.objectOf)((0, _validation.anything)()).required()
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
}).required(), (0, _validation.objectOf)({
|
|
27
|
+
xdm: (0, _validation.objectOf)({
|
|
28
|
+
mediaCollection: (0, _validation.objectOf)({
|
|
29
|
+
playhead: (0, _validation.number)().required(),
|
|
30
|
+
sessionDetails: (0, _validation.objectOf)((0, _validation.anything)()).required()
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
}).required()], "Error validating the createMediaSession command options.");
|
|
34
|
+
return sessionValidator(options);
|
|
35
|
+
};
|
|
36
|
+
exports.default = _default;
|
|
@@ -14,5 +14,5 @@ governing permissions and limitations under the License.
|
|
|
14
14
|
*/
|
|
15
15
|
// The __VERSION__ keyword will be replace at alloy build time with the package.json version.
|
|
16
16
|
// see babel-plugin-version
|
|
17
|
-
var _default = "2.
|
|
17
|
+
var _default = "2.20.0-alpha.0";
|
|
18
18
|
exports.default = _default;
|
|
@@ -12,6 +12,8 @@ var _EventMerge = require("../components/EventMerge");
|
|
|
12
12
|
var _LibraryInfo = require("../components/LibraryInfo");
|
|
13
13
|
var _DecisioningEngine = require("../components/DecisioningEngine");
|
|
14
14
|
var _MachineLearning = require("../components/MachineLearning");
|
|
15
|
+
var _MediaCollection = require("../components/MediaCollection");
|
|
16
|
+
var _LegacyMediaAnalytics = require("../components/LegacyMediaAnalytics");
|
|
15
17
|
/*
|
|
16
18
|
Copyright 2019 Adobe. All rights reserved.
|
|
17
19
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -28,5 +30,5 @@ governing permissions and limitations under the License.
|
|
|
28
30
|
/* eslint-disable import/no-restricted-paths */
|
|
29
31
|
// TODO: Register the Components here statically for now. They might be registered differently.
|
|
30
32
|
// TODO: Figure out how sub-components will be made available/registered
|
|
31
|
-
var _default = [_DataCollector.default, _ActivityCollector.default, _Identity.default, _Audiences.default, _Personalization.default, _Context.default, _Privacy.default, _EventMerge.default, _LibraryInfo.default, _MachineLearning.default, _DecisioningEngine.default];
|
|
33
|
+
var _default = [_DataCollector.default, _ActivityCollector.default, _Identity.default, _Audiences.default, _Personalization.default, _Context.default, _Privacy.default, _EventMerge.default, _LibraryInfo.default, _MachineLearning.default, _DecisioningEngine.default, _LegacyMediaAnalytics.default, _MediaCollection.default];
|
|
32
34
|
exports.default = _default;
|
|
@@ -53,7 +53,7 @@ var _default = function _default(_ref) {
|
|
|
53
53
|
}).then(function () {
|
|
54
54
|
var endpointDomain = request.getUseIdThirdPartyDomain() ? _domain.ID_THIRD_PARTY : edgeDomain;
|
|
55
55
|
var locationHint = getLocationHint();
|
|
56
|
-
var edgeBasePathWithLocationHint = locationHint ? edgeBasePath + "/" + locationHint : edgeBasePath;
|
|
56
|
+
var edgeBasePathWithLocationHint = locationHint ? edgeBasePath + "/" + locationHint + request.getEdgeSubPath() : "" + edgeBasePath + request.getEdgeSubPath();
|
|
57
57
|
var configId = request.getDatastreamIdOverride() || datastreamId;
|
|
58
58
|
var payload = request.getPayload();
|
|
59
59
|
if (configId !== datastreamId) {
|
|
@@ -18,7 +18,8 @@ var _default = function _default(options) {
|
|
|
18
18
|
var payload = options.payload,
|
|
19
19
|
_getAction = options.getAction,
|
|
20
20
|
_getUseSendBeacon = options.getUseSendBeacon,
|
|
21
|
-
datastreamIdOverride = options.datastreamIdOverride
|
|
21
|
+
datastreamIdOverride = options.datastreamIdOverride,
|
|
22
|
+
edgeSubPath = options.edgeSubPath;
|
|
22
23
|
var id = (0, _.uuid)();
|
|
23
24
|
var shouldUseThirdPartyDomain = false;
|
|
24
25
|
var isIdentityEstablished = false;
|
|
@@ -42,6 +43,12 @@ var _default = function _default(options) {
|
|
|
42
43
|
isIdentityEstablished: isIdentityEstablished
|
|
43
44
|
});
|
|
44
45
|
},
|
|
46
|
+
getEdgeSubPath: function getEdgeSubPath() {
|
|
47
|
+
if (edgeSubPath) {
|
|
48
|
+
return edgeSubPath;
|
|
49
|
+
}
|
|
50
|
+
return "";
|
|
51
|
+
},
|
|
45
52
|
getUseIdThirdPartyDomain: function getUseIdThirdPartyDomain() {
|
|
46
53
|
return shouldUseThirdPartyDomain;
|
|
47
54
|
},
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.default = void 0;
|
|
4
|
+
var _utils = require("./utils");
|
|
5
|
+
/*
|
|
6
|
+
Copyright 2023 Adobe. All rights reserved.
|
|
7
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
var _default = function _default(typeName, maximum) {
|
|
17
|
+
return function (value, path) {
|
|
18
|
+
(0, _utils.assertValid)(value <= maximum, value, path, typeName + " less than or equal to " + maximum);
|
|
19
|
+
return value;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.default = _default;
|