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
Identify whether the script is being consumed via the CDN or NPM package #1249
Conversation
if (typeof this.internal.sdkVersion === "string") { | ||
event.tags[CtxTagKeys.internalSdkVersion] = this.internal.sdkVersion; | ||
|
||
if (event.baseType === _InternalLogMessage.dataType || event.baseType === PageView.dataType) { |
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.
Limited to the Internal messages and initial page view
let url = sdkSrc.toLowerCase(); | ||
if (url) { | ||
let src = ""; | ||
if (url.indexOf("://az416426.vo.msecnd.net/") !== -1) { |
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.
Only populating if this is from the standard CDN -- ignore non MS defined endpoints, and only include an anonymous name "cdn1" rather than the full domain/url
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.
If the script is consumed from CDN via the CName will we have to update this to match those domain names?
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.
Yes, once we have enabled additional common names this will need to be updated and I'm planning on enumerating the known names (which is why I called the existing one cdn1)
// } else { | ||
// // We need to update to at least typescript 2.9 for this to work :-( | ||
// // Leaving as a stub for now so after we upgrade this breadcrumb is available | ||
// let meta = import.meta; |
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.
Tried quite a few work-arounds to get this information with 2.5.3 (our current TS version), but nothing worked -- I could have done some sort of post processing (like the es3-poly), but that seems like overkill considering we should be upgrading to a later version of TS sooner rather than later.
} | ||
} | ||
} catch (e) { | ||
} |
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.
When caught, does that mean NPM? Is it possible to know NPM vs CDN vs unknown?
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.
This catch is unexpected and added purely to ensure that we don't crash, in which case this will mean that we don't know the outcome (same as what would happen with all IE and really old browsers).
So it's not possible to "always" determine npm, cdn or unknown. This is also why I added the snippet property as it should always be defined in which case we could assume that snippet users are using the primary CDN (vs their own).
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.
ok so for now it will report primary CDN or (NPM + custom CDN + unknown)?
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.
It will report primary CDN or nothing.
And when nothing we can assume that its NPM if also there is no snippet.
c3a1ace
to
bc2ef2a
Compare
…DN or NPM package
bc2ef2a
to
b2df774
Compare
let url = sdkSrc.toLowerCase(); | ||
if (url) { | ||
let src = ""; | ||
if (url.indexOf("://az416426.vo.msecnd.net/") !== -1) { |
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.
If the script is consumed from CDN via the CName will we have to update this to match those domain names?
…