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

@uppy/unsplash,@uppy/provider-views: add utmSource option #5580

Merged
merged 1 commit into from
Jan 8, 2025

Conversation

Murderlon
Copy link
Member

@Murderlon Murderlon commented Jan 7, 2025

Closes #5564

I don't know why I suddenly need to update the tsconfig.json's of two other projects but otherwise the build is failing. In any case better to align the settings.

@Murderlon Murderlon self-assigned this Jan 7, 2025
Copy link
Contributor

github-actions bot commented Jan 7, 2025

Diff output files
diff --git a/packages/@uppy/provider-views/lib/Browser.js b/packages/@uppy/provider-views/lib/Browser.js
index d8a3bfb..3d26a33 100644
--- a/packages/@uppy/provider-views/lib/Browser.js
+++ b/packages/@uppy/provider-views/lib/Browser.js
@@ -14,6 +14,7 @@ function Browser(props) {
     openFolder,
     noResultsLabel,
     virtualList,
+    utmSource,
   } = props;
   const [isShiftKeyPressed, setIsShiftKeyPressed] = useState(false);
   useEffect(() => {
@@ -54,6 +55,7 @@ function Browser(props) {
       i18n: i18n,
       openFolder: openFolder,
       file: item,
+      utmSource: utmSource,
     });
   if (virtualList) {
     return h(
diff --git a/packages/@uppy/provider-views/lib/Item/index.js b/packages/@uppy/provider-views/lib/Item/index.js
index dc2c3ba..6e097db 100644
--- a/packages/@uppy/provider-views/lib/Item/index.js
+++ b/packages/@uppy/provider-views/lib/Item/index.js
@@ -10,6 +10,7 @@ export default function Item(props) {
     i18n,
     openFolder,
     file,
+    utmSource,
   } = props;
   const restrictionError = file.type === "folder" ? null : file.restrictionError;
   const isDisabled = !!restrictionError && file.status !== "checked";
@@ -17,6 +18,7 @@ export default function Item(props) {
     file,
     openFolder,
     toggleCheckbox,
+    utmSource,
     i18n,
     viewType,
     showTitles,
@@ -42,7 +44,7 @@ export default function Item(props) {
         GridItem,
         ourProps,
         h("a", {
-          href: `${file.data.author.url}?utm_source=Companion&utm_medium=referral`,
+          href: `${file.data.author.url}?utm_source=${utmSource}&utm_medium=referral`,
           target: "_blank",
           rel: "noopener noreferrer",
           className: "uppy-ProviderBrowserItem-author",
diff --git a/packages/@uppy/provider-views/lib/ProviderView/ProviderView.js b/packages/@uppy/provider-views/lib/ProviderView/ProviderView.js
index e97c090..8084c9e 100644
--- a/packages/@uppy/provider-views/lib/ProviderView/ProviderView.js
+++ b/packages/@uppy/provider-views/lib/ProviderView/ProviderView.js
@@ -382,6 +382,7 @@ export default class ProviderView {
         showTitles: opts.showTitles,
         i18n: this.plugin.uppy.i18n,
         isLoading: loading,
+        utmSource: "Companion",
       }),
       h(FooterActions, {
         partialTree: partialTree,
diff --git a/packages/@uppy/provider-views/lib/SearchProviderView/SearchProviderView.js b/packages/@uppy/provider-views/lib/SearchProviderView/SearchProviderView.js
index 16576ec..a94e343 100644
--- a/packages/@uppy/provider-views/lib/SearchProviderView/SearchProviderView.js
+++ b/packages/@uppy/provider-views/lib/SearchProviderView/SearchProviderView.js
@@ -25,6 +25,12 @@ const defaultState = {
   currentFolderId: null,
   isInputMode: true,
 };
+const defaultOptions = {
+  viewType: "grid",
+  showTitles: true,
+  showFilter: true,
+  utmSource: "Companion",
+};
 export default class SearchProviderView {
   constructor(plugin, opts) {
     this.isHandlingScroll = false;
@@ -57,11 +63,6 @@ export default class SearchProviderView {
     };
     this.plugin = plugin;
     this.provider = opts.provider;
-    const defaultOptions = {
-      viewType: "grid",
-      showTitles: true,
-      showFilter: true,
-    };
     this.opts = {
       ...defaultOptions,
       ...opts,
@@ -247,6 +248,7 @@ export default class SearchProviderView {
         isLoading: loading,
         i18n: i18n,
         virtualList: false,
+        utmSource: this.opts.utmSource,
       }),
       h(FooterActions, {
         partialTree: partialTree,
diff --git a/packages/@uppy/unsplash/lib/Unsplash.js b/packages/@uppy/unsplash/lib/Unsplash.js
index 470f0f3..97b6951 100644
--- a/packages/@uppy/unsplash/lib/Unsplash.js
+++ b/packages/@uppy/unsplash/lib/Unsplash.js
@@ -57,6 +57,7 @@ export default class Unsplash extends UIPlugin {
       provider: this.provider,
       viewType: "unsplash",
       showFilter: true,
+      utmSource: this.opts.utmSource,
     });
     const {
       target,

@Murderlon Murderlon force-pushed the unsplash-utm-source branch from 4ef8909 to 99012f3 Compare January 7, 2025 14:19
@Murderlon Murderlon force-pushed the unsplash-utm-source branch from 99012f3 to d59ab54 Compare January 7, 2025 16:42
@Murderlon Murderlon merged commit bc1578a into main Jan 8, 2025
16 checks passed
@Murderlon Murderlon deleted the unsplash-utm-source branch January 8, 2025 09:14
github-actions bot added a commit that referenced this pull request Jan 8, 2025
| Package                    | Version | Package                    | Version |
| -------------------------- | ------- | -------------------------- | ------- |
| @uppy/google-drive-picker  |   0.3.1 | @uppy/unsplash             |   4.3.0 |
| @uppy/google-photos-picker |   0.3.1 | @uppy/utils                |   6.1.1 |
| @uppy/onedrive             |   4.2.1 | @uppy/xhr-upload           |   4.3.1 |
| @uppy/provider-views       |   4.4.0 | uppy                       |  4.12.0 |
| @uppy/svelte               |   4.3.0 |                            |         |

- @uppy/unsplash,@uppy/provider-views: add utmSource option (Merlijn Vos / #5580)
- @uppy/xhr-upload: allow custom error message in onAfterResponse (Merlijn Vos / #5578)
- @uppy/onedrive: fix AsyncStore import (Merlijn Vos / #5579)
- @uppy/google-drive-picker,@uppy/google-photos-picker: Fix Google Picker plugins locale (Merlijn Vos / #5575)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unsplash utm_source hard-coded to "Companion"
1 participant