@internetarchive/ia-book-actions 0.1.5-b2 → 0.1.6-alpha1
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/demo/index.html +2 -2
- package/package.json +1 -1
- package/src/core/config/sentry-events.js +2 -0
- package/src/core/services/actions-handler/actions-handler.js +13 -6
- package/src/core/services/loan-analytics.js +8 -8
- package/src/core/services/loan-renew-helper.js +0 -7
- package/src/ia-book-actions.js +1 -1
- package/test/components/timer-countdown.test.js +7 -3
- package/test/core/services/loan-renew-helper.test.js +1 -2
package/demo/index.html
CHANGED
|
@@ -132,10 +132,10 @@
|
|
|
132
132
|
iaBookActions.localCache = localCache;
|
|
133
133
|
|
|
134
134
|
let loanTotalTime2Min = { loanTotalTime: 10, loanRenewAtLast: 5, pageChangedInLast: 5 };
|
|
135
|
-
let loanTotalTime5Min = { loanTotalTime: 300, loanRenewAtLast:
|
|
135
|
+
let loanTotalTime5Min = { loanTotalTime: 300, loanRenewAtLast: 180, pageChangedInLast: 15 };
|
|
136
136
|
let loanTotalTime1Hour = { loanTotalTime: 3600, loanRenewAtLast: 600, pageChangedInLast: 900 };
|
|
137
137
|
|
|
138
|
-
iaBookActions.loanRenewTimeConfig =
|
|
138
|
+
iaBookActions.loanRenewTimeConfig = loanTotalTime2Min;
|
|
139
139
|
|
|
140
140
|
let lendingStatus1 = iaBookActions.lendingStatus;
|
|
141
141
|
let secondsLeftOnLoan = iaBookActions.loanRenewTimeConfig.loanTotalTime;
|
package/package.json
CHANGED
|
@@ -5,6 +5,8 @@ export const sentryLogs = {
|
|
|
5
5
|
disconnectedCallback: 'IABookActions:disconnectedCallback',
|
|
6
6
|
bookHasRenewed:
|
|
7
7
|
'IABookActions:handleLoanAutoRenewed - book has renewed for next one hour',
|
|
8
|
+
bookRenewFailed:
|
|
9
|
+
'IABookActions:handleLoanRenewNow - failed to renew',
|
|
8
10
|
browseHasExpired:
|
|
9
11
|
'IABookActions:browseHasExpired - one-hour loan has been expired',
|
|
10
12
|
bookWasExpired:
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
|
|
3
3
|
import { URLHelper } from '../../config/url-helper.js';
|
|
4
|
+
import { sentryLogs } from '../../config/sentry-events.js';
|
|
4
5
|
|
|
5
6
|
import ActionsHandlerService from './actions-handler-service.js';
|
|
6
7
|
import LoanAnanlytics from '../loan-analytics.js';
|
|
@@ -141,12 +142,18 @@ export default class ActionsHandler extends LitElement {
|
|
|
141
142
|
action,
|
|
142
143
|
identifier: this.identifier,
|
|
143
144
|
success: data => {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
145
|
+
if (data?.success === true && data?.loan?.renewal === true) {
|
|
146
|
+
this.setBrowseTimeSession();
|
|
147
|
+
this.dispatchEvent(
|
|
148
|
+
new CustomEvent('loanAutoRenewed', {
|
|
149
|
+
detail: { action, data },
|
|
150
|
+
})
|
|
151
|
+
);
|
|
152
|
+
} else {
|
|
153
|
+
window?.Sentry?.captureMessage(
|
|
154
|
+
`${sentryLogs.bookRenewFailed} - Error: ${JSON.stringify(data)}`
|
|
155
|
+
);
|
|
156
|
+
}
|
|
150
157
|
},
|
|
151
158
|
error: data => {
|
|
152
159
|
this.dispatchActionError(action, data);
|
|
@@ -144,14 +144,14 @@ export default class LoanAnanlytics {
|
|
|
144
144
|
* @memberof LoanAnanlytics
|
|
145
145
|
*/
|
|
146
146
|
sendEvent(eventCategory, eventAction, label, extraParams) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
147
|
+
console.log(
|
|
148
|
+
'eventCategory:-',
|
|
149
|
+
eventCategory,
|
|
150
|
+
'\t||\teventAction:-',
|
|
151
|
+
eventAction,
|
|
152
|
+
'\t||\tlabel:-',
|
|
153
|
+
label
|
|
154
|
+
);
|
|
155
155
|
|
|
156
156
|
window?.archive_analytics?.send_event_no_sampling(
|
|
157
157
|
eventCategory,
|
|
@@ -126,13 +126,6 @@ export class LoanRenewHelper {
|
|
|
126
126
|
// convert time from second to minute
|
|
127
127
|
timeLeft = Math.ceil(timeLeft / 60);
|
|
128
128
|
|
|
129
|
-
/**
|
|
130
|
-
* reduce 1 min from the auto return warning texts
|
|
131
|
-
* to compensate for the 50 second buffer we’ve introduced to handle the race condition
|
|
132
|
-
* @see IABookActions:loanRenew addEventListener
|
|
133
|
-
*/
|
|
134
|
-
if (timeLeft > 1) timeLeft = timeLeft - 1;
|
|
135
|
-
|
|
136
129
|
// convert time from minute to hour
|
|
137
130
|
if (timeLeft > 59) {
|
|
138
131
|
timeLeft = 1; // 1 hour
|
package/src/ia-book-actions.js
CHANGED
|
@@ -539,7 +539,7 @@ export default class IABookActions extends LitElement {
|
|
|
539
539
|
await this.showToastMessage();
|
|
540
540
|
await this.resetTimerCountState();
|
|
541
541
|
|
|
542
|
-
window?.Sentry?.captureMessage(
|
|
542
|
+
window?.Sentry?.captureMessage(sentryLogs.bookHasRenewed);
|
|
543
543
|
|
|
544
544
|
// testing console....
|
|
545
545
|
console.log('IABookActions: AutoRenewed:- ', {
|
|
@@ -2,7 +2,11 @@ import { html, fixture, expect, aTimeout } from '@open-wc/testing';
|
|
|
2
2
|
import '../../src/ia-book-actions.js';
|
|
3
3
|
import '../../src/components/timer-countdown.js';
|
|
4
4
|
|
|
5
|
-
const container = ({
|
|
5
|
+
const container = ({
|
|
6
|
+
secondsLeftOnLoan,
|
|
7
|
+
loanTotalTime,
|
|
8
|
+
loanRenewAtLast,
|
|
9
|
+
} = {}) =>
|
|
6
10
|
html`<timer-countdown
|
|
7
11
|
.secondsLeftOnLoan=${secondsLeftOnLoan}
|
|
8
12
|
.loanTotalTime=${loanTotalTime}
|
|
@@ -20,7 +24,7 @@ describe('<timer-countdown>', () => {
|
|
|
20
24
|
);
|
|
21
25
|
|
|
22
26
|
await el.updateComplete;
|
|
23
|
-
// expect(
|
|
27
|
+
// expect(window.IALendingIntervals.timerCountdown).to.be.undefined;
|
|
24
28
|
});
|
|
25
29
|
|
|
26
30
|
it('timer interval is not undefined when loan is active', async () => {
|
|
@@ -36,6 +40,6 @@ describe('<timer-countdown>', () => {
|
|
|
36
40
|
await el.updateComplete;
|
|
37
41
|
|
|
38
42
|
expect(el.secondsLeftOnLoan).to.equal(2);
|
|
39
|
-
// expect(el.
|
|
43
|
+
// expect(el.timerCountdown).to.not.be.undefined;
|
|
40
44
|
});
|
|
41
45
|
});
|
|
@@ -79,9 +79,8 @@ describe('Loan Renew Determine', () => {
|
|
|
79
79
|
'65' // in seconds
|
|
80
80
|
);
|
|
81
81
|
|
|
82
|
-
// we will get 1 min remaining since, we reduced 1 min from remaining time
|
|
83
82
|
expect(toastMsg).to.be.equal(
|
|
84
|
-
'This book will be automatically returned in
|
|
83
|
+
'This book will be automatically returned in 2 minutes unless you turn a page.'
|
|
85
84
|
);
|
|
86
85
|
});
|
|
87
86
|
});
|