Skip to content

Commit

Permalink
Update tooling (#43)
Browse files Browse the repository at this point in the history
* Update tooling to address audit warnings

* Fix TS build errors

* Remove old webpack arg

* Update Preact dep

* Bump versions & bundles for release

* Don't let webpack use arrow funcs
  • Loading branch information
cgwyllie authored Aug 27, 2021
1 parent 4f16749 commit 0093069
Show file tree
Hide file tree
Showing 13 changed files with 12,912 additions and 4,354 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/worker.js

Large diffs are not rendered by default.

17,196 changes: 12,867 additions & 4,329 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kumulos/web",
"version": "1.10.0",
"version": "1.10.1",
"description": "Official SDK for integrating Kumulos services with your web projects",
"main": "dist/index.js",
"types": "types/src/index.d.ts",
Expand All @@ -13,7 +13,7 @@
"scripts": {
"build": "webpack",
"dev": "webpack --watch",
"dist": "NODE_ENV=production webpack -p",
"dist": "NODE_ENV=production webpack",
"snippet": "tsc -t es2015 --outFile dist/snippet.js src/web/snippet.ts && uglifyjs dist/snippet.js",
"test": "jest"
},
Expand All @@ -25,22 +25,22 @@
"license": "MIT",
"devDependencies": {
"@types/jest": "^26.0.14",
"css-loader": "^3.4.0",
"css-loader": "^6.2.0",
"jest": "^26.4.2",
"node-sass": "^4.14.1",
"node-sass": "^6.0.1",
"prettier": "^1.19.1",
"sass-loader": "^8.0.0",
"style-loader": "^1.0.2",
"terser": "^5.2.1",
"terser-webpack-plugin": "^4.1.0",
"sass-loader": "^12.1.0",
"style-loader": "^3.2.1",
"terser": "^5.7.2",
"terser-webpack-plugin": "^5.1.4",
"ts-jest": "^26.4.0",
"ts-loader": "^6.2.0",
"typescript": "^3.9.2",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.9"
"ts-loader": "^9.2.5",
"typescript": "^4.4.2",
"webpack": "^5.51.1",
"webpack-cli": "^4.8.0"
},
"dependencies": {
"clipboard-copy": "^4.0.1",
"preact": "^10.5.13"
"preact": "^10.5.14"
}
}
9 changes: 6 additions & 3 deletions src/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ async function loadConfig<TConfigType>(
const cacheKeys = getCacheKeys(cacheKey);
let config = await get<TConfigType>(cacheKeys.CONFIG_CACHE_KEY);

const lastLoadTime = (await get<number>(cacheKeys.CONFIG_CACHE_KEY_UPDATED)) ?? 0;
const lastLoadTime =
(await get<number>(cacheKeys.CONFIG_CACHE_KEY_UPDATED)) ?? 0;
let updatedRemoteConfig = false;

if (Date.now() - lastLoadTime > MAX_CACHE_AGE_MS) {
Expand Down Expand Up @@ -79,13 +80,15 @@ export async function loadDdlConfig(
} catch (err) {
console.warn(
`loadDdlConfig: failed to load Deferred DeepLink configuration`,
err.message
err
);
// undefined return / no config
}
}

export async function deleteDdlBannerConfigFromCache(bannerUuid: string): Promise<void> {
export async function deleteDdlBannerConfigFromCache(
bannerUuid: string
): Promise<void> {
const cacheKeys = getCacheKeys(ConfigCacheType.DDL);

let configs = await get<DdlPromptConfig[]>(cacheKeys.CONFIG_CACHE_KEY);
Expand Down
2 changes: 1 addition & 1 deletion src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { authedFetch, cyrb53, uuidv4 } from './utils';
import { del, get, set } from './storage';
import { Channel } from './channels';

const SDK_VERSION = '1.10.0';
const SDK_VERSION = '1.10.1';
const SDK_TYPE = 10;
const EVENTS_BASE_URL = 'https://events.kumulos.com';
export const PUSH_BASE_URL = 'https://push.kumulos.com';
Expand Down
3 changes: 1 addition & 2 deletions src/core/push/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ export function trackOpenFromQuery(ctx: Context) {
export function notificationFromPayload(
payload: PushPayload
): KumulosPushNotification {
const userData = { ...payload.data };
delete userData['k.message'];
const { 'k.message': _, ...userData } = payload.data;

const push: KumulosPushNotification = {
id: payload.data['k.message'].data.id,
Expand Down
2 changes: 1 addition & 1 deletion src/prompts/ddl/manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
loadDdlConfig,
deleteDdlBannerConfigFromCache
} from '../../core/config';
import { maybePersistReminder, isPromptSuppressed } from '../prompt-reminder';
import { maybePersistReminder } from '../prompt-reminder';
import { deferPromptActivation } from '../utils';
import { sendClickRequest } from '../../fp';
import { FingerprintComponents } from '../../fp/types';
Expand Down
6 changes: 5 additions & 1 deletion src/prompts/prompt-reminder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ export async function isPromptSuppressed(
return true;
}

const { uiActions } = prompt as PromptUiActions;
if (!('uiActions' in prompt)) {
return false;
}

const { uiActions } = prompt;

if (uiActions.decline.type !== UiActionType.REMIND) {
return false;
Expand Down
7 changes: 5 additions & 2 deletions src/prompts/triggers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class PromptTriggerEventFilter<T extends PromptConfig> {
async filterPrompts(
prompts: PromptConfigs<T>,
filter: (prompt: T) => boolean = (_: T) => true
) {
): Promise<T[]> {
console.info('Evaluating prompt triggers');

const matchedPrompts = [];
Expand All @@ -145,7 +145,10 @@ export class PromptTriggerEventFilter<T extends PromptConfig> {

this.eventQueue = [];

return matchedPrompts;
// Cast necessary to narrow the type from the constraint.
// Seems the TS compiler isn't quite smart enough when handling
// the 'T extends PromptConfig' constraint.
return matchedPrompts as T[];
}

private handleSdkEvent = (e: SdkEvent) => {
Expand Down
5 changes: 5 additions & 0 deletions src/w3c.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// The expirationTime field is missing from TS defs, but documented on MDN:
// https://developer.mozilla.org/en-US/docs/Web/API/PushSubscription/expirationTime
interface PushSubscription {
expirationTime: DOMHighResTimeStamp;
}
4 changes: 4 additions & 0 deletions src/worker.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// https://developer.mozilla.org/en-US/docs/Web/API/ExtendableEvent/waitUntil
interface Event {
waitUntil(p: Promise<unknown>): void;
}
2 changes: 2 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ module.exports = [
output: { ...output, library: 'kumulos', libraryTarget: 'umd' }
},
{
target: ['webworker', 'es5'],
mode: environment,
entry: {
worker: './src/worker/index.ts'
Expand All @@ -71,6 +72,7 @@ module.exports = [
output
},
{
target: ['web', 'es5'],
mode: environment,
entry: {
'web-bundle': './src/web/index.ts'
Expand Down

0 comments on commit 0093069

Please sign in to comment.