src/runtime/entitlements-manager.js
/**
   * Sends a pingback that marks a metering entitlement as used.
   * @param {!Entitlements} entitlements
   */
Sends a pingback that marks a metering entitlement as used.
@param {!Entitlements} entitlements
Sends a pingback that marks a metering entitlement as used . @param { !Entitlements } entitlements
consumeMeter_(entitlements) {
    const entitlement = entitlements.getEntitlementForThis();
    if (!entitlement || entitlement.source !== GOOGLE_METERING_SOURCE) {
      return;
    }
    if (!queryStringHasFreshGaaParams(this.win_.location.search)) {
      return;
    }
    this.deps_
      .eventManager()
      .logSwgEvent(AnalyticsEvent.EVENT_UNLOCKED_BY_METER, false);
    const token = this.getGaaToken_();
    const jwt = new EntitlementJwt();
    jwt.setSource(entitlement.source);
    jwt.setJwt(entitlement.subscriptionToken);
    return this.postEntitlementsRequest_(
      jwt,
      EntitlementResult.UNLOCKED_METER,
      EntitlementSource.GOOGLE_SHOWCASE_METERING_SERVICE,
      token
    );
  }
consumeMeter_ ( entitlements ) { const entitlement = entitlements . getEntitlementForThis ( ) ; if ( ! entitlement || entitlement . source !== GOOGLE_METERING_SOURCE ) { return ; } if ( ! queryStringHasFreshGaaParams ( this . win_ . location . search ) ) { return ; } this . deps_ . eventManager ( ) . logSwgEvent ( AnalyticsEvent . EVENT_UNLOCKED_BY_METER , false ) ; const token = this . getGaaToken_ ( ) ; const jwt = new EntitlementJwt ( ) ; jwt . setSource ( entitlement . source ) ; jwt . setJwt ( entitlement . subscriptionToken ) ; return this . postEntitlementsRequest_ ( jwt , EntitlementResult . UNLOCKED_METER , EntitlementSource . GOOGLE_SHOWCASE_METERING_SERVICE , token ) ; }
Sends a pingback that marks a metering entitlement as used.
Sends a pingback that marks a metering entitlement as used .
// Verify GAA params are present, otherwise bail since the pingback // shouldn't happen on non-metering requests.