Skip to content
Open
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
1 change: 1 addition & 0 deletions alpha/apps/kaltura/lib/reports/kDruidBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
const DRUID_TIME_FORMAT = 'timeFormat';
const DRUID_UNION = 'union';
const DRUID_PATTERN = 'pattern';
const DRUID_BY_ROW = 'byRow';

// druid response keywords
const DRUID_TIMESTAMP = 'timestamp';
Expand Down Expand Up @@ -375,7 +376,7 @@

if (self::$query_cache)
{
$cacheKey = 'druidQuery-' . md5($post);

Check warning on line 379 in alpha/apps/kaltura/lib/reports/kDruidBase.php

View check run for this annotation

OX Security / ox-security/scan

Weak Encryption Algorithm • PHP • Public Repo

Use strong, current encryption algorithms like AES-256. Avoid deprecated algorithms like DES, 3DES, RC4, and MD5. Use well-established cryptographic libraries and keep them updated.
$response = self::$query_cache->get($cacheKey);
if ($response)
{
Expand Down
34 changes: 34 additions & 0 deletions alpha/apps/kaltura/lib/reports/kKavaBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class kKavaBase extends kDruidBase
const DATASOURCE_MEETING_REALTIME = 'meeting-events-realtime';
const DATASOURCE_CNC_EVENTS = 'cnc-events';
const DATASOURCE_APPLICATION_EVENTS = 'application-events';
const DATASOURCE_IMMERSIVE_AGENTS_EVENTS = 'immersive-agents-events';

// dimensions
const DIMENSION_PARTNER_ID = 'partnerId';
Expand Down Expand Up @@ -91,6 +92,9 @@ class kKavaBase extends kDruidBase
const DIMENSION_COMPANY = 'company';
const DIMENSION_FLAVOR_ID = 'flavorId';
const DIMENSION_VIDEO_CODEC = 'videoCodec';
const DIMENSION_EVENT_MULTI_VAR1 = 'eventMultiVar1';
const DIMENSION_AGENT_ID = 'agentId';
const DIMENSION_GENIE_ID = 'genieId';

// metrics
const METRIC_COUNT = 'count';
Expand Down Expand Up @@ -197,6 +201,12 @@ class kKavaBase extends kDruidBase
const EVENT_TYPE_BUTTON_CLICKED = 'buttonClicked';
const EVENT_TYPE_QR_CODE_SCANNED = 'qrCodeScanned';

// event types - immersive agents events
const EVENT_TYPE_MESSAGE_RESPONSE = 'messageResponse';
const EVENT_TYPE_AVATAR_CALL_STARTED = 'callStarted';
const EVENT_TYPE_AVATAR_CALL_ENDED = 'callEnded';
const EVENT_TYPE_MESSAGE_FEEDBACK = 'messageFeedbackSent';

// view events
const VIEW_EVENT_INTERVAL = 10;
const VIEW_EVENT_PERIOD = 'PT10S';
Expand Down Expand Up @@ -344,6 +354,10 @@ class kKavaBase extends kDruidBase
const USER_TAB_NOT_FOCUSED_MIC_MUTED_FULL_SCREEN_OFF_CAMERA_ON_SOUND_OFF_ON_STAGE = 'TabNotFocusedMicMutedFullScreenOffCameraOnSoundOffOnStage';
const USER_TAB_NOT_FOCUSED_MIC_MUTED_FULL_SCREEN_OFF_CAMERA_ON_SOUND_OFF_OFF_STAGE = 'TabNotFocusedMicMutedFullScreenOffCameraOnSoundOffOffStage';

// immersive agents experience values
const CHAT_EXPERIENCE = 'Chat';
const CALL_EXPERIENCE = 'Call';

protected static $realtime_engagement = array(
self::USER_SOUND_ON_TAB_FOCUSED,
self::USER_SOUND_ON_TAB_FOCUSED_FULL_SCREEN,
Expand Down Expand Up @@ -607,6 +621,13 @@ class kKavaBase extends kDruidBase
self::EVENT_TYPE_VE_PARTICIPATED_POST_EVENT,
);

protected static $immersive_agents_events_types = array(
self::EVENT_TYPE_MESSAGE_RESPONSE,
self::EVENT_TYPE_AVATAR_CALL_STARTED,
self::EVENT_TYPE_AVATAR_CALL_ENDED,
self::EVENT_TYPE_MESSAGE_FEEDBACK
);

//general values
const VALUE_UNKNOWN = 'Unknown';
const VALUE_ZERO = '0';
Expand Down Expand Up @@ -881,6 +902,19 @@ class kKavaBase extends kDruidBase
self::DIMENSION_EVENT_VAR3 => 1,
self::DIMENSION_EVENT_VAR4 => 1,
self::DIMENSION_VIRTUAL_EVENT_ID => 1,
),
self::DATASOURCE_IMMERSIVE_AGENTS_EVENTS => array(
self::DIMENSION_EVENT_TYPE => 1,
self::DIMENSION_PARTNER_ID => 1,
self::DIMENSION_PARTNER_PARENT_ID => 1,
self::DIMENSION_CONTEXT_ID => 1,
self::DIMENSION_KUSER_ID => 1,
self::DIMENSION_GENIE_ID => 1,
self::DIMENSION_AGENT_ID => 1,
self::DIMENSION_EVENT_VAR1 => 1,
self::DIMENSION_EVENT_VAR2 => 1,
self::DIMENSION_EVENT_VAR3 => 1,
self::DIMENSION_EVENT_MULTI_VAR1 => 1,
)
);

