@knocklabs/client 0.17.2 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"knock.mjs","sources":["../../src/knock.ts"],"sourcesContent":["import { jwtDecode } from \"jwt-decode\";\n\nimport ApiClient from \"./api\";\nimport FeedClient from \"./clients/feed\";\nimport MessageClient from \"./clients/messages\";\nimport MsTeamsClient from \"./clients/ms-teams\";\nimport ObjectClient from \"./clients/objects\";\nimport Preferences from \"./clients/preferences\";\nimport SlackClient from \"./clients/slack\";\nimport UserClient from \"./clients/users\";\nimport {\n AuthenticateOptions,\n KnockOptions,\n LogLevel,\n UserId,\n UserIdOrUserWithProperties,\n UserTokenExpiringCallback,\n} from \"./interfaces\";\n\nconst DEFAULT_HOST = \"https://api.knock.app\";\n\nclass Knock {\n public host: string;\n private apiClient: ApiClient | null = null;\n public userId: string | undefined | null;\n public userToken?: string;\n public logLevel?: LogLevel;\n private tokenExpirationTimer: ReturnType<typeof setTimeout> | null = null;\n readonly feeds = new FeedClient(this);\n readonly objects = new ObjectClient(this);\n readonly preferences = new Preferences(this);\n readonly slack = new SlackClient(this);\n readonly msTeams = new MsTeamsClient(this);\n readonly user = new UserClient(this);\n readonly messages = new MessageClient(this);\n\n constructor(\n readonly apiKey: string,\n options: KnockOptions = {},\n ) {\n this.host = options.host || DEFAULT_HOST;\n this.logLevel = options.logLevel;\n\n this.log(\"Initialized Knock instance\");\n\n // Fail loudly if we're using the wrong API key\n if (this.apiKey && this.apiKey.startsWith(\"sk_\")) {\n throw new Error(\n \"[Knock] You are using your secret API key on the client. Please use the public key.\",\n );\n }\n }\n\n client() {\n // Initiate a new API client if we don't have one yet\n if (!this.apiClient) {\n this.apiClient = this.createApiClient();\n }\n\n return this.apiClient;\n }\n\n /**\n * @deprecated Passing `userId` as a `string` is deprecated and will be removed in a future version.\n * Please pass a `user` object instead containing an `id` value.\n * example:\n * ```ts\n * knock.authenticate({ id: \"user_123\" });\n * ```\n */\n authenticate(\n userIdOrUserWithProperties: UserId,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticateOptions,\n ): never;\n authenticate(\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticateOptions,\n ): void;\n authenticate(\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticateOptions,\n ) {\n let reinitializeApi = false;\n const currentApiClient = this.apiClient;\n const userId = this.getUserId(userIdOrUserWithProperties);\n\n // If we've previously been initialized and the values have now changed, then we\n // need to reinitialize any stateful connections we have\n if (\n currentApiClient &&\n (this.userId !== userId || this.userToken !== userToken)\n ) {\n this.log(\"userId or userToken changed; reinitializing connections\");\n this.feeds.teardownInstances();\n this.teardown();\n reinitializeApi = true;\n }\n\n this.userId = userId;\n this.userToken = userToken;\n\n this.log(`Authenticated with userId ${userId}`);\n\n if (this.userToken && options?.onUserTokenExpiring instanceof Function) {\n this.maybeScheduleUserTokenExpiration(\n options.onUserTokenExpiring,\n options.timeBeforeExpirationInMs,\n );\n }\n\n // If we get the signal to reinitialize the api client, then we want to create a new client\n // and the reinitialize any existing feed real-time connections we have so everything continues\n // to work with the new credentials we've been given\n if (reinitializeApi) {\n this.apiClient = this.createApiClient();\n this.feeds.reinitializeInstances();\n this.log(\"Reinitialized real-time connections\");\n }\n\n // Inline identify the user if we've been given an object with an id.\n if (\n typeof userIdOrUserWithProperties === \"object\" &&\n userIdOrUserWithProperties?.id\n ) {\n const { id, ...properties } = userIdOrUserWithProperties;\n this.user.identify(properties);\n }\n\n return;\n }\n\n failIfNotAuthenticated() {\n if (!this.isAuthenticated()) {\n throw new Error(\"Not authenticated. Please call `authenticate` first.\");\n }\n }\n\n /*\n Returns whether or this Knock instance is authenticated. Passing `true` will check the presence\n of the userToken as well.\n */\n isAuthenticated(checkUserToken = false) {\n return checkUserToken ? !!(this.userId && this.userToken) : !!this.userId;\n }\n\n // Used to teardown any connected instances\n teardown() {\n if (this.tokenExpirationTimer) {\n clearTimeout(this.tokenExpirationTimer);\n }\n if (this.apiClient?.socket && this.apiClient.socket.isConnected()) {\n this.apiClient.socket.disconnect();\n }\n }\n\n log(message: string, force = false) {\n if (this.logLevel === \"debug\" || force) {\n console.log(`[Knock] ${message}`);\n }\n }\n\n /**\n * Initiates an API client\n */\n private createApiClient() {\n return new ApiClient({\n apiKey: this.apiKey,\n host: this.host,\n userToken: this.userToken,\n });\n }\n\n private async maybeScheduleUserTokenExpiration(\n callbackFn: UserTokenExpiringCallback,\n timeBeforeExpirationInMs: number = 30_000,\n ) {\n if (!this.userToken) return;\n\n const decoded = jwtDecode(this.userToken);\n const expiresAtMs = (decoded.exp ?? 0) * 1000;\n const nowMs = Date.now();\n\n // Expiration is in the future\n if (expiresAtMs && expiresAtMs > nowMs) {\n // Check how long until the token should be regenerated\n // | ----------------- | ----------------------- |\n // ^ now ^ expiration offset ^ expires at\n const msInFuture = expiresAtMs - timeBeforeExpirationInMs - nowMs;\n\n this.tokenExpirationTimer = setTimeout(async () => {\n const newToken = await callbackFn(this.userToken as string, decoded);\n\n // Reauthenticate which will handle reinitializing sockets\n if (typeof newToken === \"string\") {\n this.authenticate(this.userId!, newToken, {\n onUserTokenExpiring: callbackFn,\n timeBeforeExpirationInMs: timeBeforeExpirationInMs,\n });\n }\n }, msInFuture);\n }\n }\n\n /**\n * Returns the user id from the given userIdOrUserWithProperties\n * @param userIdOrUserWithProperties - The user id or user object\n * @returns The user id\n * @throws {Error} If the user object does not contain an `id` property\n */\n private getUserId(userIdOrUserWithProperties: UserIdOrUserWithProperties) {\n if (\n typeof userIdOrUserWithProperties === \"string\" ||\n !userIdOrUserWithProperties\n ) {\n return userIdOrUserWithProperties;\n }\n\n if (userIdOrUserWithProperties?.id) {\n return userIdOrUserWithProperties.id;\n }\n\n throw new Error(\"`user` object must contain an `id` property\");\n }\n}\n\nexport default Knock;\n"],"names":["DEFAULT_HOST","Knock","apiKey","options","__publicField","FeedClient","ObjectClient","Preferences","SlackClient","MsTeamsClient","UserClient","MessageClient","userIdOrUserWithProperties","userToken","reinitializeApi","currentApiClient","userId","id","properties","checkUserToken","_a","message","force","ApiClient","callbackFn","timeBeforeExpirationInMs","decoded","jwtDecode","expiresAtMs","nowMs","msInFuture","newToken"],"mappings":";;;;;;;;;;;;AAmBA,MAAMA,IAAe;AAErB,MAAMC,EAAM;AAAA,EAeV,YACWC,GACTC,IAAwB,IACxB;AAjBK,IAAAC,EAAA;AACC,IAAAA,EAAA,mBAA8B;AAC/B,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AACC,IAAAA,EAAA,8BAA6D;AAC5D,IAAAA,EAAA,eAAQ,IAAIC,EAAW,IAAI;AAC3B,IAAAD,EAAA,iBAAU,IAAIE,EAAa,IAAI;AAC/B,IAAAF,EAAA,qBAAc,IAAIG,EAAY,IAAI;AAClC,IAAAH,EAAA,eAAQ,IAAII,EAAY,IAAI;AAC5B,IAAAJ,EAAA,iBAAU,IAAIK,EAAc,IAAI;AAChC,IAAAL,EAAA,cAAO,IAAIM,EAAW,IAAI;AAC1B,IAAAN,EAAA,kBAAW,IAAIO,EAAc,IAAI;AAYxC,QATS,KAAA,SAAAT,GAGJ,KAAA,OAAOC,EAAQ,QAAQH,GAC5B,KAAK,WAAWG,EAAQ,UAExB,KAAK,IAAI,4BAA4B,GAGjC,KAAK,UAAU,KAAK,OAAO,WAAW,KAAK;AAC7C,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,EACF;AAAA,EAGF,SAAS;AAEH,WAAC,KAAK,cACH,KAAA,YAAY,KAAK,gBAAgB,IAGjC,KAAK;AAAA,EAAA;AAAA,EAqBd,aACES,GACAC,GACAV,GACA;AACA,QAAIW,IAAkB;AACtB,UAAMC,IAAmB,KAAK,WACxBC,IAAS,KAAK,UAAUJ,CAA0B;AAoCxD,QA/BEG,MACC,KAAK,WAAWC,KAAU,KAAK,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AA;AAAA,EAGH,MAAc,iCACZC,GACAC,IAAmC,KACnC;AACI,QAAA,CAAC,KAAK,UAAW;AAEf,UAAAC,IAAUC,EAAU,KAAK,SAAS,GAClCC,KAAeF,EAAQ,OAAO,KAAK,KACnCG,IAAQ,KAAK,IAAI;AAGnB,QAAAD,KAAeA,IAAcC,GAAO;AAIhC,YAAAC,IAAaF,IAAcH,IAA2BI;AAEvD,WAAA,uBAAuB,WAAW,YAAY;AACjD,cAAME,IAAW,MAAMP,EAAW,KAAK,WAAqBE,CAAO;AAG/D,QAAA,OAAOK,KAAa,YACjB,KAAA,aAAa,KAAK,QAASA,GAAU;AAAA,UACxC,qBAAqBP;AAAA,UACrB,0BAAAC;AAAA,QAAA,CACD;AAAA,SAEFK,CAAU;AAAA,IAAA;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASM,UAAUlB,GAAwD;AACxE,QACE,OAAOA,KAA+B,YACtC,CAACA;AAEM,aAAAA;AAGT,QAAIA,KAAA,QAAAA,EAA4B;AAC9B,aAAOA,EAA2B;AAG9B,UAAA,IAAI,MAAM,6CAA6C;AAAA,EAAA;AAEjE;"}
1
+ {"version":3,"file":"knock.mjs","sources":["../../src/knock.ts"],"sourcesContent":["import { jwtDecode } from \"jwt-decode\";\n\nimport ApiClient from \"./api\";\nimport FeedClient from \"./clients/feed\";\nimport MessageClient from \"./clients/messages\";\nimport MsTeamsClient from \"./clients/ms-teams\";\nimport ObjectClient from \"./clients/objects\";\nimport Preferences from \"./clients/preferences\";\nimport SlackClient from \"./clients/slack\";\nimport UserClient from \"./clients/users\";\nimport {\n AuthenticateOptions,\n KnockOptions,\n LogLevel,\n UserId,\n UserIdOrUserWithProperties,\n UserTokenExpiringCallback,\n} from \"./interfaces\";\n\nconst DEFAULT_HOST = \"https://api.knock.app\";\n\nclass Knock {\n public host: string;\n private apiClient: ApiClient | null = null;\n public userId: string | undefined | null;\n public userToken?: string;\n public logLevel?: LogLevel;\n private tokenExpirationTimer: ReturnType<typeof setTimeout> | null = null;\n readonly feeds = new FeedClient(this);\n readonly objects = new ObjectClient(this);\n readonly preferences = new Preferences(this);\n readonly slack = new SlackClient(this);\n readonly msTeams = new MsTeamsClient(this);\n readonly user = new UserClient(this);\n readonly messages = new MessageClient(this);\n\n constructor(\n readonly apiKey: string,\n options: KnockOptions = {},\n ) {\n this.host = options.host || DEFAULT_HOST;\n this.logLevel = options.logLevel;\n\n this.log(\"Initialized Knock instance\");\n\n // Fail loudly if we're using the wrong API key\n if (this.apiKey && this.apiKey.startsWith(\"sk_\")) {\n throw new Error(\n \"[Knock] You are using your secret API key on the client. Please use the public key.\",\n );\n }\n }\n\n client() {\n // Initiate a new API client if we don't have one yet\n if (!this.apiClient) {\n this.apiClient = this.createApiClient();\n }\n\n return this.apiClient;\n }\n\n /**\n * @deprecated Passing `userId` as a `string` is deprecated and will be removed in a future version.\n * Please pass a `user` object instead containing an `id` value.\n * example:\n * ```ts\n * knock.authenticate({ id: \"user_123\" });\n * ```\n */\n authenticate(\n userIdOrUserWithProperties: UserId,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticateOptions,\n ): never;\n authenticate(\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticateOptions,\n ): void;\n authenticate(\n userIdOrUserWithProperties: UserIdOrUserWithProperties,\n userToken?: Knock[\"userToken\"],\n options?: AuthenticateOptions,\n ) {\n let reinitializeApi = false;\n const currentApiClient = this.apiClient;\n const userId = this.getUserId(userIdOrUserWithProperties);\n const identificationStrategy = options?.identificationStrategy || \"inline\";\n\n // If we've previously been initialized and the values have now changed, then we\n // need to reinitialize any stateful connections we have\n if (\n currentApiClient &&\n (this.userId !== userId || this.userToken !== userToken)\n ) {\n this.log(\"userId or userToken changed; reinitializing connections\");\n this.feeds.teardownInstances();\n this.teardown();\n reinitializeApi = true;\n }\n\n this.userId = userId;\n this.userToken = userToken;\n\n this.log(`Authenticated with userId ${userId}`);\n\n if (this.userToken && options?.onUserTokenExpiring instanceof Function) {\n this.maybeScheduleUserTokenExpiration(\n options.onUserTokenExpiring,\n options.timeBeforeExpirationInMs,\n );\n }\n\n // If we get the signal to reinitialize the api client, then we want to create a new client\n // and the reinitialize any existing feed real-time connections we have so everything continues\n // to work with the new credentials we've been given\n if (reinitializeApi) {\n this.apiClient = this.createApiClient();\n this.feeds.reinitializeInstances();\n this.log(\"Reinitialized real-time connections\");\n }\n\n // We explicitly skip the inline identification if the strategy is set to \"skip\"\n if (identificationStrategy === \"skip\") {\n this.log(\"Skipping inline user identification\");\n return;\n }\n\n // Inline identify the user if we've been given an object with an id\n // and the strategy is set to \"inline\".\n if (\n identificationStrategy === \"inline\" &&\n typeof userIdOrUserWithProperties === \"object\" &&\n userIdOrUserWithProperties?.id\n ) {\n this.log(`Identifying user ${userIdOrUserWithProperties.id} inline`);\n const { id, ...properties } = userIdOrUserWithProperties;\n this.user.identify(properties);\n }\n\n return;\n }\n\n failIfNotAuthenticated() {\n if (!this.isAuthenticated()) {\n throw new Error(\"Not authenticated. Please call `authenticate` first.\");\n }\n }\n\n /*\n Returns whether or this Knock instance is authenticated. Passing `true` will check the presence\n of the userToken as well.\n */\n isAuthenticated(checkUserToken = false) {\n return checkUserToken ? !!(this.userId && this.userToken) : !!this.userId;\n }\n\n // Used to teardown any connected instances\n teardown() {\n if (this.tokenExpirationTimer) {\n clearTimeout(this.tokenExpirationTimer);\n }\n if (this.apiClient?.socket && this.apiClient.socket.isConnected()) {\n this.apiClient.socket.disconnect();\n }\n }\n\n log(message: string, force = false) {\n if (this.logLevel === \"debug\" || force) {\n console.log(`[Knock] ${message}`);\n }\n }\n\n /**\n * Initiates an API client\n */\n private createApiClient() {\n return new ApiClient({\n apiKey: this.apiKey,\n host: this.host,\n userToken: this.userToken,\n });\n }\n\n private async maybeScheduleUserTokenExpiration(\n callbackFn: UserTokenExpiringCallback,\n timeBeforeExpirationInMs: number = 30_000,\n ) {\n if (!this.userToken) return;\n\n const decoded = jwtDecode(this.userToken);\n const expiresAtMs = (decoded.exp ?? 0) * 1000;\n const nowMs = Date.now();\n\n // Expiration is in the future\n if (expiresAtMs && expiresAtMs > nowMs) {\n // Check how long until the token should be regenerated\n // | ----------------- | ----------------------- |\n // ^ now ^ expiration offset ^ expires at\n const msInFuture = expiresAtMs - timeBeforeExpirationInMs - nowMs;\n\n this.tokenExpirationTimer = setTimeout(async () => {\n const newToken = await callbackFn(this.userToken as string, decoded);\n\n // Reauthenticate which will handle reinitializing sockets\n if (typeof newToken === \"string\") {\n this.authenticate(this.userId!, newToken, {\n onUserTokenExpiring: callbackFn,\n timeBeforeExpirationInMs: timeBeforeExpirationInMs,\n });\n }\n }, msInFuture);\n }\n }\n\n /**\n * Returns the user id from the given userIdOrUserWithProperties\n * @param userIdOrUserWithProperties - The user id or user object\n * @returns The user id\n * @throws {Error} If the user object does not contain an `id` property\n */\n private getUserId(userIdOrUserWithProperties: UserIdOrUserWithProperties) {\n if (\n typeof userIdOrUserWithProperties === \"string\" ||\n !userIdOrUserWithProperties\n ) {\n return userIdOrUserWithProperties;\n }\n\n if (userIdOrUserWithProperties?.id) {\n return userIdOrUserWithProperties.id;\n }\n\n throw new Error(\"`user` object must contain an `id` property\");\n }\n}\n\nexport default Knock;\n"],"names":["DEFAULT_HOST","Knock","apiKey","options","__publicField","FeedClient","ObjectClient","Preferences","SlackClient","MsTeamsClient","UserClient","MessageClient","userIdOrUserWithProperties","userToken","reinitializeApi","currentApiClient","userId","identificationStrategy","id","properties","checkUserToken","_a","message","force","ApiClient","callbackFn","timeBeforeExpirationInMs","decoded","jwtDecode","expiresAtMs","nowMs","msInFuture","newToken"],"mappings":";;;;;;;;;;;;AAmBA,MAAMA,IAAe;AAErB,MAAMC,EAAM;AAAA,EAeV,YACWC,GACTC,IAAwB,IACxB;AAjBK,IAAAC,EAAA;AACC,IAAAA,EAAA,mBAA8B;AAC/B,IAAAA,EAAA;AACA,IAAAA,EAAA;AACA,IAAAA,EAAA;AAC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BAAkB;IAQ1B,OAAO,CAAC,YAAY;IAgBd,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa;IA2BhD,gBAAgB,CACpB,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,aAAa,EACnB,QAAQ,CAAC,EAAE,WAAW;IA0BlB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa;IA6B1D,OAAO,CAAC,SAAS;IA4DjB,OAAO,CAAC,gBAAgB;IA4BxB,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,mBAAmB;IA+C3B,OAAO,CAAC,8BAA8B;IAatC,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,WAAW;IASnB,OAAO,CAAC,sBAAsB;IAiC9B,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,oBAAoB,CA4B1B;IAIF,OAAO,CAAC,sBAAsB;IAO9B,OAAO,CAAC,kCAAkC;IAyC1C,OAAO,CAAC,oBAAoB;CAgB7B"}
@@ -1,10 +1,12 @@
1
- import { GuideActivationUrlRuleData, GuideData, GuideGroupData, KnockGuide, KnockGuideActivationUrlPattern, SelectFilterParams } from './types';
1
+ import { GroupStage, GuideActivationUrlRuleData, GuideData, GuideGroupData, KnockGuide, KnockGuideActivationUrlPattern, SelectFilterParams, StoreState } from './types';
2
2
  export declare class SelectionResult<K = number, V = KnockGuide> extends Map<K, V> {
3
3
  metadata: {
4
4
  guideGroup: GuideGroupData;
5
5
  } | undefined;
6
6
  constructor();
7
7
  }
