@newskit-render/feature-flags 0.1.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +17 -11
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,50 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.4.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/feature-flags@0.3.1...@newskit-render/feature-flags@0.4.0) (2021-11-22)
7
+
8
+
9
+ ### Features
10
+
11
+ * **PPDSR-0:** fix broken dependecy ([#521](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/521)) ([2690dd3](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/2690dd3bc6cf61a88740a0ff935adf461be02416))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.3.1](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/feature-flags@0.3.0...@newskit-render/feature-flags@0.3.1) (2021-11-15)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **PPDSR-541:** change packages to get published ([#506](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/506)) ([4de773b](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/4de773b8e22663a2822f64255f347c32384532c0))
23
+
24
+
25
+
26
+
27
+
28
+ # [0.3.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/feature-flags@0.2.0...@newskit-render/feature-flags@0.3.0) (2021-11-10)
29
+
30
+
31
+ ### Features
32
+
33
+ * **PPDSR-496:** add next link wrapper component ([#500](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/500)) ([a8ca436](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/a8ca436f6f8061d58e857eb83d7d3ee9cfb449a6))
34
+
35
+
36
+
37
+
38
+
39
+ # [0.2.0](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/feature-flags@0.1.2...@newskit-render/feature-flags@0.2.0) (2021-11-10)
40
+
41
+
42
+ ### Features
43
+
44
+ * **PPDSR-500:** Up next version and switch to es2015 ([#496](https://github.com/newscorp-ghfb/ncu-newskit-render/issues/496)) ([1e41435](https://github.com/newscorp-ghfb/ncu-newskit-render/commit/1e414351247e4c069a829a0a2210a8e6da0e0287))
45
+
46
+
47
+
48
+
49
+
6
50
  ## [0.1.2](https://github.com/newscorp-ghfb/ncu-newskit-render/compare/@newskit-render/feature-flags@0.1.1...@newskit-render/feature-flags@0.1.2) (2021-11-08)
7
51
 
8
52
  **Note:** Version bump only for package @newskit-render/feature-flags
package/README.md CHANGED
@@ -3,13 +3,15 @@
3
3
  A package for adding feature flags to projects generated by newskit-render.
4
4
 
5
5
  ## How to use:
6
+
6
7
  `yarn add @newskit-render/feature-flags` or <br />
7
8
  `npm install --save @newskit-render/feature-flags` <br /><br />
8
9
 
9
10
  There are two ways that feature flags can be utilized.
10
- ### getFeatureFlags() in getServerSideProps ###
11
11
 
12
- The most performant way to use feature flags is to call `getFeatureFlags()` in `getServersideProps` and then use them throughout the page. This way the implementation will only be available for the current page and and wouldn't effect the rest of the site.
12
+ ### getFeatureFlags() in getServerSideProps
13
+
14
+ The most performant way to use feature flags is to call `getFeatureFlags()` in `getServersideProps` and then use them throughout the page. This way the implementation will only be available for the current page and and wouldn't effect the rest of the site.
13
15
  To do so you will need to initialize the package by calling `createFeatureFlagsInstance` with the sdkKey from optimizely.
14
16
  Best practice is to store your sdk key in environment variables, the examples below utilize that method.
15
17
  For local use, you cadd the Optimizely SDK key from your project in your `.env.local` file like so
@@ -19,6 +21,7 @@ Optionally the config can be switched to suit your need. More on this can be fou
19
21
  An example implementation would be as follows:
20
22
 
21
23
  `pages/index.ts`
24
+
22
25
  ```
23
26
  import {getFeatureFlags, createFeatureFlagsInstance} from '@newskit-render/feature-flags';
24
27
 
@@ -31,7 +34,7 @@ export async function getServerSideProps(context) {
31
34
  // other queries,
32
35
  getFeatureFlags()
33
36
  ])
34
-
37
+
35
38
  const featureFlags = featureFlagsResult.value;
36
39
 
37
40
  return {
@@ -42,6 +45,7 @@ export async function getServerSideProps(context) {
42
45
  }
43
46
  }
44
47
  ```
48
+
45
49
  `samplePage/index.tsx`
46
50
 
47
51
  ```
@@ -51,9 +55,9 @@ import { FeatureFlag } from '@newskit-render/feature-flags'
51
55
  const SectionPage: React.FC<{
52
56
  page: Page
53
57
  // pageprops...
54
- featureFlags?: FeatureFlag[]
58
+ featureFlags?: FeatureFlag[]
55
59
  }> = ({ page, pageprops..., featureFlags }) => {
56
-
60
+
57
61
  return(
58
62
  <Layout>
59
63
  {featureFlags && featureFlags['test_flag'] && <p>FEATURE FLAG IS HEREEE</p>}
@@ -67,14 +71,15 @@ export default SamplePage
67
71
 
68
72
  ```
69
73
 
70
- ### hooks in getInitialProps ###
74
+ ### hooks in getInitialProps
71
75
 
72
76
  Alternatively, feature flags can be applied on the whole app. To do so, you'll need to instantiate the package in `getInitialProps` of the main app, then call `getFeatureFlags` and pass the result to the whole app.
73
- By calling the `useFeatureFlagsContext` hook, the list of featureFlags can be accessed from any point of the site.
77
+ By calling the `useFeatureFlagsContext` hook, the list of featureFlags can be accessed from any point of the site.
74
78
  <br /> <br />
75
79
  Below we explore a solution, where we use it in the header of the app.
76
80
 
77
81
  `pages/_app.tsx`
82
+
78
83
  ```
79
84
  import { getFeatureFlags, FeatureFlagsContextProvider, FeatureFlag, createFeatureFlagsInstance } from '@newskit-render/feature-flags';
80
85
 
@@ -94,7 +99,6 @@ MyApp.getInitialProps = async () => {
94
99
  export default MyApp
95
100
  ```
96
101
 
97
-
98
102
  `header/index.tsx`
99
103
 
100
104
  ```
@@ -102,7 +106,7 @@ import { useFeatureFlagsContext } from '@newskit-render/feature-flags';
102
106
 
103
107
  const Header: React.FC<{ user: UserData }> = ({ user }) => {
104
108
  const featureFlags = useFeatureFlagsContext();
105
-
109
+
106
110
  return (
107
111
  <>
108
112
  <StyledHeader>
@@ -122,8 +126,10 @@ const Header: React.FC<{ user: UserData }> = ({ user }) => {
122
126
 
123
127
  export default Header
124
128
  ```
125
- ### createFeatureFlagsInstance ###
126
- `createFeatureFlagsInstance` takes config object as parameter. The config object consists of [`optimizelyConfig`](https://docs.developers.optimizely.com/full-stack/v4.0/docs/initialize-sdk-javascript-node#section-parameters), `userId`, `defaultFeatureFlags`, `logLevel`. The only requirement for the feature flags to be instantiated is passing optimizely sdk key to `optimizelyConfig`. Further, the whole config can be changed to suit your needs.
129
+
130
+ ### createFeatureFlagsInstance
131
+
132
+ `createFeatureFlagsInstance` takes config object as parameter. The config object consists of [`optimizelyConfig`](https://docs.developers.optimizely.com/full-stack/v4.0/docs/initialize-sdk-javascript-node#section-parameters), `userId`, `defaultFeatureFlags`, `logLevel`. The only requirement for the feature flags to be instantiated is passing optimizely sdk key to `optimizelyConfig`. Further, the whole config can be changed to suit your needs.
127
133
  `userId` serves as optimizely user identity.
128
134
  `defaultFeatureFlags` are used in the event that optimizely doesn't load up and initial values are required.
129
135
  `logLevel` serves to configure the optimizely logger if you wish to use it. It accepts `critical`, `error`, `warning`, `debug` or `info`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newskit-render/feature-flags",
3
- "version": "0.1.2",
3
+ "version": "0.4.0",
4
4
  "description": "A package for utilizing feature flags for newskit-render consumers, based on optimizely's capabilities.",
5
5
  "author": "",
6
6
  "license": "UNLICENSED",