Expand Down
59 changes: 59 additions & 0 deletions alpha/apps/kaltura/lib/reports/kKavaImmersiveAgentsReports.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

class kKavaImmersiveAgentsReports extends kKavaReportsMgr
{
protected static $reports_def = array(

ReportType::IMMERSIVE_AGENTS_HIGHLIGHTS => array(
self::REPORT_METRICS => array(self::METRIC_UNIQUE_THREADS, self::EVENT_TYPE_MESSAGE_RESPONSE, self::METRIC_AVG_MESSAGES, self::METRIC_UNIQUE_USERS),
self::REPORT_GRAPH_METRICS => array(self::METRIC_UNIQUE_THREADS, self::EVENT_TYPE_MESSAGE_RESPONSE, self::METRIC_AVG_MESSAGES, self::METRIC_UNIQUE_USERS),
),

ReportType::IMMERSIVE_AGENTS_MESSAGES_OVERTIME => array(
self::REPORT_GRAPH_METRICS => array(self::EVENT_TYPE_MESSAGE_RESPONSE)
),

ReportType::IMMERSIVE_AGENTS_MESSAGE_FEEDBACK => array(
self::REPORT_DIMENSION_MAP => array(
'reactionType' => self::DIMENSION_EVENT_VAR2,
),
self::REPORT_METRICS => array(self::EVENT_TYPE_MESSAGE_FEEDBACK)
),

ReportType::IMMERSIVE_AGENTS_TOP_SOURCES => array(
self::REPORT_DIMENSION_MAP => array(
'source' => self::DIMENSION_EVENT_MULTI_VAR1,
'source_name' => self::DIMENSION_EVENT_MULTI_VAR1,
'source_type' => self::DIMENSION_EVENT_MULTI_VAR1,
),
self::REPORT_ENRICH_DEF => array(
self::REPORT_ENRICH_OUTPUT => array('source_name','source_type'),
self::REPORT_ENRICH_FUNC => 'kKavaReportsMgr::genericQueryEnrich',
self::REPORT_ENRICH_CONTEXT => array(
'peer' => 'entryPeer',
'columns' => array('NAME', 'MEDIA_TYPE'),
),
),
self::REPORT_METRICS => array(self::EVENT_TYPE_MESSAGE_RESPONSE, self::METRIC_UNIQUE_USERS)
),

ReportType::IMMERSIVE_AGENTS_AVATAR_SESSIONS => array(
self::REPORT_METRICS => array(self::EVENT_TYPE_AVATAR_CALL_STARTED, self::METRIC_AVATAR_CALL_DURATION, self::METRIC_AVATAR_AVG_CALL_DURATION),
)

);

public static function getReportDef($report_type, $input_filter, $response_options = null)
{
$report_def = isset(self::$reports_def[$report_type]) ? self::$reports_def[$report_type] : null;
if (is_null($report_def))
{
return null;
}

$report_def[self::REPORT_DATA_SOURCE] = self::DATASOURCE_IMMERSIVE_AGENTS_EVENTS;
self::initTransformTimeDimensions();

return $report_def;
}
}
71 changes: 64 additions & 7 deletions alpha/apps/kaltura/lib/reports/kKavaReportsMgr.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
const METRIC_SEGMENT_DOWNLOAD_TIME_SUM = 'segmentDownloadTimeSum';
const METRIC_MANIFEST_DOWNLOAD_TIME_SUM = 'manifestDownloadTimeSum';
const METRIC_VIEW_TIME_SUM = 'viewTimeSum';
const METRIC_UNIQUE_THREAD_IDS = 'uniqueThreadIds';
const METRIC_CALL_DURATION_SUM = 'callDurationSum';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think there is already a use case where we need to return number of calls (maybe per agents)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the avatar call started event, no need to define another metric for this.


// druid calculated metrics
const METRIC_QUARTILE_PLAY_TIME = 'sum_time_viewed';
Expand Down Expand Up @@ -149,7 +151,11 @@
const METRIC_MEETING_CAMERA_ON_VIEW_TIME = 'meeting_camera_on_view_time';
const METRIC_TRANSCODING_ADDED_ENTRIES_DURATION_SEC = 'transcoding_added_entries_duration_sec';
const METRIC_TRANSCODING_ADDED_ENTRIES_DURATION = 'transcoding_added_entries_duration';

const METRIC_UNIQUE_THREADS = 'unique_threads';
const METRIC_AVG_MESSAGES = 'avg_messages';
const METRIC_AVATAR_CALL_MESSAGES = 'avatar_call_messages';
const METRIC_AVATAR_CALL_DURATION = 'avatar_call_duration';
const METRIC_AVATAR_AVG_CALL_DURATION = 'avatar_avg_call_duration';

// druid intermediate metrics
const METRIC_PLAYTHROUGH = 'play_through';
Expand All @@ -170,6 +176,7 @@
const METRIC_MEETING_VIEW_TIME_SEC = 'meeting_view_time_sec';
const METRIC_UNION_LIVE_MEETING_VIEW_TIME = 'union_live_meeting_view_time';
const METRIC_UNION_LIVE_MEETING_VOD_VIEW_TIME = 'union_live_meeting_vod_view_time';
const METRIC_AVATAR_CALL_DURATION_SEC = 'avatar_call_duration_sec';

// non druid metrics
const METRIC_BANDWIDTH_STORAGE_MB = 'combined_bandwidth_storage';
Expand Down Expand Up @@ -276,6 +283,7 @@
const KAVA_VE_REGISTRATION_CLASS = 'kKavaVeRegistrationReports';
const KAVA_EP_REPORTS_CLASS = 'kKavaEventPlatformReports';
const KAVA_CNC_REPORTS_CLASS = 'kKavaCnCReports';
const KAVA_IMMERSIVE_AGENTS_CLASS = 'kKavaImmersiveAgentsReports';

/// report settings
// report settings - common
Expand Down Expand Up @@ -496,6 +504,10 @@
self::EVENT_TYPE_BUTTON_CLICKED,
self::EVENT_TYPE_QR_CODE_SCANNED,
self::EVENT_TYPE_DOCUMENT_IMPRESSION,
self::EVENT_TYPE_MESSAGE_RESPONSE,
self::EVENT_TYPE_AVATAR_CALL_STARTED,
self::EVENT_TYPE_AVATAR_CALL_ENDED,
self::EVENT_TYPE_MESSAGE_FEEDBACK,
);

