Skip to content

Commit fe72a43

Browse files
committed
Added the ability to automatically get the configuration settings after 2.5 minutes of inactivity (#50)
1 parent fbe11f5 commit fe72a43

11 files changed

+173
-69
lines changed

dist/exceptionless.d.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ export declare class EventPluginManager {
116116
export declare class HeartbeatPlugin implements IEventPlugin {
117117
priority: number;
118118
name: string;
119-
private _heartbeatInterval;
120-
private _heartbeatIntervalId;
119+
private _interval;
120+
private _intervalId;
121121
constructor(heartbeatInterval?: number);
122122
run(context: EventPluginContext, next?: () => void): void;
123123
}
@@ -378,6 +378,14 @@ export interface IInnerError {
378378
stack_trace?: IStackFrame[];
379379
target_method?: IMethod;
380380
}
381+
export declare class SettingsResponse {
382+
success: boolean;
383+
settings: any;
384+
settingsVersion: number;
385+
message: string;
386+
exception: any;
387+
constructor(success: boolean, settings: any, settingsVersion?: number, exception?: any, message?: string);
388+
}
381389
export declare class ConfigurationDefaultsPlugin implements IEventPlugin {
382390
priority: number;
383391
name: string;
@@ -421,6 +429,15 @@ export declare class EventExclusionPlugin implements IEventPlugin {
421429
name: string;
422430
run(context: EventPluginContext, next?: () => void): void;
423431
}
432+
export declare class UpdateConfigurationSettingsWhileIdlePlugin implements IEventPlugin {
433+
priority: number;
434+
name: string;
435+
private _config;
436+
private _interval;
437+
private _intervalId;
438+
constructor(config: Configuration, interval?: number);
439+
run(context: EventPluginContext, next?: () => void): void;
440+
}
424441
export interface IError extends IInnerError {
425442
modules?: IModule[];
426443
}
@@ -444,14 +461,6 @@ export interface SubmissionRequest {
444461
url: string;
445462
data: string;
446463
}
447-
export declare class SettingsResponse {
448-
success: boolean;
449-
settings: any;
450-
settingsVersion: number;
451-
message: string;
452-
exception: any;
453-
constructor(success: boolean, settings: any, settingsVersion?: number, exception?: any, message?: string);
454-
}
455464
export declare class InMemoryStorage implements IStorage {
456465
private maxItems;
457466
private items;

dist/exceptionless.js

Lines changed: 50 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.node.js

Lines changed: 50 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/exceptionless.node.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/configuration/SettingsManager.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,18 @@ export class SettingsManager {
2020
}
2121

2222
public static applySavedServerSettings(config: Configuration): void {
23+
if (!config) {
24+
return;
25+
}
26+
2327
let savedSettings = this.getSavedServerSettings(config);
2428
config.log.info('Applying saved settings.');
2529
config.settings = Utils.merge(config.settings, savedSettings.settings);
2630
this.changed(config);
2731
}
2832

2933
public static checkVersion(version: number, config: Configuration): void {
30-
if (version) {
34+
if (version && config) {
3135
let savedSettings = this.getSavedServerSettings(config);
3236
let savedVersion = savedSettings.version;
3337
if (version > savedVersion) {
@@ -38,13 +42,17 @@ export class SettingsManager {
3842
}
3943

4044
public static updateSettings(config: Configuration): void {
45+
if (!config) {
46+
return;
47+
}
48+
4149
if (!config.isValid) {
4250
config.log.error('Unable to update settings: ApiKey is not set.');
4351
return;
4452
}
4553

4654
config.submissionClient.getSettings(config, (response: SettingsResponse) => {
47-
if (!response || !response.success || !response.settings) {
55+
if (!config || !response || !response.success || !response.settings) {
4856
return;
4957
}
5058

src/plugins/EventPluginManager.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { EnvironmentInfoPlugin } from './default/EnvironmentInfoPlugin';
99
import { SubmissionMethodPlugin } from './default/SubmissionMethodPlugin';
1010
import { DuplicateCheckerPlugin } from './default/DuplicateCheckerPlugin';
1111
import { EventExclusionPlugin } from './default/EventExclusionPlugin';
12+
import { UpdateConfigurationSettingsWhileIdlePlugin } from './default/UpdateConfigurationSettingsWhileIdlePlugin';
1213

1314
export class EventPluginManager {
1415
public static run(context: EventPluginContext, callback: (context?: EventPluginContext) => void): void {
@@ -51,5 +52,6 @@ export class EventPluginManager {
5152
config.addPlugin(new RequestInfoPlugin());
5253
config.addPlugin(new EnvironmentInfoPlugin());
5354
config.addPlugin(new SubmissionMethodPlugin());
55+
config.addPlugin(new UpdateConfigurationSettingsWhileIdlePlugin(config));
5456
}
5557
}

0 commit comments

Comments
 (0)