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

Method sendSubscriptionState

third_party/subscriptions-project/swg.js:14514–14544  ·  view source on GitHub ↗

@override

(state, jsonProducts)

Source from the content-addressed store, hash-verified

14512
14513 /** @override */
14514 sendSubscriptionState(state, jsonProducts) {
14515 if (!isEnumValue(SubscriptionState, state)) {
14516 throw new Error('Invalid subscription state provided');
14517 }
14518 if (
14519 (SubscriptionState.SUBSCRIBER == state ||
14520 SubscriptionState.PAST_SUBSCRIBER == state) &&
14521 !jsonProducts
14522 ) {
14523 throw new Error(
14524 'Entitlements must be provided for users with' +
14525 ' active or expired subscriptions'
14526 );
14527 }
14528 if (jsonProducts && !isObject(jsonProducts)) {
14529 throw new Error('Entitlements must be an Object');
14530 }
14531 let productsOrSkus = null;
14532 if (jsonProducts) {
14533 productsOrSkus = JSON.stringify(jsonProducts);
14534 }
14535 this.eventManager_.logEvent({
14536 eventType: AnalyticsEvent.EVENT_SUBSCRIPTION_STATE,
14537 eventOriginator: EventOriginator.PUBLISHER_CLIENT,
14538 isFromUserAction: null,
14539 additionalParameters: {
14540 state,
14541 productsOrSkus,
14542 },
14543 });
14544 }
14545
14546 /** @override */
14547 sendEvent(userEvent) {

Callers 1

sendSubscriptionStateMethod · 0.45

Calls 4

stringifyMethod · 0.80
isEnumValueFunction · 0.70
isObjectFunction · 0.70
logEventMethod · 0.45

Tested by

no test coverage detected