@internetarchive/ia-book-actions 0.1.5-alpha2 → 0.1.5-alpha3
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/components/collapsible-action-group.js +9 -4
- package/src/core/services/actions-config.js +1 -0
- package/src/core/services/actions-handler/actions-handler.js +28 -76
- package/src/core/services/loan-analytics.js +10 -40
- package/src/core/services/loan-renew-helper.js +1 -0
- package/src/core/services/loan-token-poller.js +19 -23
- package/src/ia-book-actions.js +18 -10
package/demo/index.html
CHANGED
|
@@ -131,8 +131,8 @@
|
|
|
131
131
|
iaBookActions.returnUrl = '';
|
|
132
132
|
iaBookActions.localCache = localCache;
|
|
133
133
|
|
|
134
|
-
let loanTotalTime2Min = { loanTotalTime:
|
|
135
|
-
let loanTotalTime5Min = { loanTotalTime: 300, loanRenewAtLast:
|
|
134
|
+
let loanTotalTime2Min = { loanTotalTime: 70, loanRenewAtLast: 65, pageChangedInLast: 5 };
|
|
135
|
+
let loanTotalTime5Min = { loanTotalTime: 300, loanRenewAtLast: 180, pageChangedInLast: 15 };
|
|
136
136
|
let loanTotalTime1Hour = { loanTotalTime: 3600, loanRenewAtLast: 600, pageChangedInLast: 900 };
|
|
137
137
|
|
|
138
138
|
iaBookActions.loanRenewTimeConfig = loanTotalTime2Min;
|
package/package.json
CHANGED
|
@@ -204,7 +204,11 @@ export class CollapsibleActionGroup extends ActionsHandler {
|
|
|
204
204
|
href="${action.url}"
|
|
205
205
|
target=${action.target}
|
|
206
206
|
@click=${() => {
|
|
207
|
-
this.clickHandler(
|
|
207
|
+
this.clickHandler(
|
|
208
|
+
action.id,
|
|
209
|
+
action.analyticsEvent,
|
|
210
|
+
action?.borrowType
|
|
211
|
+
);
|
|
208
212
|
}}
|
|
209
213
|
>
|
|
210
214
|
${action.id === 'purchaseBook' ? purchaseIcon : ''} ${action.text}
|
|
@@ -225,7 +229,7 @@ export class CollapsibleActionGroup extends ActionsHandler {
|
|
|
225
229
|
return html`<button
|
|
226
230
|
class="ia-button ${action.className} ${initialButton ? 'initial' : ''}"
|
|
227
231
|
@click=${() => {
|
|
228
|
-
this.clickHandler(action.id, analyticsEvent);
|
|
232
|
+
this.clickHandler(action.id, analyticsEvent, action?.borrowType);
|
|
229
233
|
}}
|
|
230
234
|
>
|
|
231
235
|
${action.text}
|
|
@@ -238,10 +242,10 @@ export class CollapsibleActionGroup extends ActionsHandler {
|
|
|
238
242
|
* @param { object } gaEvent - contains analytics event action and category
|
|
239
243
|
* @param { string } gaEvent.category
|
|
240
244
|
* @param { string } gaEvent.action
|
|
241
|
-
*
|
|
245
|
+
* @param { string } borrowType browse|borrow
|
|
242
246
|
* @fires CollapsibleActionGroup#{eventName} - (will be browseBook, borrowBook etc...)
|
|
243
247
|
*/
|
|
244
|
-
clickHandler(eventName, gaEvent) {
|
|
248
|
+
clickHandler(eventName, gaEvent, borrowType = '') {
|
|
245
249
|
this.dropdownState = 'close';
|
|
246
250
|
this.dropdownArrow = dropdownClosed;
|
|
247
251
|
|
|
@@ -251,6 +255,7 @@ export class CollapsibleActionGroup extends ActionsHandler {
|
|
|
251
255
|
new CustomEvent(eventName, {
|
|
252
256
|
detail: {
|
|
253
257
|
event: { category, action },
|
|
258
|
+
borrowType,
|
|
254
259
|
},
|
|
255
260
|
})
|
|
256
261
|
);
|
|
@@ -37,134 +37,83 @@ export default class ActionsHandler extends LitElement {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
bindEvents() {
|
|
40
|
-
this.addEventListener('browseBook', (
|
|
40
|
+
this.addEventListener('browseBook', () => {
|
|
41
41
|
this.handleBrowseIt();
|
|
42
42
|
this.loanAnanlytics?.storeLoanStatsCount(this.identifier, 'browse');
|
|
43
|
-
const { category, action } = detail.event;
|
|
44
|
-
this.loanAnanlytics?.sendEvent(
|
|
45
|
-
category,
|
|
46
|
-
action,
|
|
47
|
-
`identifier=${this.identifier}`
|
|
48
|
-
);
|
|
49
43
|
});
|
|
50
44
|
|
|
51
|
-
this.addEventListener('browseBookAgain', (
|
|
45
|
+
this.addEventListener('browseBookAgain', () => {
|
|
52
46
|
this.handleBrowseIt();
|
|
53
47
|
this.loanAnanlytics?.storeLoanStatsCount(this.identifier, 'browseagain');
|
|
54
|
-
const { category, action } = detail.event;
|
|
55
|
-
this.loanAnanlytics?.sendEvent(
|
|
56
|
-
category,
|
|
57
|
-
action,
|
|
58
|
-
`identifier=${this.identifier}`
|
|
59
|
-
);
|
|
60
48
|
});
|
|
61
49
|
|
|
62
|
-
this.addEventListener('autoRenew', (
|
|
50
|
+
this.addEventListener('autoRenew', () => {
|
|
63
51
|
this.handleLoanRenewNow();
|
|
64
52
|
this.loanAnanlytics?.storeLoanStatsCount(this.identifier, 'autorenew');
|
|
65
|
-
const { category, action } = detail.event;
|
|
66
|
-
this.loanAnanlytics?.sendEvent(
|
|
67
|
-
category,
|
|
68
|
-
action,
|
|
69
|
-
`identifier=${this.identifier}`
|
|
70
|
-
);
|
|
71
53
|
});
|
|
72
54
|
|
|
73
|
-
this.addEventListener('autoReturn', (
|
|
55
|
+
this.addEventListener('autoReturn', () => {
|
|
56
|
+
this.deleteLoanCookies();
|
|
74
57
|
this.loanAnanlytics?.storeLoanStatsCount(this.identifier, 'autoreturn');
|
|
75
|
-
const { category, action } = detail.event;
|
|
76
|
-
this.loanAnanlytics?.sendEvent(
|
|
77
|
-
category,
|
|
78
|
-
action,
|
|
79
|
-
`identifier=${this.identifier}`
|
|
80
|
-
);
|
|
81
58
|
});
|
|
82
59
|
|
|
83
60
|
this.addEventListener('returnNow', ({ detail }) => {
|
|
84
|
-
|
|
61
|
+
// use loan stats count when 1-hour borrow is active
|
|
62
|
+
if (detail?.borrowType === 'browse') {
|
|
63
|
+
this.loanAnanlytics?.storeLoanStatsCount(this.identifier, 'return');
|
|
64
|
+
}
|
|
65
|
+
|
|
85
66
|
this.handleReturnIt();
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
action
|
|
90
|
-
|
|
91
|
-
|
|
67
|
+
|
|
68
|
+
// send these events if 14-day borrow return
|
|
69
|
+
if (detail?.borrowType === 'borrow') {
|
|
70
|
+
const { category, action } = detail.event;
|
|
71
|
+
this.loanAnanlytics?.sendEvent(category, action, this.identifier);
|
|
72
|
+
}
|
|
92
73
|
});
|
|
93
74
|
|
|
94
75
|
this.addEventListener('borrowBook', ({ detail }) => {
|
|
95
76
|
this.handleBorrowIt();
|
|
96
77
|
const { category, action } = detail.event;
|
|
97
|
-
this.loanAnanlytics?.sendEvent(
|
|
98
|
-
category,
|
|
99
|
-
action,
|
|
100
|
-
`identifier=${this.identifier}`
|
|
101
|
-
);
|
|
78
|
+
this.loanAnanlytics?.sendEvent(category, action, this.identifier);
|
|
102
79
|
});
|
|
103
80
|
|
|
104
81
|
this.addEventListener('loginAndBorrow', ({ detail }) => {
|
|
105
82
|
this.handleLoginOk();
|
|
106
83
|
const { category, action } = detail.event;
|
|
107
|
-
this.loanAnanlytics?.sendEvent(
|
|
108
|
-
category,
|
|
109
|
-
action,
|
|
110
|
-
`identifier=${this.identifier}`
|
|
111
|
-
);
|
|
84
|
+
this.loanAnanlytics?.sendEvent(category, action, this.identifier);
|
|
112
85
|
});
|
|
113
86
|
|
|
114
87
|
this.addEventListener('leaveWaitlist', ({ detail }) => {
|
|
115
88
|
this.handleRemoveFromWaitingList();
|
|
116
89
|
const { category, action } = detail.event;
|
|
117
|
-
this.loanAnanlytics?.sendEvent(
|
|
118
|
-
category,
|
|
119
|
-
action,
|
|
120
|
-
`identifier=${this.identifier}`
|
|
121
|
-
);
|
|
90
|
+
this.loanAnanlytics?.sendEvent(category, action, this.identifier);
|
|
122
91
|
});
|
|
123
92
|
|
|
124
93
|
this.addEventListener('joinWaitlist', ({ detail }) => {
|
|
125
94
|
this.handleReserveIt();
|
|
126
95
|
const { category, action } = detail.event;
|
|
127
|
-
this.loanAnanlytics?.sendEvent(
|
|
128
|
-
category,
|
|
129
|
-
action,
|
|
130
|
-
`identifier=${this.identifier}`
|
|
131
|
-
);
|
|
96
|
+
this.loanAnanlytics?.sendEvent(category, action, this.identifier);
|
|
132
97
|
});
|
|
133
98
|
|
|
134
99
|
this.addEventListener('purchaseBook', ({ detail }) => {
|
|
135
100
|
const { category, action } = detail.event;
|
|
136
|
-
this.loanAnanlytics?.sendEvent(
|
|
137
|
-
category,
|
|
138
|
-
action,
|
|
139
|
-
`identifier=${this.identifier}`
|
|
140
|
-
);
|
|
101
|
+
this.loanAnanlytics?.sendEvent(category, action, this.identifier);
|
|
141
102
|
});
|
|
142
103
|
|
|
143
104
|
this.addEventListener('adminAccess', ({ detail }) => {
|
|
144
105
|
const { category, action } = detail.event;
|
|
145
|
-
this.loanAnanlytics?.sendEvent(
|
|
146
|
-
category,
|
|
147
|
-
action,
|
|
148
|
-
`identifier=${this.identifier}`
|
|
149
|
-
);
|
|
106
|
+
this.loanAnanlytics?.sendEvent(category, action, this.identifier);
|
|
150
107
|
});
|
|
151
108
|
|
|
152
109
|
this.addEventListener('exitAdminAccess', ({ detail }) => {
|
|
153
110
|
const { category, action } = detail.event;
|
|
154
|
-
this.loanAnanlytics?.sendEvent(
|
|
155
|
-
category,
|
|
156
|
-
action,
|
|
157
|
-
`identifier=${this.identifier}`
|
|
158
|
-
);
|
|
111
|
+
this.loanAnanlytics?.sendEvent(category, action, this.identifier);
|
|
159
112
|
});
|
|
160
113
|
|
|
161
114
|
this.addEventListener('bookTitleBar', ({ detail }) => {
|
|
162
115
|
const { category, action } = detail.event;
|
|
163
|
-
this.loanAnanlytics?.sendEvent(
|
|
164
|
-
category,
|
|
165
|
-
action,
|
|
166
|
-
`identifier=${this.identifier}`
|
|
167
|
-
);
|
|
116
|
+
this.loanAnanlytics?.sendEvent(category, action, this.identifier);
|
|
168
117
|
});
|
|
169
118
|
}
|
|
170
119
|
|
|
@@ -214,7 +163,10 @@ export default class ActionsHandler extends LitElement {
|
|
|
214
163
|
identifier: this.identifier,
|
|
215
164
|
success: () => {
|
|
216
165
|
this.deleteLoanCookies();
|
|
217
|
-
URLHelper.goToUrl(this.returnUrl, true);
|
|
166
|
+
// URLHelper.goToUrl(this.returnUrl, true);
|
|
167
|
+
setTimeout(() => {
|
|
168
|
+
URLHelper.goToUrl(this.returnUrl, true);
|
|
169
|
+
}, this.waitUntillBorrowComplete * 1000);
|
|
218
170
|
},
|
|
219
171
|
error: data => {
|
|
220
172
|
this.dispatchActionError(action, data);
|
|
@@ -46,11 +46,7 @@ export default class LoanAnanlytics {
|
|
|
46
46
|
);
|
|
47
47
|
} catch (error) {
|
|
48
48
|
console.log(error);
|
|
49
|
-
this.sendEvent(
|
|
50
|
-
'Cookies-Error-Actions',
|
|
51
|
-
error,
|
|
52
|
-
`identifier=${this.identifier}`
|
|
53
|
-
);
|
|
49
|
+
this.sendEvent('Cookies-Error-Actions', error, this.identifier);
|
|
54
50
|
}
|
|
55
51
|
}
|
|
56
52
|
|
|
@@ -78,7 +74,7 @@ export default class LoanAnanlytics {
|
|
|
78
74
|
browse = browse ? Number(browse) + 1 : 1;
|
|
79
75
|
this.gaStats.browse = browse;
|
|
80
76
|
|
|
81
|
-
// reset renew and expire count
|
|
77
|
+
// reset renew and expire count
|
|
82
78
|
renew = 0;
|
|
83
79
|
expire = 0;
|
|
84
80
|
break;
|
|
@@ -92,7 +88,7 @@ export default class LoanAnanlytics {
|
|
|
92
88
|
expire = expire ? Number(expire) + 1 : 1;
|
|
93
89
|
this.gaStats.expire = expire;
|
|
94
90
|
|
|
95
|
-
// reset renew and expire count
|
|
91
|
+
// reset renew and expire count
|
|
96
92
|
renew = 0;
|
|
97
93
|
expire = 0;
|
|
98
94
|
break;
|
|
@@ -104,37 +100,13 @@ export default class LoanAnanlytics {
|
|
|
104
100
|
this.lendingEventCounts = { browse, renew, expire };
|
|
105
101
|
|
|
106
102
|
// obtain GA category, event
|
|
107
|
-
// const { category, event } = await this.getGACategoryAction(action);
|
|
108
103
|
const category = analyticsCategories.browse;
|
|
109
104
|
const event = `browse${this.paddedNumber(
|
|
110
105
|
this.gaStats?.browse
|
|
111
106
|
)}-autorenew${this.paddedNumber(this.gaStats?.renew)}:${action}`;
|
|
112
107
|
|
|
113
108
|
// send google analytics events
|
|
114
|
-
this.sendEvent(category, event,
|
|
115
|
-
browse: this.gaStats?.browse,
|
|
116
|
-
renew: this.gaStats?.renew,
|
|
117
|
-
expire: this.gaStats?.expire,
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* @param {string} action - like 'browse|autorenew|etc...'
|
|
125
|
-
* @return {object} - contains GA category and event
|
|
126
|
-
* - @param {string}
|
|
127
|
-
* - @param {string}
|
|
128
|
-
*
|
|
129
|
-
* @memberof LoanAnanlytics
|
|
130
|
-
*/
|
|
131
|
-
getGACategoryAction(action) {
|
|
132
|
-
const GACategory = analyticsCategories.browse;
|
|
133
|
-
const GAAction = `browse${this.paddedNumber(
|
|
134
|
-
this.gaStats?.browse
|
|
135
|
-
)}-autorenew${this.paddedNumber(this.gaStats?.renew)}:${action}`;
|
|
136
|
-
|
|
137
|
-
return { GACategory, GAAction };
|
|
109
|
+
this.sendEvent(category, event, this.identifier);
|
|
138
110
|
}
|
|
139
111
|
|
|
140
112
|
/**
|
|
@@ -168,21 +140,19 @@ export default class LoanAnanlytics {
|
|
|
168
140
|
* @memberof LoanAnanlytics
|
|
169
141
|
*/
|
|
170
142
|
sendEvent(eventCategory, eventAction, label, extraParams) {
|
|
171
|
-
console.
|
|
172
|
-
'eventCategory:-
|
|
143
|
+
console.log(
|
|
144
|
+
'eventCategory:-',
|
|
173
145
|
eventCategory,
|
|
174
|
-
'\
|
|
146
|
+
'\t||\teventAction:-',
|
|
175
147
|
eventAction,
|
|
176
|
-
'\
|
|
177
|
-
label
|
|
178
|
-
'\nextraParams:- ',
|
|
179
|
-
extraParams
|
|
148
|
+
'\t||\tlabel:-',
|
|
149
|
+
label
|
|
180
150
|
);
|
|
181
151
|
|
|
182
152
|
window?.archive_analytics?.send_event_no_sampling(
|
|
183
153
|
eventCategory,
|
|
184
154
|
eventAction,
|
|
185
|
-
label ||
|
|
155
|
+
label || this.identifier,
|
|
186
156
|
extraParams
|
|
187
157
|
);
|
|
188
158
|
}
|
|
@@ -89,6 +89,7 @@ export class LoanRenewHelper {
|
|
|
89
89
|
) {
|
|
90
90
|
this.result.texts = this.loanReturnWarning;
|
|
91
91
|
this.result.renewNow = false; // not viewed
|
|
92
|
+
console.log('warning msg appears');
|
|
92
93
|
} else if (pageChangedTime >= pageChangeTimeFrame) {
|
|
93
94
|
this.result.texts = '';
|
|
94
95
|
this.result.renewNow = true; // viewed in last time frame
|
|
@@ -37,18 +37,18 @@ export class LoanTokenPoller {
|
|
|
37
37
|
|
|
38
38
|
if (this.borrowType) {
|
|
39
39
|
// send consecutiveLoanCounts for browsed books only.
|
|
40
|
-
if (this.borrowType === 'browsed') {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
40
|
+
// if (this.borrowType === 'browsed') {
|
|
41
|
+
// try {
|
|
42
|
+
// const existingCount = Cookies.getItem(
|
|
43
|
+
// `loan-count-${this.identifier}`
|
|
44
|
+
// );
|
|
45
|
+
// consecutiveLoanCounts = existingCount ?? 1;
|
|
46
|
+
// } catch (error) {
|
|
47
|
+
// window?.Sentry?.captureException(
|
|
48
|
+
// `${sentryLogs.enableBookAcces} - CookieError: ${error}`
|
|
49
|
+
// );
|
|
50
|
+
// }
|
|
51
|
+
// }
|
|
52
52
|
|
|
53
53
|
// Do an initial token, then set an interval
|
|
54
54
|
this.handleLoanTokenPoller(true);
|
|
@@ -67,16 +67,12 @@ export class LoanTokenPoller {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
// event category and action for browsing book access
|
|
70
|
-
const category = `${this.borrowType}BookAccess`;
|
|
71
|
-
const action = `${
|
|
72
|
-
|
|
73
|
-
}${consecutiveLoanCounts}`;
|
|
74
|
-
|
|
75
|
-
this.loanAnalytics?.sendEvent(
|
|
76
|
-
category,
|
|
77
|
-
action,
|
|
78
|
-
`identifier=${this.identifier}`
|
|
79
|
-
);
|
|
70
|
+
// const category = `${this.borrowType}BookAccess`;
|
|
71
|
+
// const action = `${
|
|
72
|
+
// this.borrowType === 'browsed' ? 'BrowseCounts-' : 'Counts-'
|
|
73
|
+
// }${consecutiveLoanCounts}`;
|
|
74
|
+
|
|
75
|
+
// this.loanAnalytics?.sendEvent(category, action, this.identifier);
|
|
80
76
|
} else {
|
|
81
77
|
window?.Sentry?.captureMessage(
|
|
82
78
|
`${sentryLogs.bookAccessed} - not borrowed`
|
|
@@ -104,7 +100,7 @@ export class LoanTokenPoller {
|
|
|
104
100
|
this.loanAnalytics?.sendEvent(
|
|
105
101
|
'LendingServiceLoanError',
|
|
106
102
|
action,
|
|
107
|
-
|
|
103
|
+
this.identifier
|
|
108
104
|
);
|
|
109
105
|
},
|
|
110
106
|
success: () => {
|
package/src/ia-book-actions.js
CHANGED
|
@@ -11,6 +11,7 @@ import './components/book-title-bar.js';
|
|
|
11
11
|
import './components/text-group.js';
|
|
12
12
|
import './components/info-icon.js';
|
|
13
13
|
import './components/timer-countdown.js';
|
|
14
|
+
import './core/config/ia-lending-intervals.js';
|
|
14
15
|
|
|
15
16
|
import { GetLendingActions } from './core/services/get-lending-actions.js';
|
|
16
17
|
import { mobileContainerWidth } from './core/config/constants.js';
|
|
@@ -18,9 +19,6 @@ import { sentryLogs } from './core/config/sentry-events.js';
|
|
|
18
19
|
import { LoanTokenPoller } from './core/services/loan-token-poller.js';
|
|
19
20
|
import { LoanRenewHelper } from './core/services/loan-renew-helper.js';
|
|
20
21
|
|
|
21
|
-
import './core/config/ia-lending-intervals.js';
|
|
22
|
-
import * as Cookies from './core/services/doc-cookies.js';
|
|
23
|
-
|
|
24
22
|
export const events = {
|
|
25
23
|
browseExpired: 'IABookReader:BrowsingHasExpired',
|
|
26
24
|
};
|
|
@@ -75,6 +73,7 @@ export default class IABookActions extends LitElement {
|
|
|
75
73
|
this.borrowType = ''; // (browsed|borrowed)
|
|
76
74
|
this.consecutiveLoanCounts = 1; // consecutive loan count
|
|
77
75
|
this.suppressToast = false;
|
|
76
|
+
this.suppressAutoRenew = false;
|
|
78
77
|
this.browseTimer = undefined;
|
|
79
78
|
|
|
80
79
|
/**
|
|
@@ -173,6 +172,7 @@ export default class IABookActions extends LitElement {
|
|
|
173
172
|
|
|
174
173
|
async setupLendingToolbarActions() {
|
|
175
174
|
this.suppressToast = false;
|
|
175
|
+
this.suppressAutoRenew = false;
|
|
176
176
|
|
|
177
177
|
this.lendingOptions = new GetLendingActions(
|
|
178
178
|
this.userid,
|
|
@@ -259,6 +259,10 @@ export default class IABookActions extends LitElement {
|
|
|
259
259
|
this.suppressToast = true;
|
|
260
260
|
this.closeToastManager();
|
|
261
261
|
|
|
262
|
+
if (this.suppressAutoRenew) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
|
|
262
266
|
if (this.borrowType === 'browsed') {
|
|
263
267
|
this.autoLoanRenewChecker(true);
|
|
264
268
|
}
|
|
@@ -290,6 +294,11 @@ export default class IABookActions extends LitElement {
|
|
|
290
294
|
this.addEventListener('IABookActions:loanRenew', async event => {
|
|
291
295
|
await this.autoLoanRenewChecker(false);
|
|
292
296
|
|
|
297
|
+
// maybe the renew with-in last 1 minute is too short of a transition time between xhr, loading images etc... let NOT renew in last 50 seconds.
|
|
298
|
+
if (event?.detail?.secondsLeft < 50) {
|
|
299
|
+
this.suppressAutoRenew = true;
|
|
300
|
+
}
|
|
301
|
+
|
|
293
302
|
// show warning message with remaining time to auto returned it.
|
|
294
303
|
if (this.loanRenewResult.renewNow === false) {
|
|
295
304
|
this.loanRenewResult.secondsLeft = event.detail.secondsLeft;
|
|
@@ -405,9 +414,6 @@ export default class IABookActions extends LitElement {
|
|
|
405
414
|
await this.localCache.delete(`${this.identifier}-loanTime`);
|
|
406
415
|
await this.localCache.delete(`${this.identifier}-pageChangedTime`);
|
|
407
416
|
|
|
408
|
-
// remove loan-renew-count-<identifier> cookie
|
|
409
|
-
Cookies.removeItem(`loan-renew-count-${this.identifier}`);
|
|
410
|
-
|
|
411
417
|
// show message after browsed book is expired.
|
|
412
418
|
this.loanRenewResult.renewNow = false;
|
|
413
419
|
this.loanRenewResult.texts =
|
|
@@ -507,8 +513,10 @@ export default class IABookActions extends LitElement {
|
|
|
507
513
|
* - show success message
|
|
508
514
|
* - then change the remaining time
|
|
509
515
|
* - reset timer state
|
|
516
|
+
* @param {object} event
|
|
510
517
|
*/
|
|
511
|
-
async handleLoanAutoRenewed() {
|
|
518
|
+
async handleLoanAutoRenewed(event) {
|
|
519
|
+
// TODO: just read DATA variable here to apply security { action, data }
|
|
512
520
|
if (this.loanRenewResult.renewNow) {
|
|
513
521
|
window?.IALendingIntervals?.clearAll();
|
|
514
522
|
|
|
@@ -518,12 +526,12 @@ export default class IABookActions extends LitElement {
|
|
|
518
526
|
await this.resetTimerCountState();
|
|
519
527
|
|
|
520
528
|
window?.Sentry?.captureMessage(`${sentryLogs.bookHasRenewed}`);
|
|
521
|
-
// TODO: analytics?? for consecutive renew.....
|
|
522
529
|
|
|
523
530
|
// testing console....
|
|
524
|
-
console.log(
|
|
531
|
+
console.log('IABookActions: AutoRenewed:- ', {
|
|
532
|
+
ajaxResponse: event?.detail?.data,
|
|
525
533
|
loanRenewResult: this.loanRenewResult,
|
|
526
|
-
|
|
534
|
+
secondsLeftOnLoan: Math.round(this.lendingStatus.secondsLeftOnLoan),
|
|
527
535
|
resetTimerCountState: this._shadowRoot.querySelector('timer-countdown'),
|
|
528
536
|
});
|
|
529
537
|
}
|