protected static $media_type_count_aggrs = array(
Expand Down Expand Up @@ -619,6 +631,7 @@
self::METRIC_UNIQUE_PRIVATE_MESSAGE_SENT_USERS => 'floor',
self::METRIC_UNIQUE_ATTENDEES => 'floor',
self::METRIC_VE_ATTENDED_UNIQUE_USERS => 'floor',
self::METRIC_UNIQUE_THREADS => 'floor',
);

protected static $transform_time_dimensions = null;
Expand Down Expand Up @@ -695,11 +708,14 @@
self::METRIC_PRIVATE_CHAT_PARTICIPATION => true,
self::METRIC_UNIQUE_ATTENDEES => true,
self::METRIC_VE_ATTENDED_UNIQUE_USERS => true,
self::METRIC_UNIQUE_THREADS => true,
self::METRIC_AVATAR_AVG_CALL_DURATION => true,
);

protected static $multi_value_dimensions = array(
self::DIMENSION_CATEGORIES,
self::DIMENSION_POSITION,
self::DIMENSION_EVENT_MULTI_VAR1,
);

protected static $dynamic_metrics = array(
Expand Down Expand Up @@ -820,6 +836,7 @@
5 => self::KAVA_VE_REGISTRATION_CLASS,
6 => self::KAVA_EP_REPORTS_CLASS,
7 => self::KAVA_CNC_REPORTS_CLASS,
8 => self::KAVA_IMMERSIVE_AGENTS_CLASS,
);

protected static $aggregations_def = array();
Expand Down Expand Up @@ -1530,10 +1547,17 @@
self::getNotFilter(self::getInFilter(self::DIMENSION_SOURCE_TYPE, array('Recorded Live Stream'))))),
self::getLongSumAggregator(self::METRIC_TRANSCODING_ADDED_ENTRIES_DURATION_SEC, self::METRIC_DURATION_SEC));

self::$metrics_def[self::METRIC_TRANSCODING_ADDED_ENTRIES_DURATION] = array(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this was needed to be moved?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved it to the list of metrics, it was in the aggregations definitions list.

self::DRUID_AGGR => array(self::METRIC_TRANSCODING_ADDED_ENTRIES_DURATION_SEC),
self::DRUID_POST_AGGR => self::getConstantRatioPostAggr(
self::METRIC_TRANSCODING_ADDED_ENTRIES_DURATION, self::METRIC_TRANSCODING_ADDED_ENTRIES_DURATION_SEC, '60'));
self::$aggregations_def[self::METRIC_UNIQUE_THREADS] = self::getFilteredAggregator(
self::getInFilter(self::DIMENSION_EVENT_TYPE, self::$immersive_agents_events_types),
self::getHyperUniqueAggregator(self::METRIC_UNIQUE_THREADS, self::METRIC_UNIQUE_THREAD_IDS));

self::$aggregations_def[self::METRIC_AVATAR_CALL_MESSAGES] = self::getFilteredAggregator(
self::getSelectorFilter(self::DIMENSION_EVENT_VAR2, self::CALL_EXPERIENCE),
self::getLongSumAggregator(self::EVENT_TYPE_MESSAGE_RESPONSE, self::METRIC_COUNT));

self::$aggregations_def[self::METRIC_AVATAR_CALL_DURATION_SEC] = self::getFilteredAggregator(
self::getSelectorFilter(self::DIMENSION_EVENT_TYPE, self::EVENT_TYPE_AVATAR_CALL_ENDED),
self::getLongSumAggregator(self::METRIC_AVATAR_CALL_DURATION_SEC, self::METRIC_CALL_DURATION_SUM));

