Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Vue 3 example #1115

Merged
1 commit merged into from
Aug 1, 2023
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
29 changes: 29 additions & 0 deletions examples/vuejs3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# vue-project

This template should help get you started developing with Vue 3 in Vite.

## Recommended IDE Setup

[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).

## Customize configuration

See [Vite Configuration Reference](https://vitejs.dev/config/).

## Project Setup

```sh
npm install
```

### Compile and Hot-Reload for Development

```sh
npm run dev
```

### Compile and Minify for Production

```sh
npm run build
```
13 changes: 13 additions & 0 deletions examples/vuejs3/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rollbar Vue Example</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
18 changes: 18 additions & 0 deletions examples/vuejs3/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "vue-project",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"rollbar": "^2.26.2",
"vue": "^3.3.4"
},
"devDependencies": {
"@vitejs/plugin-vue": "^4.2.3",
"vite": "^4.4.6"
}
}
Binary file added examples/vuejs3/public/favicon.ico
Binary file not shown.
9 changes: 9 additions & 0 deletions examples/vuejs3/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script setup>
import RollbarTest from './components/RollbarTest.vue';
</script>

<template>
<main>
<RollbarTest />
</main>
</template>
16 changes: 16 additions & 0 deletions examples/vuejs3/src/components/RollbarTest.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<div>
<button @click="triggerError">Trigger Error</button>
</div>
</template>

<script>
export default {
methods: {
triggerError() {
// Simulate an error
throw new Error('Testing Rollbar integration');
},
},
};
</script>
13 changes: 13 additions & 0 deletions examples/vuejs3/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import './assets/main.css';

import { createApp } from 'vue';
import App from './App.vue';

import RollbarPlugin from './rollbar'; // Path to your rollbar.js file
import RollbarTest from './components/RollbarTest.vue'; // Path to your RollbarTest.vue file //TESTING

const app = createApp(App);
app.use(RollbarPlugin);
app.component('RollbarTest', RollbarTest);

createApp(App).mount('#app');
13 changes: 13 additions & 0 deletions examples/vuejs3/src/rollbar.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export default {
accessToken: 'POST_CLIENT_ITEM_ACCESS_TOKEN',
captureUncaught: true,
captureUnhandledRejections: true,
payload: {
environment: 'dev',
client: {
javascript: {
code_version: '1.0.0',
}
}
},
};
17 changes: 17 additions & 0 deletions examples/vuejs3/src/rollbar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// rollbar.js
import Rollbar from 'rollbar';
import config from './rollbar.config';

const rollbar = new Rollbar(config);

export default {
install(app) {
app.config.errorHandler = (error, vm, info) => {
rollbar.error(error, { vueComponent: vm, info });
if (app.config.devtools) {
console.error(error);
}
};
app.provide('rollbar', rollbar);
},
};
16 changes: 16 additions & 0 deletions examples/vuejs3/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
})
Loading