Giter Club home page Giter Club logo

Comments (2)

linear avatar linear commented on July 20, 2024

HIG-4742 cross domain identification - apply identifier across differnet projects based on fingerprint

from highlight.

greptile-apps avatar greptile-apps commented on July 20, 2024

To implement cross-domain identification and allow the clientID to persist via a cookie for backfilling sessions, follow these steps:

  1. Backend Changes:

    • Update the AppendProperties function in /backend/public-graph/graph/resolver.go to handle cross-domain cookies.
    func (r *Resolver) AppendProperties(ctx context.Context, sessionID int, properties map[string]string, propType Property) error {
        // Existing code...
        // Set cross-domain cookie for clientID
        http.SetCookie(w, &http.Cookie{
            Name:     "clientID",
            Value:    clientID,
            Path:     "/",
            Domain:   ".yourdomain.com", // Set to your domain
            HttpOnly: true,
            Secure:   true,
        })
        // Existing code...
    }
  2. Frontend Changes:

    • Modify the init function in /sdk/firstload/src/index.tsx to read and set the clientID from a cookie.
    init: (projectID?: string | number, options?: HighlightOptions) => {
        // Existing code...
        let clientID = document.cookie.split('; ').find(row => row.startsWith('clientID='))?.split('=')[1];
        if (!clientID) {
            clientID = GenerateSecureID();
            document.cookie = `clientID=${clientID}; path=/; domain=.yourdomain.com; Secure; HttpOnly`;
        }
        // Existing code...
    }
  3. Session Backfilling:

    • Ensure the sessionIsBackfilled function in /frontend/src/pages/Player/utils/utils.ts correctly identifies sessions using the clientID.
    export const sessionIsBackfilled = (session: Session): boolean => {
        return !!session.clientID && !!session.identifier && !session.identified;
    };

References

/backend/public-graph/graph/resolver.go
/backend/model/model.go
/sdk/firstload/src/index.tsx
/sdk/client/src/index.tsx
/frontend/src/pages/Player/utils/utils.ts
/frontend/src/pages/Player/utils/utils.test.ts
/docs-content/getting-started/2_frontend-backend-mapping.md

Ask Greptile

from highlight.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.