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

feat(FEC-14049): add referrer to getPlaybackContext calls #240

Merged
merged 2 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/k-provider/common/base-provider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import {getLogLevel, setLogLevel, setLogger, LogLevelType, LogLevel} from '../../util/logger';
import DataLoaderManager from './data-loader-manager';
import Error from '../../util/error/error';
import {ProviderEntryListObject, ProviderMediaConfigObject, ProviderPlaylistInfoObject, ProviderMediaConfigSourcesObject, ProviderNetworkRetryParameters, ProviderOptionsObject, ProviderPlaylistObject} from '../../types';
import {
ProviderEntryListObject,
ProviderMediaConfigObject,
ProviderPlaylistInfoObject,
ProviderMediaConfigSourcesObject,
ProviderNetworkRetryParameters,
ProviderOptionsObject,
ProviderPlaylistObject
} from '../../types';

export default class BaseProvider<MI> {
private _partnerId: number;
Expand All @@ -11,7 +19,9 @@ export default class BaseProvider<MI> {
public _dataLoader!: DataLoaderManager;
private _playerVersion: string;
public _logger: any;
public _referrer?: string;
protected _isAnonymous: boolean;

public _networkRetryConfig: ProviderNetworkRetryParameters = {
async: true,
timeout: 0,
Expand Down Expand Up @@ -58,6 +68,7 @@ export default class BaseProvider<MI> {
this._isAnonymous = !options.ks;
this._ks = options.ks || '';
this._playerVersion = playerVersion;
this._referrer = options.referrer;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down Expand Up @@ -109,4 +120,4 @@ export default class BaseProvider<MI> {
}
}

export {BaseProvider}
export {BaseProvider};
8 changes: 4 additions & 4 deletions src/k-provider/ovp/loaders/media-entry-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {KalturaMediaEntry} from '../response-types';
import {ILoader} from '../../../types';

type OVPMediaEntryLoaderResponse = {
entry: KalturaMediaEntry,
playBackContextResult: KalturaPlaybackContext,
metadataListResult: KalturaMetadataListResponse
entry: KalturaMediaEntry;
playBackContextResult: KalturaPlaybackContext;
metadataListResult: KalturaMetadataListResponse;
};
export type {OVPMediaEntryLoaderResponse};

Expand Down Expand Up @@ -68,7 +68,7 @@ export default class OVPMediaEntryLoader implements ILoader {
requests.push(OVPBaseEntryService.list(config.serviceUrl, params.ks, params.entryId, params.redirectFromEntryId, params.referenceId));
// Use the entry id from the request result to support loading by referenceId
const serviceEntryId = params.ks === '{1:result:ks}' ? '{2:result:objects:0:id}' : '{1:result:objects:0:id}';
requests.push(OVPBaseEntryService.getPlaybackContext(config.serviceUrl, params.ks, serviceEntryId));
requests.push(OVPBaseEntryService.getPlaybackContext(config.serviceUrl, params.ks, serviceEntryId, params.referrer));
MosheMaorKaltura marked this conversation as resolved.
Show resolved Hide resolved
requests.push(OVPMetadataService.list(config.serviceUrl, params.ks, serviceEntryId));
return requests;
}
Expand Down
8 changes: 5 additions & 3 deletions src/k-provider/ovp/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import {
ProviderFilterOptionsObject,
ProviderMediaConfigObject,
ProviderMediaConfigSourcesObject,
ProviderOptionsObject, ProviderPlaylistInfoObject,
ProviderPlaylistObject, RequestLoader
ProviderOptionsObject,
ProviderPlaylistInfoObject,
ProviderPlaylistObject,
RequestLoader
} from '../../types';

export default class OVPProvider extends BaseProvider<OVPProviderMediaInfoObject> {
Expand Down Expand Up @@ -65,7 +67,7 @@ export default class OVPProvider extends BaseProvider<OVPProviderMediaInfoObject
this._dataLoader.add(OVPSessionLoader, {widgetId: this.widgetId});
}
const redirectFromEntryId = this._getEntryRedirectFilter(mediaInfo);
this._dataLoader.add(OVPMediaEntryLoader, {entryId, ks, redirectFromEntryId, referenceId});
this._dataLoader.add(OVPMediaEntryLoader, {entryId, ks, redirectFromEntryId, referenceId, referrer: this._referrer});
MosheMaorKaltura marked this conversation as resolved.
Show resolved Hide resolved
return this._dataLoader.fetchData().then(
response => {
try {
Expand Down
4 changes: 2 additions & 2 deletions src/k-provider/ovp/services/base-entry-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default class OVPBaseEntryService extends OVPService {
* @returns {RequestBuilder} The request builder
* @static
*/
public static getPlaybackContext(serviceUrl: string, ks: string, serviceEntryId: string): RequestBuilder {
public static getPlaybackContext(serviceUrl: string, ks: string, serviceEntryId: string, referrer?: string): RequestBuilder {
const headers: Map<string, string> = new Map();
headers.set('Content-Type', 'application/json');
const request = new RequestBuilder(headers);
Expand All @@ -23,7 +23,7 @@ export default class OVPBaseEntryService extends OVPService {
request.method = 'POST';
request.url = request.getUrl(serviceUrl);
request.tag = 'baseEntry-getPlaybackContext';
const contextDataParams = {objectType: 'KalturaContextDataParams', flavorTags: 'all'};
const contextDataParams = {objectType: 'KalturaContextDataParams', flavorTags: 'all', referrer};
request.params = {entryId: serviceEntryId, ks: ks, contextDataParams: contextDataParams};
return request;
}
Expand Down
1 change: 1 addition & 0 deletions src/types/provider-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export type ProviderOptionsObject = {
filterOptions?: ProviderFilterOptionsObject;
ignoreServerConfig?: boolean;
loadThumbnailWithKs?: boolean;
referrer?: string;
};
Loading