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

Allow subscriptions.configure() to be called with a Config object from GaaMetering.init() #3502

Merged

Conversation

everyplace
Copy link
Contributor

@everyplace everyplace commented May 6, 2024

This PR exposes a new initialization variable in GaaMetering.init(), swgInitConfig, which allows for any subscriptions configuration parameter to be passed to the auto-initializer in GaaMetering.

  • When using GaaMetering, developers are expected to include swg.js and set it to initialize manually.
  • swg.js initialization is handled by GaaMetering.init() if required.
  • There are times passing a configuration parameter is required for the proper execution of swg.js, for example setting a paySwgVersion.

With this PR, the following code may now be used to specify a configuration during initialization:

     GaaMetering.init({
        shouldInitializeSwG: true,
        googleApiClientId: GOOGLE_API_CLIENT_ID,
        allowedReferrers: [
          'example.com',
          'test.com',
          'localhost',
          'google.com',
        ],
        userState: {},
        unlockArticle: () => {},
        showPaywall: () => {},
        handleLogin: () => {},
        handleSwGEntitlement: () => {},
        registerUserPromise: new Promise(() => {}),
        handleLoginPromise: new Promise(() => {}),
        publisherEntitlementPromise: new Promise(() => {}),
        swgInitConfig: {}, //configuration object matching the Config type that subscriptions.configure() expects.
      });

@everyplace everyplace changed the title A proposal for passing a complete swg configuration object to the man… Allow subscriptions.configure() to be called with a Config object from GaaMetering.init() May 6, 2024
@everyplace everyplace marked this pull request as ready for review May 6, 2024 18:15
@ChrisAntaki ChrisAntaki merged commit fe87089 into subscriptions-project:main May 6, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants