UNPKG

@sheerid/jslib-nightly

Version:

SheerID JavaScript Library

228 lines (227 loc) • 9.11 kB
import { VerificationStep, VerificationResponse, WithCoreFields } from '../types/types'; export declare enum isTestValues { TRUE = "true", FALSE = "false" } export declare const testRequestEmailDomains: string[]; export declare enum EventName { ASR_SELECTED = "AsrSelected",// Add School Request clicked by user FORM_PASTE = "FormPaste",// When content is pasted into the form! INVALID_FORM_SUBMIT = "InvalidFormSubmit",// When a form is submitted but has validation errors STEP_SEEN = "StepSeen",// when a consumer first sees a step (once) STEP_SUBMITTED = "StepSubmitted",// when a consumer submits the step (but before we know that Platform gave a 2xx rsp) STEP_ACCEPTED = "StepAccepted",// when platform responds w/ 2xx response ORG_SELECTED = "OrgSelected",// an org was clicked from the list ORGS_DISPLAYED = "OrgsDisplayed",// orgs are listed/shown to the user VIEW_EXPERIMENT = "ViewExperiment",// describe the variation for an experiment. Usually a Launch Darkly experiment SUCCESS_REDIRECT_CLICKED = "SuccessRedirectClicked",// when user clicks the redirect button on the success step SSO_SIGN_IN_CLICKED = "SsoSignInClicked",// when user clicks the SSO sign-in button SSO_CANCEL_CLICKED = "SsoCancelClicked",// when user clicks the SSO cancel button DOC_UPLOAD_ADD_FILES = "DocUploadAddFiles",// when user clicks the add files button on doc upload step DOC_UPLOAD_REMOVE_FILES = "DocUploadRemoveFiles",// when user clicks the remove files button on doc upload step /** @deprecated Use STEP_SEEN instead */ COLLECT_STARTED = "CollectStarted",// Collect step is started /** @deprecated Use STEP_SUBMITTED instead */ COLLECT_SUBMITTED = "CollectSubmitted",// Collect step's submit button is clicked /** @deprecated use specifically-named events instead, e.g. "LCP" event */ PERFORMANCE = "Performance", USER_PROPERTIES = "user_properties", /** @deprecated use specifically-named events instead, e.g. "CollectSubmitted" event */ VERIFICATION = "Verification", VERIFICATION_HELP = "VerificationHelp" } export declare enum CustomDimensionNames { /** @deprecated - Age is potentially sensitive data and should not be sent HC-1117 */ age = "age", jslibVersionActual = "jslibVersionActual", programId = "programId", segment = "segment", subSegment = "subSegment", testMode = "testMode",// whether the program is in test mode, or not testRequest = "testRequest",// true if using an email with `@sheerid.com` when filling in the form verificationId = "verificationId", flags = "flags",// a JSON string of all experiment flags options = "options",// a csv of the options that were set in setOptions flag = "flag",// deprecated - use "flags" which is a user-scoped dimension step = "step",// the verification step on which the event occurred stepAction = "step_action",// deprecated - use a descriptive event name instead /** * An identifier for a value of this event. Could be the form element name or another * unique identifier. Not to be confused with the event name itself. */ identifier = "id", verificationHelpStatus = "verificationHelpStatus" } /** * Metrics should be somewhat generic but make sense within the context of a specific event. * e.g. "event duration" is generic, could be used for a page load event or a organization * search event or a user reading terms and conditions event. */ export declare enum CustomMetricNames { /** * The duration of an event. See our event documentation for context on what this measures, exactly * Unit: milliseconds */ EVENT_DURATION = "eventDuration", /** * For any search related event, how many characters are in the input at the time of search */ QUERY_LENGTH = "queryLength", /** * For any search related event, which spot in the result list was chosen? * Lower numbers are higher on the list (1 at top). A user selecting rank 1 is ideal. */ SELECTED_RESULT_RANK = "selectedResultRank", /** * For any event, especially search events, the number of results returned to the user */ NUMBER_OF_RESULTS = "numberOfResults", /** * For any event, number of times a user had to "re-work" something (a frustration metric) * e.g. in a search input box, number of times user pressed backspace or delete */ NUMBER_REWORKS = "numberReworks", /** * @deprecated * @TODO Change this to an event name * * Specific to step loading * Unit: milliseconds */ INITIAL_STEP_LOAD = "initialStepLoad", /** * @deprecated * @TODO Change this to an event name * * For any event (either entire page load or a portion of a page load) the loading time * before most content is painted in-browser * Unit: milliseconds */ LCP = "largestContentfulPaint" } interface GaEvent { eventName: EventName; params: { [a: string]: string | number; }; } /** * GA event for after a search returns results and they display to the user */ export interface OrgsDisplayedEvent extends GaEvent { eventName: EventName.ORGS_DISPLAYED; params: { [CustomMetricNames.QUERY_LENGTH]: number; /** * How long (ms) before showing organization result list to user */ [CustomMetricNames.EVENT_DURATION]: number; [CustomMetricNames.NUMBER_OF_RESULTS]: number; }; } /** * GA event for when an org is selected by the user */ export interface OrgSelectedEvent extends GaEvent { eventName: EventName.ORG_SELECTED; params: { [CustomMetricNames.QUERY_LENGTH]: number; [CustomMetricNames.NUMBER_REWORKS]: number; [CustomMetricNames.SELECTED_RESULT_RANK]: number; /** * How long (ms) between first keypress and an org selected */ [CustomMetricNames.EVENT_DURATION]: number; [CustomMetricNames.NUMBER_OF_RESULTS]: number; }; } /** * GA event for when Add School Request is clicked */ export type AsrEvent = { eventName: EventName.ASR_SELECTED; params: { [CustomMetricNames.QUERY_LENGTH]: number; [CustomMetricNames.NUMBER_REWORKS]: number; /** * Time since first letter typed into the search input */ [CustomMetricNames.EVENT_DURATION]: number; [CustomMetricNames.NUMBER_OF_RESULTS]: number; }; }; export type PasteEvent = { eventName: EventName.FORM_PASTE; params: { [CustomMetricNames.QUERY_LENGTH]: number; [CustomDimensionNames.identifier]: string; }; }; /** * Collect step first shown to user after page loaded */ export type CollectStepStartEvent = { eventName: EventName.COLLECT_STARTED; params: {}; }; /** * Collect step submitted */ export type CollectStepSubmitEvent = { eventName: EventName.COLLECT_SUBMITTED; params: { /** * Amount of milliseconds it took to fill out the form and click submit */ [CustomMetricNames.EVENT_DURATION]: number; }; }; /** * GA event for when the verificationHelp endpoint is used */ export type VerificationHelpEvent = { eventName: EventName.VERIFICATION_HELP; params: { [CustomDimensionNames.verificationHelpStatus]: string; [CustomDimensionNames.programId]: number; }; }; export type CTAClickEventParams = { programId: string; locale: string; verificationId: string; }; export declare const recordGaEvent: (event: GaEvent) => Promise<void>; export declare const recordCTAClickEvent: (eventName: EventName, eventParams: CTAClickEventParams) => Promise<void>; /** * Sets or a user dimension */ export declare const setUserDimension: (dimensionName: CustomDimensionNames, value: string) => void; /** * Sets or updates user dimensions for all subsequent events */ export declare const recordVerificationResponse: (verificationResponse: VerificationResponse) => void; /** * Sets a user dimension * @deprecated Use setUserDimension instead */ export declare const setDimension: (dimensionName: CustomDimensionNames, value: string) => void; export declare const setGaDimensionTestRequest: (viewModel: WithCoreFields) => void; export declare function observePerformanceMetrics(): void; /** * Record a Verification Step event * @deprecated use recordGaEvent() instead */ export declare const recordEvent: (step: VerificationStep, stepAction?: string) => void; /** @deprecated Use recordGaEvent() instead */ export declare const recordPerformanceMetric: (name: CustomMetricNames, value: number) => void; /** * An event that is sent once a user sees a variant of an experiment flag * Potentially fired multiple times per user/session * * Records the "flag" dimension value as a string like: "{flagName}:{flagValue}" * OR * records as just "{flagName}" (old) for backward compatibility w/ ExperimentComponent if you omit the 2nd arg */ export declare const recordViewExperimentEvent: (flagName: string, flagValue?: string) => void; export {};