@internetarchive/ia-book-actions 0.0.23 → 0.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/ia-book-actions",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "description": "Bookreader actions for borrowable book",
5
5
  "author": "Internet Archive",
6
6
  "license": "AGPL-3.0-only",
@@ -93,7 +93,7 @@ export default css`
93
93
  }
94
94
  .open {
95
95
  display: block;
96
- z-index: 2;
96
+ z-index: 4;
97
97
  }
98
98
  .visible {
99
99
  display: inline-block;
@@ -1,5 +1,6 @@
1
1
  import ActionsHandlerService from './actions-handler/actions-handler-service.js';
2
2
  import * as Cookies from './doc-cookies.js';
3
+ import { analyticsCategories } from '../config/analytics-event-and-category.js';
3
4
 
4
5
  /**
5
6
  * This class is used to create loan token for borrowed books
@@ -13,6 +14,7 @@ export class LoanTokenPoller {
13
14
  this.successCallback = successCallback; // callback function to be called after loan token is created
14
15
  this.errorCallback = errorCallback; // callback function to be called after loan token is created
15
16
  this.pollerDelay = pollerDelay; // value in ms (1000 ms = 1 sec)
17
+ this.analyticsCategories = analyticsCategories;
16
18
 
17
19
  this.loanTokenInterval = undefined;
18
20
  this.enableBookAccess();
@@ -69,13 +71,14 @@ export class LoanTokenPoller {
69
71
  }
70
72
  }
71
73
 
72
- sendEvent(eventCategory, eventAction) {
74
+ sendEvent(eventCategory, eventAction, extraParams = {}) {
73
75
  // eslint-disable-next-line no-console
74
- console?.log('Book action: ', { eventCategory, eventAction });
76
+ console?.log('Book action: ', { eventCategory, eventAction, extraParams });
75
77
  window?.archive_analytics?.send_event_no_sampling(
76
78
  eventCategory,
77
79
  eventAction,
78
- `identifier=${this.identifier}`
80
+ `identifier=${this.identifier}`,
81
+ extraParams
79
82
  );
80
83
  }
81
84
 
@@ -85,7 +88,15 @@ export class LoanTokenPoller {
85
88
  identifier: this.identifier,
86
89
  action,
87
90
  error: data => {
88
- window?.Sentry?.captureMessage('handleLoanTokenPoller error');
91
+ window?.Sentry?.captureMessage(`
92
+ handleLoanTokenPoller error, identifier:${this.identifier}, borrowType:${this.borrowType}, interval:${this.loanTokenInterval}
93
+ `);
94
+ this.sendEvent(this.analyticsCategories.browse, 'LoanTokenError', {
95
+ identifier: this.identifier,
96
+ isInitial: isInitial,
97
+ borrowType: this.borrowType,
98
+ interval: this.loanTokenInterval,
99
+ });
89
100
  this.disconnectedInterval(); // stop token fetch api
90
101
  this.errorCallback({ detail: { action, data } });
91
102
  },