express-addon-analytics

1.0.33 • Public • Published

Adobe Express Add-on Analytics

Analytics for Adobe Express Add-ons

Install

npm install express-addon-analytics

Usage

Tracking a user (once per session)

import { ExpressAnalytics} from "express-addon-analytics/ExpressAnalytics";

// in App.firstUpdated() function 
await this.addOnUISdk.ready;

this.analytics = new ExpressAnalytics(this.addOnUISdk, "https://myendpointUrl.com");

await analytics.trackUserAsync();

You can call this multiple times during session to add additional user metrics in the extra parameter.

Tracking an event (multiple times per session)

import { ExpressAnalytics} from "express-addon-analytics/ExpressAnalytics";
....

// this.addOnUISdk has already been initialized

// track a page deletion event passing the page width and height as parameters
await this.analytics.trackEventAsync("delete_page", {
    width: pageWidth, 
    height: pageHeight});

Tracking an error (multiple times per session)

import { ExpressAnalytics} from "express-addon-analytics/ExpressAnalytics";
....

// this.addOnUISdk has already been initialized

 try {
   ...
   // code that throws an exception
   ...
} catch (error:unknown){
    const err = error as Error;
    await this._analytics.trackErrorAsync(err);
}

Stopping session tracking

A pulse event will be sent every 15 seconds. The interval can be changed before the ExpressAnalytics object is created with ExpressAnalytics.PulseInterval = 20000; to change it to 20 seconds, for example. This pulse helps determine session duration as there is no "closed" event for the add-on. You can always stop it with this code.

this.analytis.dispose();

Logging Browser Errors

By default, errors from Express Analytics will not be logged to the browser console. For debugging you can set the LogErrors property to true.

ExpressAnalytics.LogErrors = true;

Package Sidebar

Install

npm i express-addon-analytics

Weekly Downloads

124

Version

1.0.33

License

MIT

Unpacked Size

28.3 kB

Total Files

8

Last publish

Collaborators

  • mscherotter