Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwG Release 0.1.22.121 #30383

Merged
merged 1 commit into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion third_party/subscriptions-project/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** Version: 0.1.22.120 */
/** Version: 0.1.22.121 */
/**
* Copyright 2018 The Subscribe with Google Authors. All Rights Reserved.
*
Expand Down
186 changes: 164 additions & 22 deletions third_party/subscriptions-project/swg.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/** Version: 0.1.22.120 */
/** Version: 0.1.22.121 */
/**
* Copyright 2018 The Subscribe with Google Authors. All Rights Reserved.
*
Expand Down Expand Up @@ -5711,6 +5711,7 @@ const SubscriptionFlows = {
COMPLETE_DEFERRED_ACCOUNT_CREATION: 'completeDeferredAccountCreation',
LINK_ACCOUNT: 'linkAccount',
SHOW_LOGIN_PROMPT: 'showLoginPrompt',
SHOW_METER_REGWALL: 'showMeterRegwall',
SHOW_LOGIN_NOTIFICATION: 'showLoginNotification',
SHOW_METER_TOAST: 'showMeterToast',
};
Expand Down Expand Up @@ -6014,7 +6015,7 @@ function feCached(url) {
*/
function feArgs(args) {
return Object.assign(args, {
'_client': 'SwG 0.1.22.120',
'_client': 'SwG 0.1.22.121',
});
}

Expand Down Expand Up @@ -7133,7 +7134,7 @@ class ActivityPorts$1 {
'analyticsContext': context.toArray(),
'publicationId': pageConfig.getPublicationId(),
'productId': pageConfig.getProductId(),
'_client': 'SwG 0.1.22.120',
'_client': 'SwG 0.1.22.121',
'supportsEventManager': true,
},
args || {}
Expand Down Expand Up @@ -7982,7 +7983,7 @@ class AnalyticsService {
context.setTransactionId(getUuid());
}
context.setReferringOrigin(parseUrl$1(this.getReferrer_()).origin);
context.setClientVersion('SwG 0.1.22.120');
context.setClientVersion('SwG 0.1.22.121');
context.setUrl(getCanonicalUrl(this.doc_));

const utmParams = parseQueryString$1(this.getQueryString_());
Expand Down Expand Up @@ -10397,6 +10398,87 @@ const MeterClientTypes = {
LICENSED_BY_GOOGLE: 1,
};

/**
* Copyright 2020 The Subscribe with Google Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

class MeterToastApi {
/**
* @param {!./deps.DepsDef} deps
*/
constructor(deps) {
/** @private @const {!./deps.DepsDef} */
this.deps_ = deps;

/** @private @const {!Window} */
this.win_ = deps.win();

/** @private @const {!../components/activities.ActivityPorts} */
this.activityPorts_ = deps.activities();

/** @private @const {!../components/dialog-manager.DialogManager} */
this.dialogManager_ = deps.dialogManager();

/** @private @const {!ActivityIframeView} */
this.activityIframeView_ = new ActivityIframeView(
this.win_,
this.activityPorts_,
feUrl('/metertoastiframe'),
feArgs({
publicationId: deps.pageConfig().getPublicationId(),
productId: deps.pageConfig().getProductId(),
hasSubscriptionCallback: deps.callbacks().hasSubscribeRequestCallback(),
}),
/* shouldFadeBody */ true
);
}

/**
* Shows the user the metering toast.
* @return {!Promise}
*/
start() {
this.deps_
.callbacks()
.triggerFlowStarted(SubscriptionFlows.SHOW_METER_TOAST);
this.activityIframeView_.on(
ViewSubscriptionsResponse,
this.startNativeFlow_.bind(this)
);
return this.dialogManager_.openView(this.activityIframeView_);
}

/**
* Sets a callback function to happen onCancel.
* @param {function()} onCancelCallback
*/
setOnCancelCallback(onCancelCallback) {
this.activityIframeView_.onCancel(onCancelCallback);
}