8
+ export declare const formatGroupStage: (stage: GroupStage) => string;
9
+ export declare const formatState: (state: StoreState) => string;
8
10
  export declare const formatFilters: (filters?: SelectFilterParams) => string;
9
11
  export declare const byKey: <T extends {
10
12
  key: string;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/clients/guide/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,SAAS,EACT,cAAc,EAC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Ae,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,UAAU,CAAE,SAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IACxE,QAAQ,EAAE;QAAE,UAAU,EAAE,cAAc,CAAA;KAAE,GAAG,SAAS,CAAC;;CAKtD;AAED,eAAO,MAAM,gBAAgB,GAAI,OAAO,UAAU,WAEjD,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,OAAO,UAAU,WAE5C,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,UAAS,kBAAuB,WAO7D,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,EAAE,OAAO,CAAC,EAAE,OAE1D,CAAC;AAUF,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAO3C,eAAO,MAAM,gBAAgB,GAAI,UAAS,SAAS,EAAO,KAUnD,cACN,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,aAAa,cAAc,EAAE,+BAI3D,CAAC;AAMJ,eAAO,MAAM,gBAAgB,GAC3B,2BAA2B,MAAM,EACjC,yBAAyB,MAAM,YA0BhC,CAAC;AAGF,eAAO,MAAM,MAAM,GAAI,UAAU,MAAM,oBAMtC,CAAC;AAGF,eAAO,MAAM,eAAe,GAC1B,KAAK,GAAG,EACR,SAAS,0BAA0B,YAmBpC,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAC5B,KAAK,GAAG,EACR,UAAU,0BAA0B,EAAE,wBA4BvC,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAC/B,KAAK,GAAG,EACR,aAAa,8BAA8B,EAAE,wBA4B9C,CAAC"}
@@ -43,6 +43,7 @@ export type UserTokenExpiringCallback = (currentToken: string, decodedToken: Jwt
43
43
  export interface AuthenticateOptions {
44
44
  onUserTokenExpiring?: UserTokenExpiringCallback;
45
45
  timeBeforeExpirationInMs?: number;
46
+ identificationStrategy?: "inline" | "skip";
46
47
  }
47
48
  export interface Bulk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8C;IAC1E,QAAQ,CAAC,KAAK,aAAwB;IACtC,QAAQ,CAAC,OAAO,eAA0B;IAC1C,QAAQ,CAAC,WAAW,cAAyB;IAC7C,QAAQ,CAAC,KAAK,cAAyB;IACvC,QAAQ,CAAC,OAAO,gBAA2B;IAC3C,QAAQ,CAAC,IAAI,aAAwB;IACrC,QAAQ,CAAC,QAAQ,gBAA2B;gBAGjC,MAAM,EAAE,MAAM,EACvB,OAAO,GAAE,YAAiB;IAe5B,MAAM;IASN;;;;;;;OAOG;IACH,YAAY,CACV,0BAA0B,EAAE,MAAM,EAClC,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,EAC9B,OAAO,CAAC,EAAE,mBAAmB,GAC5B,KAAK;IACR,YAAY,CACV,0BAA0B,EAAE,0BAA0B,EACtD,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,EAC9B,OAAO,CAAC,EAAE,mBAAmB,GAC5B,IAAI;IAiEP,sBAAsB;IAUtB,eAAe,CAAC,cAAc,UAAQ;IAKtC,QAAQ;IASR,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,UAAQ;IAMlC;;OAEG;IACH,OAAO,CAAC,eAAe;YAQT,gCAAgC;IA+B9C;;;;;OAKG;IACH,OAAO,CAAC,SAAS;CAclB;AAED,eAAe,KAAK,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knocklabs/client",
3
- "version": "0.17.2",
3
+ "version": "0.18.1",
4
4
  "description": "The clientside library for interacting with Knock",
5
5
  "homepage": "https://github.com/knocklabs/javascript/tree/main/packages/client",
6
6
  "author": "@knocklabs",
@@ -12,6 +12,8 @@ import {
12
12
  checkIfThrottled,
13
13
  findDefaultGroup,
14
14
  formatFilters,
15
+ formatGroupStage,
16
+ formatState,
15
17
  mockDefaultGroup,
16
18
  newUrl,
17
19
  predicateUrlPatterns,
@@ -219,7 +221,10 @@ export class KnockGuideClient {
219
221
  readonly targetParams: TargetParams = {},
220
222
  readonly options: ConstructorOpts = {},
221
223
  ) {
222
- const { trackLocationFromWindow = true } = options;
224
+ const {
225
+ trackLocationFromWindow = true,
226
+ throttleCheckInterval = DEFAULT_COUNTER_INCREMENT_INTERVAL,
227
+ } = options;
223
228
  const win = checkForWindow();
224
229
 
225
230
  const location = trackLocationFromWindow ? win?.location.href : undefined;
@@ -247,8 +252,10 @@ export class KnockGuideClient {
247
252
  this.listenForLocationChangesFromWindow();
248
253
  }
249
254
 
250
- // Start the counter loop to increment at an interval.
251
- this.startCounterInterval();
255
+ if (throttleCheckInterval) {
256
+ // Start the counter loop to increment at an interval.
257
+ this.startCounterInterval(throttleCheckInterval);
258
+ }
252
259
 
253
260
  this.knock.log("[Guide] Initialized a guide client");
254
261
  }
@@ -258,11 +265,7 @@ export class KnockGuideClient {
258
265
  this.store.setState((state) => ({ ...state, counter: state.counter + 1 }));
259
266
  }
260
267
 
261
- private startCounterInterval() {
262
- const {
263
- throttleCheckInterval: delay = DEFAULT_COUNTER_INCREMENT_INTERVAL,
264
- } = this.options;
265
-
268
+ private startCounterInterval(delay: number) {
266
269
  this.counterIntervalId = setInterval(() => {
267
270
  this.knock.log("[Guide] Counter interval tick");
268
271
  if (this.stage && this.stage.status !== "closed") return;
@@ -286,8 +289,8 @@ export class KnockGuideClient {
286
289
  }
287
290
 
288
291
  async fetch(opts?: { filters?: QueryFilterParams }) {
292
+ this.knock.log("[Guide] .fetch");
289
293
  this.knock.failIfNotAuthenticated();
290
- this.knock.log("[Guide] Loading all eligible guides");
291
294
 
292
295
  const queryParams = this.buildQueryParams(opts?.filters);
293
296
  const queryKey = this.formatQueryKey(queryParams);
@@ -306,6 +309,7 @@ export class KnockGuideClient {
306
309
 
307
310
  let queryStatus: QueryStatus;
308
311
  try {
312
+ this.knock.log("[Guide] Fetching all eligible guides");
309
313
  const data = await this.knock.user.getGuides<
310
314
  GetGuidesQueryParams,
311
315
  GetGuidesResponse
@@ -314,6 +318,7 @@ export class KnockGuideClient {
314
318
 
315
319
  const { entries, guide_groups: groups, guide_group_display_logs } = data;
316
320
 
321
+ this.knock.log("[Guide] Loading fetched guides");
317
322
  this.store.setState((state) => ({
318
323
  ...state,
319
324
  guideGroups: groups?.length > 0 ? groups : [mockDefaultGroup(entries)],
@@ -444,9 +449,12 @@ export class KnockGuideClient {
444
449
  }
445
450
 
446
451
  setLocation(href: string, additionalParams: Partial<StoreState> = {}) {
452
+ this.knock.log(`[Guide] .setLocation (loc=${href})`);
453
+
447
454
  // Make sure to clear out the stage.
448
455
  this.clearGroupStage();
449
456
 
457
+ this.knock.log("[Guide] Updating the tracked location");
450
458
  this.store.setState((state) => {
451
459
  // Clear preview guides if no longer in preview mode
452
460
  const previewGuides = additionalParams?.debug?.previewSessionId
@@ -470,13 +478,16 @@ export class KnockGuideClient {
470
478
  state: StoreState,
471
479
  filters: SelectFilterParams = {},
472
480
  ): KnockGuide<C>[] {
481
+ this.knock.log(
482
+ `[Guide] .selectGuides (filters: ${formatFilters(filters)}; state: ${formatState(state)})`,
483
+ );
473
484
  if (
474
485
  Object.keys(state.guides).length === 0 &&
475
486
  Object.keys(state.previewGuides).length === 0
476
487
  ) {
488
+ this.knock.log("[Guide] Exiting selection (no guides)");
477
489
  return [];
478
490
  }
479
- this.knock.log(`[Guide] Selecting guides for: ${formatFilters(filters)}`);
480
491
 
481
492
  const result = select(state, filters);
482
493
 
@@ -495,26 +506,33 @@ export class KnockGuideClient {
495
506
  state: StoreState,
496
507
  filters: SelectFilterParams = {},
497
508
  ): KnockGuide<C> | undefined {
509
+ this.knock.log(
510
+ `[Guide] .selectGuide (filters: ${formatFilters(filters)}; state: ${formatState(state)})`,
511
+ );
498
512
  if (
499
513
  Object.keys(state.guides).length === 0 &&
500
514
  Object.keys(state.previewGuides).length === 0
501
515
  ) {
516
+ this.knock.log("[Guide] Exiting selection (no guides)");
502
517
  return undefined;
503
518
  }
504
- this.knock.log(`[Guide] Selecting a guide for: ${formatFilters(filters)}`);
505
519
 
506
520
  const result = select(state, filters);
507
521
 
508
522
  if (result.size === 0) {
509
- this.knock.log("[Guide] Selection returned zero result");
523
+ this.knock.log("[Guide] Selection found zero result");
510
524
  return undefined;
511
525
  }
512
526
 
513
527
  const [index, guide] = [...result][0]!;
528
+ this.knock.log(
529
+ `[Guide] Selection found: \`${guide.key}\` (total: ${result.size})`,
530
+ );
514
531
 
515
532
  // If a guide ignores the group limit, then return immediately to render
516
533
  // always.
517
534
  if (guide.bypass_global_group_limit) {
535
+ this.knock.log(`[Guide] Returning the unthrottled guide: ${guide.key}`);
518
536
  return guide;
519
537
  }
520
538
 
@@ -533,7 +551,10 @@ export class KnockGuideClient {
533
551
  throttleWindowStartedAt,
534
552
  defaultGroup.display_interval,
535
553
  );
536
- if (throttled) return undefined;
554
+ if (throttled) {
555
+ this.knock.log(`[Guide] Throttling the selected guide: ${guide.key}`);
556
+ return undefined;
557
+ }
537
558
  }
538
559
 
539
560
  // Starting here to the end of this method represents the core logic of how
@@ -579,11 +600,20 @@ export class KnockGuideClient {
579
600
  case "patch": {
580
601
  this.knock.log(`[Guide] Patching the group stage: ${guide.key}`);
581
602
  this.stage.ordered[index] = guide.key;
582
- return this.stage.resolved === guide.key ? guide : undefined;
603
+
604
+ const ret = this.stage.resolved === guide.key ? guide : undefined;
605
+ this.knock.log(
606
+ `[Guide] Returning \`${ret?.key}\` (stage: ${formatGroupStage(this.stage)})`,
607
+ );
608
+ return ret;
583
609
  }
584
610
 
585
611
  case "closed": {
586
- return this.stage.resolved === guide.key ? guide : undefined;
612
+ const ret = this.stage.resolved === guide.key ? guide : undefined;
613
+ this.knock.log(
614
+ `[Guide] Returning \`${ret?.key}\` (stage: ${formatGroupStage(this.stage)})`,
615
+ );
616
+ return ret;
587
617
  }
588
618
  }
589
619
  }
@@ -612,10 +642,9 @@ export class KnockGuideClient {
612
642
  // Close the current non-closed stage to resolve the prevailing guide up next
613
643
  // for display amongst the ones that have been staged.
614
644
  private closePendingGroupStage() {
645
+ this.knock.log("[Guide] .closePendingGroupStage");
615
646
  if (!this.stage || this.stage.status === "closed") return;
616
647
 
617
- this.knock.log("[Guide] Closing the current group stage");
618
-
619
648
  // Should have been cleared already since this method should be called as a
620
649
  // callback to a setTimeout, but just to be safe.
621
650
  this.ensureClearTimeout();
@@ -632,6 +661,10 @@ export class KnockGuideClient {
632
661
  resolved = this.stage.ordered.find((x) => x !== undefined);
633
662
  }
634
663
 
664
+ this.knock.log(
665
+ `[Guide] Closing the current group stage: resolved=${resolved}`,
666
+ );
667
+
635
668
  this.stage = {
636
669
  ...this.stage,
637
670
  status: "closed",
@@ -648,10 +681,9 @@ export class KnockGuideClient {
648
681
  // rendered until we are ready to resolve the updated stage and re-render.
649
682
  // Note, must be called ahead of updating the state store.
650
683
  private patchClosedGroupStage() {
684
+ this.knock.log("[Guide] .patchClosedGroupStage");
651
685
  if (this.stage?.status !== "closed") return;
652
686
 
653
- this.knock.log("[Guide] Patching the current group stage");
654
-
655
687
  const { orderResolutionDuration: delay = 0 } = this.options;
656
688
 
657
689
  const timeoutId = setTimeout(() => {
@@ -662,6 +694,8 @@ export class KnockGuideClient {
662
694
  // Just to be safe.
663
695
  this.ensureClearTimeout();
664
696
 
697
+ this.knock.log("[Guide] Patching the current group stage");
698
+
665
699
  this.stage = {
666
700
  ...this.stage,
667
701
  status: "patch",
@@ -673,10 +707,10 @@ export class KnockGuideClient {
673
707
  }
674
708
 
675
709
  private clearGroupStage() {
710
+ this.knock.log("[Guide] .clearGroupStage");
676
711
  if (!this.stage) return;
677
712
 
678
713
  this.knock.log("[Guide] Clearing the current group stage");
679
-
680
714
  this.ensureClearTimeout();
681
715
  this.stage = undefined;
682
716
  }
@@ -738,7 +772,7 @@ export class KnockGuideClient {
738
772
  metadata?: GenericData,
739
773
  ) {
740
774
  this.knock.log(
741
- `[Guide] Marking as interacted (Guide key: ${guide.key}, Step ref:${step.ref})`,
775
+ `[Guide] Marking as interacted (Guide key: ${guide.key}; Step ref:${step.ref})`,
742
776
  );
743
777
 
744
778
  const ts = new Date().toISOString();
@@ -1023,11 +1057,12 @@ export class KnockGuideClient {
1023
1057
  const href = win.location.href;
1024
1058
  if (this.store.state.location === href) return;
1025
1059
 
1026
- this.knock.log(`[Guide] Handle Location change: ${href}`);
1060
+ this.knock.log(`[Guide] Detected a location change: ${href}`);
1027
1061
 
1028
1062
  // If entering debug mode, fetch all guides.
1029
1063
  const currentDebugParams = this.store.state.debug;
1030
1064
  const newDebugParams = detectDebugParams();
1065
+
1031
1066
  this.setLocation(href, { debug: newDebugParams });
1032
1067
 
1033
1068
  // If debug state has changed, refetch guides and resubscribe to the websocket channel
@@ -1,10 +1,12 @@
1
1
  import {
2
+ GroupStage,
2
3
  GuideActivationUrlRuleData,
3
4
  GuideData,
4
5
  GuideGroupData,
5
6
  KnockGuide,
6
7
  KnockGuideActivationUrlPattern,
7
8
  SelectFilterParams,
9
+ StoreState,
8
10
  } from "./types";
9
11
 
10
12
  // Extends the map class to allow having metadata on it, which is used to record
@@ -18,6 +20,14 @@ export class SelectionResult<K = number, V = KnockGuide> extends Map<K, V> {
18
20
  }
19
21
  }
20
22
 
23
+ export const formatGroupStage = (stage: GroupStage) => {
24
+ return `status=${stage.status}, resolved=${stage.resolved}`;
25
+ };
26
+
27
+ export const formatState = (state: StoreState) => {
28
+ return `loc=${state.location}`;
29
+ };
30
+
21
31
  export const formatFilters = (filters: SelectFilterParams = {}) => {
22
32
  return [
23
33
  filters.key && `key=${filters.key}`,
package/src/interfaces.ts CHANGED
@@ -54,6 +54,7 @@ export type UserTokenExpiringCallback = (
54
54
  export interface AuthenticateOptions {
55
55
  onUserTokenExpiring?: UserTokenExpiringCallback;
56
56
  timeBeforeExpirationInMs?: number;
57
+ identificationStrategy?: "inline" | "skip";
57
58
  }
58
59
 
59
60
  export interface BulkOperation {
package/src/knock.ts CHANGED
@@ -86,6 +86,7 @@ class Knock {
86
86
  let reinitializeApi = false;
87
87
  const currentApiClient = this.apiClient;
88
88
  const userId = this.getUserId(userIdOrUserWithProperties);
89
+ const identificationStrategy = options?.identificationStrategy || "inline";
89
90
 
90
91
  // If we've previously been initialized and the values have now changed, then we
91
92
  // need to reinitialize any stateful connections we have
@@ -120,11 +121,20 @@ class Knock {
120
121
  this.log("Reinitialized real-time connections");
121
122
  }
122
123
 
123
- // Inline identify the user if we've been given an object with an id.
124
+ // We explicitly skip the inline identification if the strategy is set to "skip"
125
+ if (identificationStrategy === "skip") {
126
+ this.log("Skipping inline user identification");
127
+ return;
128
+ }
129
+
130
+ // Inline identify the user if we've been given an object with an id
131
+ // and the strategy is set to "inline".
124
132
  if (
133
+ identificationStrategy === "inline" &&
125
134
  typeof userIdOrUserWithProperties === "object" &&
126
135
  userIdOrUserWithProperties?.id
127
136
  ) {
137
+ this.log(`Identifying user ${userIdOrUserWithProperties.id} inline`);
128
138
  const { id, ...properties } = userIdOrUserWithProperties;
129
139
  this.user.identify(properties);
130
140
  }