-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
agent: add telemetry/recordEvent to replace graphql/logEvent (#1713)
1. Add `telemetry/recordEvent`, which sends events to a telemetry recorder provider backed by a backwards-compatible GraphQL exporter - the same one we use for VSCode, added in #1192. This replaces the current `graphql/logEvent` 2. Deprecate `extensionConfiguration.eventProperties` 3. Clients should now provide `{ extensionConfiguration: { anonymousUserID }` up-front ## Test plan `pnpm build` and `node dist/index.js` are okay, but might need some help testing this properly with a real extension
- Loading branch information
Showing
12 changed files
with
241 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { SourcegraphGraphQLAPIClient } from '@sourcegraph/cody-shared/src/sourcegraph-api/graphql' | ||
import { GraphQLTelemetryExporter } from '@sourcegraph/cody-shared/src/sourcegraph-api/telemetry/GraphQLTelemetryExporter' | ||
import { BillingCategory, BillingProduct } from '@sourcegraph/cody-shared/src/telemetry-v2' | ||
import { | ||
defaultEventRecordingOptions, | ||
MarketingTrackingProvider, | ||
MarketingTrackingTelemetryProcessor, | ||
TelemetryRecorderProvider, | ||
} from '@sourcegraph/telemetry' | ||
|
||
import { ClientInfo } from '../protocol-alias' | ||
|
||
/** | ||
* Default implementation of a TelemetryRecorderProvider for use in the Agent | ||
* handler only. | ||
*/ | ||
export class AgentHandlerTelemetryRecorderProvider extends TelemetryRecorderProvider<BillingProduct, BillingCategory> { | ||
constructor( | ||
graphql: SourcegraphGraphQLAPIClient, | ||
clientInfo: ClientInfo, | ||
marketingTrackingProvider: MarketingTrackingProvider | ||
) { | ||
super( | ||
{ | ||
client: clientInfo.name, | ||
clientVersion: clientInfo.version, | ||
}, | ||
new GraphQLTelemetryExporter(graphql, clientInfo.extensionConfiguration?.anonymousUserID || '', 'all'), | ||
[new MarketingTrackingTelemetryProcessor(marketingTrackingProvider)], | ||
{ | ||
...defaultEventRecordingOptions, | ||
bufferTimeMs: 0, // disable buffering for now | ||
} | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.