@internetarchive/ia-book-actions 1.4.4-alpha11 → 1.4.4-alpha12
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
|
@@ -372,6 +372,12 @@ export default class ActionsHandler extends LitElement {
|
|
|
372
372
|
new Date().getTime() + this.loanTotalTime * 1000
|
|
373
373
|
);
|
|
374
374
|
|
|
375
|
+
log('[ActionsHandler] setBrowseTimeSession: resetting loanTime', {
|
|
376
|
+
identifier: this.identifier,
|
|
377
|
+
expireDate,
|
|
378
|
+
loanTotalTime: this.loanTotalTime,
|
|
379
|
+
});
|
|
380
|
+
|
|
375
381
|
// set a value
|
|
376
382
|
await this.localCache.set({
|
|
377
383
|
key: `${this.identifier}-loanTime`,
|
|
@@ -381,12 +387,20 @@ export default class ActionsHandler extends LitElement {
|
|
|
381
387
|
|
|
382
388
|
// delete pageChangedTime when book is auto renew at nth minute
|
|
383
389
|
await this.localCache.delete(`${this.identifier}-pageChangedTime`);
|
|
390
|
+
|
|
391
|
+
log('[ActionsHandler] setBrowseTimeSession: loanTime reset complete', {
|
|
392
|
+
identifier: this.identifier,
|
|
393
|
+
});
|
|
384
394
|
} catch (error) {
|
|
385
|
-
log(error);
|
|
395
|
+
log('[ActionsHandler] setBrowseTimeSession failed', error);
|
|
386
396
|
}
|
|
387
397
|
}
|
|
388
398
|
|
|
389
399
|
deleteLoanCookies() {
|
|
400
|
+
log('[ActionsHandler] deleteLoanCookies: expiring loan cookies', {
|
|
401
|
+
identifier: this.identifier,
|
|
402
|
+
});
|
|
403
|
+
|
|
390
404
|
const date = new Date();
|
|
391
405
|
date.setTime(date.getTime() - 24 * 60 * 60 * 1000); // one day ago
|
|
392
406
|
|
|
@@ -159,16 +159,16 @@ export default class LoanAnanlytics {
|
|
|
159
159
|
* @memberof LoanAnanlytics
|
|
160
160
|
*/
|
|
161
161
|
sendEvent(eventCategory, eventAction, label, extraParams) {
|
|
162
|
-
log(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
);
|
|
162
|
+
// log(
|
|
163
|
+
// 'eventCategory:-',
|
|
164
|
+
// eventCategory,
|
|
165
|
+
// '||\teventAction:-',
|
|
166
|
+
// eventAction,
|
|
167
|
+
// '||\tlabel:-',
|
|
168
|
+
// label,
|
|
169
|
+
// '||\textraParams:-',
|
|
170
|
+
// extraParams,
|
|
171
|
+
// );
|
|
172
172
|
|
|
173
173
|
window?.archive_analytics?.send_event_no_sampling(
|
|
174
174
|
eventCategory,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import ActionsHandlerService from './actions-handler/actions-handler-service.js';
|
|
3
3
|
import LoanAnanlytics from './loan-analytics.js';
|
|
4
4
|
import { sentryLogs } from '../config/sentry-events.js';
|
|
5
|
+
import log from './log.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* This class is used to create loan token for borrowed books
|
|
@@ -77,11 +78,21 @@ export class LoanTokenPoller {
|
|
|
77
78
|
*/
|
|
78
79
|
async handleLoanTokenPoller(isInitial = false, retryCount = 0) {
|
|
79
80
|
const action = 'create_token';
|
|
81
|
+
log('[LoanTokenPoller] create_token requested', {
|
|
82
|
+
identifier: this.identifier,
|
|
83
|
+
isInitial,
|
|
84
|
+
retryCount,
|
|
85
|
+
});
|
|
80
86
|
ActionsHandlerService({
|
|
81
87
|
identifier: this.identifier,
|
|
82
88
|
action,
|
|
83
89
|
error: data => this.handleTokenError(data, isInitial, retryCount),
|
|
84
90
|
success: () => {
|
|
91
|
+
log('[LoanTokenPoller] create_token succeeded', {
|
|
92
|
+
identifier: this.identifier,
|
|
93
|
+
isInitial,
|
|
94
|
+
retryCount,
|
|
95
|
+
});
|
|
85
96
|
if (isInitial) this.successCallback();
|
|
86
97
|
},
|
|
87
98
|
});
|
|
@@ -104,18 +115,37 @@ export class LoanTokenPoller {
|
|
|
104
115
|
typeof data?.error === 'string' &&
|
|
105
116
|
/do not currently have this book borrowed/i.test(data.error);
|
|
106
117
|
|
|
118
|
+
log('[LoanTokenPoller] create_token failed', {
|
|
119
|
+
identifier: this.identifier,
|
|
120
|
+
isInitial,
|
|
121
|
+
retryCount,
|
|
122
|
+
isStaleLoanReadError,
|
|
123
|
+
error: data?.error,
|
|
124
|
+
});
|
|
125
|
+
|
|
107
126
|
if (
|
|
108
127
|
isInitial &&
|
|
109
128
|
isStaleLoanReadError &&
|
|
110
129
|
retryCount < this.maxInitialTokenRetries
|
|
111
130
|
) {
|
|
112
131
|
const delay = this.initialTokenRetryDelay * (retryCount + 1);
|
|
132
|
+
log('[LoanTokenPoller] retrying create_token after stale-loan-read error', {
|
|
133
|
+
identifier: this.identifier,
|
|
134
|
+
nextRetryCount: retryCount + 1,
|
|
135
|
+
delay,
|
|
136
|
+
});
|
|
113
137
|
setTimeout(() => {
|
|
114
138
|
this.handleLoanTokenPoller(true, retryCount + 1);
|
|
115
139
|
}, delay);
|
|
116
140
|
return;
|
|
117
141
|
}
|
|
118
142
|
|
|
143
|
+
log('[LoanTokenPoller] giving up on create_token, reporting error', {
|
|
144
|
+
identifier: this.identifier,
|
|
145
|
+
isInitial,
|
|
146
|
+
retryCount,
|
|
147
|
+
});
|
|
148
|
+
|
|
119
149
|
this.errorCallback({ detail: { action, data } });
|
|
120
150
|
|
|
121
151
|
// send error to Sentry
|
package/src/ia-book-actions.js
CHANGED
|
@@ -465,7 +465,15 @@ export default class IABookActions extends LitElement {
|
|
|
465
465
|
* On error: handleLendingActionError() shows showLoanUnavailableModal().
|
|
466
466
|
*/
|
|
467
467
|
autoRenewExpiredLoan() {
|
|
468
|
-
if (this.loanRenewInProgress)
|
|
468
|
+
if (this.loanRenewInProgress) {
|
|
469
|
+
log('[IABookActions] autoRenewExpiredLoan: skipped, renewal already in progress', {
|
|
470
|
+
identifier: this.identifier,
|
|
471
|
+
});
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
log('[IABookActions] autoRenewExpiredLoan: starting silent renewal', {
|
|
475
|
+
identifier: this.identifier,
|
|
476
|
+
});
|
|
469
477
|
this.loanRenewInProgress = true;
|
|
470
478
|
this.recoveringFromLoanExpiry = true;
|
|
471
479
|
|
|
@@ -578,7 +586,10 @@ export default class IABookActions extends LitElement {
|
|
|
578
586
|
* Execute when loan is expired
|
|
579
587
|
*/
|
|
580
588
|
async browseHasExpired() {
|
|
581
|
-
log('[IABookActions] browseHasExpired'
|
|
589
|
+
log('[IABookActions] browseHasExpired', {
|
|
590
|
+
identifier: this.identifier,
|
|
591
|
+
loanRenewInProgress: this.loanRenewInProgress,
|
|
592
|
+
});
|
|
582
593
|
window?.IALendingIntervals?.clearAll();
|
|
583
594
|
|
|
584
595
|
const currStatus = {
|
|
@@ -591,6 +602,9 @@ export default class IABookActions extends LitElement {
|
|
|
591
602
|
// remove respected key:value for loan-renew
|
|
592
603
|
await this.localCache.delete(`${this.identifier}-loanTime`);
|
|
593
604
|
await this.localCache.delete(`${this.identifier}-pageChangedTime`);
|
|
605
|
+
log('[IABookActions] browseHasExpired: cleared loanTime/pageChangedTime cache', {
|
|
606
|
+
identifier: this.identifier,
|
|
607
|
+
});
|
|
594
608
|
|
|
595
609
|
// show message after browsed book is expired.
|
|
596
610
|
this.loanRenewResult.renewNow = false;
|
|
@@ -817,9 +831,8 @@ export default class IABookActions extends LitElement {
|
|
|
817
831
|
}
|
|
818
832
|
|
|
819
833
|
log('[IABookActions] timer', {
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
pageChangedInLast: this.loanRenewTimeConfig.pageChangedInLast,
|
|
834
|
+
whatShouldLeft: resyncd.whatShouldLeft,
|
|
835
|
+
whatIsleft: secondsLeft,
|
|
823
836
|
});
|
|
824
837
|
|
|
825
838
|
/**
|
|
@@ -978,6 +991,14 @@ export default class IABookActions extends LitElement {
|
|
|
978
991
|
const action = event?.detail?.action;
|
|
979
992
|
const errorMsg = event?.detail?.data?.error;
|
|
980
993
|
|
|
994
|
+
log('[IABookActions] handleLendingActionError', {
|
|
995
|
+
identifier: this.identifier,
|
|
996
|
+
action,
|
|
997
|
+
errorMsg,
|
|
998
|
+
loanRenewInProgress: this.loanRenewInProgress,
|
|
999
|
+
recoveringFromLoanExpiry: this.recoveringFromLoanExpiry,
|
|
1000
|
+
});
|
|
1001
|
+
|
|
981
1002
|
if (action === 'create_token') {
|
|
982
1003
|
// A create_token hiccup only affects BookReader's page-image access
|
|
983
1004
|
// token — it says nothing about how much time is left on the loan
|