Skip to content
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

add trackTrace and expose analytics extension to react plugin #1697

Merged
merged 6 commits into from
Oct 23, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
96 changes: 48 additions & 48 deletions common/config/rush/npm-shrinkwrap.json

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

22 changes: 20 additions & 2 deletions extensions/applicationinsights-react-js/src/ReactPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import {
IConfig, IPageViewTelemetry, IMetricTelemetry, IAppInsights, IEventTelemetry, IExceptionTelemetry
IConfig, IPageViewTelemetry, IMetricTelemetry, IAppInsights, IEventTelemetry, IExceptionTelemetry, ITraceTelemetry
} from "@microsoft/applicationinsights-common";
import {
IPlugin, IConfiguration, IAppInsightsCore, IDiagnosticLogger,
Expand Down Expand Up @@ -50,6 +50,13 @@ export default class ReactPlugin extends BaseTelemetryPlugin {
return safeGetCookieMgr(this.core);
}

/**
* Get the current analytics plugin instance.
*/
getAnalyticsPlugin(): IAppInsights {
kryalama marked this conversation as resolved.
Show resolved Hide resolved
return this._analyticsPlugin;
}

/**
* Add Part A fields to the event
* @param event The event that needs to be processed
Expand Down Expand Up @@ -94,7 +101,18 @@ export default class ReactPlugin extends BaseTelemetryPlugin {
this.diagLog().throwInternal(
LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
}
};
}

trackTrace(trace: ITraceTelemetry, customProperties?: {
[key: string]: any;
}) {
if (this._analyticsPlugin) {
this._analyticsPlugin.trackTrace(trace, customProperties);
} else {
this.diagLog().throwInternal(
LoggingSeverity.CRITICAL, _InternalMessageId.TelemetryInitializerFailed, "Analytics plugin is not available, React plugin telemetry will not be sent: ");
}
}


private addHistoryListener(history: History): void {
Expand Down