Skip to content

auto settings #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions dist/exceptionless.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ export declare class EventPluginManager {
export declare class HeartbeatPlugin implements IEventPlugin {
priority: number;
name: string;
private _heartbeatInterval;
private _heartbeatIntervalId;
private _interval;
private _intervalId;
constructor(heartbeatInterval?: number);
run(context: EventPluginContext, next?: () => void): void;
}
Expand Down Expand Up @@ -378,6 +378,14 @@ export interface IInnerError {
stack_trace?: IStackFrame[];
target_method?: IMethod;
}
export declare class SettingsResponse {
success: boolean;
settings: any;
settingsVersion: number;
message: string;
exception: any;
constructor(success: boolean, settings: any, settingsVersion?: number, exception?: any, message?: string);
}
export declare class ConfigurationDefaultsPlugin implements IEventPlugin {
priority: number;
name: string;
Expand Down Expand Up @@ -421,6 +429,15 @@ export declare class EventExclusionPlugin implements IEventPlugin {
name: string;
run(context: EventPluginContext, next?: () => void): void;
}
export declare class UpdateConfigurationSettingsWhileIdlePlugin implements IEventPlugin {
priority: number;
name: string;
private _config;
private _interval;
private _intervalId;
constructor(config: Configuration, interval?: number);
run(context: EventPluginContext, next?: () => void): void;
}
export interface IError extends IInnerError {
modules?: IModule[];
}
Expand All @@ -444,14 +461,6 @@ export interface SubmissionRequest {
url: string;
data: string;
}
export declare class SettingsResponse {
success: boolean;
settings: any;
settingsVersion: number;
message: string;
exception: any;
constructor(success: boolean, settings: any, settingsVersion?: number, exception?: any, message?: string);
}
export declare class InMemoryStorage implements IStorage {
private maxItems;
private items;
Expand Down
72 changes: 50 additions & 22 deletions dist/exceptionless.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/exceptionless.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/exceptionless.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/exceptionless.min.js.map

Large diffs are not rendered by default.

72 changes: 50 additions & 22 deletions dist/exceptionless.node.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/exceptionless.node.js.map

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions src/configuration/SettingsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@ export class SettingsManager {
}

public static applySavedServerSettings(config: Configuration): void {
if (!config) {
return;
}

let savedSettings = this.getSavedServerSettings(config);
config.log.info('Applying saved settings.');
config.settings = Utils.merge(config.settings, savedSettings.settings);
this.changed(config);
}

public static checkVersion(version: number, config: Configuration): void {
if (version) {
if (version && config) {
let savedSettings = this.getSavedServerSettings(config);
let savedVersion = savedSettings.version;
if (version > savedVersion) {
Expand All @@ -38,13 +42,17 @@ export class SettingsManager {
}

public static updateSettings(config: Configuration): void {
if (!config) {
return;
}

if (!config.isValid) {
config.log.error('Unable to update settings: ApiKey is not set.');
return;
}

config.submissionClient.getSettings(config, (response: SettingsResponse) => {
if (!response || !response.success || !response.settings) {
if (!config || !response || !response.success || !response.settings) {
return;
}

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/EventPluginManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { EnvironmentInfoPlugin } from './default/EnvironmentInfoPlugin';
import { SubmissionMethodPlugin } from './default/SubmissionMethodPlugin';
import { DuplicateCheckerPlugin } from './default/DuplicateCheckerPlugin';
import { EventExclusionPlugin } from './default/EventExclusionPlugin';
import { UpdateConfigurationSettingsWhileIdlePlugin } from './default/UpdateConfigurationSettingsWhileIdlePlugin';

export class EventPluginManager {
public static run(context: EventPluginContext, callback: (context?: EventPluginContext) => void): void {
Expand Down Expand Up @@ -51,5 +52,6 @@ export class EventPluginManager {
config.addPlugin(new RequestInfoPlugin());
config.addPlugin(new EnvironmentInfoPlugin());
config.addPlugin(new SubmissionMethodPlugin());
config.addPlugin(new UpdateConfigurationSettingsWhileIdlePlugin(config));
}
}
Loading