Skip to content

Commit cfdc753

Browse files
Document and Clean Up (#8)
* remove package-lock from vue client * rename server fix dependencies update command * move test.js to separate folder and provide a README * move react-test.html to a separate folder and provide a README * update vue readme provide info about region * update react README default to App update comments about script region remove unused react boilerplate code * update Angular README add comments about script region * update top-level README
1 parent ae9cf8c commit cfdc753

File tree

19 files changed

+155
-150
lines changed

19 files changed

+155
-150
lines changed

README.md

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
1-
# em-beddable example
2-
A simple example of how to Embed the Embeddable.com web component in your site
1+
# em-beddable Web Component Example
32

4-
# steps
3+
A simple example of how to Embed the Embeddable.com Web Component in your website.
4+
There are currently 5 examples in this repository:
55

6-
To test your Embedded web component:
6+
- [HTTP server with html response](http-server/README.md)
7+
- [simple React.js example](static-react/README.md)
8+
- [React.js using "Create React App"](client-react/README.md)
9+
- [Angular](client-angular/README.md)
10+
- [Vue](client-vue/README.md)
711

8-
1. click "Publish" on your Embeddable dashboard to get your `API_KEY` and `EMBEDDABLE_ID`
9-
2. clone/download this repo
10-
3. update `src/test.js` to use your `API_KEY` and `EMBEDDABLE_ID`
11-
4. run `node src/test.js`
12-
5. open `localhost:8080` to see your embedded dashboard
12+
Also includes a simple node server that uses the [tokens API](https://docs.embeddable.com/deployment/tokens-api).
1313

14-
# documentation
14+
## Prerequisites
1515

16-
[here](https://trevorio.notion.site/Embedding-an-Embeddable-2e7b7c09909f47ee9d3fee64f4e6fcd9)
16+
Most examples require [Node.js](https://nodejs.org) version 20 or newer to be installed.
1717

18-
# react.js
18+
## Steps
1919

20-
There is a simple react example in `src/react-test.html` (though you'll need to update the `token` manually)
20+
1. clone or download this repository
21+
2. choose an example, and follow the README file contained in it
22+
23+
## Token Server
24+
25+
Two examples, `client-react` and `client-vue`, require the
26+
token server included in this repository to be running.
27+
28+
### Token Server Steps
29+
30+
1. click "Publish" on your Embeddable dashboard to get your `API_KEY`
31+
2. update `token-server/.env` to use your `API_KEY`, and optionally set the `USER_KEY`
32+
3. set the `BASE_URL`, and optionally the `SECURITY_CONTEXT` in `token-server/index.js`
33+
4. run `npm i` to install dependencies
34+
5. run `npm run token-server`
35+
6. follow the instructions in the `client-*` folder to run a client

client-angular/README.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
# AngularExample
1+
# Angular Example
22

3-
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 20.1.4.
3+
Example for how to embed the Embeddable Web Component in an Angular app.
44

5-
## Development server
5+
## Steps
66

7-
To start a local development server, run:
7+
1. run `npm i`
8+
2. in `src/index.html` make sure you are loading the embed from the correct region
9+
3. in `src/app/app.ts` set the `BASE_URL`, `API_KEY`, `EMBEDDABLE_ID` and `USER_KEY`
10+
4. run `npm run start`
811

9-
```bash
10-
ng serve
11-
```
12-
13-
Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
14-
15-
## Embeddable
16-
17-
This is an example repo for [Embeddable](https://embeddable.com), the developer toolkit for customer-facing analytics. If you're looking to embed into an Angular app, this should help you get started. If you're looking for other information, you should [check out our docs!](https://docs.embeddable.com/)
12+
Note: This example does not use the token server from this repository.

client-angular/angular.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,8 @@
9292
}
9393
}
9494
}
95+
},
96+
"cli": {
97+
"analytics": false
9598
}
9699
}

client-angular/package-lock.json

Lines changed: 22 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client-angular/src/app/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* NOTE: This demo does not use the server in `/server` - that's for the react client
3+
* NOTE: This demo does not use the server in `/server` - that's for the react and vue clients
44
*
55
*/
66
import { Component, CUSTOM_ELEMENTS_SCHEMA, signal } from '@angular/core';

client-angular/src/index.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@
66
<base href="/">
77
<meta name="viewport" content="width=device-width, initial-scale=1">
88
<link rel="icon" type="image/x-icon" href="favicon.ico">
9-
<script type="module" src="https://embed.embeddable.com/js/v1/?region=eu">
10-
</script>
9+
<!--
10+
If you are on the EU server, please uncomment that tag and comment
11+
out the US tag.
12+
-->
13+
<script type="module" src="https://embed.embeddable.com/js/v1/?region=US"></script>
14+
<!--
15+
<script type="module" src="https://embed.embeddable.com/js/v1/?region=EU"></script>
16+
-->
1117
</head>
1218
<body>
1319
<app-root></app-root>

client-react/README.md

Lines changed: 22 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,32 @@
1-
# Getting Started with Create React App
1+
# React App Example
22

3-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
3+
Example for how to embed the Embeddable Web Component in a React.js app created using [Create React App](https://create-react-app.dev/).
44

5-
## Available Scripts
5+
This example contains two versions. One showing how to embed a single dashboard,
6+
and another showing how to control 3 embeddable in tabs from a single embeddable.
67

7-
In the project directory, you can run:
8+
## App Example
89

9-
### `npm start`
10+
This example is active by default. It shows all dashboards available to you as buttons,
11+
and allows you to preview how to embed any of them.
1012

11-
Runs the app in the development mode.\
12-
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13+
### App Steps
1314

14-
The page will reload when you make changes.\
15-
You may also see any lint errors in the console.
15+
1. run `npm i`
16+
2. in `public/index.html` make sure you are loading the embed from the correct region
17+
3. make sure the token server is running. It can be ran from the **parent folder** using `npm run token-server`
18+
4. run `npm start`
1619

17-
### `npm run build`
20+
## Multi Tab Example
1821

19-
Builds the app for production to the `build` folder.\
20-
It correctly bundles React in production mode and optimizes the build for the best performance.
22+
This example demonstrates how to use one Embeddable to control any amount of other Embeddables,
23+
making use of [variables](https://docs.embeddable.com/deployment/interactivity#pass-in-and-update-variables).
2124

22-
The build is minified and the filenames include the hashes.\
23-
Your app is ready to be deployed!
25+
### Multi Tab Steps
2426

25-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
26-
27-
### `npm run eject`
28-
29-
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
30-
31-
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
32-
33-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
34-
35-
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
36-
37-
## Learn More
38-
39-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
40-
41-
To learn React, check out the [React documentation](https://reactjs.org/).
42-
43-
### Code Splitting
44-
45-
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
46-
47-
### Analyzing the Bundle Size
48-
49-
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
50-
51-
### Making a Progressive Web App
52-
53-
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
54-
55-
### Advanced Configuration
56-
57-
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
58-
59-
### Deployment
60-
61-
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
62-
63-
### `npm run build` fails to minify
64-
65-
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
27+
1. run `npm i`
28+
2. in `public/index.html` make sure you are loading the embed from the correct region
29+
3. in `src/index.js` replace `<App>` with `<MultiTabApp>`
30+
4. in `src/MultiTabApp.js` replace the IDs in the `embeddables` constant with the IDs of the dashboards you'd like to use
31+
5. make sure the token server is running. It can be ran from the **parent folder** using `npm run token-server`
32+
6. run `npm start`

client-react/public/index.html

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,19 @@
99
name="description"
1010
content="Web site created using create-react-app"
1111
/>
12-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13-
<!--
14-
manifest.json provides metadata used when your web app is installed on a
15-
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
16-
-->
17-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
18-
<!--
19-
Notice the use of %PUBLIC_URL% in the tags above.
20-
It will be replaced with the URL of the `public` folder during the build.
21-
Only files inside the `public` folder can be referenced from the HTML.
22-
23-
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
24-
work correctly both with client-side routing and a non-root public URL.
25-
Learn how to configure a non-root public URL by running `npm run build`.
26-
-->
2712
<title>React App</title>
2813
<!--
29-
If you are on the EU server, please uncommented that tag and comment
14+
If you are on the EU server, please uncomment that tag and comment
3015
out the US tag.
3116
-->
3217
<script
3318
type="module"
34-
src="https://api.us.embeddable.com/js/v1/">
19+
src="https://embed.embeddable.com/js/v1/?region=US">
3520
</script>
3621
<!--
3722
<script
3823
type="module"
39-
src="https://api.eu.embeddable.com/js/v1/">
24+
src="https://embed.embeddable.com/js/v1/?region=EU">
4025
</script>
4126
-->
4227
</head>

0 commit comments

Comments
 (0)