Skip to content

Commit 7e1bba0

Browse files
authored
fix to avoid missing steps (#12)
1 parent 71ea35a commit 7e1bba0

14 files changed

+46
-75
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ test-build.pem
2727
test-build.zip
2828
test-build-firefox.zip
2929
/readme_assets/*-clear.png
30+
31+
.windsurf/rules/snyk_rules.md
32+
/zip

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "snyk-api-and-web-record-sequence",
3-
"version": "0.0.8",
3+
"version": "1.0.0",
44
"description": "Snyk API & Web Record login/sequence",
55
"license": "MIT",
66
"scripts": {

src/manifest-firefox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Snyk API & Web Sequence Recorder",
3-
"version": "0.0.8",
3+
"version": "1.0.0",
44
"browser_specific_settings": {
55
"gecko": {
66

src/pages/Background/index.js

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,77 @@ import '../../assets/img/icon-34.png';
22
import '../../assets/img/icon-128.png';
33

44
(function () {
5-
let startURLDomensionsUpdated = false;
5+
let startURLDimensionsUpdated = false;
66
let aEvents = [];
77

8+
chrome.storage.local.get(['recordingEvents', 'startURLDimensionsUpdated', 'recordingTimestamp'], (data) => {
9+
const now = Date.now();
10+
const dataTTL = 10 * 60 * 1000;
11+
12+
if (data.recordingTimestamp && (now - data.recordingTimestamp) > dataTTL) {
13+
chrome.storage.local.remove(['recordingEvents', 'startURLDimensionsUpdated', 'recordingTimestamp']);
14+
aEvents = [];
15+
startURLDimensionsUpdated = false;
16+
} else {
17+
if (data.recordingEvents && Array.isArray(data.recordingEvents)) {
18+
aEvents = data.recordingEvents;
19+
}
20+
if (data.startURLDimensionsUpdated !== undefined) {
21+
startURLDimensionsUpdated = data.startURLDimensionsUpdated;
22+
}
23+
}
24+
});
25+
826
chrome.storage.sync.get(['isRecording'], (data) => {
927
if (data.isRecording) {
1028
(chrome.action || chrome.browserAction).setBadgeText(
1129
{
1230
text: '🔴',
1331
},
14-
() => {}
32+
() => { }
1533
);
1634
} else {
1735
(chrome.action || chrome.browserAction).setBadgeText(
1836
{
1937
text: '',
2038
},
21-
() => {}
39+
() => { }
2240
);
2341
}
2442
});
2543

44+
function saveEventsToStorage() {
45+
chrome.storage.local.set({
46+
recordingEvents: aEvents,
47+
startURLDimensionsUpdated: startURLDimensionsUpdated,
48+
recordingTimestamp: Date.now()
49+
});
50+
}
51+
2652
chrome.runtime.onMessage.addListener((data, sender, sendResponse) => {
2753
if (data.messageType === 'events') {
28-
if (!startURLDomensionsUpdated) {
29-
startURLDomensionsUpdated = true;
54+
if (!startURLDimensionsUpdated) {
55+
startURLDimensionsUpdated = true;
3056
if (aEvents.length === 1 && data.event.type === 'goto') {
3157
aEvents[0].windowWidth = data.event.windowWidth;
3258
aEvents[0].windowHeight = data.event.windowHeight;
3359

3460
if (aEvents[0].url === data.event.url) {
61+
saveEventsToStorage();
3562
return;
3663
}
3764
}
3865
}
3966
aEvents.push(data.event);
67+
saveEventsToStorage();
4068
} else if (data.messageType === 'start') {
41-
startURLDomensionsUpdated = false;
69+
startURLDimensionsUpdated = false;
4270
aEvents = [data.event];
71+
saveEventsToStorage();
4372
} else if (data.messageType === 'clear') {
44-
startURLDomensionsUpdated = false;
73+
startURLDimensionsUpdated = false;
4574
aEvents = [];
75+
chrome.storage.local.remove(['recordingEvents', 'startURLDimensionsUpdated', 'recordingTimestamp']);
4676
} else if (data.messageType === 'give_recording_data') {
4777
chrome.runtime.sendMessage({
4878
messageType: 'recording_data',

test-build-firefox/8867f464cc4dd91227f8.svg

Lines changed: 0 additions & 31 deletions
This file was deleted.
-2.09 KB
Binary file not shown.

0 commit comments

Comments
 (0)