-
Notifications
You must be signed in to change notification settings - Fork 151
Does it support nonce? #377
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
Comments
Thanks @caub, that's a great suggestion, I'll add to our backlog to add. |
@pooyaj can I follow the same patterns as the |
@yordis yes! a PR is appreciated 🙌 |
Are there any plans on adding the |
@yakovenkodenis I am not using Segment at the moment, take the lead and open a PR, I can assist if I still remember how |
What I have currently tried locally is add // packages/browser/src/core/analytics/index.ts
export interface InitOptions {
nonce?: string
....
}
// packages/browser/src/plugins/ajs-destination/index.ts
export class LegacyDestination implements InternalPluginWithAddMiddleware {
...
async load(ctx: Context, analyticsInstance: Analytics): Promise<void> {
...
const integrationSource =
this.integrationSource ??
(await loadIntegration(
ctx,
this.name,
this.version,
this.options.obfuscate,
{ ...(this.options.nonce ? { nonce: this.options.nonce } : {}) } // this line is new
))
...
}
...
}
// packages/browser/src/plugins/ajs-destination/loader.ts
...
export async function loadIntegration(
ctx: Context,
name: string,
version: string,
obfuscate?: boolean,
attributes?: Record<string, string> // this parameter is new
): Promise<ClassicIntegrationSource> {
...
try {
await loadScript(fullPath, attributes) // passing the attributes object with `nonce`
...
}
... This appears to work when calling I thought that in the end the path from Specifically, I was looking at the following files:
|
For CSP, I'd like to do
AnalyticsBrowser.load({ writeKey, nonce })
where nonce is a CSP nonce passed to allow specific scriptsThe text was updated successfully, but these errors were encountered: