@@ -50,6 +50,13 @@ const getAppsMediaEvent = async (
5050
5151export type OphanVideoStyle = 'youtube' | 'loop' | 'cinemagraph' | 'default' ;
5252
53+ const dispatchOphanAttentionEvent = (
54+ eventType : 'videoPlaying' | 'videoPause' | 'videoEnded' ,
55+ ) => {
56+ const event = new Event ( eventType , { bubbles : true } ) ;
57+ document . dispatchEvent ( event ) ;
58+ } ;
59+
5360const ophanTrackerWeb = ( id : string , videoStyle : OphanVideoStyle ) => {
5461 return ( trackingEvent : VideoEventKey ) : void => {
5562 void getOphan ( 'Web' ) . then ( ( ophan ) => {
@@ -69,6 +76,22 @@ const ophanTrackerWeb = (id: string, videoStyle: OphanVideoStyle) => {
6976 } ;
7077} ;
7178
79+ const ophanAttention = ( ) => {
80+ return ( trackingEvent : VideoEventKey ) : void => {
81+ if ( trackingEvent === 'play' || trackingEvent === 'resume' ) {
82+ dispatchOphanAttentionEvent ( 'videoPlaying' ) ;
83+ }
84+
85+ if ( trackingEvent === 'pause' ) {
86+ dispatchOphanAttentionEvent ( 'videoPause' ) ;
87+ }
88+
89+ if ( trackingEvent === 'end' ) {
90+ dispatchOphanAttentionEvent ( 'videoEnded' ) ;
91+ }
92+ } ;
93+ } ;
94+
7295const ophanTrackerApps = ( id : string , videoStyle : OphanVideoStyle ) => {
7396 return ( trackingEvent : VideoEventKey ) : void => {
7497 void getAppsMediaEvent ( trackingEvent ) . then ( ( appsMediaEvent ) => {
@@ -88,4 +111,4 @@ const ophanTrackerApps = (id: string, videoStyle: OphanVideoStyle) => {
88111 } ;
89112} ;
90113
91- export { ophanTrackerApps , ophanTrackerWeb } ;
114+ export { ophanAttention , ophanTrackerApps , ophanTrackerWeb } ;
0 commit comments