Skip to content

Commit

Permalink
feat: updated getUserAgentIntegration
Browse files Browse the repository at this point in the history
  • Loading branch information
egordidenko committed Apr 29, 2024
1 parent a840e90 commit b343069
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AdapterUploadCtxProvider } from "../core/AdapterUploadCtxProvider";
import type { TProps } from "../types";
import { getStyleSource } from "../default";
import { getCalcPropertyOfProps } from "../../utils/getCalcPropertyOfProps";
import { getUserAgentIntegration } from "../../utils/getUserAgentIntegration";
import { getUserAgentIntegration } from "../../utils/getUserAgentIntegration.ts";

LR.registerBlocks(LR);

Expand All @@ -33,7 +33,7 @@ export const FileUploaderInline: FC<TProps> = ({
return (
<div className={className}>
{/* @ts-ignore */}
<AdapterConfig userAgentIntegration={getUserAgentIntegration(config.pubkey)} ctx-name={CTX_NAME} {...config} />
<AdapterConfig userAgentIntegration={getUserAgentIntegration()} ctx-name={CTX_NAME} {...config} />
{/* @ts-ignore */}
<AdapterUploadCtxProvider
ref={refUploadCtxProvider}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AdapterUploadCtxProvider } from "../core/AdapterUploadCtxProvider";
import type { TProps } from "../types";
import { getStyleSource } from "../default";
import { getCalcPropertyOfProps } from "../../utils/getCalcPropertyOfProps";
import { getUserAgentIntegration } from "../../utils/getUserAgentIntegration";
import { getUserAgentIntegration } from "../../utils/getUserAgentIntegration.ts";

LR.registerBlocks(LR);

Expand Down Expand Up @@ -34,7 +34,7 @@ export const FileUploaderMinimal: FC<TProps> = ({
return (
<div className={className}>
{/* @ts-ignore */}
<AdapterConfig userAgentIntegration={getUserAgentIntegration(config.pubkey)} ctx-name={CTX_NAME} {...config} />
<AdapterConfig userAgentIntegration={getUserAgentIntegration()} ctx-name={CTX_NAME} {...config} />
{/* @ts-ignore */}
<AdapterUploadCtxProvider
ref={refUploadCtxProvider}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { getStyleSource } from "../default";
import type { TProps } from "../types";

import { getCalcPropertyOfProps } from "../../utils/getCalcPropertyOfProps";
import { getUserAgentIntegration } from "../../utils/getUserAgentIntegration";
import { getUserAgentIntegration } from "../../utils/getUserAgentIntegration.ts";

LR.registerBlocks(LR);

Expand Down Expand Up @@ -35,7 +35,7 @@ export const FileUploaderRegular: FC<TProps> = ({
return (
<div className={className}>
{/* @ts-ignore */}
<AdapterConfig userAgentIntegration={getUserAgentIntegration(config.pubkey)} ctx-name={CTX_NAME} {...config}/>
<AdapterConfig userAgentIntegration={getUserAgentIntegration()} ctx-name={CTX_NAME} {...config} />
{/* @ts-ignore */}
<AdapterUploadCtxProvider
ref={refUploadCtxProvider}
Expand Down
13 changes: 13 additions & 0 deletions packages/react-uploader/src/utils/getUserAgentIntegration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getUserAgentIntegration = void 0;
var package_json_1 = require("../../package.json");
var react_1 = require("react");
var blocks_1 = require("@uploadcare/blocks");
var LIBRARY_NAME = blocks_1.PACKAGE_NAME;
var LIBRARY_VERSIONS = blocks_1.PACKAGE_VERSION;
var getUserAgentIntegration = function (publicKey) {
return "".concat(LIBRARY_NAME, "/").concat(LIBRARY_VERSIONS, "/").concat(publicKey, " (JavaScript; React/").concat(react_1.version, "; ").concat(package_json_1.name, "/").concat(package_json_1.version, ")");
};
exports.getUserAgentIntegration = getUserAgentIntegration;
(0, exports.getUserAgentIntegration)('12');
10 changes: 7 additions & 3 deletions packages/react-uploader/src/utils/getUserAgentIntegration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { version, name } from "../../package.json";
import {
version as reactUploaderVersion,
name as reactUploaderName,
} from "../../package.json";
import { version } from "react";

export const getUserAgentIntegration = (pubkey: string) => {
return `${name}/${version}/${pubkey} (JavaScript; React;)`;
export const getUserAgentIntegration = () => {
return `React/${version}; ${reactUploaderName}/${reactUploaderVersion}`;
};

0 comments on commit b343069

Please sign in to comment.