Socket
Socket
Sign inDemoInstall

gatsby-source-optimizely-v2

Package Overview
Dependencies
5
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gatsby-source-optimizely-v2

This unofficial source plugin makes Optimizely API data available in GatsbyJS sites. Currently in active development.


Version published
Maintainers
1
Created

Readme

Source

gatsby-source-optimizely-v2

This unofficial source plugin makes Optimizely/Episerver API data available in GatsbyJS sites. Currently in active development.

Commitizen friendly

Features

  • Support for multiple Optimizely API versions
  • Support for additional headers

Installation and Setup

For npm:

npm install gatsby-source-optimizely-v2

For yarn:

yarn add gatsby-source-optimizely-v2

Setup this plugin in gatsby-config.js as follows (*required fields):

module.exports = {
	// ...

	plugins: [
		// ...

		{
			resolve: "gatsby-source-optimizely-v2",
			options: {
				auth: {
					site_url: process.env.OPTMIZELY_API_SITE_URL // The URL of the Optimizely API site,
					username: process.env.OPTMIZELY_API_USERNAME // The username of the Optimizely API user.,
					password: process.env.OPTMIZELY_API_PASSWORD // The password of the Optimizely API user.,
					grant_type: process.env.OPTMIZELY_API_GRANT_TYPE, // // The grant type of the Optimizely API user. Default is "password"
					client_id: process.env.OPTMIZELY_API_CLIENT_ID, // The client ID of the Optimizely API user. Default is "Default"
				},

				// Add single or multiple `Optimizely` API endpoints to the source.
				endpoints: {
					OptimizelySites: "/v2.0/site",
					OptimizelyContent: "/v2.0/content/994?expand=*",
					OptimizelyContent: "/v2.0/content/994/children?expand=*",
					OptimizelySearchContent: "/v2.0/search/content?expand=*",
				},
			},
		},
	],
};

Additional Options

Headers

Add additional headers to the auth request as follows:

options: {
	// ...

	auth: {
		siteUrl: process.env.OPTMIZELY_API_SITE_URL,
		username: process.env.OPTMIZELY_API_USERNAME,
		password: process.env.OPTMIZELY_API_PASSWORD,
		grant_type: process.env.OPTMIZELY_API_GRANT_TYPE,
		client_id: process.env.OPTMIZELY_API_CLIENT_ID,
		headers: {
			// Single header
			"X-Custom-Header": "Custom Value",

			// Mutiple headers
			"Access-Control-Allow-Credentials": "Custom Value",
			"Access-Control-Allow-Origin": "Custom Value",

			// Additional `optimizely` headers
			"Accept-Language": "en"
		}
	},
}

How to Query

Assuming you correctly setup the plugin in gatsby-config.js and you have a OptimizelyContent node name and its valid endpoint:

options: {
	// ...

	endpoints: {
		OptimizelyContent: "/v2.0/content/994?expand=*";
	}
}

you can query the data as follows:

{
	allBigCommerceProducts {
		nodes {
			name
			price
			id
			sku
			variants {
				id
				product_id
				price
				cost_price
				image_url
				sku
			}
			reviews_count
			reviews_rating_sum
			page_title
			images {
				id
				description
				product_id
				date_modified
			}
			bigcommerce_id
			brand_id
			custom_url {
				url
			}
			categories
			availability
		}
		totalCount
	}
}

Contributing

Please feel free to contribute! PRs are always welcome.

License

This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.

Author

Guy Romelle Magayano

License

Released under the MIT license.

Keywords

FAQs

Last updated on 11 Feb 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc