extensions/amp-analytics/0.1/events.js
/**
   * Triggers a custom event for the associated root.
   * @param {!AnalyticsEvent} event
   */
Triggers a custom event for the associated root.
Triggers a custom event for the associated root .
trigger(event) {
    const eventType = event['type'];
    const isSandboxEvent = startsWith(eventType, 'sandbox-');
    const observables = this.observables_[eventType];
    if (observables) {
      observables.fire(event);
      if (isSandboxEvent) {
        return;
      }
    }
    if (isSandboxEvent) {
      this.sandboxBuffer_[eventType] = this.sandboxBuffer_[eventType] || [];
      this.sandboxBuffer_[eventType].push(event);
    } else {
      if (this.buffer_) {
        this.buffer_[eventType] = this.buffer_[eventType] || [];
        this.buffer_[eventType].push(event);
      }
    }
  }
trigger ( event ) { const eventType = event [ 'type' ] ; const isSandboxEvent = startsWith ( eventType , 'sandbox-' ) ; const observables = this . observables_ [ eventType ] ; if ( observables ) { observables . fire ( event ) ; if ( isSandboxEvent ) { return ; } } if ( isSandboxEvent ) { this . sandboxBuffer_ [ eventType ] = this . sandboxBuffer_ [ eventType ] || [ ] ; this . sandboxBuffer_ [ eventType ] . push ( event ) ; } else { if ( this . buffer_ ) { this . buffer_ [ eventType ] = this . buffer_ [ eventType ] || [ ] ; this . buffer_ [ eventType ] . push ( event ) ; } } }
Triggers a custom event for the associated root.
Triggers a custom event for the associated root .
// If listeners already present - trigger right away. // No need to buffer sandbox event if handler ready // Create buffer and enqueue buffer if needed // Check if buffer has expired