MCPcopy Create free account
hub / github.com/ampproject/amphtml / init_

Method init_

extensions/amp-analytics/0.1/session-manager.js:93–117  ·  view source on GitHub ↗

* Install event listeners for engaged singals. * `amp-analytics` waits for ampdoc to be visible first.

()

Source from the content-addressed store, hash-verified

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_() {

Callers 1

constructorMethod · 0.95

Calls 6

listenFunction · 0.90
pushMethod · 0.45
onVisibilityChangedMethod · 0.45
isVisibleMethod · 0.45

Tested by

no test coverage detected