Skip to content
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

feat: [IOCOM-2100] Common FIMS start API #6740

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
15dd29c
WiP FIMS start flow
Vangaorth Feb 17, 2025
65c58a9
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Feb 18, 2025
3fbd2b8
hook for IdPay
Vangaorth Feb 18, 2025
ea88474
Tests for useAutoFetchingServiceByIdPot
Vangaorth Feb 19, 2025
500e43f
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Feb 19, 2025
6cd4d09
Tests for useFIMSFromServiceId
Vangaorth Feb 19, 2025
e8e77b7
Tests for useFIMSAuthenticationFlow
Vangaorth Feb 19, 2025
1c005ba
Tests for renderFromRemoteConfigurationHook
Vangaorth Feb 19, 2025
d2d613d
Tests for useFIMSFromServiceData
Vangaorth Feb 19, 2025
b99bbb4
Tests for FimsFlowHandlerScreen
Vangaorth Feb 20, 2025
470dd41
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Feb 20, 2025
c601e91
Tests for handleCtaAction
Vangaorth Feb 20, 2025
0c53239
Case insensitive extractPathFromURL
Vangaorth Feb 20, 2025
ba41011
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Feb 20, 2025
791633e
Better tests for isCtaActionValid
Vangaorth Feb 20, 2025
5849aec
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Feb 20, 2025
659c3cf
Tests for fimsServiceConfiguration
Vangaorth Feb 20, 2025
a8f6002
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Feb 21, 2025
99fb32c
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Feb 24, 2025
7a1c792
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Feb 26, 2025
89dd58d
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Feb 26, 2025
8c63df7
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Feb 27, 2025
424e725
Proper io-services-metadata spec
Vangaorth Feb 27, 2025
d95be6c
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Feb 27, 2025
69a8e39
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Feb 28, 2025
1f5510f
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Feb 28, 2025
76ee8b8
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Mar 3, 2025
bffa243
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Mar 3, 2025
6df6c13
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Mar 3, 2025
8078c9b
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Mar 4, 2025
1a601df
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Mar 4, 2025
a8a49bb
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Mar 5, 2025
8620e39
Merge branch 'master' into IOCOM-2100_fimsStartFlow
Vangaorth Mar 6, 2025
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
2 changes: 1 addition & 1 deletion scripts/generate-api-models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

IO_BACKEND_VERSION=v16.7.4-RELEASE
# need to change after merge on io-services-metadata
IO_SERVICES_METADATA_VERSION=1.0.59
IO_SERVICES_METADATA_VERSION=1.0.60
# Session manager version
IO_SESSION_MANAGER_VERSION=1.4.0

Expand Down
60 changes: 1 addition & 59 deletions ts/components/ui/Markdown/handlers/__test__/link.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import * as E from "fp-ts/lib/Either";
import {
deriveCustomHandledLink,
isHttpsLink,
isIoFIMSLink,
isIoInternalLink,
removeFIMSPrefixFromUrl
isIoInternalLink
} from "../link";

const loadingCases: ReadonlyArray<
Expand Down Expand Up @@ -73,19 +71,6 @@ const loadingCases: ReadonlyArray<
]
];

const fimsCases: ReadonlyArray<
[input: string, expectedResult: ReturnType<typeof removeFIMSPrefixFromUrl>]
> = [
[
"iosso://https://italia.io/main/messages?messageId=4&serviceId=5",
"https://italia.io/main/messages?messageId=4&serviceId=5"
],
[
"iOsSo://https://italia.io/main/messages?messageId=4&serviceId=5",
"https://italia.io/main/messages?messageId=4&serviceId=5"
]
];

