Skip to content

Commit

Permalink
Merge pull request #139 from guardian/ts/add-matchertype-telemetry
Browse files Browse the repository at this point in the history
feat: 馃幐 Add matcherType to telemetry
  • Loading branch information
tjsilver committed Sep 24, 2020
2 parents 53f01eb + 457f0ef commit c2bb90e
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/ts/interfaces/IMatch.ts
Expand Up @@ -50,6 +50,7 @@ export type TMatchRequestErrorWithDefault = PartialBy<
>;

export interface IMatch<TSuggestion = ISuggestion> {
matcherType: string
matchId: string;
from: number;
to: number;
Expand Down
6 changes: 3 additions & 3 deletions src/ts/interfaces/ITelemetryData.ts
@@ -1,4 +1,4 @@
type TelemetryBool = 'true' | 'false';
type TelemetryBool = "true" | "false";

export interface ITelemetryEvent {
/**
Expand Down Expand Up @@ -35,7 +35,6 @@ export interface ITelemetryEvent {
};
}


export enum TYPERIGHTER_TELEMETRY_TYPE {
TYPERIGHTER_SUGGESTION_IS_ACCEPTED = "TYPERIGHTER_SUGGESTION_IS_ACCEPTED",
TYPERIGHTER_MARK_AS_CORRECT = "TYPERIGHTER_MARK_AS_CORRECT",
Expand All @@ -54,7 +53,8 @@ export interface ITyperighterTelemetryEvent extends ITelemetryEvent {
}

interface IMatchEventTags {
ruleId: string,
matcherType: string;
ruleId: string;
suggestion?: string;
matchId: string;
matchIsMarkedAsCorrect: TelemetryBool;
Expand Down
1 change: 1 addition & 0 deletions src/ts/services/TyperighterTelemetryAdapter.ts
Expand Up @@ -103,6 +103,7 @@ class TyperighterTelemetryAdapter {
}

private getTelemetryTagsFromMatch = (match: IMatch) => ({
matcherType: match.matcherType,
ruleId: match.ruleId,
matchId: match.matchId,
matchedText: match.matchedText,
Expand Down
1 change: 1 addition & 0 deletions src/ts/services/adapters/TyperighterAdapter.ts
Expand Up @@ -26,6 +26,7 @@ export const convertTyperighterResponse = (
matchId: v4(),
from: fromPos,
to: toPos,
matcherType: rule.matcherType,
category: rule.category,
ruleId: rule.id,
...match
Expand Down
1 change: 1 addition & 0 deletions src/ts/services/adapters/interfaces/ITyperighter.ts
Expand Up @@ -36,6 +36,7 @@ export interface ITypeRighterType {
}

export interface ITypeRighterRule {
matcherType: string;
category: ITypeRighterCategory;
description: string;
id: string;
Expand Down
1 change: 1 addition & 0 deletions src/ts/services/test/MatcherService.spec.ts
Expand Up @@ -27,6 +27,7 @@ const createResponse = (strs: string[]): ITypeRighterResponse => ({
message: "It's just a bunch of numbers, mate",
shortMessage: "It's just a bunch of numbers, mate",
rule: {
matcherType: "regex",
category: {
id: "numberCat",
name: "The number category",
Expand Down
4 changes: 4 additions & 0 deletions src/ts/state/test/reducer.spec.ts
Expand Up @@ -507,6 +507,7 @@ describe("Action handlers", () => {
it("should add hover decorations", () => {
const { state, tr } = createInitialData();
const output: IMatch = {
matcherType: "regex",
ruleId: "ruleId",
matchId: "match-id",
from: 0,
Expand Down Expand Up @@ -541,6 +542,7 @@ describe("Action handlers", () => {
it("should remove hover decorations", () => {
const { state, tr } = createInitialData();
const output: IMatch = {
matcherType: "regex",
ruleId: "ruleId",
matchId: "match-id",
from: 0,
Expand Down Expand Up @@ -580,6 +582,7 @@ describe("Action handlers", () => {
const { state } = createInitialData();
const currentMatches: IMatch[] = [
{
matcherType: "regex",
ruleId: "ruleId",
matchId: "match-id",
from: 1,
Expand Down Expand Up @@ -625,6 +628,7 @@ describe("Action handlers", () => {
...state,
currentMatches: [
{
matcherType: "regex",
ruleId: "ruleId",
matchId: "match-id",
text: "example",
Expand Down
2 changes: 2 additions & 0 deletions src/ts/state/test/selectors.spec.ts
Expand Up @@ -130,6 +130,7 @@ describe("selectors", () => {
const { state } = createInitialData();
const currentMatches: IMatch[] = [
{
matcherType: "regex",
ruleId: "ruleId",
matchId: "match-id",
from: 0,
Expand Down Expand Up @@ -166,6 +167,7 @@ describe("selectors", () => {
const { state } = createInitialData();
const currentMatches: IMatch[] = [
{
matcherType: "regex",
ruleId: "ruleId",
matchId: "match-id",
from: 0,
Expand Down
1 change: 1 addition & 0 deletions src/ts/test/createTyperighterPlugin.spec.ts
Expand Up @@ -59,6 +59,7 @@ describe("createTyperighterPlugin", () => {
matches: [
{
...blocks[0],
matcherType: "regex",
ruleId: "ruleId",
matchId: "matchId",
matchedText: blocks[0].text,
Expand Down
2 changes: 2 additions & 0 deletions src/ts/test/helpers/fixtures.ts
Expand Up @@ -89,6 +89,7 @@ export const createMatcherResponse = (
};

const newMatch = {
matcherType: "regex",
ruleId: "ruleId",
category,
matchedText: "block text",
Expand Down Expand Up @@ -126,6 +127,7 @@ export const createMatch = (
colour: "eeeee"
}
): IMatch => ({
matcherType: "regex",
ruleId: "ruleId",
category,
matchedText: "block text",
Expand Down

0 comments on commit c2bb90e

Please sign in to comment.