Clean up plugin logs to new plugin log type
Change-Id: I0737666f6c200520858dfd442327b7540c70134a
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-reporting-js-api.ts b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-reporting-js-api.ts
index 595fb4f..0427b43 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-reporting-js-api.ts
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-reporting-js-api.ts
@@ -18,7 +18,6 @@
import {appContext} from '../../../services/app-context';
import {PluginApi} from '../../../api/plugin';
import {EventDetails, ReportingPluginApi} from '../../../api/reporting';
-import {LifeCycle} from '../../../constants/reporting';
/**
* Defines all methods that will be exported to plugin from reporting service.
@@ -32,7 +31,7 @@
reportInteraction(eventName: string, details?: EventDetails) {
this.reporting.trackApi(this.plugin, 'reporting', 'reportInteraction');
- this.reporting.reportInteraction(
+ this.reporting.reportPluginInteractionLog(
`${this.plugin.getPluginName()}-${eventName}`,
details
);
@@ -40,10 +39,9 @@
reportLifeCycle(eventName: string, details?: EventDetails) {
this.reporting.trackApi(this.plugin, 'reporting', 'reportLifeCycle');
- this.reporting.reportLifeCycle(LifeCycle.PLUGIN_LIFE_CYCLE, {
- ...details,
- pluginName: this.plugin.getPluginName(),
- eventName,
- });
+ this.reporting.reportPluginLifeCycleLog(
+ `${this.plugin.getPluginName()}-${eventName}`,
+ details
+ );
}
}
diff --git a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-reporting-js-api_test.js b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-reporting-js-api_test.js
index ffc2fbb..71cc565 100644
--- a/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-reporting-js-api_test.js
+++ b/polygerrit-ui/app/elements/shared/gr-js-api-interface/gr-reporting-js-api_test.js
@@ -43,30 +43,34 @@
});
test('redirect reportInteraction call to reportingService', () => {
- sinon.spy(appContext.reportingService, 'reportInteraction');
+ sinon.spy(appContext.reportingService, 'reportPluginInteractionLog');
reporting.reportInteraction('test', {});
- assert.isTrue(appContext.reportingService.reportInteraction.called);
+ assert.isTrue(appContext.reportingService.reportPluginInteractionLog
+ .called);
assert.equal(
- appContext.reportingService.reportInteraction.lastCall.args[0],
+ appContext.reportingService.reportPluginInteractionLog.lastCall
+ .args[0],
'testplugin-test'
);
assert.deepEqual(
- appContext.reportingService.reportInteraction.lastCall.args[1],
+ appContext.reportingService.reportPluginInteractionLog.lastCall
+ .args[1],
{}
);
});
test('redirect reportLifeCycle call to reportingService', () => {
- sinon.spy(appContext.reportingService, 'reportLifeCycle');
+ sinon.spy(appContext.reportingService, 'reportPluginLifeCycleLog');
reporting.reportLifeCycle('test', {});
- assert.isTrue(appContext.reportingService.reportLifeCycle.called);
+ assert.isTrue(appContext.reportingService.reportPluginLifeCycleLog
+ .called);
assert.equal(
- appContext.reportingService.reportLifeCycle.lastCall.args[0],
- 'Plugin life cycle'
+ appContext.reportingService.reportPluginLifeCycleLog.lastCall.args[0],
+ 'testplugin-test'
);
assert.deepEqual(
- appContext.reportingService.reportLifeCycle.lastCall.args[1],
- {pluginName: 'testplugin', eventName: 'test'}
+ appContext.reportingService.reportPluginLifeCycleLog.lastCall.args[1],
+ {}
);
});
});
diff --git a/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts b/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts
index ac072f3..1445a59 100644
--- a/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts
+++ b/polygerrit-ui/app/services/gr-reporting/gr-reporting.ts
@@ -94,7 +94,8 @@
*/
reportRpcTiming(anonymizedUrl: string, elapsed: number): void;
reportLifeCycle(eventName: LifeCycle, details?: EventDetails): void;
-
+ reportPluginLifeCycleLog(eventName: string, details?: EventDetails): void;
+ reportPluginInteractionLog(eventName: string, details?: EventDetails): void;
/**
* Use this method, if you want to check/count how often a certain code path
* is executed. For example you can use this method to prove that certain code
diff --git a/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts b/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
index 0b93f07..2cc6f41 100644
--- a/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
+++ b/polygerrit-ui/app/services/gr-reporting/gr-reporting_impl.ts
@@ -75,6 +75,14 @@
},
};
+const PLUGIN = {
+ TYPE: 'plugin-log',
+ CATEGORY: {
+ LIFECYCLE: 'lifecycle',
+ INTERACTION: 'interaction',
+ },
+};
+
const STARTUP_TIMERS: {[name: string]: number} = {
[Timing.PLUGINS_LOADED]: 0,
[Timing.METRICS_PLUGIN_LOADED]: 0,
@@ -778,6 +786,28 @@
);
}
+ reportPluginLifeCycleLog(eventName: string, details: EventDetails) {
+ this.reporter(
+ PLUGIN.TYPE,
+ PLUGIN.CATEGORY.LIFECYCLE,
+ eventName,
+ undefined,
+ details,
+ true
+ );
+ }
+
+ reportPluginInteractionLog(eventName: string, details: EventDetails) {
+ this.reporter(
+ PLUGIN.TYPE,
+ PLUGIN.CATEGORY.INTERACTION,
+ eventName,
+ undefined,
+ details,
+ true
+ );
+ }
+
reportInteraction(eventName: string | Interaction, details: EventDetails) {
this.reporter(
INTERACTION.TYPE,
diff --git a/polygerrit-ui/app/services/gr-reporting/gr-reporting_mock.ts b/polygerrit-ui/app/services/gr-reporting/gr-reporting_mock.ts
index 24c27e0..13461bf 100644
--- a/polygerrit-ui/app/services/gr-reporting/gr-reporting_mock.ts
+++ b/polygerrit-ui/app/services/gr-reporting/gr-reporting_mock.ts
@@ -79,6 +79,8 @@
log(`reportInteraction '${eventName}': ${JSON.stringify(details)}`);
},
reportLifeCycle: () => {},
+ reportPluginLifeCycleLog: () => {},
+ reportPluginInteractionLog: () => {},
reportRpcTiming: () => {},
setRepoName: () => {},
setChangeId: () => {},