// Note: metrics that have post aggregations are defined below, any metric that
// is not explicitly set on $metrics_def is assumed to be a simple aggregation
Expand Down Expand Up @@ -2047,6 +2071,30 @@
self::getHyperUniqueCardinalityPostAggregator(self::METRIC_UNIQUE_PRIVATE_MESSAGE_SENT_USERS, self::METRIC_UNIQUE_PRIVATE_MESSAGE_SENT_USERS),
self::getHyperUniqueCardinalityPostAggregator(self::METRIC_UNIQUE_LOGGED_IN_USERS, self::METRIC_UNIQUE_LOGGED_IN_USERS))));

self::$metrics_def[self::METRIC_TRANSCODING_ADDED_ENTRIES_DURATION] = array(
self::DRUID_AGGR => array(self::METRIC_TRANSCODING_ADDED_ENTRIES_DURATION_SEC),
self::DRUID_POST_AGGR => self::getConstantRatioPostAggr(
self::METRIC_TRANSCODING_ADDED_ENTRIES_DURATION, self::METRIC_TRANSCODING_ADDED_ENTRIES_DURATION_SEC, '60'));

self::$metrics_def[self::METRIC_AVG_MESSAGES] = array(
self::DRUID_AGGR => array(self::EVENT_TYPE_MESSAGE_RESPONSE, self::METRIC_UNIQUE_THREADS),
self::DRUID_POST_AGGR => self::getArithmeticPostAggregator(
self::METRIC_AVG_MESSAGES, "/", array(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can there be 0 division?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Druid does not throw an error in such case

self::getFieldAccessPostAggregator(self::EVENT_TYPE_MESSAGE_RESPONSE),
self::getHyperUniqueCardinalityPostAggregator(self::METRIC_UNIQUE_THREADS, self::METRIC_UNIQUE_THREADS))));

self::$metrics_def[self::METRIC_AVATAR_CALL_DURATION] = array(
self::DRUID_AGGR => array(self::METRIC_AVATAR_CALL_DURATION_SEC),
self::DRUID_POST_AGGR => self::getConstantRatioPostAggr(
self::METRIC_AVATAR_CALL_DURATION, self::METRIC_AVATAR_CALL_DURATION_SEC, '60'));

self::$metrics_def[self::METRIC_AVATAR_AVG_CALL_DURATION] = array(
self::DRUID_AGGR => array(self::METRIC_AVATAR_CALL_DURATION_SEC, self::EVENT_TYPE_AVATAR_CALL_ENDED),
self::DRUID_POST_AGGR => self::getArithmeticPostAggregator(
self::METRIC_AVATAR_AVG_CALL_DURATION, '/', array(
self::getConstantRatioPostAggr('subCallDuration', self::METRIC_AVATAR_CALL_DURATION_SEC, '60'),
self::getFieldAccessPostAggregator(self::EVENT_TYPE_AVATAR_CALL_ENDED))));

self::$headers_to_metrics = array_flip(self::$metrics_to_headers);

self::$combined_metrics = array(
Expand Down Expand Up @@ -3006,6 +3054,8 @@
'companies' => array(self::DRUID_DIMENSION => self::DIMENSION_COMPANY),
'event_session_context_ids' => array(self::DRUID_DIMENSION => self::DIMENSION_EVENT_SESSION_CONTEXT_ID),
'video_codec' => array(self::DRUID_DIMENSION => self::DIMENSION_VIDEO_CODEC),
'agent_ids' => array(self::DRUID_DIMENSION => self::DIMENSION_AGENT_ID),
'genie_ids' => array(self::DRUID_DIMENSION => self::DIMENSION_GENIE_ID),
);

foreach ($field_dim_map as $field => $field_filter_def)
Expand Down Expand Up @@ -3453,10 +3503,17 @@
{
$report_def = self::getBaseReportDef($data_source, $partner_id, $intervals, array(), $filter, self::DRUID_GRANULARITY_ALL, $filter_metrics);
$report_def[self::DRUID_QUERY_TYPE] = self::DRUID_TIMESERIES;
$report_def[self::DRUID_AGGR][] = array(
$cardinality_aggr = array(
self::DRUID_TYPE => self::DRUID_CARDINALITY,
self::DRUID_NAME => self::METRIC_CARDINALITY,
self::DRUID_FIELDS => is_array($dimension) ? $dimension : array($dimension));
self::DRUID_FIELDS => is_array($dimension) ? $dimension : array($dimension)
);
if (in_array($dimension, self::$multi_value_dimensions))
{
$cardinality_aggr[self::DRUID_BY_ROW] = false;
}
$report_def[self::DRUID_AGGR][] = $cardinality_aggr;

return $report_def;
}