/**
* @param {ViewSubscriptionsResponse} response
* @private
*/
startNativeFlow_(response) {
if (response.getNative()) {
this.deps_.callbacks().triggerSubscribeRequest();
}
}
}

/**
* Copyright 2018 The Subscribe with Google Authors. All Rights Reserved.
*
Expand Down Expand Up @@ -10995,8 +11077,12 @@ class EntitlementsManager {
* @private
*/
maybeShowToast_(entitlement) {
// Check if storage bit is set. It's only set by the `Entitlements.ack`
// method.
// Don't show toast for metering entitlements.
if (entitlement.source === GOOGLE_METERING_SOURCE) {
return Promise.resolve();
}

// Check if storage bit is set. It's only set by the `Entitlements.ack` method.
return this.storage_.get(TOAST_STORAGE_KEY).then((value) => {
const toastWasShown = value === '1';
if (toastWasShown) {
Expand Down Expand Up @@ -11033,27 +11119,14 @@ class EntitlementsManager {
*/
consume_(entitlements, onCloseDialog) {
if (entitlements.enablesThisWithGoogleMetering()) {
const activityIframeView_ = new ActivityIframeView(
this.win_,
this.deps_.activities(),
feUrl('/metertoastiframe'),
feArgs({
'productId': this.deps_.pageConfig().getProductId(),
'publicationId': this.deps_.pageConfig().getPublicationId(),
'productType': ProductType.UI_CONTRIBUTION,
'list': 'default',
'skus': null,
'isClosable': true,
}),
/* shouldFadeBody */ true
);
activityIframeView_.onCancel(() => {
const meterToastApi = new MeterToastApi(this.deps_);
meterToastApi.setOnCancelCallback(() => {
if (onCloseDialog) {
onCloseDialog();
}
this.sendPingback_(entitlements);
});
return this.deps_.dialogManager().openView(activityIframeView_);
return meterToastApi.start();
}
}

Expand Down Expand Up @@ -12458,6 +12531,67 @@ class LoginPromptApi {
}
}

/**
* Copyright 2020 The Subscribe with Google Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

class MeterRegwallApi {
/**
* @param {!./deps.DepsDef} deps
* @param {{ gsiUrl: string, alreadyRegisteredUrl: string}} params
*/
constructor(deps, params) {
/** @private @const {!./deps.DepsDef} */
this.deps_ = deps;

/** @private @const {!Window} */
this.win_ = deps.win();

/** @private @const {!../components/activities.ActivityPorts} */
this.activityPorts_ = deps.activities();

/** @private @const {!../components/dialog-manager.DialogManager} */
this.dialogManager_ = deps.dialogManager();

/** @private @const {!ActivityIframeView} */
this.activityIframeView_ = new ActivityIframeView(
this.win_,
this.activityPorts_,
feUrl('/meterregwalliframe'),
feArgs({
publicationId: deps.pageConfig().getPublicationId(),
productId: deps.pageConfig().getProductId(),
gsiUrl: params.gsiUrl,
alreadyRegisteredUrl: params.alreadyRegisteredUrl,
}),
/* shouldFadeBody */ true
);
}

/**
* Prompts the user to register to the meter.
* @return {!Promise}
*/
start() {
this.deps_
.callbacks()
.triggerFlowStarted(SubscriptionFlows.SHOW_METER_REGWALL);
return this.dialogManager_.openView(this.activityIframeView_);
}
}

/**
* Copyright 2018 The Subscribe with Google Authors. All Rights Reserved.
*
Expand Down Expand Up @@ -16924,6 +17058,14 @@ class ConfiguredRuntime {
});
}

/** @override */
showMeterRegwall(meterRegwallArgs) {
return this.documentParsed_.then(() => {
const wait = new MeterRegwallApi(this, meterRegwallArgs);
return wait.start();
});
}

/** @override */
setOnLoginRequest(callback) {
this.callbacks_.setOnLoginRequest(callback);
Expand Down