* Install event listeners for engaged singals. * `amp-analytics` waits for ampdoc to be visible first.
()
| 91 | * `amp-analytics` waits for ampdoc to be visible first. |
| 92 | */ |
| 93 | init_() { |
| 94 | this.setInitialEngagedSignals_(); |
| 95 | this.unlisteners_.push( |
| 96 | listen(this.win_, 'focus', () => { |
| 97 | this.isFocused_ = true; |
| 98 | this.updateEngagedForSessions_(); |
| 99 | }), |
| 100 | listen(this.win_, 'blur', () => { |
| 101 | this.isFocused_ = false; |
| 102 | this.updateEngagedForSessions_(); |
| 103 | }), |
| 104 | listen(this.win_, 'pageshow', () => { |
| 105 | this.isOpen_ = true; |
| 106 | this.updateEngagedForSessions_(); |
| 107 | }), |
| 108 | listen(this.win_, 'pagehide', () => { |
| 109 | this.isOpen_ = false; |
| 110 | this.updateEngagedForSessions_(); |
| 111 | }), |
| 112 | this.ampdoc_.onVisibilityChanged(() => { |
| 113 | this.isVisible_ = this.ampdoc_.isVisible(); |
| 114 | this.updateEngagedForSessions_(); |
| 115 | }) |
| 116 | ); |
| 117 | } |
| 118 | |
| 119 | /** Sets the initial states of the engaged signals used for all sessions. */ |
| 120 | setInitialEngagedSignals_() { |
no test coverage detected