@inploi/sdk 1.5.2 → 1.6.0
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.
- package/cdn/index.js +1 -1
- package/dist/index.d.mts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/cdn/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// This is an inploi sdk script. Learn more at https://inploi.com
|
|
2
2
|
|
|
3
|
-
"use strict";(()=>{var
|
|
3
|
+
"use strict";(()=>{var h=Object.defineProperty,x=Object.defineProperties;var b=Object.getOwnPropertyDescriptors;var y=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable;var m=(e,o,t)=>o in e?h(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,c=(e,o)=>{for(var t in o||(o={}))T.call(o,t)&&m(e,t,o[t]);if(y)for(var t of y(o))S.call(o,t)&&m(e,t,o[t]);return e},f=(e,o)=>x(e,b(o));var l=(e,o,t)=>new Promise((n,i)=>{var s=r=>{try{p(t.next(r))}catch(u){i(u)}},a=r=>{try{p(t.throw(r))}catch(u){i(u)}},p=r=>r.done?n(r.value):Promise.resolve(r.value).then(s,a);p((t=t.apply(e,o)).next())});var P={sandbox:"https://preview.api.inploi.com",production:"https://api.inploi.com"},A=1,v="/analytics/log";var w=({apiClient:e,logger:o})=>({log:n=>l(void 0,null,function*(){try{let i={library:{name:"inploi-sdk",version:A},page:"request"in n&&n.request instanceof Request?{href:n.request.url,referrer:n.request.referrer,title:""}:{href:location.href,referrer:document.referrer,title:document.title}},s={event:n.event,sent_at:new Date().toISOString(),context:i,properties:n.properties,custom_properties:n.customProperties};return yield e.fetch(v,{method:"POST",body:JSON.stringify(s)}),{success:!0,data:s}}catch(i){return o.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:i}}})});var I="Unauthenticated",O="This action is unauthorized.",L=e=>{let o={Accept:"application/json","Content-Type":"application/json","x-publishable-key":e.publishableKey};return{fetch:(i,...s)=>l(void 0,[i,...s],function*(t,n={}){let a=f(c({},n),{headers:c(c({},n.headers),o)}),r=yield(yield fetch(`${e.baseUrl}${t}`,a)).json();if(typeof r=="object"&&r!==null&&"message"in r){if(r.message===I)throw new Error("You are not authenticated.");if(r.message===O)throw new Error("You are not authorised to perform this action.");if("exception"in r)throw new Error(`API error: \u201C${r.message}\u201D`);if("errors"in r)throw new Error(`API error: \u201C${r.message}\u201D`)}return r})}};var g="%c[inploi SDK]",d="color: #65BC67; font-weight: bold;",E={warn:(...e)=>console.warn(g,d,...e),error:(...e)=>console.error(g,d,...e),info:(...e)=>console.info(g,d,...e),log:(...e)=>console.log(g,d,...e)};function _({publishableKey:e,env:o,logger:t=E}){let n=L({baseUrl:P[o],publishableKey:e}),i=w({apiClient:n,logger:t});return{register:a=>a({logger:t,apiClient:n,analytics:i})}}typeof window.inploi!="object"&&(window.inploi={});window.process=window.process||{};window.process.env=window.process.env||{};window.process.env.NODE_ENV="production";window.inploi.initialiseSdk=_;})();
|
package/dist/index.d.mts
CHANGED
|
@@ -15,6 +15,17 @@ type AnalyticsLogParams = {
|
|
|
15
15
|
properties: {
|
|
16
16
|
job_id: string;
|
|
17
17
|
};
|
|
18
|
+
} | {
|
|
19
|
+
event: 'APPLY_FLOW_NODE';
|
|
20
|
+
properties: {
|
|
21
|
+
/** Increment by 1 per node interpreted */
|
|
22
|
+
sequence: number;
|
|
23
|
+
from_node_id: string | null;
|
|
24
|
+
to_node_id: string;
|
|
25
|
+
job_id: string;
|
|
26
|
+
flow_id: string;
|
|
27
|
+
flow_version: number;
|
|
28
|
+
};
|
|
18
29
|
} | {
|
|
19
30
|
event: 'IDENTIFY' | 'SUBMIT_FORM' | 'VIEW_PAGE';
|
|
20
31
|
properties?: never;
|
|
@@ -92,7 +103,7 @@ type InitialiseInploiSdkParams = {
|
|
|
92
103
|
logger?: Logger;
|
|
93
104
|
};
|
|
94
105
|
declare function initialiseSdk({ publishableKey, env, logger }: InitialiseInploiSdkParams): {
|
|
95
|
-
|
|
106
|
+
register: <P extends InploiSdkPlugin>(plugin: P) => ReturnType<P>;
|
|
96
107
|
};
|
|
97
108
|
|
|
98
109
|
export { AnalyticsLogEvent, AnalyticsService, ApiClient, InitialiseInploiSdkParams, Logger, Plugin, PluginParams, createPlugin, initialiseSdk, inploiBrandedLogger, noLogging };
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,17 @@ type AnalyticsLogParams = {
|
|
|
15
15
|
properties: {
|
|
16
16
|
job_id: string;
|
|
17
17
|
};
|
|
18
|
+
} | {
|
|
19
|
+
event: 'APPLY_FLOW_NODE';
|
|
20
|
+
properties: {
|
|
21
|
+
/** Increment by 1 per node interpreted */
|
|
22
|
+
sequence: number;
|
|
23
|
+
from_node_id: string | null;
|
|
24
|
+
to_node_id: string;
|
|
25
|
+
job_id: string;
|
|
26
|
+
flow_id: string;
|
|
27
|
+
flow_version: number;
|
|
28
|
+
};
|
|
18
29
|
} | {
|
|
19
30
|
event: 'IDENTIFY' | 'SUBMIT_FORM' | 'VIEW_PAGE';
|
|
20
31
|
properties?: never;
|
|
@@ -92,7 +103,7 @@ type InitialiseInploiSdkParams = {
|
|
|
92
103
|
logger?: Logger;
|
|
93
104
|
};
|
|
94
105
|
declare function initialiseSdk({ publishableKey, env, logger }: InitialiseInploiSdkParams): {
|
|
95
|
-
|
|
106
|
+
register: <P extends InploiSdkPlugin>(plugin: P) => ReturnType<P>;
|
|
96
107
|
};
|
|
97
108
|
|
|
98
109
|
export { AnalyticsLogEvent, AnalyticsService, ApiClient, InitialiseInploiSdkParams, Logger, Plugin, PluginParams, createPlugin, initialiseSdk, inploiBrandedLogger, noLogging };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var l=Object.defineProperty,
|
|
1
|
+
"use strict";var l=Object.defineProperty,k=Object.defineProperties,b=Object.getOwnPropertyDescriptor,w=Object.getOwnPropertyDescriptors,C=Object.getOwnPropertyNames,P=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var f=(e,t,r)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,g=(e,t)=>{for(var r in t||(t={}))A.call(t,r)&&f(e,r,t[r]);if(P)for(var r of P(t))O.call(t,r)&&f(e,r,t[r]);return e},L=(e,t)=>k(e,w(t));var M=(e,t)=>{for(var r in t)l(e,r,{get:t[r],enumerable:!0})},R=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of C(t))!A.call(e,i)&&i!==r&&l(e,i,{get:()=>t[i],enumerable:!(o=b(t,i))||o.enumerable});return e};var F=e=>R(l({},"__esModule",{value:!0}),e);var c=(e,t,r)=>new Promise((o,i)=>{var s=n=>{try{a(r.next(n))}catch(y){i(y)}},p=n=>{try{a(r.throw(n))}catch(y){i(y)}},a=n=>n.done?o(n.value):Promise.resolve(n.value).then(s,p);a((r=r.apply(e,t)).next())});var q={};M(q,{createPlugin:()=>v,initialiseSdk:()=>S,inploiBrandedLogger:()=>u,noLogging:()=>x});module.exports=F(q);var d="%c[inploi SDK]",m="color: #65BC67; font-weight: bold;",u={warn:(...e)=>console.warn(d,m,...e),error:(...e)=>console.error(d,m,...e),info:(...e)=>console.info(d,m,...e),log:(...e)=>console.log(d,m,...e)},x={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var v=e=>e;var E={sandbox:"https://preview.api.inploi.com",production:"https://api.inploi.com"},_=1,h="/analytics/log";var T=({apiClient:e,logger:t})=>({log:o=>c(void 0,null,function*(){try{let i={library:{name:"inploi-sdk",version:_},page:"request"in o&&o.request instanceof Request?{href:o.request.url,referrer:o.request.referrer,title:""}:{href:location.href,referrer:document.referrer,title:document.title}},s={event:o.event,sent_at:new Date().toISOString(),context:i,properties:o.properties,custom_properties:o.customProperties};return yield e.fetch(h,{method:"POST",body:JSON.stringify(s)}),{success:!0,data:s}}catch(i){return t.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:i}}})});var N="Unauthenticated",j="This action is unauthorized.",I=e=>{let t={Accept:"application/json","Content-Type":"application/json","x-publishable-key":e.publishableKey};return{fetch:(i,...s)=>c(void 0,[i,...s],function*(r,o={}){let p=L(g({},o),{headers:g(g({},o.headers),t)}),n=yield(yield fetch(`${e.baseUrl}${r}`,p)).json();if(typeof n=="object"&&n!==null&&"message"in n){if(n.message===N)throw new Error("You are not authenticated.");if(n.message===j)throw new Error("You are not authorised to perform this action.");if("exception"in n)throw new Error(`API error: \u201C${n.message}\u201D`);if("errors"in n)throw new Error(`API error: \u201C${n.message}\u201D`)}return n})}};function S({publishableKey:e,env:t,logger:r=u}){let o=I({baseUrl:E[t],publishableKey:e}),i=T({apiClient:o,logger:r});return{register:p=>p({logger:r,apiClient:o,analytics:i})}}0&&(module.exports={createPlugin,initialiseSdk,inploiBrandedLogger,noLogging});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/sdk.logger.ts","../src/sdk.plugins.ts","../src/sdk.constants.ts","../src/sdk.analytics.ts","../src/sdk.api.ts","../src/sdk.ts"],"sourcesContent":["export { inploiBrandedLogger, noLogging } from './sdk.logger';\nexport type { Logger } from './sdk.logger';\n\nexport type { Plugin, PluginParams } from './sdk.plugins';\nexport { createPlugin } from './sdk.plugins';\n\nexport type { ApiClient } from './sdk.api';\n\nexport { initialiseSdk } from './sdk';\nexport type { InitialiseInploiSdkParams } from './sdk';\n\nexport type { AnalyticsService, AnalyticsLogEvent } from './sdk.analytics';\n","export const CONSOLE_PREFIX = '%c[inploi SDK]';\nexport const CONSOLE_STYLE = 'color: #65BC67; font-weight: bold;';\n\ntype LogMessage = (...data: any[]) => void;\nexport type Logger = {\n\twarn: LogMessage;\n\terror: LogMessage;\n\tinfo: LogMessage;\n\tlog: LogMessage;\n};\n\nexport const inploiBrandedLogger: Logger = {\n\twarn: (...args) => console.warn(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n\terror: (...args) => console.error(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n\tinfo: (...args) => console.info(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n\tlog: (...args) => console.log(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n};\n\nexport const noLogging: Logger = { info: () => void 0, error: () => void 0, log: () => void 0, warn: () => void 0 };\n","import { AnalyticsService } from './sdk.analytics';\nimport { ApiClient } from './sdk.api';\nimport { Logger } from './sdk.logger';\n\nexport type PluginParams = {\n\tapiClient: ApiClient;\n\tlogger: Logger;\n};\n\nexport type Plugin<T extends string, P extends Record<string, unknown>> = {\n\tpluginName: T;\n\tpure_createActions: (params: PluginParams) => P;\n};\n\ntype PluginDependencies = {\n\tapiClient: ApiClient;\n\tlogger: Logger;\n\tanalytics: AnalyticsService;\n};\n\nexport type InploiSdkPlugin = (dependencies: PluginDependencies) => any;\n\nexport const createPlugin = <T extends InploiSdkPlugin>(pluginFn: T) => pluginFn;\n","/**\n * The environment the SDK should run in.\n * - `production`: data will be stored and displayed on dashboards\n * - `sandbox`: data will be stored temporarily and purged periodically\n */\nexport type AppEnvironment = 'production' | 'sandbox';\n\nexport const ENV_TO_API_URL: Record<AppEnvironment, string> = {\n\tsandbox: 'https://preview.api.inploi.com',\n\tproduction: 'https://api.inploi.com',\n};\n\n/**\n * Change to invalidate existing sessions. Useful for when data has changed.\n * It does not need to be in sync with the library version, and is not semver.\n */\nexport const ANALYTICS_DATA_VERSION = 1;\n\nexport const LOG_PATHNAME = '/analytics/log';\n","import { Flatten, ResponseObj } from '@inploi/core/common';\n\nimport { ApiClient, Logger } from '.';\nimport { ANALYTICS_DATA_VERSION, LOG_PATHNAME } from './sdk.constants';\n\ntype AnalyticsLogParams =\n\t| {\n\t\t\tevent: 'VIEW_JOB' | 'APPLY_START' | 'APPLY_COMPLETE';\n\t\t\tproperties: {\n\t\t\t\tjob_id: string; // External job ID\n\t\t\t};\n\t }\n\t| {\n\t\t\tevent: 'IDENTIFY' | 'SUBMIT_FORM' | 'VIEW_PAGE';\n\t\t\tproperties?: never;\n\t };\n\nexport type AnalyticsLogEvent = AnalyticsLogParams['event'];\n\ntype EventPropertyMap = {\n\t[Param in AnalyticsLogParams as Param['event']]: Flatten<Omit<Param, 'event'>>;\n};\n\ntype AnalyticsContext = {\n\tlibrary: {\n\t\tname: 'inploi-sdk';\n\t\tversion: number;\n\t};\n\tpage: {\n\t\thref: string;\n\t\treferrer: string;\n\t\ttitle: string;\n\t};\n};\n\ntype TrackPayload<P = EventPropertyMap[keyof EventPropertyMap]['properties']> = {\n\tevent: AnalyticsLogEvent;\n\tsent_at: string;\n\tcontext: AnalyticsContext;\n\tproperties: P;\n\tcustom_properties?: Record<string, unknown>;\n};\n\ntype LogFnParams<T extends keyof EventPropertyMap> = {\n\tevent: T;\n\tcustomProperties?: Record<string, unknown>;\n\t/** Passing a request will make logging possible on a server environment. */\n\trequest?: Request;\n} & EventPropertyMap[T];\n\ntype LogFn = <T extends keyof EventPropertyMap>(\n\tparams: LogFnParams<T>,\n) => Promise<ResponseObj<TrackPayload<EventPropertyMap[T]['properties']>>>;\n\nexport type AnalyticsService = {\n\tlog: LogFn;\n};\n\nexport const createAnalyticsService = ({ apiClient, logger }: { logger: Logger; apiClient: ApiClient }) => {\n\tconst logFn: LogFn = async params => {\n\t\ttry {\n\t\t\tconst context: AnalyticsContext = {\n\t\t\t\tlibrary: {\n\t\t\t\t\tname: 'inploi-sdk',\n\t\t\t\t\tversion: ANALYTICS_DATA_VERSION,\n\t\t\t\t},\n\t\t\t\tpage:\n\t\t\t\t\t// if there’s a request, use it instead of browser APIs which are not available on the server\n\t\t\t\t\t'request' in params && params.request instanceof Request\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\thref: params.request.url,\n\t\t\t\t\t\t\t\treferrer: params.request.referrer,\n\t\t\t\t\t\t\t\ttitle: '',\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\thref: location.href,\n\t\t\t\t\t\t\t\treferrer: document.referrer,\n\t\t\t\t\t\t\t\ttitle: document.title,\n\t\t\t\t\t\t },\n\t\t\t};\n\n\t\t\tconst payload: TrackPayload = {\n\t\t\t\tevent: params.event,\n\t\t\t\tsent_at: new Date().toISOString(),\n\t\t\t\tcontext,\n\t\t\t\tproperties: params.properties,\n\t\t\t\tcustom_properties: params.customProperties,\n\t\t\t};\n\t\t\tawait apiClient.fetch(LOG_PATHNAME, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tbody: JSON.stringify(payload),\n\t\t\t});\n\n\t\t\treturn { success: true, data: payload };\n\t\t} catch (e) {\n\t\t\t/** We dont’t log any PII on the console */\n\t\t\tlogger.error('Failed to send log to API. Inspect error response of `log` for more information.');\n\t\t\treturn { success: false, error: e };\n\t\t}\n\t};\n\n\treturn {\n\t\tlog: logFn,\n\t};\n};\n","export const unauthenticatedMessage = 'Unauthenticated';\nexport const unauthorisedMessage = 'This action is unauthorized.';\n\nexport type ApiClient = {\n\tfetch: (pathname: string, options?: RequestInit) => Promise<unknown>;\n};\n\nexport const createApiClient = (params: { baseUrl: string; publishableKey: string }): ApiClient => {\n\tconst defaultHeaders: HeadersInit = {\n\t\tAccept: 'application/json',\n\t\t'Content-Type': 'application/json',\n\t\t'x-publishable-key': params.publishableKey,\n\t};\n\n\treturn {\n\t\t/** Fetches from a pathname with a pre-established base path.\n\t\t * Parses received output as JSON, and throw if one of the common error messages is received.\n\t\t */\n\t\tfetch: async (pathname, options = {}) => {\n\t\t\tconst init = { ...options, headers: { ...options.headers, ...defaultHeaders } };\n\t\t\tconst response = await fetch(`${params.baseUrl}${pathname}`, init);\n\t\t\tconst json = await response.json();\n\n\t\t\tif (typeof json === 'object' && json !== null && 'message' in json) {\n\t\t\t\tif (json.message === unauthenticatedMessage) {\n\t\t\t\t\tthrow new Error('You are not authenticated.');\n\t\t\t\t}\n\t\t\t\tif (json.message === unauthorisedMessage) {\n\t\t\t\t\tthrow new Error('You are not authorised to perform this action.');\n\t\t\t\t}\n\t\t\t\tif ('exception' in response) {\n\t\t\t\t\tthrow new Error(`API error: “${json.message}”`);\n\t\t\t\t}\n\t\t\t\tif ('errors' in response) {\n\t\t\t\t\tthrow new Error(`API error: “${json.message}”`);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn json;\n\t\t},\n\t};\n};\n","import { createAnalyticsService } from './sdk.analytics';\nimport { createApiClient } from './sdk.api';\nimport { AppEnvironment, ENV_TO_API_URL } from './sdk.constants';\nimport { Logger, inploiBrandedLogger } from './sdk.logger';\nimport { InploiSdkPlugin } from './sdk.plugins';\n\nexport type InitialiseInploiSdkParams = {\n\t/** Your public API key for the inploi SDK. */\n\tpublishableKey: string;\n\t/** Which app environment to run. This ultimately affects which inploi endpoints to gather data are going to be used.\n\t * Anything other than `production` should be considered a development environment and the data periodicaly purged. */\n\tenv: AppEnvironment;\n\t/** Logger object that handles logging of different levels.\n\t * You can override this to use your own logger, or to disable logging altogether by importing and passing `noLogging`.\n\t * @default inploiBrandedLogger\n\t * */\n\tlogger?: Logger;\n};\n\nexport function initialiseSdk({ publishableKey, env, logger = inploiBrandedLogger }: InitialiseInploiSdkParams) {\n\tconst apiClient = createApiClient({ baseUrl: ENV_TO_API_URL[env], publishableKey });\n\tconst analytics = createAnalyticsService({ apiClient, logger });\n\n\tconst registerPlugin = <P extends InploiSdkPlugin>(plugin: P): ReturnType<P> => {\n\t\treturn plugin({ logger, apiClient, analytics });\n\t};\n\n\treturn { registerPlugin };\n}\n"],"mappings":"i9BAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,EAAA,kBAAAC,EAAA,wBAAAC,EAAA,cAAAC,IAAA,eAAAC,EAAAN,GCAO,IAAMO,EAAiB,iBACjB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ogger","args","noLogging","createPlugin","pluginFn","ENV_TO_API_URL","ANALYTICS_DATA_VERSION","LOG_PATHNAME","createAnalyticsService","apiClient","logger","params","__async","context","ANALYTICS_DATA_VERSION","payload","LOG_PATHNAME","e","unauthenticatedMessage","unauthorisedMessage","createApiClient","params","defaultHeaders","_0","_1","__async","pathname","options","init","__spreadProps","__spreadValues","response","json","initialiseSdk","publishableKey","env","logger","inploiBrandedLogger","apiClient","createApiClient","ENV_TO_API_URL","analytics","createAnalyticsService","plugin"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/sdk.logger.ts","../src/sdk.plugins.ts","../src/sdk.constants.ts","../src/sdk.analytics.ts","../src/sdk.api.ts","../src/sdk.ts"],"sourcesContent":["export { inploiBrandedLogger, noLogging } from './sdk.logger';\nexport type { Logger } from './sdk.logger';\n\nexport type { Plugin, PluginParams } from './sdk.plugins';\nexport { createPlugin } from './sdk.plugins';\n\nexport type { ApiClient } from './sdk.api';\n\nexport { initialiseSdk } from './sdk';\nexport type { InitialiseInploiSdkParams } from './sdk';\n\nexport type { AnalyticsService, AnalyticsLogEvent } from './sdk.analytics';\n","export const CONSOLE_PREFIX = '%c[inploi SDK]';\nexport const CONSOLE_STYLE = 'color: #65BC67; font-weight: bold;';\n\ntype LogMessage = (...data: any[]) => void;\nexport type Logger = {\n\twarn: LogMessage;\n\terror: LogMessage;\n\tinfo: LogMessage;\n\tlog: LogMessage;\n};\n\nexport const inploiBrandedLogger: Logger = {\n\twarn: (...args) => console.warn(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n\terror: (...args) => console.error(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n\tinfo: (...args) => console.info(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n\tlog: (...args) => console.log(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n};\n\nexport const noLogging: Logger = { info: () => void 0, error: () => void 0, log: () => void 0, warn: () => void 0 };\n","import { AnalyticsService } from './sdk.analytics';\nimport { ApiClient } from './sdk.api';\nimport { Logger } from './sdk.logger';\n\nexport type PluginParams = {\n\tapiClient: ApiClient;\n\tlogger: Logger;\n};\n\nexport type Plugin<T extends string, P extends Record<string, unknown>> = {\n\tpluginName: T;\n\tpure_createActions: (params: PluginParams) => P;\n};\n\ntype PluginDependencies = {\n\tapiClient: ApiClient;\n\tlogger: Logger;\n\tanalytics: AnalyticsService;\n};\n\nexport type InploiSdkPlugin = (dependencies: PluginDependencies) => any;\n\nexport const createPlugin = <T extends InploiSdkPlugin>(pluginFn: T) => pluginFn;\n","/**\n * The environment the SDK should run in.\n * - `production`: data will be stored and displayed on dashboards\n * - `sandbox`: data will be stored temporarily and purged periodically\n */\nexport type AppEnvironment = 'production' | 'sandbox';\n\nexport const ENV_TO_API_URL: Record<AppEnvironment, string> = {\n\tsandbox: 'https://preview.api.inploi.com',\n\tproduction: 'https://api.inploi.com',\n};\n\n/**\n * Change to invalidate existing sessions. Useful for when data has changed.\n * It does not need to be in sync with the library version, and is not semver.\n */\nexport const ANALYTICS_DATA_VERSION = 1;\n\nexport const LOG_PATHNAME = '/analytics/log';\n","import { Flatten, ResponseObj } from '@inploi/core/common';\n\nimport { ApiClient, Logger } from '.';\nimport { ANALYTICS_DATA_VERSION, LOG_PATHNAME } from './sdk.constants';\n\ntype AnalyticsLogParams =\n\t| {\n\t\t\tevent: 'VIEW_JOB' | 'APPLY_START' | 'APPLY_COMPLETE';\n\t\t\tproperties: {\n\t\t\t\tjob_id: string; // External job ID\n\t\t\t};\n\t }\n\t| {\n\t\t\tevent: 'APPLY_FLOW_NODE';\n\t\t\tproperties: {\n\t\t\t\t/** Increment by 1 per node interpreted */\n\t\t\t\tsequence: number;\n\t\t\t\tfrom_node_id: string | null;\n\t\t\t\tto_node_id: string;\n\t\t\t\tjob_id: string;\n\t\t\t\tflow_id: string;\n\t\t\t\tflow_version: number;\n\t\t\t};\n\t }\n\t| {\n\t\t\tevent: 'IDENTIFY' | 'SUBMIT_FORM' | 'VIEW_PAGE';\n\t\t\tproperties?: never;\n\t };\n\nexport type AnalyticsLogEvent = AnalyticsLogParams['event'];\n\ntype EventPropertyMap = {\n\t[Param in AnalyticsLogParams as Param['event']]: Flatten<Omit<Param, 'event'>>;\n};\n\ntype AnalyticsContext = {\n\tlibrary: {\n\t\tname: 'inploi-sdk';\n\t\tversion: number;\n\t};\n\tpage: {\n\t\thref: string;\n\t\treferrer: string;\n\t\ttitle: string;\n\t};\n};\n\ntype TrackPayload<P = EventPropertyMap[keyof EventPropertyMap]['properties']> = {\n\tevent: AnalyticsLogEvent;\n\tsent_at: string;\n\tcontext: AnalyticsContext;\n\tproperties: P;\n\tcustom_properties?: Record<string, unknown>;\n};\n\ntype LogFnParams<T extends keyof EventPropertyMap> = {\n\tevent: T;\n\tcustomProperties?: Record<string, unknown>;\n\t/** Passing a request will make logging possible on a server environment. */\n\trequest?: Request;\n} & EventPropertyMap[T];\n\ntype LogFn = <T extends keyof EventPropertyMap>(\n\tparams: LogFnParams<T>,\n) => Promise<ResponseObj<TrackPayload<EventPropertyMap[T]['properties']>>>;\n\nexport type AnalyticsService = {\n\tlog: LogFn;\n};\n\nexport const createAnalyticsService = ({ apiClient, logger }: { logger: Logger; apiClient: ApiClient }) => {\n\tconst logFn: LogFn = async params => {\n\t\ttry {\n\t\t\tconst context: AnalyticsContext = {\n\t\t\t\tlibrary: {\n\t\t\t\t\tname: 'inploi-sdk',\n\t\t\t\t\tversion: ANALYTICS_DATA_VERSION,\n\t\t\t\t},\n\t\t\t\tpage:\n\t\t\t\t\t// if there’s a request, use it instead of browser APIs which are not available on the server\n\t\t\t\t\t'request' in params && params.request instanceof Request\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\thref: params.request.url,\n\t\t\t\t\t\t\t\treferrer: params.request.referrer,\n\t\t\t\t\t\t\t\ttitle: '',\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\thref: location.href,\n\t\t\t\t\t\t\t\treferrer: document.referrer,\n\t\t\t\t\t\t\t\ttitle: document.title,\n\t\t\t\t\t\t },\n\t\t\t};\n\n\t\t\tconst payload: TrackPayload = {\n\t\t\t\tevent: params.event,\n\t\t\t\tsent_at: new Date().toISOString(),\n\t\t\t\tcontext,\n\t\t\t\tproperties: params.properties,\n\t\t\t\tcustom_properties: params.customProperties,\n\t\t\t};\n\t\t\tawait apiClient.fetch(LOG_PATHNAME, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tbody: JSON.stringify(payload),\n\t\t\t});\n\n\t\t\treturn { success: true, data: payload };\n\t\t} catch (e) {\n\t\t\t/** We dont’t log any PII on the console */\n\t\t\tlogger.error('Failed to send log to API. Inspect error response of `log` for more information.');\n\t\t\treturn { success: false, error: e };\n\t\t}\n\t};\n\n\treturn {\n\t\tlog: logFn,\n\t};\n};\n","export const unauthenticatedMessage = 'Unauthenticated';\nexport const unauthorisedMessage = 'This action is unauthorized.';\n\nexport type ApiClient = {\n\tfetch: (pathname: string, options?: RequestInit) => Promise<unknown>;\n};\n\nexport const createApiClient = (params: { baseUrl: string; publishableKey: string }): ApiClient => {\n\tconst defaultHeaders: HeadersInit = {\n\t\tAccept: 'application/json',\n\t\t'Content-Type': 'application/json',\n\t\t'x-publishable-key': params.publishableKey,\n\t};\n\n\treturn {\n\t\t/** Fetches from a pathname with a pre-established base path.\n\t\t * Parses received output as JSON, and throw if one of the common error messages is received.\n\t\t */\n\t\tfetch: async (pathname, options = {}) => {\n\t\t\tconst init = { ...options, headers: { ...options.headers, ...defaultHeaders } };\n\t\t\tconst response = await fetch(`${params.baseUrl}${pathname}`, init);\n\t\t\tconst json = await response.json();\n\n\t\t\tif (typeof json === 'object' && json !== null && 'message' in json) {\n\t\t\t\tif (json.message === unauthenticatedMessage) {\n\t\t\t\t\tthrow new Error('You are not authenticated.');\n\t\t\t\t}\n\t\t\t\tif (json.message === unauthorisedMessage) {\n\t\t\t\t\tthrow new Error('You are not authorised to perform this action.');\n\t\t\t\t}\n\t\t\t\tif ('exception' in json) {\n\t\t\t\t\tthrow new Error(`API error: “${json.message}”`);\n\t\t\t\t}\n\t\t\t\tif ('errors' in json) {\n\t\t\t\t\tthrow new Error(`API error: “${json.message}”`);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn json;\n\t\t},\n\t};\n};\n","import { createAnalyticsService } from './sdk.analytics';\nimport { createApiClient } from './sdk.api';\nimport { AppEnvironment, ENV_TO_API_URL } from './sdk.constants';\nimport { Logger, inploiBrandedLogger } from './sdk.logger';\nimport { InploiSdkPlugin } from './sdk.plugins';\n\nexport type InitialiseInploiSdkParams = {\n\t/** Your public API key for the inploi SDK. */\n\tpublishableKey: string;\n\t/** Which app environment to run. This ultimately affects which inploi endpoints to gather data are going to be used.\n\t * Anything other than `production` should be considered a development environment and the data periodicaly purged. */\n\tenv: AppEnvironment;\n\t/** Logger object that handles logging of different levels.\n\t * You can override this to use your own logger, or to disable logging altogether by importing and passing `noLogging`.\n\t * @default inploiBrandedLogger\n\t * */\n\tlogger?: Logger;\n};\n\nexport function initialiseSdk({ publishableKey, env, logger = inploiBrandedLogger }: InitialiseInploiSdkParams) {\n\tconst apiClient = createApiClient({ baseUrl: ENV_TO_API_URL[env], publishableKey });\n\tconst analytics = createAnalyticsService({ apiClient, logger });\n\n\tconst register = <P extends InploiSdkPlugin>(plugin: P): ReturnType<P> => {\n\t\treturn plugin({ logger, apiClient, analytics });\n\t};\n\n\treturn { register };\n}\n"],"mappings":"i9BAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,kBAAAE,EAAA,kBAAAC,EAAA,wBAAAC,EAAA,cAAAC,IAAA,eAAAC,EAAAN,GCAO,IAAMO,EAAiB,iBACjBC,EAAgB,qCAUhBC,EAA8B,CAC1C,KAAM,IAAIC,IAAS,QAAQ,KAAKH,EAAgBC,EAAe,GAAGE,CAAI,EACtE,MAAO,IAAIA,IAAS,QAAQ,MAAMH,EAAgBC,EAAe,GAAGE,CAAI,EACxE,KAAM,IAAIA,IAAS,QAAQ,KAAKH,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GAAAC,GAAA,UAA3BE,EAAUC,EAAU,CAAC,EAAM,CACxC,IAAMC,EAAOC,EAAAC,EAAA,GAAKH,GAAL,CAAc,QAASG,IAAA,GAAKH,EAAQ,SAAYL,EAAiB,GAExES,EAAO,MADI,MAAM,MAAM,GAAGV,EAAO,OAAO,GAAGK,CAAQ,GAAIE,CAAI,GACrC,KAAK,EAEjC,GAAI,OAAOG,GAAS,UAAYA,IAAS,MAAQ,YAAaA,EAAM,CACnE,GAAIA,EAAK,UAAYb,EACpB,MAAM,IAAI,MAAM,4BAA4B,EAE7C,GAAIa,EAAK,UAAYZ,EACpB,MAAM,IAAI,MAAM,gDAAgD,EAEjE,GAAI,cAAeY,EAClB,MAAM,IAAI,MAAM,oBAAeA,EAAK,OAAO,QAAG,EAE/C,GAAI,WAAYA,EACf,MAAM,IAAI,MAAM,oBAAeA,EAAK,OAAO,QAAG,CAEhD,CACA,OAAOA,CACR,EACD,CACD,ECrBO,SAASC,EAAc,CAAE,eAAAC,EAAgB,IAAAC,EAAK,OAAAC,EAASC,CAAoB,EAA8B,CAC/G,IAAMC,EAAYC,EAAgB,CAAE,QAASC,EAAeL,CAAG,EAAG,eAAAD,CAAe,CAAC,EAC5EO,EAAYC,EAAuB,CAAE,UAAAJ,EAAW,OAAAF,CAAO,CAAC,EAM9D,MAAO,CAAE,SAJoCO,GACrCA,EAAO,CAAE,OAAAP,EAAQ,UAAAE,EAAW,UAAAG,CAAU,CAAC,CAG7B,CACnB","names":["src_exports","__export","createPlugin","initialiseSdk","inploiBrandedLogger","noLogging","__toCommonJS","CONSOLE_PREFIX","CONSOLE_STYLE","inploiBrandedLogger","args","noLogging","createPlugin","pluginFn","ENV_TO_API_URL","ANALYTICS_DATA_VERSION","LOG_PATHNAME","createAnalyticsService","apiClient","logger","params","__async","context","ANALYTICS_DATA_VERSION","payload","LOG_PATHNAME","e","unauthenticatedMessage","unauthorisedMessage","createApiClient","params","defaultHeaders","_0","_1","__async","pathname","options","init","__spreadProps","__spreadValues","json","initialiseSdk","publishableKey","env","logger","inploiBrandedLogger","apiClient","createApiClient","ENV_TO_API_URL","analytics","createAnalyticsService","plugin"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var _=Object.defineProperty,h=Object.defineProperties;var T=Object.getOwnPropertyDescriptors;var y=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable;var P=(e,r,t)=>r in e?_(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,l=(e,r)=>{for(var t in r||(r={}))I.call(r,t)&&P(e,t,r[t]);if(y)for(var t of y(r))S.call(r,t)&&P(e,t,r[t]);return e},f=(e,r)=>h(e,T(r));var g=(e,r,t)=>new Promise((n,i)=>{var s=o=>{try{a(t.next(o))}catch(m){i(m)}},p=o=>{try{a(t.throw(o))}catch(m){i(m)}},a=o=>o.done?n(o.value):Promise.resolve(o.value).then(s,p);a((t=t.apply(e,r)).next())});var c="%c[inploi SDK]",d="color: #65BC67; font-weight: bold;",u={warn:(...e)=>console.warn(c,d,...e),error:(...e)=>console.error(c,d,...e),info:(...e)=>console.info(c,d,...e),log:(...e)=>console.log(c,d,...e)},k={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var b=e=>e;var A={sandbox:"https://preview.api.inploi.com",production:"https://api.inploi.com"},L=1,x="/analytics/log";var v=({apiClient:e,logger:r})=>({log:n=>g(void 0,null,function*(){try{let i={library:{name:"inploi-sdk",version:L},page:"request"in n&&n.request instanceof Request?{href:n.request.url,referrer:n.request.referrer,title:""}:{href:location.href,referrer:document.referrer,title:document.title}},s={event:n.event,sent_at:new Date().toISOString(),context:i,properties:n.properties,custom_properties:n.customProperties};return yield e.fetch(x,{method:"POST",body:JSON.stringify(s)}),{success:!0,data:s}}catch(i){return r.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:i}}})});var w="Unauthenticated",C="This action is unauthorized.",E=e=>{let r={Accept:"application/json","Content-Type":"application/json","x-publishable-key":e.publishableKey};return{fetch:(i,...s)=>g(void 0,[i,...s],function*(t,n={}){let p=f(l({},n),{headers:l(l({},n.headers),r)}),o=yield(yield fetch(`${e.baseUrl}${t}`,p)).json();if(typeof o=="object"&&o!==null&&"message"in o){if(o.message===w)throw new Error("You are not authenticated.");if(o.message===C)throw new Error("You are not authorised to perform this action.");if("exception"in o)throw new Error(`API error: \u201C${o.message}\u201D`);if("errors"in o)throw new Error(`API error: \u201C${o.message}\u201D`)}return o})}};function O({publishableKey:e,env:r,logger:t=u}){let n=E({baseUrl:A[r],publishableKey:e}),i=v({apiClient:n,logger:t});return{register:p=>p({logger:t,apiClient:n,analytics:i})}}export{b as createPlugin,O as initialiseSdk,u as inploiBrandedLogger,k as noLogging};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sdk.logger.ts","../src/sdk.plugins.ts","../src/sdk.constants.ts","../src/sdk.analytics.ts","../src/sdk.api.ts","../src/sdk.ts"],"sourcesContent":["export const CONSOLE_PREFIX = '%c[inploi SDK]';\nexport const CONSOLE_STYLE = 'color: #65BC67; font-weight: bold;';\n\ntype LogMessage = (...data: any[]) => void;\nexport type Logger = {\n\twarn: LogMessage;\n\terror: LogMessage;\n\tinfo: LogMessage;\n\tlog: LogMessage;\n};\n\nexport const inploiBrandedLogger: Logger = {\n\twarn: (...args) => console.warn(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n\terror: (...args) => console.error(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n\tinfo: (...args) => console.info(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n\tlog: (...args) => console.log(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n};\n\nexport const noLogging: Logger = { info: () => void 0, error: () => void 0, log: () => void 0, warn: () => void 0 };\n","import { AnalyticsService } from './sdk.analytics';\nimport { ApiClient } from './sdk.api';\nimport { Logger } from './sdk.logger';\n\nexport type PluginParams = {\n\tapiClient: ApiClient;\n\tlogger: Logger;\n};\n\nexport type Plugin<T extends string, P extends Record<string, unknown>> = {\n\tpluginName: T;\n\tpure_createActions: (params: PluginParams) => P;\n};\n\ntype PluginDependencies = {\n\tapiClient: ApiClient;\n\tlogger: Logger;\n\tanalytics: AnalyticsService;\n};\n\nexport type InploiSdkPlugin = (dependencies: PluginDependencies) => any;\n\nexport const createPlugin = <T extends InploiSdkPlugin>(pluginFn: T) => pluginFn;\n","/**\n * The environment the SDK should run in.\n * - `production`: data will be stored and displayed on dashboards\n * - `sandbox`: data will be stored temporarily and purged periodically\n */\nexport type AppEnvironment = 'production' | 'sandbox';\n\nexport const ENV_TO_API_URL: Record<AppEnvironment, string> = {\n\tsandbox: 'https://preview.api.inploi.com',\n\tproduction: 'https://api.inploi.com',\n};\n\n/**\n * Change to invalidate existing sessions. Useful for when data has changed.\n * It does not need to be in sync with the library version, and is not semver.\n */\nexport const ANALYTICS_DATA_VERSION = 1;\n\nexport const LOG_PATHNAME = '/analytics/log';\n","import { Flatten, ResponseObj } from '@inploi/core/common';\n\nimport { ApiClient, Logger } from '.';\nimport { ANALYTICS_DATA_VERSION, LOG_PATHNAME } from './sdk.constants';\n\ntype AnalyticsLogParams =\n\t| {\n\t\t\tevent: 'VIEW_JOB' | 'APPLY_START' | 'APPLY_COMPLETE';\n\t\t\tproperties: {\n\t\t\t\tjob_id: string; // External job ID\n\t\t\t};\n\t }\n\t| {\n\t\t\tevent: 'IDENTIFY' | 'SUBMIT_FORM' | 'VIEW_PAGE';\n\t\t\tproperties?: never;\n\t };\n\nexport type AnalyticsLogEvent = AnalyticsLogParams['event'];\n\ntype EventPropertyMap = {\n\t[Param in AnalyticsLogParams as Param['event']]: Flatten<Omit<Param, 'event'>>;\n};\n\ntype AnalyticsContext = {\n\tlibrary: {\n\t\tname: 'inploi-sdk';\n\t\tversion: number;\n\t};\n\tpage: {\n\t\thref: string;\n\t\treferrer: string;\n\t\ttitle: string;\n\t};\n};\n\ntype TrackPayload<P = EventPropertyMap[keyof EventPropertyMap]['properties']> = {\n\tevent: AnalyticsLogEvent;\n\tsent_at: string;\n\tcontext: AnalyticsContext;\n\tproperties: P;\n\tcustom_properties?: Record<string, unknown>;\n};\n\ntype LogFnParams<T extends keyof EventPropertyMap> = {\n\tevent: T;\n\tcustomProperties?: Record<string, unknown>;\n\t/** Passing a request will make logging possible on a server environment. */\n\trequest?: Request;\n} & EventPropertyMap[T];\n\ntype LogFn = <T extends keyof EventPropertyMap>(\n\tparams: LogFnParams<T>,\n) => Promise<ResponseObj<TrackPayload<EventPropertyMap[T]['properties']>>>;\n\nexport type AnalyticsService = {\n\tlog: LogFn;\n};\n\nexport const createAnalyticsService = ({ apiClient, logger }: { logger: Logger; apiClient: ApiClient }) => {\n\tconst logFn: LogFn = async params => {\n\t\ttry {\n\t\t\tconst context: AnalyticsContext = {\n\t\t\t\tlibrary: {\n\t\t\t\t\tname: 'inploi-sdk',\n\t\t\t\t\tversion: ANALYTICS_DATA_VERSION,\n\t\t\t\t},\n\t\t\t\tpage:\n\t\t\t\t\t// if there’s a request, use it instead of browser APIs which are not available on the server\n\t\t\t\t\t'request' in params && params.request instanceof Request\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\thref: params.request.url,\n\t\t\t\t\t\t\t\treferrer: params.request.referrer,\n\t\t\t\t\t\t\t\ttitle: '',\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\thref: location.href,\n\t\t\t\t\t\t\t\treferrer: document.referrer,\n\t\t\t\t\t\t\t\ttitle: document.title,\n\t\t\t\t\t\t },\n\t\t\t};\n\n\t\t\tconst payload: TrackPayload = {\n\t\t\t\tevent: params.event,\n\t\t\t\tsent_at: new Date().toISOString(),\n\t\t\t\tcontext,\n\t\t\t\tproperties: params.properties,\n\t\t\t\tcustom_properties: params.customProperties,\n\t\t\t};\n\t\t\tawait apiClient.fetch(LOG_PATHNAME, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tbody: JSON.stringify(payload),\n\t\t\t});\n\n\t\t\treturn { success: true, data: payload };\n\t\t} catch (e) {\n\t\t\t/** We dont’t log any PII on the console */\n\t\t\tlogger.error('Failed to send log to API. Inspect error response of `log` for more information.');\n\t\t\treturn { success: false, error: e };\n\t\t}\n\t};\n\n\treturn {\n\t\tlog: logFn,\n\t};\n};\n","export const unauthenticatedMessage = 'Unauthenticated';\nexport const unauthorisedMessage = 'This action is unauthorized.';\n\nexport type ApiClient = {\n\tfetch: (pathname: string, options?: RequestInit) => Promise<unknown>;\n};\n\nexport const createApiClient = (params: { baseUrl: string; publishableKey: string }): ApiClient => {\n\tconst defaultHeaders: HeadersInit = {\n\t\tAccept: 'application/json',\n\t\t'Content-Type': 'application/json',\n\t\t'x-publishable-key': params.publishableKey,\n\t};\n\n\treturn {\n\t\t/** Fetches from a pathname with a pre-established base path.\n\t\t * Parses received output as JSON, and throw if one of the common error messages is received.\n\t\t */\n\t\tfetch: async (pathname, options = {}) => {\n\t\t\tconst init = { ...options, headers: { ...options.headers, ...defaultHeaders } };\n\t\t\tconst response = await fetch(`${params.baseUrl}${pathname}`, init);\n\t\t\tconst json = await response.json();\n\n\t\t\tif (typeof json === 'object' && json !== null && 'message' in json) {\n\t\t\t\tif (json.message === unauthenticatedMessage) {\n\t\t\t\t\tthrow new Error('You are not authenticated.');\n\t\t\t\t}\n\t\t\t\tif (json.message === unauthorisedMessage) {\n\t\t\t\t\tthrow new Error('You are not authorised to perform this action.');\n\t\t\t\t}\n\t\t\t\tif ('exception' in response) {\n\t\t\t\t\tthrow new Error(`API error: “${json.message}”`);\n\t\t\t\t}\n\t\t\t\tif ('errors' in response) {\n\t\t\t\t\tthrow new Error(`API error: “${json.message}”`);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn json;\n\t\t},\n\t};\n};\n","import { createAnalyticsService } from './sdk.analytics';\nimport { createApiClient } from './sdk.api';\nimport { AppEnvironment, ENV_TO_API_URL } from './sdk.constants';\nimport { Logger, inploiBrandedLogger } from './sdk.logger';\nimport { InploiSdkPlugin } from './sdk.plugins';\n\nexport type InitialiseInploiSdkParams = {\n\t/** Your public API key for the inploi SDK. */\n\tpublishableKey: string;\n\t/** Which app environment to run. This ultimately affects which inploi endpoints to gather data are going to be used.\n\t * Anything other than `production` should be considered a development environment and the data periodicaly purged. */\n\tenv: AppEnvironment;\n\t/** Logger object that handles logging of different levels.\n\t * You can override this to use your own logger, or to disable logging altogether by importing and passing `noLogging`.\n\t * @default inploiBrandedLogger\n\t * */\n\tlogger?: Logger;\n};\n\nexport function initialiseSdk({ publishableKey, env, logger = inploiBrandedLogger }: InitialiseInploiSdkParams) {\n\tconst apiClient = createApiClient({ baseUrl: ENV_TO_API_URL[env], publishableKey });\n\tconst analytics = createAnalyticsService({ apiClient, logger });\n\n\tconst registerPlugin = <P extends InploiSdkPlugin>(plugin: P): ReturnType<P> => {\n\t\treturn plugin({ logger, apiClient, analytics });\n\t};\n\n\treturn { registerPlugin };\n}\n"],"mappings":"0nBAAO,IAAMA,EAAiB,iBACjBC,EAAgB,qCAUhBC,EAA8B,CAC1C,KAAM,IAAIC,IAAS,QAAQ,KAAKH,EAAgBC,EAAe,GAAGE,CAAI,EACtE,MAAO,IAAIA,IAAS,QAAQ,MAAMH,EAAgBC,EAAe,GAAGE,CAAI,EACxE,KAAM,IAAIA,IAAS,QAAQ,KAAKH,EAAgBC,EAAe,GAAGE,CAAI,EACtE,IAAK,IAAIA,IAAS,QAAQ,IAAIH,EAAgBC,EAAe,GAAGE,CAAI,CACrE,EAEaC,EAAoB,CAAE,KAAM,IAAG,GAAW,MAAO,IAAG,GAAW,IAAK,IAAG,GAAW,KAAM,IAAG,EAAU,ECI3G,IAAMC,EAA2CC,GAAgBA,ECfjE,IAAMC,EAAiD,CAC7D,QAAS,iCACT,WAAY,wBACb,EAMaC,EAAyB,EAEzBC,EAAe,iBCwCrB,IAAMC,EAAyB,C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EACpB,MAAM,IAAI,MAAM,4BAA4B,EAE7C,GAAIc,EAAK,UAAYb,EACpB,MAAM,IAAI,MAAM,gDAAgD,EAEjE,GAAI,cAAeY,EAClB,MAAM,IAAI,MAAM,oBAAeC,EAAK,OAAO,QAAG,EAE/C,GAAI,WAAYD,EACf,MAAM,IAAI,MAAM,oBAAeC,EAAK,OAAO,QAAG,CAEhD,CACA,OAAOA,CACR,EACD,CACD,ECrBO,SAASC,EAAc,CAAE,eAAAC,EAAgB,IAAAC,EAAK,OAAAC,EAASC,CAAoB,EAA8B,CAC/G,IAAMC,EAAYC,EAAgB,CAAE,QAASC,EAAeL,CAAG,EAAG,eAAAD,CAAe,CAAC,EAC5EO,EAAYC,EAAuB,CAAE,UAAAJ,EAAW,OAAAF,CAAO,CAAC,EAM9D,MAAO,CAAE,eAJ0CO,GAC3CA,EAAO,CAAE,OAAAP,EAAQ,UAAAE,EAAW,UAAAG,CAAU,CAAC,CAGvB,CACzB","names":["CONSOLE_PREFIX","CONSOLE_STYLE","inploiBrandedLogger","args","noLogging","createPlugin","pluginFn","ENV_TO_API_URL","ANALYTICS_DATA_VERSION","LOG_PATHNAME","createAnalyticsService","apiClient","logger","params","__async","context","ANALYTICS_DATA_VERSION","payload","LOG_PATHNAME","e","unauthenticatedMessage","unauthorisedMessage","createApiClient","params","defaultHeaders","_0","_1","__async","pathname","options","init","__spreadProps","__spreadValues","response","json","initialiseSdk","publishableKey","env","logger","inploiBrandedLogger","apiClient","createApiClient","ENV_TO_API_URL","analytics","createAnalyticsService","plugin"]}
|
|
1
|
+
{"version":3,"sources":["../src/sdk.logger.ts","../src/sdk.plugins.ts","../src/sdk.constants.ts","../src/sdk.analytics.ts","../src/sdk.api.ts","../src/sdk.ts"],"sourcesContent":["export const CONSOLE_PREFIX = '%c[inploi SDK]';\nexport const CONSOLE_STYLE = 'color: #65BC67; font-weight: bold;';\n\ntype LogMessage = (...data: any[]) => void;\nexport type Logger = {\n\twarn: LogMessage;\n\terror: LogMessage;\n\tinfo: LogMessage;\n\tlog: LogMessage;\n};\n\nexport const inploiBrandedLogger: Logger = {\n\twarn: (...args) => console.warn(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n\terror: (...args) => console.error(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n\tinfo: (...args) => console.info(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n\tlog: (...args) => console.log(CONSOLE_PREFIX, CONSOLE_STYLE, ...args),\n};\n\nexport const noLogging: Logger = { info: () => void 0, error: () => void 0, log: () => void 0, warn: () => void 0 };\n","import { AnalyticsService } from './sdk.analytics';\nimport { ApiClient } from './sdk.api';\nimport { Logger } from './sdk.logger';\n\nexport type PluginParams = {\n\tapiClient: ApiClient;\n\tlogger: Logger;\n};\n\nexport type Plugin<T extends string, P extends Record<string, unknown>> = {\n\tpluginName: T;\n\tpure_createActions: (params: PluginParams) => P;\n};\n\ntype PluginDependencies = {\n\tapiClient: ApiClient;\n\tlogger: Logger;\n\tanalytics: AnalyticsService;\n};\n\nexport type InploiSdkPlugin = (dependencies: PluginDependencies) => any;\n\nexport const createPlugin = <T extends InploiSdkPlugin>(pluginFn: T) => pluginFn;\n","/**\n * The environment the SDK should run in.\n * - `production`: data will be stored and displayed on dashboards\n * - `sandbox`: data will be stored temporarily and purged periodically\n */\nexport type AppEnvironment = 'production' | 'sandbox';\n\nexport const ENV_TO_API_URL: Record<AppEnvironment, string> = {\n\tsandbox: 'https://preview.api.inploi.com',\n\tproduction: 'https://api.inploi.com',\n};\n\n/**\n * Change to invalidate existing sessions. Useful for when data has changed.\n * It does not need to be in sync with the library version, and is not semver.\n */\nexport const ANALYTICS_DATA_VERSION = 1;\n\nexport const LOG_PATHNAME = '/analytics/log';\n","import { Flatten, ResponseObj } from '@inploi/core/common';\n\nimport { ApiClient, Logger } from '.';\nimport { ANALYTICS_DATA_VERSION, LOG_PATHNAME } from './sdk.constants';\n\ntype AnalyticsLogParams =\n\t| {\n\t\t\tevent: 'VIEW_JOB' | 'APPLY_START' | 'APPLY_COMPLETE';\n\t\t\tproperties: {\n\t\t\t\tjob_id: string; // External job ID\n\t\t\t};\n\t }\n\t| {\n\t\t\tevent: 'APPLY_FLOW_NODE';\n\t\t\tproperties: {\n\t\t\t\t/** Increment by 1 per node interpreted */\n\t\t\t\tsequence: number;\n\t\t\t\tfrom_node_id: string | null;\n\t\t\t\tto_node_id: string;\n\t\t\t\tjob_id: string;\n\t\t\t\tflow_id: string;\n\t\t\t\tflow_version: number;\n\t\t\t};\n\t }\n\t| {\n\t\t\tevent: 'IDENTIFY' | 'SUBMIT_FORM' | 'VIEW_PAGE';\n\t\t\tproperties?: never;\n\t };\n\nexport type AnalyticsLogEvent = AnalyticsLogParams['event'];\n\ntype EventPropertyMap = {\n\t[Param in AnalyticsLogParams as Param['event']]: Flatten<Omit<Param, 'event'>>;\n};\n\ntype AnalyticsContext = {\n\tlibrary: {\n\t\tname: 'inploi-sdk';\n\t\tversion: number;\n\t};\n\tpage: {\n\t\thref: string;\n\t\treferrer: string;\n\t\ttitle: string;\n\t};\n};\n\ntype TrackPayload<P = EventPropertyMap[keyof EventPropertyMap]['properties']> = {\n\tevent: AnalyticsLogEvent;\n\tsent_at: string;\n\tcontext: AnalyticsContext;\n\tproperties: P;\n\tcustom_properties?: Record<string, unknown>;\n};\n\ntype LogFnParams<T extends keyof EventPropertyMap> = {\n\tevent: T;\n\tcustomProperties?: Record<string, unknown>;\n\t/** Passing a request will make logging possible on a server environment. */\n\trequest?: Request;\n} & EventPropertyMap[T];\n\ntype LogFn = <T extends keyof EventPropertyMap>(\n\tparams: LogFnParams<T>,\n) => Promise<ResponseObj<TrackPayload<EventPropertyMap[T]['properties']>>>;\n\nexport type AnalyticsService = {\n\tlog: LogFn;\n};\n\nexport const createAnalyticsService = ({ apiClient, logger }: { logger: Logger; apiClient: ApiClient }) => {\n\tconst logFn: LogFn = async params => {\n\t\ttry {\n\t\t\tconst context: AnalyticsContext = {\n\t\t\t\tlibrary: {\n\t\t\t\t\tname: 'inploi-sdk',\n\t\t\t\t\tversion: ANALYTICS_DATA_VERSION,\n\t\t\t\t},\n\t\t\t\tpage:\n\t\t\t\t\t// if there’s a request, use it instead of browser APIs which are not available on the server\n\t\t\t\t\t'request' in params && params.request instanceof Request\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\thref: params.request.url,\n\t\t\t\t\t\t\t\treferrer: params.request.referrer,\n\t\t\t\t\t\t\t\ttitle: '',\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\thref: location.href,\n\t\t\t\t\t\t\t\treferrer: document.referrer,\n\t\t\t\t\t\t\t\ttitle: document.title,\n\t\t\t\t\t\t },\n\t\t\t};\n\n\t\t\tconst payload: TrackPayload = {\n\t\t\t\tevent: params.event,\n\t\t\t\tsent_at: new Date().toISOString(),\n\t\t\t\tcontext,\n\t\t\t\tproperties: params.properties,\n\t\t\t\tcustom_properties: params.customProperties,\n\t\t\t};\n\t\t\tawait apiClient.fetch(LOG_PATHNAME, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tbody: JSON.stringify(payload),\n\t\t\t});\n\n\t\t\treturn { success: true, data: payload };\n\t\t} catch (e) {\n\t\t\t/** We dont’t log any PII on the console */\n\t\t\tlogger.error('Failed to send log to API. Inspect error response of `log` for more information.');\n\t\t\treturn { success: false, error: e };\n\t\t}\n\t};\n\n\treturn {\n\t\tlog: logFn,\n\t};\n};\n","export const unauthenticatedMessage = 'Unauthenticated';\nexport const unauthorisedMessage = 'This action is unauthorized.';\n\nexport type ApiClient = {\n\tfetch: (pathname: string, options?: RequestInit) => Promise<unknown>;\n};\n\nexport const createApiClient = (params: { baseUrl: string; publishableKey: string }): ApiClient => {\n\tconst defaultHeaders: HeadersInit = {\n\t\tAccept: 'application/json',\n\t\t'Content-Type': 'application/json',\n\t\t'x-publishable-key': params.publishableKey,\n\t};\n\n\treturn {\n\t\t/** Fetches from a pathname with a pre-established base path.\n\t\t * Parses received output as JSON, and throw if one of the common error messages is received.\n\t\t */\n\t\tfetch: async (pathname, options = {}) => {\n\t\t\tconst init = { ...options, headers: { ...options.headers, ...defaultHeaders } };\n\t\t\tconst response = await fetch(`${params.baseUrl}${pathname}`, init);\n\t\t\tconst json = await response.json();\n\n\t\t\tif (typeof json === 'object' && json !== null && 'message' in json) {\n\t\t\t\tif (json.message === unauthenticatedMessage) {\n\t\t\t\t\tthrow new Error('You are not authenticated.');\n\t\t\t\t}\n\t\t\t\tif (json.message === unauthorisedMessage) {\n\t\t\t\t\tthrow new Error('You are not authorised to perform this action.');\n\t\t\t\t}\n\t\t\t\tif ('exception' in json) {\n\t\t\t\t\tthrow new Error(`API error: “${json.message}”`);\n\t\t\t\t}\n\t\t\t\tif ('errors' in json) {\n\t\t\t\t\tthrow new Error(`API error: “${json.message}”`);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn json;\n\t\t},\n\t};\n};\n","import { createAnalyticsService } from './sdk.analytics';\nimport { createApiClient } from './sdk.api';\nimport { AppEnvironment, ENV_TO_API_URL } from './sdk.constants';\nimport { Logger, inploiBrandedLogger } from './sdk.logger';\nimport { InploiSdkPlugin } from './sdk.plugins';\n\nexport type InitialiseInploiSdkParams = {\n\t/** Your public API key for the inploi SDK. */\n\tpublishableKey: string;\n\t/** Which app environment to run. This ultimately affects which inploi endpoints to gather data are going to be used.\n\t * Anything other than `production` should be considered a development environment and the data periodicaly purged. */\n\tenv: AppEnvironment;\n\t/** Logger object that handles logging of different levels.\n\t * You can override this to use your own logger, or to disable logging altogether by importing and passing `noLogging`.\n\t * @default inploiBrandedLogger\n\t * */\n\tlogger?: Logger;\n};\n\nexport function initialiseSdk({ publishableKey, env, logger = inploiBrandedLogger }: InitialiseInploiSdkParams) {\n\tconst apiClient = createApiClient({ baseUrl: ENV_TO_API_URL[env], publishableKey });\n\tconst analytics = createAnalyticsService({ apiClient, logger });\n\n\tconst register = <P extends InploiSdkPlugin>(plugin: P): ReturnType<P> => {\n\t\treturn plugin({ logger, api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ger","args","noLogging","createPlugin","pluginFn","ENV_TO_API_URL","ANALYTICS_DATA_VERSION","LOG_PATHNAME","createAnalyticsService","apiClient","logger","params","__async","context","ANALYTICS_DATA_VERSION","payload","LOG_PATHNAME","e","unauthenticatedMessage","unauthorisedMessage","createApiClient","params","defaultHeaders","_0","_1","__async","pathname","options","init","__spreadProps","__spreadValues","json","initialiseSdk","publishableKey","env","logger","inploiBrandedLogger","apiClient","createApiClient","ENV_TO_API_URL","analytics","createAnalyticsService","plugin"]}
|