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

Adding type definitions #19

merged 17 commits into from Nov 5, 2019

adding an anonymize function

  • Loading branch information
patrick-fs committed Nov 3, 2019
commit c7ab7360be33dfd8663753696a8f382ab051f9b6
@@ -6,22 +6,27 @@ interface SnippetOptions {
script?: string

export type BrowserApiArg = { [key: string]: any };
interface UserVars {
displayName?: string;
email?: string;
[key: string]: any;

export type LogLevel = 'log' | 'info' | 'warn' | 'error' | 'debug';

// API functions that are available as soon as the snippet has executed.
export function anonymize(): void;
export function consent(userConsents?: boolean): void;
export function disableConsole(): void;
export function enableConsole(): void;
export function event(eventName: string, eventProperties: BrowserApiArg): void;
export function identify(uid: string, customVars?: BrowserApiArg): void;
export function event(eventName: string, eventProperties: { [key: string]: any }): void;
export function identify(uid: string, customVars?: UserVars): void;
export function log(level: LogLevel, ...msg: any[]): void;
export function log(...msg: any[]): void;
export function restart(): void;
export function shutdown(): void;
export function setUserVars(customVars: BrowserApiArg): void;
export function setUserVars(customVars: UserVars): void;
export function init(options: SnippetOptions): void;

// API functions that are available after /rec/page returns.
export function getCurrentSession(): string | null;
export function getCurrentSessionURL(now?: boolean): string | null;
@@ -48,5 +48,6 @@ const initOnce = (fn, message) => (...args) => {

wrappedFS.init = initOnce(init, 'FullStory init has already been called once. Additional invocations are ignored');
wrappedFS.anonymize = () => wrappedFS.identify(false);

This comment has been minimized.

Copy link

patrick-fs Nov 3, 2019

Author Member

I added anonymize because:

  1. There are plans to add anonymize to the snippet anyway
  2. I twisted myself in knots trying to figure out a meaningful way to express identify(false) as a typed signature: identify(dontAnonymize: boolean) results in a double-negative (ew) and implies that this function call may be required because anonymization is default behavior
  3. identify(true) has no meaning
export default wrappedFS;
@@ -12,11 +12,13 @@ beforeEach(() => {

describe('core', () => {
it('should define snippet functions', () => {
const functions = ['event',
it('should define browser API functions', () => {
const functions = ['anonymize',
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.