@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,57 @@
|
|
|
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
|
+
|
|
13
|
+
import toInteger from "../../utils/toInteger";
|
|
14
|
+
export default (({
|
|
15
|
+
config,
|
|
16
|
+
mediaEventManager,
|
|
17
|
+
mediaSessionCacheManager
|
|
18
|
+
}) => {
|
|
19
|
+
return ({
|
|
20
|
+
playerId,
|
|
21
|
+
sessionId,
|
|
22
|
+
onBeforeMediaEvent
|
|
23
|
+
}) => {
|
|
24
|
+
const currentTime = Date.now();
|
|
25
|
+
const {
|
|
26
|
+
mainPingInterval
|
|
27
|
+
} = config.mediaCollection;
|
|
28
|
+
const playerSession = mediaSessionCacheManager.getSession(playerId);
|
|
29
|
+
if (Math.abs(currentTime - playerSession.latestTriggeredEvent) / 1000 > mainPingInterval) {
|
|
30
|
+
const {
|
|
31
|
+
playhead,
|
|
32
|
+
qoeDataDetails
|
|
33
|
+
} = onBeforeMediaEvent(playerId);
|
|
34
|
+
const xdm = {
|
|
35
|
+
eventType: "media.ping",
|
|
36
|
+
mediaCollection: {
|
|
37
|
+
playhead: toInteger(playhead),
|
|
38
|
+
sessionID: sessionId,
|
|
39
|
+
qoeDataDetails
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const event = mediaEventManager.createMediaEvent({
|
|
43
|
+
options: {
|
|
44
|
+
xdm
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return mediaEventManager.trackMediaEvent({
|
|
48
|
+
event
|
|
49
|
+
}).then(() => {
|
|
50
|
+
mediaSessionCacheManager.updateLastTriggeredEventTS({
|
|
51
|
+
playerId
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return Promise.resolve();
|
|
56
|
+
};
|
|
57
|
+
});
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
/* eslint-disable import/no-restricted-paths */
|
|
13
|
+
|
|
14
|
+
import MediaEvents from "./mediaConstants/mediaEvents";
|
|
15
|
+
import createMediaRequestPayload from "./createMediaRequestPayload";
|
|
16
|
+
import createMediaRequest from "./createMediaRequest";
|
|
17
|
+
import injectTimestamp from "../Context/injectTimestamp";
|
|
18
|
+
import { deepAssign, toInteger } from "../../utils";
|
|
19
|
+
export default (({
|
|
20
|
+
config,
|
|
21
|
+
eventManager,
|
|
22
|
+
consent,
|
|
23
|
+
sendEdgeNetworkRequest
|
|
24
|
+
}) => {
|
|
25
|
+
return {
|
|
26
|
+
createMediaEvent({
|
|
27
|
+
options
|
|
28
|
+
}) {
|
|
29
|
+
const {
|
|
30
|
+
xdm = {}
|
|
31
|
+
} = options;
|
|
32
|
+
const event = {
|
|
33
|
+
xdm
|
|
34
|
+
};
|
|
35
|
+
const timestamp = injectTimestamp(() => new Date());
|
|
36
|
+
timestamp(event.xdm);
|
|
37
|
+
return event;
|
|
38
|
+
},
|
|
39
|
+
createMediaSession(options) {
|
|
40
|
+
const {
|
|
41
|
+
playerName,
|
|
42
|
+
channel,
|
|
43
|
+
version
|
|
44
|
+
} = config.mediaCollection;
|
|
45
|
+
const event = eventManager.createEvent();
|
|
46
|
+
event.setUserXdm(options.xdm);
|
|
47
|
+
event.mergeXdm({
|
|
48
|
+
eventType: MediaEvents.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({
|
|
60
|
+
event,
|
|
61
|
+
playerId,
|
|
62
|
+
onBeforeMediaEvent,
|
|
63
|
+
sessionID
|
|
64
|
+
}) {
|
|
65
|
+
if (!playerId || !onBeforeMediaEvent) {
|
|
66
|
+
return event;
|
|
67
|
+
}
|
|
68
|
+
const {
|
|
69
|
+
playhead,
|
|
70
|
+
qoeDataDetails
|
|
71
|
+
} = onBeforeMediaEvent({
|
|
72
|
+
playerId
|
|
73
|
+
});
|
|
74
|
+
if (event.mergeXdm) {
|
|
75
|
+
event.mergeXdm({
|
|
76
|
+
mediaCollection: {
|
|
77
|
+
playhead: toInteger(playhead),
|
|
78
|
+
qoeDataDetails
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return event;
|
|
82
|
+
}
|
|
83
|
+
return deepAssign(event, {
|
|
84
|
+
xdm: {
|
|
85
|
+
mediaCollection: {
|
|
86
|
+
playhead: toInteger(playhead),
|
|
87
|
+
qoeDataDetails,
|
|
88
|
+
sessionID
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
trackMediaSession({
|
|
94
|
+
event,
|
|
95
|
+
playerId,
|
|
96
|
+
onBeforeMediaEvent
|
|
97
|
+
}) {
|
|
98
|
+
return eventManager.sendEvent(event, {
|
|
99
|
+
playerId,
|
|
100
|
+
onBeforeMediaEvent
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
trackMediaEvent({
|
|
104
|
+
event
|
|
105
|
+
}) {
|
|
106
|
+
const action = event.xdm.eventType.split(".")[1];
|
|
107
|
+
const mediaRequestPayload = createMediaRequestPayload();
|
|
108
|
+
const request = createMediaRequest({
|
|
109
|
+
mediaRequestPayload,
|
|
110
|
+
action
|
|
111
|
+
});
|
|
112
|
+
mediaRequestPayload.addEvent(event);
|
|
113
|
+
return consent.awaitConsent().then(() => {
|
|
114
|
+
return sendEdgeNetworkRequest({
|
|
115
|
+
request
|
|
116
|
+
}).then(() => {
|
|
117
|
+
return {};
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
|
|
13
|
+
import { createRequest } from "../../utils/request";
|
|
14
|
+
export default (({
|
|
15
|
+
mediaRequestPayload,
|
|
16
|
+
action
|
|
17
|
+
}) => {
|
|
18
|
+
return createRequest({
|
|
19
|
+
payload: mediaRequestPayload,
|
|
20
|
+
edgeSubPath: "/va",
|
|
21
|
+
getAction() {
|
|
22
|
+
return action;
|
|
23
|
+
},
|
|
24
|
+
getUseSendBeacon() {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
|
|
13
|
+
import { createAddIdentity, createHasIdentity, createRequestPayload } from "../../utils/request";
|
|
14
|
+
export default (() => {
|
|
15
|
+
const content = {};
|
|
16
|
+
const payload = createRequestPayload({
|
|
17
|
+
content,
|
|
18
|
+
addIdentity: createAddIdentity(content),
|
|
19
|
+
hasIdentity: createHasIdentity(content)
|
|
20
|
+
});
|
|
21
|
+
payload.addEvent = event => {
|
|
22
|
+
content.events = content.events || [];
|
|
23
|
+
content.events.push(event);
|
|
24
|
+
};
|
|
25
|
+
return payload;
|
|
26
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
|
|
13
|
+
export default (() => {
|
|
14
|
+
let mediaSessionCache;
|
|
15
|
+
const getSession = playerId => {
|
|
16
|
+
return mediaSessionCache[playerId] || {};
|
|
17
|
+
};
|
|
18
|
+
const saveHeartbeat = ({
|
|
19
|
+
playerId,
|
|
20
|
+
heartbeatId
|
|
21
|
+
}) => {
|
|
22
|
+
const mediaSession = mediaSessionCache[playerId];
|
|
23
|
+
if (!mediaSession) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
mediaSession.heartbeatId = heartbeatId;
|
|
27
|
+
};
|
|
28
|
+
const stopHeartbeat = ({
|
|
29
|
+
playerId
|
|
30
|
+
}) => {
|
|
31
|
+
const mediaSession = mediaSessionCache[playerId];
|
|
32
|
+
if (!mediaSession) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
clearInterval(mediaSession.heartbeatId);
|
|
36
|
+
mediaSession.heartbeatId = null;
|
|
37
|
+
};
|
|
38
|
+
const updateLastTriggeredEventTS = ({
|
|
39
|
+
playerId
|
|
40
|
+
}) => {
|
|
41
|
+
const player = mediaSessionCache[playerId];
|
|
42
|
+
if (!player) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
player.latestTriggeredEvent = Date.now();
|
|
46
|
+
};
|
|
47
|
+
const storeSession = ({
|
|
48
|
+
playerId,
|
|
49
|
+
sessionDetails
|
|
50
|
+
}) => {
|
|
51
|
+
if (mediaSessionCache === undefined) {
|
|
52
|
+
mediaSessionCache = {};
|
|
53
|
+
}
|
|
54
|
+
mediaSessionCache[playerId] = sessionDetails;
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
getSession,
|
|
58
|
+
stopHeartbeat,
|
|
59
|
+
updateLastTriggeredEventTS,
|
|
60
|
+
storeSession,
|
|
61
|
+
saveHeartbeat
|
|
62
|
+
};
|
|
63
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
|
|
13
|
+
import MediaEvents from "./mediaConstants/mediaEvents";
|
|
14
|
+
export default (({
|
|
15
|
+
mediaSessionCacheManager
|
|
16
|
+
}) => {
|
|
17
|
+
return ({
|
|
18
|
+
playerId,
|
|
19
|
+
xdm
|
|
20
|
+
}) => {
|
|
21
|
+
if (!playerId) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const {
|
|
25
|
+
eventType
|
|
26
|
+
} = xdm;
|
|
27
|
+
if (eventType === MediaEvents.SESSION_COMPLETE || eventType === MediaEvents.SESSION_END) {
|
|
28
|
+
mediaSessionCacheManager.stopHeartbeat({
|
|
29
|
+
playerId
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
mediaSessionCacheManager.updateLastTriggeredEventTS({
|
|
33
|
+
playerId
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
});
|
|
@@ -0,0 +1,158 @@
|
|
|
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
|
+
|
|
13
|
+
import { string, number, objectOf } from "../../utils/validation";
|
|
14
|
+
import createMediaSessionCacheManager from "./createMediaSessionCacheManager";
|
|
15
|
+
import validateMediaEventOptions from "./validateMediaEventOptions";
|
|
16
|
+
import validateSessionOptions from "./validateMediaSessionOptions";
|
|
17
|
+
import createMediaEventManager from "./createMediaEventManager";
|
|
18
|
+
import { noop } from "../../utils";
|
|
19
|
+
import createHeartbeatEngine from "./createHeartbeatEngine";
|
|
20
|
+
import createUpdateMediaSessionState from "./createUpdateMediaSessionState";
|
|
21
|
+
const createMediaCollection = ({
|
|
22
|
+
config,
|
|
23
|
+
logger,
|
|
24
|
+
eventManager,
|
|
25
|
+
sendEdgeNetworkRequest,
|
|
26
|
+
consent
|
|
27
|
+
}) => {
|
|
28
|
+
const mediaSessionCacheManager = createMediaSessionCacheManager({
|
|
29
|
+
config
|
|
30
|
+
});
|
|
31
|
+
const mediaEventManager = createMediaEventManager({
|
|
32
|
+
config,
|
|
33
|
+
eventManager,
|
|
34
|
+
logger,
|
|
35
|
+
consent,
|
|
36
|
+
sendEdgeNetworkRequest
|
|
37
|
+
});
|
|
38
|
+
const heartbeatTicker = createHeartbeatEngine({
|
|
39
|
+
config,
|
|
40
|
+
mediaEventManager,
|
|
41
|
+
mediaSessionCacheManager
|
|
42
|
+
});
|
|
43
|
+
const updateMediaSessionState = createUpdateMediaSessionState({
|
|
44
|
+
mediaSessionCacheManager
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
lifecycle: {
|
|
48
|
+
onBeforeEvent({
|
|
49
|
+
playerId,
|
|
50
|
+
onBeforeMediaEvent,
|
|
51
|
+
onResponse = noop
|
|
52
|
+
}) {
|
|
53
|
+
onResponse(({
|
|
54
|
+
response
|
|
55
|
+
}) => {
|
|
56
|
+
const sessionId = response.getPayloadsByType("media-analytics:new-session");
|
|
57
|
+
logger.info("Media session ID returned: ", sessionId);
|
|
58
|
+
if (sessionId.length > 0) {
|
|
59
|
+
if (playerId && onBeforeMediaEvent) {
|
|
60
|
+
const heartbeatId = setInterval(() => {
|
|
61
|
+
heartbeatTicker({
|
|
62
|
+
sessionId: sessionId[0].sessionId,
|
|
63
|
+
playerId,
|
|
64
|
+
onBeforeMediaEvent
|
|
65
|
+
});
|
|
66
|
+
}, 1000);
|
|
67
|
+
mediaSessionCacheManager.saveHeartbeat({
|
|
68
|
+
playerId,
|
|
69
|
+
heartbeatId
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
sessionId: sessionId[0].sessionId
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return {};
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
commands: {
|
|
81
|
+
createMediaSession: {
|
|
82
|
+
optionsValidator: options => validateSessionOptions({
|
|
83
|
+
options
|
|
84
|
+
}),
|
|
85
|
+
run: options => {
|
|
86
|
+
const {
|
|
87
|
+
playerId,
|
|
88
|
+
onBeforeMediaEvent
|
|
89
|
+
} = options;
|
|
90
|
+
const event = mediaEventManager.createMediaSession(options);
|
|
91
|
+
mediaEventManager.augmentMediaEvent({
|
|
92
|
+
event,
|
|
93
|
+
playerId,
|
|
94
|
+
onBeforeMediaEvent
|
|
95
|
+
});
|
|
96
|
+
const sessionPromise = mediaEventManager.trackMediaSession({
|
|
97
|
+
event,
|
|
98
|
+
playerId,
|
|
99
|
+
onBeforeMediaEvent
|
|
100
|
+
});
|
|
101
|
+
mediaSessionCacheManager.storeSession({
|
|
102
|
+
playerId,
|
|
103
|
+
sessionDetails: {
|
|
104
|
+
sessionPromise,
|
|
105
|
+
onBeforeMediaEvent,
|
|
106
|
+
latestTriggeredEvent: Date.now()
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
return sessionPromise;
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
sendMediaEvent: {
|
|
113
|
+
optionsValidator: options => validateMediaEventOptions({
|
|
114
|
+
options
|
|
115
|
+
}),
|
|
116
|
+
run: options => {
|
|
117
|
+
const event = mediaEventManager.createMediaEvent({
|
|
118
|
+
options
|
|
119
|
+
});
|
|
120
|
+
const {
|
|
121
|
+
playerId
|
|
122
|
+
} = options;
|
|
123
|
+
const {
|
|
124
|
+
onBeforeMediaEvent,
|
|
125
|
+
sessionPromise
|
|
126
|
+
} = mediaSessionCacheManager.getSession(playerId);
|
|
127
|
+
sessionPromise.then(result => {
|
|
128
|
+
const finalEvent = mediaEventManager.augmentMediaEvent({
|
|
129
|
+
event,
|
|
130
|
+
playerId,
|
|
131
|
+
onBeforeMediaEvent,
|
|
132
|
+
sessionID: result.sessionId
|
|
133
|
+
});
|
|
134
|
+
return mediaEventManager.trackMediaEvent({
|
|
135
|
+
event: finalEvent
|
|
136
|
+
}).then(() => {
|
|
137
|
+
updateMediaSessionState({
|
|
138
|
+
playerId,
|
|
139
|
+
xdm: finalEvent.xdm
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
createMediaCollection.namespace = "Media Collection";
|
|
149
|
+
createMediaCollection.configValidators = objectOf({
|
|
150
|
+
mediaCollection: objectOf({
|
|
151
|
+
channel: string().nonEmpty().required(),
|
|
152
|
+
playerName: string().nonEmpty().required(),
|
|
153
|
+
version: string(),
|
|
154
|
+
mainPingInterval: number().minimum(10).maximum(60).default(10),
|
|
155
|
+
adPingInterval: number().minimum(10).maximum(60).default(10)
|
|
156
|
+
}).noUnknownFields()
|
|
157
|
+
});
|
|
158
|
+
export default createMediaCollection;
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
import { anyOf, anything, number, objectOf, string } from "../../utils/validation";
|
|
13
|
+
export default (({
|
|
14
|
+
options
|
|
15
|
+
}) => {
|
|
16
|
+
const validator = anyOf([objectOf({
|
|
17
|
+
playerId: string().required(),
|
|
18
|
+
xdm: objectOf({
|
|
19
|
+
eventType: string().required(),
|
|
20
|
+
mediaCollection: objectOf(anything())
|
|
21
|
+
}).required()
|
|
22
|
+
}).required(), objectOf({
|
|
23
|
+
xdm: objectOf({
|
|
24
|
+
eventType: string().required(),
|
|
25
|
+
mediaCollection: objectOf({
|
|
26
|
+
playhead: number().integer().required(),
|
|
27
|
+
sessionID: string().required()
|
|
28
|
+
}).required()
|
|
29
|
+
}).required()
|
|
30
|
+
}).required()], "Error validating the sendMediaEvent command options.");
|
|
31
|
+
return validator(options);
|
|
32
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
|
|
13
|
+
import { anyOf, anything, callback, number, objectOf, string } from "../../utils/validation";
|
|
14
|
+
export default (({
|
|
15
|
+
options
|
|
16
|
+
}) => {
|
|
17
|
+
const sessionValidator = anyOf([objectOf({
|
|
18
|
+
playerId: string().required(),
|
|
19
|
+
onBeforeMediaEvent: callback().required(),
|
|
20
|
+
xdm: objectOf({
|
|
21
|
+
mediaCollection: objectOf({
|
|
22
|
+
sessionDetails: objectOf(anything()).required()
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
}).required(), objectOf({
|
|
26
|
+
xdm: objectOf({
|
|
27
|
+
mediaCollection: objectOf({
|
|
28
|
+
playhead: number().required(),
|
|
29
|
+
sessionDetails: objectOf(anything()).required()
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
}).required()], "Error validating the createMediaSession command options.");
|
|
33
|
+
return sessionValidator(options);
|
|
34
|
+
});
|
|
@@ -23,7 +23,9 @@ import createEventMerge from "../components/EventMerge";
|
|
|
23
23
|
import createLibraryInfo from "../components/LibraryInfo";
|
|
24
24
|
import createDecisioningEngine from "../components/DecisioningEngine";
|
|
25
25
|
import createMachineLearning from "../components/MachineLearning";
|
|
26
|
+
import createMediaCollection from "../components/MediaCollection";
|
|
27
|
+
import createLegacyMediaAnalytics from "../components/LegacyMediaAnalytics";
|
|
26
28
|
|
|
27
29
|
// TODO: Register the Components here statically for now. They might be registered differently.
|
|
28
30
|
// TODO: Figure out how sub-components will be made available/registered
|
|
29
|
-
export default [createDataCollector, createActivityCollector, createIdentity, createAudiences, createPersonalization, createContext, createPrivacy, createEventMerge, createLibraryInfo, createMachineLearning, createDecisioningEngine];
|
|
31
|
+
export default [createDataCollector, createActivityCollector, createIdentity, createAudiences, createPersonalization, createContext, createPrivacy, createEventMerge, createLibraryInfo, createMachineLearning, createDecisioningEngine, createLegacyMediaAnalytics, createMediaCollection];
|
|
@@ -53,7 +53,7 @@ export default (({
|
|
|
53
53
|
}).then(() => {
|
|
54
54
|
const endpointDomain = request.getUseIdThirdPartyDomain() ? ID_THIRD_PARTY_DOMAIN : edgeDomain;
|
|
55
55
|
const locationHint = getLocationHint();
|
|
56
|
-
const edgeBasePathWithLocationHint = locationHint ? `${edgeBasePath}/${locationHint}` : edgeBasePath
|
|
56
|
+
const edgeBasePathWithLocationHint = locationHint ? `${edgeBasePath}/${locationHint}${request.getEdgeSubPath()}` : `${edgeBasePath}${request.getEdgeSubPath()}`;
|
|
57
57
|
const configId = request.getDatastreamIdOverride() || datastreamId;
|
|
58
58
|
const payload = request.getPayload();
|
|
59
59
|
if (configId !== datastreamId) {
|
|
@@ -18,7 +18,8 @@ export default (options => {
|
|
|
18
18
|
payload,
|
|
19
19
|
getAction,
|
|
20
20
|
getUseSendBeacon,
|
|
21
|
-
datastreamIdOverride
|
|
21
|
+
datastreamIdOverride,
|
|
22
|
+
edgeSubPath
|
|
22
23
|
} = options;
|
|
23
24
|
const id = uuid();
|
|
24
25
|
let shouldUseThirdPartyDomain = false;
|
|
@@ -43,6 +44,12 @@ export default (options => {
|
|
|
43
44
|
isIdentityEstablished
|
|
44
45
|
});
|
|
45
46
|
},
|
|
47
|
+
getEdgeSubPath() {
|
|
48
|
+
if (edgeSubPath) {
|
|
49
|
+
return edgeSubPath;
|
|
50
|
+
}
|
|
51
|
+
return "";
|
|
52
|
+
},
|
|
46
53
|
getUseIdThirdPartyDomain() {
|
|
47
54
|
return shouldUseThirdPartyDomain;
|
|
48
55
|
},
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
import { assertValid } from "./utils";
|
|
13
|
+
export default ((typeName, maximum) => (value, path) => {
|
|
14
|
+
assertValid(value <= maximum, value, path, `${typeName} less than or equal to ${maximum}`);
|
|
15
|
+
return value;
|
|
16
|
+
});
|
|
@@ -77,6 +77,7 @@ import createDeprecatedValidator from "./createDeprecatedValidator";
|
|
|
77
77
|
import createLiteralValidator from "./createLiteralValidator";
|
|
78
78
|
import createMapOfValuesValidator from "./createMapOfValuesValidator";
|
|
79
79
|
import createMinimumValidator from "./createMinimumValidator";
|
|
80
|
+
import createMaximumValidator from "./createMaximumValidator";
|
|
80
81
|
import createNoUnknownFieldsValidator from "./createNoUnknownFieldsValidator";
|
|
81
82
|
import createNonEmptyValidator from "./createNonEmptyValidator";
|
|
82
83
|
import createObjectOfValidator from "./createObjectOfValidator";
|
|
@@ -113,6 +114,9 @@ const minimumInteger = function minimumInteger(minValue) {
|
|
|
113
114
|
const minimumNumber = function minimumNumber(minValue) {
|
|
114
115
|
return nullSafeChain(this, createMinimumValidator("a number", minValue));
|
|
115
116
|
};
|
|
117
|
+
const maximumNumber = function maximumNumber(maxValue) {
|
|
118
|
+
return nullSafeChain(this, createMaximumValidator("a number", maxValue));
|
|
119
|
+
};
|
|
116
120
|
const integer = function integer() {
|
|
117
121
|
return nullSafeChain(this, integerValidator, {
|
|
118
122
|
minimum: minimumInteger
|
|
@@ -164,6 +168,7 @@ const literal = function literal(literalValue) {
|
|
|
164
168
|
const number = function number() {
|
|
165
169
|
return nullSafeChain(this, numberValidator, {
|
|
166
170
|
minimum: minimumNumber,
|
|
171
|
+
maximum: maximumNumber,
|
|
167
172
|
integer,
|
|
168
173
|
unique
|
|
169
174
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/alloy",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.20.0-alpha.0",
|
|
4
4
|
"description": "Adobe Experience Platform Web SDK",
|
|
5
5
|
"main": "libEs5/index.js",
|
|
6
6
|
"module": "libEs6/index.js",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"uuid": "^3.3.2"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@adobe/alloy": "^2.19.
|
|
73
|
+
"@adobe/alloy": "^2.19.1",
|
|
74
74
|
"@babel/cli": "^7.12.8",
|
|
75
75
|
"@babel/core": "^7.2.2",
|
|
76
76
|
"@babel/plugin-proposal-object-rest-spread": "^7.3.2",
|