Logging with Hub v1

Sentry, Google Analytics, and New Relic support

Hub v1 offers support to the main logging resources through HubCommon, importing the Logger object from hub/utils/logger

Main API#

class Logger {
constructor() {
this.sentryActive = false;
this.debug = false;
this.applicationID = null;
this.isLocal = DomainParser.isLocal();
this.env = DomainParser.env;
this.releaseName = 'Hub v1';
this.releaseId = 'HubCommon 5';

Initializing the logger#

The logger class will be initialized by default using the (Sentry Hub Project) DSN and (New Relic) Application IDs

  • init(options): set the options that will be used for Sentry, and New Relic.

    import Logger from "hub/utils/logger";
    dsn: "https://94ae3299b4cb43f784110af6d666bc26@o163465.ingest.sentry.io/5413944", // example
    releaseName: "MyApp",
    releaseId: "AppVersion",
    debug: true,
    applicationID: "54584452", // example
    disableNewRelic: false,
    • dsn (string) start with a default Hub DSN
    • releaseName (string) defaults to Hub v1
    • releaseId (string) defaults to HubCommon 5
    • debug (boolean) will run Sentry and New Relic for localhost for debug
    • applicationID (string) to set a custom application id to be used by new relic
    • disableNewRelic (boolean) to not run new relic for your app
    • all options can be overrided for each Hub v1 app
  • Other methods avaliable: setReleaseName, setReleaseId, setDebug, overrideDefaultErrorHandlers


To setup your own Sentry project, see the Sentry Guide

  • Sentry.setupSentry({dsn, release, debug}) starts up the Sentry configuration, setting the Enviroment. Will not run for localhost.

    import Logger from "hub/utils/logger";
  • Sentry.setUserContext(UserContext) sets the information for which user got the error (to investigate a possible permission issue). It is set by default using the logged user.

    import Logger from "hub/utils/logger";
    import UserContext from "hub/utils/userContextModel";
  • Other Sentry APIs avaliable: captureException, captureMessage, addBreadcrumb

New Relic#

Enables the possibility to set your own application id

import Logger from "hub/utils/logger";

Google Analytics#

To setup your own Google Analytics views, see the Configuring Analytics Guide

  • Set the default Hub Google Analytics ID (UA-53263868-10)

  • Set default page view app.on('change', Backbone.History)

  • Create function initialize(code) to set your own GA code instead of changing the index.html

  • Send events:

    import tracker from "hub/utils/ga";
    import UserContext from "hub/utils/userContextModel";
    category: `EntityID ${UserContext.ParentEntityId}`,
    label: `UserID ${UserContext.Id}`,
    action: "App initialize",
Last updated on by Michelle Wiebe