describe("deriveCustomHandledLink", () => {
test.each(loadingCases)(
"given %p as argument, returns %p",
Expand All @@ -96,16 +81,6 @@ describe("deriveCustomHandledLink", () => {
);
});

describe("removeFIMSPrefixFromUrl", () => {
test.each(fimsCases)(
"given %p as argument, returns %p",
(firstArg, expectedResult) => {
const result = removeFIMSPrefixFromUrl(firstArg);
expect(result).toEqual(expectedResult);
}
);
});

describe("isHttpsLink", () => {
["https://", "hTtPs://", "HTTPS://"].forEach(protocol => {
it(`should return true for '${protocol}'`, () => {
Expand Down Expand Up @@ -139,39 +114,6 @@ describe("isHttpsLink", () => {
});
});

describe("isIoFIMSLink", () => {
["iosso://", "iOsSo://", "IOSSO://"].forEach(protocol => {
it(`should return true for '${protocol}'`, () => {
const isIOFIMSLink = isIoFIMSLink(`${protocol}whatever`);
expect(isIOFIMSLink).toBe(true);
});
});
[
"iosso:/",
"iosso:",
"iosso",
"https://",
"http://",
"ioit://",
"iohandledlink://",
"clipboard://",
"clipboard:",
"sms://",
"sms:",
"tel://",
"tel:",
"mailto://",
"mailto:",
"copy://",
"copy:"
].forEach(protocol => {
it(`should return false for '${protocol}'`, () => {
const isIOFIMSLink = isIoFIMSLink(`${protocol}whatever`);
expect(isIOFIMSLink).toBe(false);
});
});
});

describe("isIoInternalLink", () => {
["ioit://", "iOiT://", "IOIT://"].forEach(protocol => {
it(`should return true for '${protocol}'`, () => {
Expand Down
15 changes: 1 addition & 14 deletions ts/components/ui/Markdown/handlers/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,15 @@ import { IOToast } from "@pagopa/io-app-design-system";
import * as E from "fp-ts/lib/Either";
import * as t from "io-ts";
import I18n from "../../../../i18n";
import {
IO_FIMS_LINK_PREFIX,
IO_FIMS_LINK_PROTOCOL,
IO_INTERNAL_LINK_PREFIX
} from "../../../../utils/navigation";
import { IO_INTERNAL_LINK_PREFIX } from "../../../../utils/navigation";
import { openWebUrl } from "../../../../utils/url";

export const isIoInternalLink = (href: string): boolean =>
href.toLowerCase().startsWith(IO_INTERNAL_LINK_PREFIX);

export const isIoFIMSLink = (href: string): boolean =>
href.toLowerCase().startsWith(IO_FIMS_LINK_PREFIX);

export const isHttpsLink = (href: string): boolean =>
href.toLowerCase().startsWith("https://");

export const removeFIMSPrefixFromUrl = (fimsUrlWithProtocol: string) => {
// eslint-disable-next-line no-useless-escape
const regexp = new RegExp(`^${IO_FIMS_LINK_PROTOCOL}\/\/`, "i");
return fimsUrlWithProtocol.replace(regexp, "");
};

/**
* a dedicated codec for CustomHandledLink
* ex: iohandledlink://tel:1234567 -> {url: tel:1234567, type: tel, value:1234567}
Expand Down
67 changes: 32 additions & 35 deletions ts/features/fims/common/analytics/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { ServiceId } from "../../../../../../definitions/backend/ServiceId";
import { ServicePublic } from "../../../../../../definitions/backend/ServicePublic";
import * as mixpanel from "../../../../../mixpanel";
import { GlobalState } from "../../../../../store/reducers/types";
import { MESSAGES_ROUTES } from "../../../../messages/navigation/routes";
import * as serviceSelectors from "../../../../services/details/store/reducers";
import * as fimsAuthenticationSelectors from "../../../singleSignOn/store/selectors";

Expand All @@ -26,9 +27,6 @@ const organizationNames = [undefined, "organization name"];
const referenceReason = "The reason";
const referenceServiceId = "01J9RSWBB4VSHVRJSY33XGA6YH" as ServiceId;
const serviceNames = [undefined, "service name"];
const sources: ReadonlyArray<
"message_detail" | "service_detail" | "credential_detail"
> = ["message_detail", "service_detail", "credential_detail"] as const;

describe("trackAuthenticationStart", () => {
beforeEach(() => {
Expand All @@ -38,38 +36,37 @@ describe("trackAuthenticationStart", () => {
organizationFiscalCodes.forEach(organizationFiscalCode =>
organizationNames.forEach(organizationName =>
serviceNames.forEach(serviceName =>
sources.forEach(source =>
it(`should match event name, and expected parameters for ${
organizationFiscalCode ? "defined " : "undefined "
} organization fiscal code, ${
organizationName ? "defined " : "undefined "
} organization name, ${
serviceName ? "defined " : "undefined "
} service name, ${source} source, `, () => {
const mixpanelTrackMock = generateMixpanelTrackMock();
void trackAuthenticationStart(
referenceServiceId,
serviceName,
organizationName,
organizationFiscalCode,
referenceCtaLabel,
source
);
expect(mixpanelTrackMock.mock.calls.length).toBe(1);
expect(mixpanelTrackMock.mock.calls[0].length).toBe(2);
expect(mixpanelTrackMock.mock.calls[0][0]).toBe("FIMS_START");
expect(mixpanelTrackMock.mock.calls[0][1]).toEqual({
event_category: "UX",
event_type: "action",
fims_label: referenceCtaLabel,
organization_fiscal_code: organizationFiscalCode,
organization_name: organizationName,
service_id: referenceServiceId,
service_name: serviceName,
source
});
})
)
it(`should match event name, and expected parameters for ${
organizationFiscalCode ? "defined " : "undefined "
} organization fiscal code, ${
organizationName ? "defined " : "undefined "
} organization name, ${
serviceName ? "defined " : "undefined "
} service name`, () => {
const source = MESSAGES_ROUTES.MESSAGE_DETAIL;
const mixpanelTrackMock = generateMixpanelTrackMock();
void trackAuthenticationStart(
referenceServiceId,
serviceName,
organizationName,
organizationFiscalCode,
referenceCtaLabel,
source
);
expect(mixpanelTrackMock.mock.calls.length).toBe(1);
expect(mixpanelTrackMock.mock.calls[0].length).toBe(2);
expect(mixpanelTrackMock.mock.calls[0][0]).toBe("FIMS_START");
expect(mixpanelTrackMock.mock.calls[0][1]).toEqual({
event_category: "UX",
event_type: "action",
fims_label: referenceCtaLabel,
organization_fiscal_code: organizationFiscalCode,
organization_name: organizationName,
service_id: referenceServiceId,
service_name: serviceName,
source
});
})
)
)
);
Expand Down
2 changes: 1 addition & 1 deletion ts/features/fims/common/analytics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const trackAuthenticationStart = (
organizationName: string | undefined,
organizationFiscalCode: string | undefined,
ctaLabel: string,
source: "message_detail" | "service_detail" | "credential_detail"
source: string
) => {
const eventName = `FIMS_START`;
const props = buildEventProperties("UX", "action", {
Expand Down
Loading
Loading