Skip to content

Commit

Permalink
Fix types and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
zlwaterfield committed Feb 13, 2024
1 parent 30bb8b9 commit 8f66d10
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 22 deletions.
2 changes: 1 addition & 1 deletion apps/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"scripts": {
"build": "next build",
"dev": "next dev",
"lint": "next lint",
"start": "next start"
},
"dependencies": {
Expand All @@ -18,6 +17,7 @@
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint-config-next": "14.1.0",
"typescript": "^5"
}
}
3 changes: 3 additions & 0 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ module.exports = {
env: {
jest: true,
},
rules: {
'jest/no-deprecated-functions': 'off',
},
parserOptions: {
project: './tsconfig.json',
},
Expand Down
6 changes: 4 additions & 2 deletions packages/web/src/generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ function track(
if (!isBrowser()) {
const msg =
'[Dub Web Analytics] is currently only supported in the browser environment. The server tracking is coming soon.';
// eslint-disable-next-line no-console -- Logging to console is intentional
console.warn(msg);
return;
}

if (!properties) {
window.da?.track?.('event', { eventName });
window.da?.track('event', { eventName });
return;
}

Expand All @@ -66,11 +67,12 @@ function track(
strip: true,
});

window.da?.track?.('event', {
window.da?.track('event', {
eventName,
properties: cleanedProperties,
});
} catch (err) {
// eslint-disable-next-line no-console -- Logging to console is intentional
console.error(err);
}
}
Expand Down
4 changes: 1 addition & 3 deletions packages/web/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ export interface AnalyticsProps {
apiKey?: string;
}

export type TrackEventProperties = {
[key: string]: AllowedPropertyValues;
};
export type TrackEventProperties = Record<string, AllowedPropertyValues>;

export interface TrackFunction {
(eventName: string, properties?: TrackEventProperties): void;
Expand Down
1 change: 0 additions & 1 deletion packages/web/src/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export function parseProperties(
if (!properties) return undefined;
let props = properties;
const errorProperties: string[] = [];
// @ts-ignore
for (const [key, value] of Object.entries(properties)) {
if (typeof value === 'object' && value !== null) {
if (options.strip) {
Expand Down
Loading

0 comments on commit 8f66d10

Please sign in to comment.