Skip to content

[MOB-11554] Resolve lint warnings #506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions react-example/src/components/EmbeddedForm.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import { FC, FormEvent, useState } from 'react';
/* eslint-disable no-console */
import {
IterableEmbeddedManager,
IterableEmbeddedMessageUpdateHandler,
trackEmbeddedSession,
trackEmbeddedReceived,
IterableResponse,
trackEmbeddedClick,
trackEmbeddedDismiss
trackEmbeddedDismiss,
trackEmbeddedReceived,
trackEmbeddedSession
} from '@iterable/web-sdk';
import { AxiosError, AxiosResponse, isAxiosError } from 'axios';
import { FC, FormEvent, useState } from 'react';
import { v4 as uuidv4 } from 'uuid';
import { TextField } from './TextField';
import {
StyledButton,
EndpointWrapper,
Form,
Heading,
Response
Response,
StyledButton
} from '../views/Components.styled';
import { TextField } from './TextField';

interface Props {
endpointName: string;
Expand Down Expand Up @@ -63,8 +66,10 @@ export const EmbeddedForm: FC<Props> = ({
await embeddedManager.syncMessages('my-website', () =>
console.log('Synced message')
);
} catch (error: any) {
setTrackResponse(JSON.stringify(error?.response?.data));
} catch (error: unknown) {
setTrackResponse(
JSON.stringify(isAxiosError(error) ? error.response?.data : error)
);
}
};

Expand All @@ -80,11 +85,11 @@ export const EmbeddedForm: FC<Props> = ({
};

trackEmbeddedReceived(receivedMessage.messageId, 'my-website')
.then((response: any) => {
.then((response: AxiosResponse<IterableResponse>) => {
setTrackResponse(JSON.stringify(response.data));
setTrackingEvent(false);
})
.catch((error: any) => {
.catch((error: AxiosError<IterableResponse>) => {
setTrackResponse(JSON.stringify(error.response.data));
setTrackingEvent(false);
});
Expand All @@ -111,11 +116,11 @@ export const EmbeddedForm: FC<Props> = ({
targetUrl,
appPackageName
})
.then((response: any) => {
.then((response: AxiosResponse<IterableResponse>) => {
setTrackResponse(JSON.stringify(response.data));
setTrackingEvent(false);
})
.catch((error: any) => {
.catch((error: AxiosError<IterableResponse>) => {
setTrackResponse(JSON.stringify(error.response.data));
setTrackingEvent(false);
});
Expand All @@ -139,11 +144,11 @@ export const EmbeddedForm: FC<Props> = ({
};

trackEmbeddedDismiss(sessionData)
.then((response: any) => {
.then((response: AxiosResponse<IterableResponse>) => {
setTrackResponse(JSON.stringify(response.data));
setTrackingEvent(false);
})
.catch((error: any) => {
.catch((error: AxiosError<IterableResponse>) => {
setTrackResponse(JSON.stringify(error.response.data));
setTrackingEvent(false);
});
Expand Down Expand Up @@ -177,11 +182,11 @@ export const EmbeddedForm: FC<Props> = ({
};

trackEmbeddedSession(sessionData)
.then((response: any) => {
.then((response: AxiosResponse<IterableResponse>) => {
setTrackResponse(JSON.stringify(response.data));
setTrackingEvent(false);
})
.catch((error: any) => {
.catch((error: AxiosError<IterableResponse>) => {
setTrackResponse(JSON.stringify(error.response.data));
setTrackingEvent(false);
});
Expand Down
22 changes: 15 additions & 7 deletions react-example/src/components/EventsForm.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
import {
InAppEventRequestParams,
InAppTrackRequestParams,
IterablePromise,
IterableResponse
} from '@iterable/web-sdk';
import { AxiosError, AxiosResponse } from 'axios';
import { ChangeEvent, FC, FormEvent, useState } from 'react';
import { IterablePromise, IterableResponse } from '@iterable/web-sdk';
import {
StyledButton,
EndpointWrapper,
Form,
Heading,
Response
Response,
StyledButton
} from '../views/Components.styled';
import { TextField } from './TextField';

interface Props {
endpointName: string;
heading: string;
needsEventName?: boolean;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
method: (...args: any) => IterablePromise<IterableResponse>;
method: (
// eslint-disable-next-line @typescript-eslint/no-unused-vars
args: InAppEventRequestParams | InAppTrackRequestParams
) => IterablePromise<IterableResponse>;
}

export const EventsForm: FC<Props> = ({
Expand Down Expand Up @@ -44,11 +52,11 @@ export const EventsForm: FC<Props> = ({
appPackageName: 'my-website'
}
})
.then((response: any) => {
.then((response: AxiosResponse<IterableResponse>) => {
setTrackResponse(JSON.stringify(response.data));
setTrackingEvent(false);
})
.catch((e: any) => {
.catch((e: AxiosError<IterableResponse>) => {
setTrackResponse(JSON.stringify(e.response.data));
setTrackingEvent(false);
});
Expand Down
15 changes: 8 additions & 7 deletions react-example/src/views/Commerce.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { IterableResponse, trackPurchase, updateCart } from '@iterable/web-sdk';
import { AxiosError, AxiosResponse } from 'axios';
import { FC, FormEvent, useState } from 'react';
import { updateCart, trackPurchase } from '@iterable/web-sdk';
import { TextField } from '../components/TextField';
import {
StyledButton,
EndpointWrapper,
Form,
Heading,
Response
Response,
StyledButton
} from './Components.styled';

interface Props {}
Expand All @@ -31,11 +32,11 @@ export const Commerce: FC<Props> = () => {
updateCart({
items: [{ name: cartItem, id: 'fdsafds', price: 100, quantity: 2 }]
})
.then((response: any) => {
.then((response: AxiosResponse<IterableResponse>) => {
setUpdateCartResponse(JSON.stringify(response.data));
setUpdatingCart(false);
})
.catch((e: any) => {
.catch((e: AxiosError<IterableResponse>) => {
setUpdateCartResponse(JSON.stringify(e.response.data));
setUpdatingCart(false);
});
Expand All @@ -48,11 +49,11 @@ export const Commerce: FC<Props> = () => {
items: [{ name: purchaseItem, id: 'fdsafds', price: 100, quantity: 2 }],
total: 200
})
.then((response: any) => {
.then((response: AxiosResponse<IterableResponse>) => {
setTrackingPurchase(false);
setTrackPurchaseResponse(JSON.stringify(response.data));
})
.catch((e: any) => {
.catch((e: AxiosError<IterableResponse>) => {
setTrackingPurchase(false);
setTrackPurchaseResponse(JSON.stringify(e.response.data));
});
Expand Down
23 changes: 12 additions & 11 deletions react-example/src/views/EmbeddedMsgs.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { FC, useState, useEffect } from 'react';
/* eslint-disable no-console */
import {
IterableEmbeddedCard,
IterableEmbeddedNotification,
IterableAction,
IterableConfig,
IterableCustomActionHandler,
IterableEmbeddedBanner,
IterableEmbeddedCard,
IterableEmbeddedManager,
IterableEmbeddedMessage,
IterableEmbeddedMessageUpdateHandler,
IterableUrlHandler,
IterableCustomActionHandler,
IterableAction,
IterableConfig
IterableEmbeddedNotification,
IterableUrlHandler
} from '@iterable/web-sdk';
import { FC, useEffect, useState } from 'react';
import { Button } from '../components/Button';
import { useUser } from '../context/Users';

Expand Down Expand Up @@ -113,7 +114,7 @@ export const EmbeddedMsgs: FC<Props> = () => {
await embeddedManager.syncMessages('my-website', () => {
console.log('messages', JSON.stringify(embeddedManager.getMessages()));
});
} catch (error: any) {
} catch (error: unknown) {
console.log('error', error);
}
};
Expand Down Expand Up @@ -236,7 +237,7 @@ export const EmbeddedMsgs: FC<Props> = () => {
appPackageName,
message,
...(useCustomStyles && { htmlElements: StyleOverrides }),
errorCallback: (error: any) =>
errorCallback: (error: unknown) =>
console.log('handleError: ', error)
});
return (
Expand All @@ -252,7 +253,7 @@ export const EmbeddedMsgs: FC<Props> = () => {
appPackageName,
message,
...(useCustomStyles && { htmlElements: StyleOverrides }),
errorCallback: (error: any) =>
errorCallback: (error: unknown) =>
console.log('handleError: ', error)
});
return (
Expand All @@ -268,7 +269,7 @@ export const EmbeddedMsgs: FC<Props> = () => {
appPackageName,
message,
...(useCustomStyles && { htmlElements: StyleOverrides }),
errorCallback: (error: any) =>
errorCallback: (error: unknown) =>
console.log('handleError: ', error)
});
return (
Expand Down
7 changes: 4 additions & 3 deletions react-example/src/views/EmbeddedMsgsImpressionTracker.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { FC, useState, useEffect, useRef } from 'react';
/* eslint-disable no-console */
import {
IterableEmbeddedCard,
IterableEmbeddedManager,
IterableEmbeddedMessage,
IterableEmbeddedMessageUpdateHandler,
IterableEmbeddedSessionManager
} from '@iterable/web-sdk';
import { FC, useEffect, useRef, useState } from 'react';
import { useUser } from '../context/Users';

interface Props {}
Expand Down Expand Up @@ -51,7 +52,7 @@ export const EmbeddedMsgsImpressionTracker: FC<Props> = () => {
);
};

let observersCard: any[] = [];
let observersCard: IntersectionObserver[] = [];

useEffect(() => {
observersCard = getCardObserver();
Expand Down Expand Up @@ -93,7 +94,7 @@ export const EmbeddedMsgsImpressionTracker: FC<Props> = () => {
await embeddedManager.syncMessages('my-website', () => {
console.log('messages', JSON.stringify(embeddedManager.getMessages()));
});
} catch (error: any) {
} catch (error: unknown) {
console.log('error', error);
}
};
Expand Down
23 changes: 12 additions & 11 deletions react-example/src/views/Users.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { FC, FormEvent, useState } from 'react';
import {
updateUser,
IterableResponse,
updateSubscriptions,
updateUser,
updateUserEmail
} from '@iterable/web-sdk';
import { AxiosError, AxiosResponse } from 'axios';
import { FC, FormEvent, useState } from 'react';
import { TextField } from '../components/TextField';

import { useUser } from '../context/Users';
import {
StyledButton,
EndpointWrapper,
Form,
Heading,
Response
Response,
StyledButton
} from './Components.styled';

interface Props {}
Expand Down Expand Up @@ -43,11 +44,11 @@ export const Users: FC<Props> = () => {
updateUser({
dataFields: { [userDataField]: 'test-data' }
})
.then((response: any) => {
.then((response: AxiosResponse<IterableResponse>) => {
setUpdateUserResponse(JSON.stringify(response.data));
setUpdatingUser(false);
})
.catch((e: any) => {
.catch((e: AxiosError<IterableResponse>) => {
setUpdateUserResponse(JSON.stringify(e.response.data));
setUpdatingUser(false);
});
Expand All @@ -57,12 +58,12 @@ export const Users: FC<Props> = () => {
e.preventDefault();
setUpdatingUserEmail(true);
updateUserEmail(email)
.then((response: any) => {
.then((response: AxiosResponse<IterableResponse>) => {
setUpdatingUserEmail(false);
setUpdateUserEmailResponse(JSON.stringify(response.data));
setLoggedInUser({ type: 'user_update', data: email });
})
.catch((e: any) => {
.catch((e: AxiosError<IterableResponse>) => {
setUpdatingUserEmail(false);
setUpdateUserEmailResponse(JSON.stringify(e.response.data));
});
Expand All @@ -73,11 +74,11 @@ export const Users: FC<Props> = () => {

setUpdatingSubscriptions(true);
updateSubscriptions({ emailListIds: [+emailListID] })
.then((response: any) => {
.then((response: AxiosResponse<IterableResponse>) => {
setUpdatingSubscriptions(false);
setUpdateSubscriptionsResponse(JSON.stringify(response.data));
})
.catch((e: any) => {
.catch((e: AxiosError<IterableResponse>) => {
setUpdatingSubscriptions(false);
setUpdateSubscriptionsResponse(JSON.stringify(e.response.data));
});
Expand Down
2 changes: 1 addition & 1 deletion src/authorization/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const cancelAxiosRequestAndMakeFetch = (
'Api-Key': authToken,
Authorization: `Bearer ${jwtToken}`
},
body: JSON.stringify({ ...config?.data, ...additionalData } || {}),
body: JSON.stringify({ ...config?.data, ...additionalData }),
keepalive: true
}).catch();

Expand Down
12 changes: 6 additions & 6 deletions src/inapp/cache.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable no-console */
import { isAxiosError } from 'axios';
import { setMany } from 'idb-keyval';
import { BrowserStorageEstimate, CachedMessage, InAppMessage } from './types';

Expand Down Expand Up @@ -32,11 +34,10 @@ export const determineRemainingStorageQuota = async () => {
const remainingQuota = usage && messageQuota - usage;

return remainingQuota || 0;
} catch (err: any /* eslint-disable-line @typescript-eslint/no-explicit-any */) {
// eslint-disable-next-line no-console
} catch (err: unknown) {
console.warn(
'Error determining remaining storage quota',
err?.response?.data?.clientErrors ?? err
isAxiosError(err) ? err.response?.data?.clientErrors : err
);
}
/** Do not try to add to cache if we cannot determine storage space. */
Expand Down Expand Up @@ -113,11 +114,10 @@ export const addNewMessagesToCache = async (

try {
await setMany(messagesToAddToCache);
} catch (err: any /* eslint-disable-line @typescript-eslint/no-explicit-any */) {
// eslint-disable-next-line no-console
} catch (err: unknown) {
console.warn(
'Error adding new messages to the browser cache',
err?.response?.data?.clientErrors ?? err
isAxiosError(err) ? err.response?.data?.clientErrors : err
);
}
}
Expand Down
Loading
Loading