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

Identify whether the script is being consumed via the CDN or NPM package #1249

Merged
merged 1 commit into from Apr 28, 2020

Conversation

MSNev
Copy link
Collaborator

@MSNev MSNev commented Apr 15, 2020

@MSNev MSNev requested a review from a team as a code owner April 15, 2020 00:29
if (typeof this.internal.sdkVersion === "string") {
event.tags[CtxTagKeys.internalSdkVersion] = this.internal.sdkVersion;

if (event.baseType === _InternalLogMessage.dataType || event.baseType === PageView.dataType) {
Copy link
Collaborator Author

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) {
Copy link
Collaborator Author

@MSNev MSNev Apr 15, 2020

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

Copy link
Member

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?

Copy link
Collaborator Author

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;
Copy link
Collaborator Author

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) {
}
Copy link
Contributor

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?

Copy link
Collaborator Author

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).

Copy link
Contributor

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)?

Copy link
Collaborator Author

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.

AISKU/src/Initialization.ts Outdated Show resolved Hide resolved
AISKU/src/Initialization.ts Outdated Show resolved Hide resolved
let url = sdkSrc.toLowerCase();
if (url) {
let src = "";
if (url.indexOf("://az416426.vo.msecnd.net/") !== -1) {
Copy link
Member

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?

@MSNev MSNev merged commit 88cf8ed into master Apr 28, 2020
@MSNev MSNev added this to the 2.5.5 milestone Jun 2, 2020
@MSNev MSNev deleted the MSNev/CDNProperty branch August 15, 2020 01:10
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.

None yet

3 participants