Expand Down Expand Up @@ -5767,7 +5824,7 @@

protected static function getTotalTableCount($partner_id, $report_def, reportsInputFilter $input_filter, $intervals, $druid_filter, $dimension, $object_ids, $response_options)
{
$cache_key = 'reportCount-' . md5("$partner_id|".serialize($report_def)."|$object_ids|".serialize($input_filter));

Check warning on line 5827 in alpha/apps/kaltura/lib/reports/kKavaReportsMgr.class.php

View check run for this annotation

OX Security / ox-security/scan

Weak Encryption Algorithm • PHP • Public Repo

Use strong, current encryption algorithms like AES-256. Avoid deprecated algorithms like DES, 3DES, RC4, and MD5. Use well-established cryptographic libraries and keep them updated.

$cache = kCacheManager::getSingleLayerCache(kCacheManager::CACHE_TYPE_REPORTS_COUNT);
if ($cache)
Expand Down
2 changes: 2 additions & 0 deletions alpha/apps/kaltura/lib/reports/myReportsMgr.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@
private static function createCacheKey ( $partner_id , $report_type , reportsInputFilter $input_filter , $object_ids )
{
if ( strlen( $partner_id ) > 40 )
$partner_id_str = md5($partner_id);

Check warning on line 671 in alpha/apps/kaltura/lib/reports/myReportsMgr.class.php

View check run for this annotation

OX Security / ox-security/scan

Weak Encryption Algorithm • PHP • Public Repo

Use strong, current encryption algorithms like AES-256. Avoid deprecated algorithms like DES, 3DES, RC4, and MD5. Use well-established cryptographic libraries and keep them updated.
else
$partner_id_str = $partner_id;

Expand Down Expand Up @@ -1569,6 +1569,8 @@
public $companies;
public $event_session_context_ids;
public $video_codec;
public $agent_ids;
public $genie_ids;

public function getFilterBy() {
return "";
Expand Down
6 changes: 6 additions & 0 deletions alpha/lib/enums/ReportType.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,10 @@ interface ReportType extends BaseEnum
const EP_LATEST_DOWNLOADED_ATTACHMENTS = 60019;

const CNC_PARTICIPATION = 70001;

const IMMERSIVE_AGENTS_HIGHLIGHTS = 80001;
const IMMERSIVE_AGENTS_MESSAGES_OVERTIME = 80002;
const IMMERSIVE_AGENTS_MESSAGE_FEEDBACK = 80003;
const IMMERSIVE_AGENTS_TOP_SOURCES = 80004;
const IMMERSIVE_AGENTS_AVATAR_SESSIONS = 80005;
}
14 changes: 14 additions & 0 deletions api_v3/lib/types/report/KalturaReportInputFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,18 @@ class KalturaReportInputFilter extends KalturaReportInputBaseFilter
*/
public $videoCodecIn;

/**
* filter by agent id
* @var string
*/
public $agentIdIn;

/**
* filter by Genie id
* @var string
*/
public $genieIdIn;

private static $map_between_objects = array
(
'keywords',
Expand Down Expand Up @@ -386,6 +398,8 @@ class KalturaReportInputFilter extends KalturaReportInputBaseFilter
'companyIn' => 'companies',
'eventSessionContextIdIn' => 'event_session_context_ids',
'videoCodecIn' => 'video_codec',
'agentIdIn' => 'agent_ids',
'genieIdIn' => 'genie_ids',
);

protected function getMapBetweenObjects()
Expand Down
Loading