Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media Collection support #370

Merged
merged 54 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
b87150e
adding support for media
Nov 15, 2023
4df99d8
adding support for meedia in launch
Nov 21, 2023
72332de
adding media event types
Nov 21, 2023
a45e0e4
adding more functionality to the media events
Nov 29, 2023
7bdd97e
adding supoort for legacy media api
Nov 30, 2023
e052c70
refactoring
Dec 20, 2023
2a41e2e
adding the register session event details
Jan 21, 2024
e42d79a
moving sessionstart to send event action
Mar 9, 2024
19be162
add a section with data element component
Mar 10, 2024
f3b29ea
fix get initial values
Mar 10, 2024
5eefd93
remove create media session action
Mar 13, 2024
5abab60
remove Media session received event
Mar 13, 2024
70e75a5
add session start to sendMediaEvent action
Mar 13, 2024
73a9442
refactor sessionStart
Mar 17, 2024
8d89754
refactor ads section
Mar 17, 2024
0eb6f5e
renaming/ refactoring
Mar 21, 2024
3b787bc
adding changes to send media event actions
Mar 27, 2024
027e67d
resolving conflicts after merging main
Mar 27, 2024
092d5e3
not return empty string values, remove alloy import
Mar 27, 2024
6ffb81d
add custom metadata
Mar 28, 2024
9382dd5
refactor of the form
Mar 29, 2024
bf8ed88
add test for configurations
Mar 29, 2024
5605bf1
fix bug
Apr 1, 2024
355df35
add states to the UI, handle media sessions with caching
Apr 9, 2024
b898aad
fix naming
Apr 9, 2024
9816e96
adding qoe data element and adjusting the manifest
Apr 10, 2024
3794de7
remove custom metadata from ad break start
Apr 10, 2024
d385a83
fix playhead and qoe
Apr 17, 2024
ab35969
Merge branch 'main' into media
Apr 17, 2024
6cab319
add formated files
Apr 17, 2024
27bdd7f
fix number field component
Apr 17, 2024
6dc96b0
refactor the getMediaAnalyticsTracker
Apr 18, 2024
5702701
add changes to inputs for send media event
Apr 18, 2024
79c352b
add changes to inputs for configuration
Apr 18, 2024
e633214
add more refactoring
Apr 18, 2024
8ed5252
return session promise
Apr 22, 2024
2caff91
return session promise
Apr 22, 2024
2c34fec
rename to streaming media
Apr 25, 2024
9056050
revert extension name
Apr 25, 2024
b8d544c
remove campaignId required from ad start
May 3, 2024
bc317e4
add interactive configuration ui for media
May 3, 2024
86e6989
added some ui improvements
May 3, 2024
a2f1a7c
fix numberfield validation
May 7, 2024
21be45a
extracted predefined values andsorted
May 7, 2024
ce44adc
fix states updats form
May 7, 2024
64bd107
add a note for getmediatracker
May 7, 2024
c2f7104
merging main
May 7, 2024
948a7c7
feedback changes
May 8, 2024
2baf070
resolving conflicts
May 8, 2024
de715b4
add default extension settings in the send media event view
May 14, 2024
ee9ecff
add updated descriptions for extension config fields
May 16, 2024
b9d1d4d
fix onChange
May 16, 2024
a86a288
fix tests after renaming
May 16, 2024
9acf7f2
rename
May 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
129 changes: 129 additions & 0 deletions scripts/helpers/createExtensionManifest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,26 @@ const createExtensionManifest = ({ version }) => {
minLength: 1
},
edgeConfigOverrides: createEdgeConfigOverridesSchema(false),
streamingMedia: {
type: "object",
properties: {
channel: {
type: "string"
},
playerName: {
type: "string"
},
appVersion: {
type: "string"
},
mainPingInterval: {
type: "integer"
},
adPingInterval: {
type: "integer"
}
}
},
personalizationStorageEnabled: {
type: "boolean"
}
Expand Down Expand Up @@ -796,6 +816,58 @@ const createExtensionManifest = ({ version }) => {
libPath: "dist/lib/actions/updateVariable/index.js",
viewPath: "actions/updateVariable.html"
},
{
displayName: "Send Media Event",
name: "send-media-event",
schema: {
$schema: "http://json-schema.org/draft-04/schema#",
type: "object",
properties: {
instanceName: {
type: "string",
minLength: 1
},
handleMediaSessionAutomatically: {
type: "boolean"
},
eventType: {
type: "string",
minLength: 1
},
playerId: {
type: "string",
minLength: 1
},
xdm: {
type: "object"
}
},
required: ["instanceName", "playerId"]
},
libPath: "dist/lib/actions/sendMediaEvent/index.js",
viewPath: "actions/sendStreamingMediaEvent.html"
},
{
displayName: "Get Media Analytics Tracker",
name: "get-media-tracker",
schema: {
$schema: "http://json-schema.org/draft-04/schema#",
type: "object",
properties: {
instanceName: {
type: "string",
minLength: 1
},
objectName: {
type: "string",
minLength: 1
}
},
required: ["instanceName"]
},
libPath: "dist/lib/actions/getMediaAnalyticsTracker/index.js",
viewPath: "actions/createMediaTracker.html"
},
{
displayName: "Evaluate rulesets",
name: "evaluate-rulesets",
Expand Down Expand Up @@ -894,6 +966,63 @@ const createExtensionManifest = ({ version }) => {
}
],
dataElements: [
{
displayName: "Media: Quality of Experience data",
name: "qoe-details-data",
schema: {
$schema: "http://json-schema.org/draft-04/schema#",
type: "object",
properties: {
bitrate: {
oneOf: [
{
type: "integer"
},
{
type: "string",
pattern: "^%[^%]+%$"
}
]
},
droppedFrames: {
oneOf: [
{
type: "integer"
},
{
type: "string",
pattern: "^%[^%]+%$"
}
]
},
framesPerSecond: {
oneOf: [
{
type: "integer"
},
{
type: "string",
pattern: "^%[^%]+%$"
}
]
},
timeToStart: {
oneOf: [
{
type: "integer"
},
{
type: "string",
pattern: "^%[^%]+%$"
}
]
}
},
additionalProperties: false
},
libPath: "dist/lib/dataElements/qoeDetailsData/index.js",
viewPath: "dataElements/qoeDetailsDataElement.html"
},
{
displayName: "Event merge ID",
name: "event-merge-id",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
Copyright 2024 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

module.exports =
({ instanceManager, windowObject }) =>
settings => {
const { instanceName, objectName = "Media" } = settings;
const instance = instanceManager.getInstance(instanceName);

if (!instance) {
throw new Error(
`Failed to get a Media Analytics Tracker for "${instanceName}". No matching instance was configured with this name.`
);
}

return instance("getMediaAnalyticsTracker", {}).then(result => {
windowObject[objectName] = result;
});
};
21 changes: 21 additions & 0 deletions src/lib/actions/getMediaAnalyticsTracker/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

const getMediaAnalyticsTracker = require("./getMediaAnalyticsTracker");
const instanceManager = require("../../instanceManager/index");

const windowObject = window;

module.exports = getMediaAnalyticsTracker({
instanceManager,
windowObject
});
76 changes: 76 additions & 0 deletions src/lib/actions/sendMediaEvent/createMediaSession.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
Copyright 2024 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

module.exports =
({ instanceManager, mediaCollectionSessionStorage, satelliteApi }) =>
settings => {
const { instanceName, handleMediaSessionAutomatically, playerId, xdm } =
settings;
const instance = instanceManager.getInstance(instanceName);

const options = { xdm };
const sessionDetails = mediaCollectionSessionStorage.get({ playerId });

if (sessionDetails) {
return Promise.resolve();
}
const { playhead, qoeDataDetails } = xdm.mediaCollection;
// eslint-disable-next-line no-underscore-dangle
const playheadVar = window._satellite.getVar(playhead);
xdm.mediaCollection.playhead = playheadVar;

if (qoeDataDetails) {
// eslint-disable-next-line no-underscore-dangle
const qoeDataDetailsVar = window._satellite.getVar(qoeDataDetails);
xdm.mediaCollection.qoeDataDetails = qoeDataDetailsVar;
}

if (handleMediaSessionAutomatically) {
options.playerId = playerId;

options.getPlayerDetails = () => {
// eslint-disable-next-line no-underscore-dangle
const playerDetails = {
// eslint-disable-next-line no-underscore-dangle
playhead: window._satellite.getVar(playhead)
};

if (qoeDataDetails) {
// eslint-disable-next-line no-underscore-dangle
playerDetails.qoeDataDetails = satelliteApi.getVar(qoeDataDetails);
}

return playerDetails;
};
}

const sessionPromise = instance("createMediaSession", options)
.then(result => {
const { sessionId } = result;
return sessionId;
})
.catch(error => {
console.error("Error creating media session", error);
throw error;
});

mediaCollectionSessionStorage.add({
playerId,
sessionDetails: {
handleMediaSessionAutomatically,
sessionPromise,
playhead,
qoeDataDetails
}
});
return sessionPromise;
};
71 changes: 71 additions & 0 deletions src/lib/actions/sendMediaEvent/createSendMediaEvent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
Copyright 2024 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

module.exports = ({
instanceManager,
trackMediaSession,
mediaCollectionSessionStorage,
satelliteApi
}) => {
return settings => {
const {instanceName, eventType, playerId, xdm} = settings;
const instance = instanceManager.getInstance(instanceName);

if (!instance) {
throw new Error(
`Failed to send media event for instance "${instanceName}". No matching instance was configured with this name.`
);
}

if (eventType === "media.sessionStart") {
return trackMediaSession(settings);
}

const sessionDetails = mediaCollectionSessionStorage.get({playerId});
if (!sessionDetails) {
console.warn(
`No media session found for player ID ${playerId}. Skipping media event ${eventType}. Make sure the session has started.`
);
return Promise.resolve();
}
return sessionDetails.sessionPromise.then(sessionID => {
if (
eventType === "media.sessionEnd" ||
eventType === "media.sessionComplete"
) {
mediaCollectionSessionStorage.remove({playerId});
}

xdm.eventType = eventType;

const options = {xdm};

if (sessionDetails.handleMediaSessionAutomatically) {
options.playerId = playerId;
} else {
xdm.mediaCollection.playhead = satelliteApi.getVar(
sessionDetails.playhead
);

if (sessionDetails.qoeDataDetails) {
xdm.mediaCollection.qoeDataDetails = satelliteApi.getVar(
sessionDetails.qoeDataDetails
);
}

xdm.mediaCollection.sessionID = sessionID;
}

return instance("sendMediaEvent", options);
});
}
};
31 changes: 31 additions & 0 deletions src/lib/actions/sendMediaEvent/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright 2024 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

const createMediaEvent = require("./createSendMediaEvent");
const createMediaSession = require("./createMediaSession");
const instanceManager = require("../../instanceManager/index");
const { mediaCollectionSessionStorage } = require("../../index");

// eslint-disable-next-line no-underscore-dangle
const satelliteApi = window._satellite;

const trackMediaSession = createMediaSession({
instanceManager,
mediaCollectionSessionStorage,
satelliteApi
});
module.exports = createMediaEvent({
instanceManager,
trackMediaSession,
mediaCollectionSessionStorage,
satelliteApi
});