0.0.2 • Published 1 year ago

@item-enonic-types/lib-sentry v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Sentry Integration Library for Enonic XP

Enonic XP Library for enhancing data sent to Sentry.

npm.io

Installation

To install this library you need to add a new dependency to your app's build.gradle file.

Gradle

repositories {
  maven { url 'https://jitpack.io' }
}

dependencies {
  include "com.enonic.xp:lib-admin:${xpVersion}"
  include "no.item:lib-xp-sentry:0.0.1"
}

Usage

import * as Sentry from "/lib/sentry";
import { parseUserAgent } from "/lib/sentry/user-agent";

export function parseRequestAndAddToSentry(req: XP.Request): void {
  const { browser, os, device } = parseUserAgent(req);

  Sentry.configureScope((scope) => {
    scope
      .setTags({
        branch: req.branch,
        repositoryId: req.repositoryId,
      })
      .setRequest({
        url: req.url,
        method: req.method,
      })
      .setContext("browser", browser)
      .setContext("os", os);

    if (device.family) {
      scope.setContext("device", {
        family: device.family,
      });
    }
  });
}

Deploying

Building

To build he project run the following code

./gradlew build

Deploy locally

Deploy locally for testing purposes:

./gradlew publishToMavenLocal

Deploy to Jitpack

Go to the Jitpack page for lib-xp-sentry to deploy from Github.

0.0.2

1 year ago