Skip to content

Commit 295011a

Browse files
author
Botond Borsits
committedJul 31, 2023
Add Vue 3 example
1 parent 70109a9 commit 295011a

File tree

10 files changed

+144
-0
lines changed

10 files changed

+144
-0
lines changed
 

‎examples/vuejs3/README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# vue-project
2+
3+
This template should help get you started developing with Vue 3 in Vite.
4+
5+
## Recommended IDE Setup
6+
7+
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
8+
9+
## Customize configuration
10+
11+
See [Vite Configuration Reference](https://vitejs.dev/config/).
12+
13+
## Project Setup
14+
15+
```sh
16+
npm install
17+
```
18+
19+
### Compile and Hot-Reload for Development
20+
21+
```sh
22+
npm run dev
23+
```
24+
25+
### Compile and Minify for Production
26+
27+
```sh
28+
npm run build
29+
```

‎examples/vuejs3/index.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<link rel="icon" href="/favicon.ico">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Rollbar Vue Example</title>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
<script type="module" src="/src/main.js"></script>
12+
</body>
13+
</html>

‎examples/vuejs3/package.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "vue-project",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "vite",
7+
"build": "vite build",
8+
"preview": "vite preview"
9+
},
10+
"dependencies": {
11+
"rollbar": "^2.26.2",
12+
"vue": "^3.3.4"
13+
},
14+
"devDependencies": {
15+
"@vitejs/plugin-vue": "^4.2.3",
16+
"vite": "^4.4.6"
17+
}
18+
}

‎examples/vuejs3/public/favicon.ico

4.19 KB
Binary file not shown.

‎examples/vuejs3/src/App.vue

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<script setup>
2+
import RollbarTest from './components/RollbarTest.vue';
3+
</script>
4+
5+
<template>
6+
<main>
7+
<RollbarTest />
8+
</main>
9+
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<template>
2+
<div>
3+
<button @click="triggerError">Trigger Error</button>
4+
</div>
5+
</template>
6+
7+
<script>
8+
export default {
9+
methods: {
10+
triggerError() {
11+
// Simulate an error
12+
throw new Error('Testing Rollbar integration');
13+
},
14+
},
15+
};
16+
</script>

‎examples/vuejs3/src/main.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import './assets/main.css';
2+
3+
import { createApp } from 'vue';
4+
import App from './App.vue';
5+
6+
import RollbarPlugin from './rollbar'; // Path to your rollbar.js file
7+
import RollbarTest from './components/RollbarTest.vue'; // Path to your RollbarTest.vue file //TESTING
8+
9+
const app = createApp(App);
10+
app.use(RollbarPlugin);
11+
app.component('RollbarTest', RollbarTest);
12+
13+
createApp(App).mount('#app');

‎examples/vuejs3/src/rollbar.config.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export default {
2+
accessToken: 'POST_CLIENT_ITEM_ACCESS_TOKEN',
3+
captureUncaught: true,
4+
captureUnhandledRejections: true,
5+
payload: {
6+
environment: 'dev',
7+
client: {
8+
javascript: {
9+
code_version: '1.0.0',
10+
}
11+
}
12+
},
13+
};

‎examples/vuejs3/src/rollbar.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// rollbar.js
2+
import Rollbar from 'rollbar';
3+
import config from './rollbar.config';
4+
5+
const rollbar = new Rollbar(config);
6+
7+
export default {
8+
install(app) {
9+
app.config.errorHandler = (error, vm, info) => {
10+
rollbar.error(error, { vueComponent: vm, info });
11+
if (app.config.devtools) {
12+
console.error(error);
13+
}
14+
};
15+
app.provide('rollbar', rollbar);
16+
},
17+
};

‎examples/vuejs3/vite.config.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { fileURLToPath, URL } from 'node:url'
2+
3+
import { defineConfig } from 'vite'
4+
import vue from '@vitejs/plugin-vue'
5+
6+
// https://vitejs.dev/config/
7+
export default defineConfig({
8+
plugins: [
9+
vue(),
10+
],
11+
resolve: {
12+
alias: {
13+
'@': fileURLToPath(new URL('./src', import.meta.url))
14+
}
15+
}
16+
})

0 commit comments

Comments
 (0)
Please sign in to comment.