zoukankan      html  css  js  c++  java
  • sentry上传sourcemap

    第一种方式:webpack 配置

    参考文档:https://docs.sentry.io/platforms/javascript/sourcemaps/

    1. 安装 @sentry/webpack-plugin 和 clean-webpack-plugin
    yarn add @sentry/webpack-plugin clean-webpack-plugin -D
    
    1. 获取 authToken(两种获取方式)
    • Organization Settings -> Developer Settings -> New Internal Integration -> Save Changes

    note: PERMISSIONS 列表中需要选中 Releases -> Admin

    • API keys -> Auth Tokens -> Create New Token
    1. 在 webpack.config.js 中添加以下代码:
    const SentryWebpackPlugin = require("@sentry/webpack-plugin");
    const { CleanWebpackPlugin } = require('clean-webpack-plugin');
    module.exports = {
      // other configuration
      plugins: [
          // 多次构建后会因文件过多无法上传,先清理一下
          new CleanWebpackPlugin(),
          new SentryWebpackPlugin({
              // 自托管 sentry 地址
              url: "",
              authToken: "",
              org: "example-org",
              project: "example-project",
              // 本地 sourcemap 所在目录
              include: "",
              // js 访问路径
              urlPrefix: ""
          }),
      ],
    };
    

    第二种方式:sentry-cli

    参考文档:https://docs.sentry.io/product/cli/configuration/
    https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/

    1. 配置和认证

    (1)获取 authToken,至少具有以下范围:

    • project:read
    • project:releases
    • org:read

    (2)配置(四种方式)

    • 创建 .sentryclirc
    [defaults]
    url = https://mysentry.invalid/
    [auth]
    token=your-auth-token
    
    • 导出为环境变量
    // .env
    
    export SENTRY_URL=https://mysentry.invalid/
    export SENTRY_AUTH_TOKEN=your-auth-token
    
    • 使用 Properties
    // .env
    
    export SENTRY_PROPERTIES=./sentry.properties
    
    // sentry.properties
    
    defaults.url=https://mysentry.invalid/
    auth.token=your-auth-token
    
    • 作为命令行参数
    sentry-cli --url https://mysentry.invalid/ --auth-token your-auth-token
    
    1. 创建新版本
    sentry-cli releases -o example-org -p example-project new <release_name>
    

    note: release_name 需要在 example-org 内唯一,且与 Sentry.init 中的 release 选项保持一致

    1. 上传 sourcemap
    sentry-cli releases -o example-org -p example-project files <release_name> upload-sourcemaps /path/to/files --url-prefix example-url
    
  • 相关阅读:
    kettle连接MySQL报错
    git切换到某个tag, 从tag切换回当前分支
    wireshark 实用过滤表达式(针对ip、协议、端口、长度和内容)
    linux下python3.6.7安装
    haproxy backup模式
    Oracle_2 随便写写
    Oracle 日期函数练习 随便写写
    RabbitMQ
    X.509标准、CA认证
    docker-compose和Dockerfile的volumes
  • 原文地址:https://www.cnblogs.com/flying-script/p/14709280.html
Copyright © 2011-2022 走看看