-
Notifications
You must be signed in to change notification settings - Fork 68
fix(tpc): custom feature detection flags #113
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@flashdesignory do you need it in other components ?
once GoogleMaps and Youtube is integrated, we should also add the feature detection there π |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM π
yes we need to discuss about theses components at the next meeting :) |
Aren't these already implemented as part of https://github.com/nuxt/scripts/blob/main/src/runtime/composables/useScript.ts#L26 ? |
we want to differentiate between all nuxt scripts and the third-party-capital integrations. |
You can just use the key? ga / gtm is tpc
Yes, this was intentional. What / which chrome flags are you referring to? |
We implemented flags in Chrome that we can use to pull usage data.
previous pr: https://github.com/nuxt/third-party-capital/pull/53 |
Is it possible to update the flags? It would make more sense for the scope prefix to match the module name. It's a bit clunky to try and support both naming conventions |
any progress on this ? |
@huang-julien - thanks for following up. I'd still like to use the updated naming convention for the following reasons:
Personally, I think the work is doable, since we're not dealing with a large number of third-parties anytime soon. |
Are you talking about |
correct, the only thing I am not sure about is if the ids match. |
Yes google analytics was using @harlan-zw i'm changing the feature detection to |
This is fine, I don't see how using different keys stops you from doing this.
It seems like this is just a matter of changing a string but maybe you can clarify further exactly how much work are we talking? Ideally these wouldn't of been set initially until we were close to making the module public, breaking changes should have been expected.
Not sure how using different keys helps with this. The reason why I prefer a properly named prefix:
Keep in mind that even if we merge this, Youtube and Google Maps will still be broken. |
Maybe I am missing something π€·.
Is that assumption correct? If so, and I am using the same flags from nuxt script, how can I differentiate if a user uses 1) or 2) ? |
We only give one option of which to use, it would be confusing otherwise and add no value to the end user. GA and GTM is using TPC. |
You're right, it's a quick string change. The larger concern is that any changes in Chromium will take a while before it hits stable (likely well after this module goes public and gathers adoption). We wanted to get a bit ahead of the curve by naming these strings before the module ships since it can take months to see the change in stable browser. |
Thanks for clarifying, In this case, I'd consider this PR okay to go ahead with. Do we need to handle GTM as well @huang-julien |
tag manager has already |
src/runtime/composables/useScript.ts
Outdated
@@ -25,7 +25,7 @@ export function useScript<T extends Record<string | symbol, any>>(input: UseScri | |||
if (!nuxtApp._scripts?.[id]) { | |||
performance?.mark?.('mark_feature_usage', { | |||
detail: { | |||
feature: `nuxt-scripts:${id}`, | |||
feature: `nuxt-third-parties-${id}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer if the non-TPC scripts used the old key name.
So could we add a config key on NuxtUseScriptOption performanceMarkFeature
which can be added as deprecated, then we provide the full key via the TPC scripts
feature: options?.performanceMarkFeature || `nuxt-scripts:${id}`,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm good with this π
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as deprecated ? Maybe as internal if you don't want it to be public
src/tpc/utils.ts
Outdated
@@ -86,7 +87,7 @@ declare global { | |||
chunks.push(` | |||
export function ${input.scriptFunctionName}<T extends ${input.tpcTypeImport}>(_options?: Input) { | |||
${functionBody.join('\n')} | |||
return useRegistryScript${hasParams ? '<T, typeof OptionSchema>' : ''}('${input.tpcKey}', options => ({ | |||
return useRegistryScript${hasParams ? '<T, typeof OptionSchema>' : ''}('${input.registryId ?? input.tpcKey}', options => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we then pass in
performanceMarkFeature: 'nuxt-third-parties-${id}`,
@huang-julien - if you're using the I remember you mentioned that these are different and if that's the case, I think we can rename that one in tpc (@housseindjirdeh ). |
π Linked issue
β Type of change
π Description
This PR add feature detection for tpc composables. It also removes
augmentWindowTypes
to make it default