Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ jobs:

- name: Upload to Cloudflare Pages
run: |
echo "<html><body>It works.</body></html>" > dist/index.html
npx wrangler pages deploy dist --project-name="featurevisor-example-cloudflare"
echo "<html><body>It works.</body></html>" > datafiles/index.html
npx wrangler pages deploy datafiles --project-name="featurevisor-example-cloudflare"
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ npm-debug.log*
.DS_Store

dist
datafiles
out
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,23 @@ $ npm install --save @featurevisor/sdk
Then use it in your application:

```js
import { createInstance } from '@featurevisor/sdk';
import { createInstance } from "@featurevisor/sdk";

const DATAFILE_URL =
"https://featurevisor-example-cloudflare.pages.dev/production/datafile-tag-all.json";

const datafileContent = await fetch(DATAFILE_URL).then((res) => res.json());

const sdk = createInstance({
datafileUrl: 'https://featurevisor-example-cloudflare.pages.dev/production/datafile-tag-all.json',
datafile: datafileContent,
});
```

Learn more about [SDK usage here](https://featurevisor.com/docs/sdks/javascript/).

## Installation

Since this example app lives outside of the Featurevisor [monorepo](https://github.com/fahad19/featurevisor), you are recommended to make sure [`package.json`](./package.json) has the latest version of [`@featurevisor/cli`](https://www.npmjs.com/package/@featurevisor/cli) package.
Since this example app lives outside of the Featurevisor [monorepo](https://github.com/featurevisor/featurevisor), you are recommended to make sure [`package.json`](./package.json) has the latest version of [`@featurevisor/cli`](https://www.npmjs.com/package/@featurevisor/cli) package.

```
$ npm ci
Expand All @@ -42,19 +49,21 @@ $ npm ci
### Lint YAMLs

```
$ npm run lint
$ npx featurevisor lint
```

### Build datafiles

```
$ npm run build
$ npx featurevisor build
```

Checkout output in `datafiles` directory.

### Test features

```
$ npm test
$ npx featurevisor test
```

## Cloudflare
Expand Down
1 change: 0 additions & 1 deletion attributes/country.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
archived: false
description: country code in lower case (two lettered)
type: string
1 change: 0 additions & 1 deletion attributes/deviceId.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
description: Device ID
type: string
capture: true
1 change: 0 additions & 1 deletion attributes/userId.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
description: User ID
type: string
capture: true
16 changes: 7 additions & 9 deletions features/baz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ tags:

bucketBy: userId

environments:
rules:
staging:
rules:
- key: "1"
segments: "*"
percentage: 100
- key: everyone
segments: "*"
percentage: 100
production:
rules:
- key: "1"
segments: "*"
percentage: 80
- key: everyone
segments: "*"
percentage: 80
16 changes: 7 additions & 9 deletions features/my_feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ tags:

bucketBy: deviceId

environments:
rules:
staging:
rules:
- key: "1"
segments: "*"
percentage: 100
- key: everyone
segments: "*"
percentage: 100
production:
rules:
- key: "1"
segments: "*"
percentage: 100
- key: everyone
segments: "*"
percentage: 100
Loading