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

Extend cross-domain linking with more user/session information #1233

Closed

Conversation

igneel64
Copy link
Contributor

@igneel64 igneel64 commented Aug 28, 2023

Extending the cross-domain linking capability with a new parameter format adding the information of cross-navigation to a URLEncoded(B64(contents)) value which will be placed in the cross-domain linker param (_sp).

The tracker now accepts a useExtendedCrossDomainLinker parameter of type ExtendedCrossDomainLinkerOptions:

{
/* Enables the new `_sp` format using the cross_navigation information */
 useExtendedCrossDomainLinker: true
}

{
/* Enables the new `_sp` format using the cross_navigation information plus optional configuration for `ExtendedCrossDomainLinkerAttributes` . */
 useExtendedCrossDomainLinker: {
  userId?: boolean;
  sessionId?: boolean;
  sourceId?: boolean;
  sourcePlatform?: boolean;
  /**
   * Allow for the collection of the link text when a cross-domain link is clicked. Can also accept a callback for customizing information collection.
   */
  reason?: boolean | ((evt: Event) => string);
}
}

The default behaviour is not changed.

Notes:

  • Added testing-library/dom allowing us to test DOM interactions on unit type of tests.

@igneel64 igneel64 marked this pull request as draft August 28, 2023 10:45
@igneel64 igneel64 force-pushed the feature/extend-cross-domain-linking-entity branch 3 times, most recently from 8c40318 to 34fb605 Compare August 28, 2023 11:15
@bundlemon
Copy link

bundlemon bot commented Aug 28, 2023

BundleMon

Files added (6)
Status Path Size Limits
libraries/browser-tracker-core/dist/index.mod
ule.js
+26.24KB 26.5KB / +10%
trackers/javascript-tracker/dist/sp.js
+24.94KB 25KB / +10%
trackers/javascript-tracker/dist/sp.lite.js
+15.22KB 16KB / +10%
trackers/browser-tracker/dist/index.umd.min.j
s
+15.07KB 15.5KB / +10%
libraries/tracker-core/dist/index.module.js
+13.35KB 15KB / +10%
trackers/browser-tracker/dist/index.module.js
+3.51KB 5KB / +10%

Total files change +98.33KB 0%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history

Copy link
Contributor

@matus-tomlein matus-tomlein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terms of the configuration of the feature, there are a couple of things on my mind:

  1. Nit: Would "optional" be better than "extended" as a name for the extra properties? Extended feels a bit like enhanced ecommerce – what will we call the extended extended version? :D
  2. I think it would make sense to make the optional properties configurable – I can imagine some people might not want to send the userId or appId in the links but want the sessionId.

My suggestion would be to make the configuration something like this:

{
    crossDomainLinkerOptionalProps: {
         userId: true,
         sessionId: true,
         sourceId: true,
         sourcePlatform: true,
         reason: true
    }
}

We could also let users enable all optional props as you do now:

{
    crossDomainLinkerOptionalProps: true
}

libraries/browser-tracker-core/src/tracker/index.ts Outdated Show resolved Hide resolved
@igneel64
Copy link
Contributor Author

About the choise of extended in the naming I was thinking that this in v3 will add the 'new' way (b64) with the additional properties.
In v4 the old one would be removed and we would only keep this one.

If though we decide to keep the same formatting (split with dots), optional will be a better naming.

@igneel64 igneel64 force-pushed the feature/extend-cross-domain-linking-entity branch from 34fb605 to 7f0f14a Compare August 28, 2023 13:19
libraries/browser-tracker-core/src/tracker/index.ts Outdated Show resolved Hide resolved
libraries/browser-tracker-core/src/tracker/index.ts Outdated Show resolved Hide resolved
libraries/browser-tracker-core/src/tracker/index.ts Outdated Show resolved Hide resolved
libraries/browser-tracker-core/src/tracker/index.ts Outdated Show resolved Hide resolved
libraries/browser-tracker-core/src/tracker/index.ts Outdated Show resolved Hide resolved
libraries/browser-tracker-core/src/tracker/types.ts Outdated Show resolved Hide resolved
libraries/browser-tracker-core/src/tracker/types.ts Outdated Show resolved Hide resolved
libraries/browser-tracker-core/src/tracker/types.ts Outdated Show resolved Hide resolved
@igneel64 igneel64 force-pushed the feature/extend-cross-domain-linking-entity branch from 027700b to 6183a19 Compare August 30, 2023 11:58
@igneel64 igneel64 marked this pull request as ready for review August 30, 2023 11:59
@igneel64 igneel64 force-pushed the feature/extend-cross-domain-linking-entity branch from 6183a19 to 616fb37 Compare August 30, 2023 12:13
Copy link
Contributor

@matus-tomlein matus-tomlein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one nitpick about the dots at the end of the string but otherwise LGTM

libraries/browser-tracker-core/src/helpers/cross_domain.ts Outdated Show resolved Hide resolved
@igneel64 igneel64 force-pushed the feature/extend-cross-domain-linking-entity branch from 616fb37 to e709c99 Compare September 2, 2023 13:36
export interface ExtendedCrossDomainLinker {
domainUserId?: string;
/* Timestamp of the cross-domain link click. */
timestamp?: number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is timestamp required for this type? It looks like the timestamp value will always come from here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type is only used internally for the creation of the domain values. I moved it around a bit to make it more clear.

@igneel64 igneel64 force-pushed the feature/extend-cross-domain-linking-entity branch 2 times, most recently from 35c3112 to a770521 Compare November 7, 2023 10:17
@igneel64 igneel64 force-pushed the feature/extend-cross-domain-linking-entity branch from a770521 to 3822437 Compare November 24, 2023 08:16
@igneel64 igneel64 force-pushed the feature/extend-cross-domain-linking-entity branch from 3822437 to 97e2ee2 Compare November 24, 2023 08:25
@igneel64 igneel64 changed the base branch from master to release/3.18.0 November 24, 2023 11:38
@matus-tomlein matus-tomlein deleted the branch release/3.18.0 December 12, 2023 13:38
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.

4 participants