Skip to content

Commit 76b0b45

Browse files
committed
fix: Extra error handling
1 parent 0ee757a commit 76b0b45

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

src/ext.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ export async function activate(context: flashpoint.ExtensionContext) {
2121
hardwareSent: () => flashpoint.getExtConfigValue('com.analytics.hardware-sent'),
2222
}
2323

24+
const sessionError = (err: Error) => {
25+
flashpoint.log.error(`Session Event Error: ${err}`);
26+
}
27+
2428
const firstLaunch = !flashpoint.getExtConfigValue('com.analytics.setup-complete');
2529
let firstConnect = true;
2630
flashpoint.onDidConnect(async () => {
@@ -66,9 +70,9 @@ export async function activate(context: flashpoint.ExtensionContext) {
6670
try {
6771
session = new Session(userId);
6872
await session.connect();
69-
session.event('Basic', 'launch', '');
73+
session.event('Basic', 'launch', '').catch(sessionError);
7074
if (flashpoint.dataVersion) {
71-
session.event('Basic', 'version', flashpoint.dataVersion);
75+
session.event('Basic', 'version', flashpoint.dataVersion).catch(sessionError);
7276
}
7377

7478
// Hardware
@@ -81,9 +85,9 @@ export async function activate(context: flashpoint.ExtensionContext) {
8185
else if (totalmem > 2147400000) { simplifiedTotalMem = '>= 2GB < 4GB'; }
8286
else if (totalmem > 10000) { simplifiedTotalMem = '< 2GB'; }
8387
Promise.all([
84-
session.event('Hardware', 'arch', arch()),
85-
session.event('Hardware', 'operatingSystem', os.version()),
86-
session.event('Hardware', 'memory', simplifiedTotalMem)
88+
session.event('Hardware', 'arch', arch()).catch(sessionError),
89+
session.event('Hardware', 'operatingSystem', os.version()).catch(sessionError),
90+
session.event('Hardware', 'memory', simplifiedTotalMem).catch(sessionError)
8791
])
8892
.then(() => {
8993
flashpoint.setExtConfigValue('com.analytics.hardware-sent', true);
@@ -96,11 +100,11 @@ export async function activate(context: flashpoint.ExtensionContext) {
96100
// Game Launch
97101
registerSub(flashpoint.games.onDidLaunchGame((game) => {
98102
if (config.games()) {
99-
session.event('Games', 'gameLaunch', game.id);
103+
session.event('Games', 'gameLaunch', game.id).catch(sessionError);
100104
const timeStart = Date.now();
101105
const listener = flashpoint.services.onServiceRemove((process) => {
102106
if (process.id === 'game.' + game.id) {
103-
session.event('GameTime', 'gameId', ((Date.now() - timeStart) / 1000).toString());
107+
session.event('GameTime', 'gameId', ((Date.now() - timeStart) / 1000).toString()).catch(sessionError);
104108
flashpoint.dispose(listener);
105109
}
106110
})
@@ -124,7 +128,7 @@ export async function activate(context: flashpoint.ExtensionContext) {
124128
const games = flashpoint.services.getServices().filter(s => s.id.startsWith('game.'));
125129
if (games.length === 1) {
126130
const gameId = games[0].id.substring(5);
127-
session.event('Repack', gameId, urlSubstring);
131+
session.event('Repack', gameId, urlSubstring).catch(sessionError);
128132
}
129133
}
130134
}

0 commit comments

Comments
 (0)