logrocket
nuxt-logrocket

用於 Nuxt 的 LogRocket 模組,可幫助您修復錯誤並瞭解使用者行為。

nuxt-logrocket

nuxt-logrocket

npm (scoped with tag)npmCircleCICodecovjs-standard-style

適用於 Nuxt.js 的 LogRocket 模組

📖 釋出說明

功能

  • Nuxt 3 & Nuxt Bridge
  • 支援 Pinia 整合
  • 能夠在開發模式下執行

設定

  • 使用 yarn 或 npm 將 nuxt-logrocket 依賴項新增到您的專案中
yarn add nuxt-logrocket

或者

npm install nuxt-logrocket --save
  • nuxt-logrocket 新增到 nuxt.config.ts 檔案的 modules 部分
import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
  modules: ['nuxt-logrocket'],

  logRocket: {
    id: '',
    dev: false,
    config: {
      //
    }
  }
})

選項

選項可以透過 執行時配置nuxt.config.ts 中的 logRocket 部分傳遞。在大多數情況下,為必需的 id 選項設定一個值就足夠了。

以下是完整的選項列表

選項型別預設必需
ID字串''
開發布林值true
啟用 Pinia布林值true
釋出字串null
控制檯已啟用布林值true
網路已啟用布林值true
網路請求清理器函式-
網路響應清理器函式-
DOM 已啟用布林值true
輸入清理器布林值false
文字清理器布林值false
基本路徑字串null
是否捕獲 IP布林值true
根主機名字串null
是否開啟除錯日誌布林值true
合併 Iframes布林值false

這是一個包含選項預設值的示例

{
  id: '',
  dev: true,
  enablePinia: true,
  config: {
    release: null,
    console: {
      isEnabled: true
    },
    network: {
      isEnabled: true,
      networkRequestSanitizer: () => {},
      networkResponseSanitizer: () => {}
    },
    dom: {
      isEnabled: true,
      inputSanitizer: false,
      textSanitizer: false,
      baseHref: null
    },
    shouldCaptureIP: true,
    rootHostname: null,
    shouldDebugLog: true,
    mergeIframes: false
  }
}

使用

正確設定後,LogRocket 會自動注入到您的應用程式中。預設情況下,此模組僅在 生產 環境和客戶端事件中執行。

要在應用程式中使用 LogRocket 注入的功能,您可以使用

const { $logRocket } = useNuxtApp()

訪問 LogRocket 網站以獲取完整功能列表:文件

Pinia

此模組自動檢測 Pinia 儲存突變並將它們附加到 LogRocket 會話。

此功能預設啟用,可以透過將 enablePinia 選項設定為 false 來停用。

import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
  modules: ['nuxt-logrocket'],

  logRocket: {
    id: '',
    enablePinia: false
  }
})

開發

  • 克隆此倉庫
  • 使用 yarn install 安裝依賴
  • 使用 yarn run dev 啟動開發伺服器
  • 在瀏覽器中訪問 https://:3000

許可證

MIT 許可證 - Alibaba Travels Co