Skip to content

Commit

Permalink
feat: disable analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
Baroshem committed Dec 20, 2023
1 parent d13f3d3 commit 0f8df15
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"stackblitz": "cd .stackblitz && yarn && yarn dev"
},
"dependencies": {
"@cloudinary-util/url-loader": "^3.10.0",
"@cloudinary-util/url-loader": "^3.23.0",
"@nuxt/kit": "^3.5.0",
"@unpic/vue": "^0.0.23",
"defu": "^6.1.2"
Expand Down
3 changes: 3 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type ModuleOptions = {
cloudName?: string;
uploadPreset?: string;
apiKey?: string;
analytics?: boolean;
};

export default defineNuxtModule<ModuleOptions>({
Expand All @@ -20,6 +21,7 @@ export default defineNuxtModule<ModuleOptions>({
},
defaults: {
cloudName: process.env.CLOUDINARY_CLOUD_NAME,
analytics: true
},
setup(options, nuxt) {
const resolver = createResolver(import.meta.url);
Expand All @@ -31,6 +33,7 @@ export default defineNuxtModule<ModuleOptions>({
uploadPreset:
process.env.CLOUDINARY_UPLOAD_PRESET || options.uploadPreset,
apiKey: process.env.CLOUDINARY_API_KEY || options.apiKey,
analytics: options.analytics
}
);

Expand Down
35 changes: 22 additions & 13 deletions src/runtime/composables/useCldImageUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,33 @@ export const useCldImageUrl = (props: ConstructUrlProps) => {

if (!cldCloudName) console.warn('`[@nuxtjs/cloudinary]` Environment variable `CLOUDINARY_CLOUD_NAME` or property `cloudinary.cloudName` missing')

return {
url: constructCloudinaryUrl({
options: {
// Have to spread the options because otherwise getting the error about props being updated while they are readonly.
...props.options
},
config: {
...props.config,
cloud: {
cloudName: cldCloudName
}
},
let cldOptions: ConstructUrlProps = {
options: {
// Have to spread the options because otherwise getting the error about props being updated while they are readonly.
...props.options
},
config: {
...props.config,
cloud: {
cloudName: cldCloudName
}
},
analytics: false
}

if (useRuntimeConfig().public.cloudinary.analytics) {
cldOptions = {
...cldOptions,
analytics: Object.assign({
sdkCode: 'D',
sdkSemver: `${pkg.version.split('.')[0]}.0.0`,
techVersion: `${nuxtPkg.version.split('.')[0]}.0.0`,
product: 'B'
}, props.analytics)
})
}
}

return {
url: constructCloudinaryUrl(cldOptions)
}
}
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -471,18 +471,18 @@
dependencies:
mime "^3.0.0"

"@cloudinary-util/url-loader@^3.10.0":
version "3.10.0"
resolved "https://registry.yarnpkg.com/@cloudinary-util/url-loader/-/url-loader-3.10.0.tgz#30dbed4d60968687c9161a60b246da62d42c3e33"
integrity sha512-RNp6WayU6e5ikA7yCRqNhp0lOwLl82vLco9EwpES2si6Hb+g9yEaeTYvobD44ISQeJUnPl6e1c/AEYVSjfzwrg==
"@cloudinary-util/url-loader@^3.23.0":
version "3.23.0"
resolved "https://registry.yarnpkg.com/@cloudinary-util/url-loader/-/url-loader-3.23.0.tgz#694aee3b858f3a01d42953f55c17b4620973c4e9"
integrity sha512-Tp6TrAkOYkgT3CyIU4nXS4utLkYN9nquTQSNW6Qqmb7vA7Y1MaSRty+F2FHV84WETK9XQDCfdCn4B+SyH4sWWw==
dependencies:
"@cloudinary-util/util" "2.2.1"
"@cloudinary-util/util" "2.3.0"
"@cloudinary/url-gen" "^1.10.2"

"@cloudinary-util/util@2.2.1":
version "2.2.1"
resolved "https://registry.yarnpkg.com/@cloudinary-util/util/-/util-2.2.1.tgz#c482d9321d37d921b347858a121c161b68782bd3"
integrity sha512-MEIqn5WtPP3mxSMTNNfpqlGS1UquAXcjmVdY/t/edD/ZWVjI85viBiOMIuF0W6n6UF5gTstLymfQNYx0YO/GZg==
"@cloudinary-util/util@2.3.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@cloudinary-util/util/-/util-2.3.0.tgz#8a2a7ad3d3f089c2fff08f53eaddd50e946048f1"
integrity sha512-0Gojd+ZRQjJQmlBEAa8Ua94amvx7uWHoUzVUEGi1S8bgF1wPcMqG07cSUGQfRwHsFQ/9XOesx76Df622E+CevA==

"@cloudinary/transformation-builder-sdk@^1.2.7":
version "1.2.8"
Expand Down

0 comments on commit 0f8df15

Please sign in to comment.