-
Notifications
You must be signed in to change notification settings - Fork 6
Dehru and JG telemetry - Send GDPR clean data to telemetry when errors/unsupported syntax present #110
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
Dehru and JG telemetry - Send GDPR clean data to telemetry when errors/unsupported syntax present #110
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
20f1f87
condition <--> array
jgellin-sf b9e51bc
in progress
a31119f
stashing
3482f43
send telemetry when errors or unsupported
f0277a6
passing basic soql errors/unsupported count to custom editor for tele…
57bcf07
simplify statement
b3c1a93
Merge branch 'develop' of github.com:forcedotcom/soql-tooling into de…
jgellin-sf 7d322ee
Better telemetry through metadata
jgellin-sf 9ad70f2
Merge branch 'jg/classifyErrorsAndUnmodeled' into dehru/telemetry
d116e31
combine jon's and my work into a single PR
d233ede
fixes for PR
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
49 changes: 49 additions & 0 deletions
49
packages/soql-builder-ui/src/modules/querybuilder/services/telemetryUtils.test.ts
This file contains hidden or 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,49 @@ | ||
| import { createQueryTelemetry } from './telemetryUtils'; | ||
| import { ToolingModelJson } from './toolingModelService'; | ||
|
|
||
| describe('Telemetry Utils', () => { | ||
| const error1 = { | ||
| type: 'UNKNOWN', | ||
| message: | ||
| "mismatched input 'BY' expecting {<EOF>, ',', 'offset', 'for', 'limit', 'having', 'order', 'update', 'bind'}", | ||
| lineNumber: 5, | ||
| charInLine: 8, | ||
| grammarRule: 'SoqlQueryContext' | ||
| }; | ||
| const error2 = { | ||
| type: 'NOSELECT', | ||
| message: | ||
| 'Incomplete SELECT clause. The SELECT clause must contain at least one SELECT expression.', | ||
| lineNumber: 1, | ||
| charInLine: 0, | ||
| grammarRule: 'SoqlSelectClauseContext' | ||
| }; | ||
| const unsupported1 = { | ||
| unmodeledSyntax: 'GROUP BY\n ORDER', | ||
| reason: 'unmodeled:group-by' | ||
| }; | ||
| const unsupported2 = { | ||
| unmodeledSyntax: 'COUNT(Id) recordCount', | ||
| reason: 'unmodeled:function-reference' | ||
| }; | ||
|
|
||
| const query = ({ | ||
| sObject: 'account', | ||
| fields: ['Id', 'Name'], | ||
| orderBy: [{ field: 'Name', nulls: 'first', order: 'desc' }], | ||
| limit: '1234', | ||
| errors: [error1, error2], | ||
| unsupported: [unsupported1, unsupported2] | ||
| } as unknown) as ToolingModelJson; | ||
| it('should create telemetry model from soql model', () => { | ||
| const telemetry = createQueryTelemetry(query); | ||
| expect(telemetry.sObject).toEqual('standard'); | ||
| expect(telemetry.fields).toEqual(query.fields.length); | ||
| expect(telemetry.orderBy).toEqual(query.orderBy.length); | ||
| expect(telemetry.errors.length).toEqual(query.errors.length); | ||
| expect(telemetry.errors[0]).toContain(error1.grammarRule); | ||
| expect(telemetry.unsupported.length).toEqual(query.unsupported.length); | ||
| expect(telemetry.unsupported[0]).toEqual(unsupported1.reason); | ||
| expect(JSON.stringify(telemetry)).not.toContain(query.fields[0]); | ||
| }); | ||
| }); |
26 changes: 26 additions & 0 deletions
26
packages/soql-builder-ui/src/modules/querybuilder/services/telemetryUtils.ts
This file contains hidden or 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,26 @@ | ||
| import { ToolingModelJson, ToolingModelService } from './toolingModelService'; | ||
| import { JsonMap } from '@salesforce/ts-types'; | ||
|
|
||
| export interface TelemetryModelJson extends JsonMap { | ||
| sObject: string; | ||
| fields: number; | ||
| orderBy: number; | ||
| limit: string; | ||
| errors: string[]; | ||
| unsupported: string[]; | ||
| } | ||
|
|
||
| export function createQueryTelemetry( | ||
| query: ToolingModelJson | ||
| ): TelemetryModelJson { | ||
| const telemetry = {} as TelemetryModelJson; | ||
| telemetry.sObject = query.sObject.indexOf('__c') > -1 ? 'custom' : 'standard'; | ||
| telemetry.fields = query.fields.length; | ||
| telemetry.orderBy = query.orderBy.length; | ||
| telemetry.limit = query.limit; | ||
| telemetry.errors = query.errors.map( | ||
| (err) => `${err.type}:${err.grammarRule}` | ||
| ); | ||
| telemetry.unsupported = query.unsupported.map((unsup) => unsup.reason); | ||
| return telemetry; | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this uses jon's new reason attribute of unsupported array.