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

embedded-v3: send sdk info in iframe #819

Merged
merged 4 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ import { embeddedCheckoutV3IncomingEvents, embeddedCheckoutV3OutgoingEvents } fr
import { IFrameWindow } from "@crossmint/client-sdk-window";
import type { CrossmintApiClient } from "@crossmint/common-sdk-base";

export type CrossmintEmbeddedCheckoutV3ServiceProps = { apiClient: CrossmintApiClient };
export type CrossmintEmbeddedCheckoutV3ServiceProps = {
apiClient: CrossmintApiClient,
sdkMetadata: {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we have access to CrossmintApiClientInternalConfig["sdkMetadata"] from here, better to keep in sync

name: string;
version: string;
}
};

export function crossmintEmbeddedCheckoutV3Service({ apiClient }: CrossmintEmbeddedCheckoutV3ServiceProps) {
export function crossmintEmbeddedCheckoutV3Service({ apiClient, sdkMetadata }: CrossmintEmbeddedCheckoutV3ServiceProps) {
function getIFrameUrl(props: CrossmintEmbeddedCheckoutV3Props) {
const urlWithPath = apiClient.buildUrl("/sdk/2024-03-05/embedded-checkout");
const queryParams = new URLSearchParams();
Expand Down Expand Up @@ -34,6 +40,7 @@ export function crossmintEmbeddedCheckoutV3Service({ apiClient }: CrossmintEmbed
}

queryParams.append("apiKey", apiClient.crossmint.apiKey);
queryParams.append("sdkMetadata", JSON.stringify(sdkMetadata));

return `${urlWithPath}?${queryParams.toString()}`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ export function EmbeddedCheckoutV3IFrame(props: CrossmintEmbeddedCheckoutV3Props
const [height, setHeight] = useState(0);

const { crossmint } = useCrossmint();
const sdkMetadata = {
name: "@crossmint/client-sdk-react-ui",
version: LIB_VERSION,
};
const apiClient = new CrossmintApiClient(crossmint, {
internalConfig: {
sdkMetadata: {
name: "@crossmint/client-sdk-react-ui",
version: LIB_VERSION,
},
sdkMetadata,
},
});
const embedV3Service = crossmintEmbeddedCheckoutV3Service({ apiClient });
const embedV3Service = crossmintEmbeddedCheckoutV3Service({ apiClient, sdkMetadata });

const ref = useRef<HTMLIFrameElement>(null);

Expand Down
Loading