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

Please add setSession to Options #373

Open
kimhecan opened this issue Mar 18, 2021 · 1 comment
Open

Please add setSession to Options #373

kimhecan opened this issue Mar 18, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@kimhecan
Copy link

kimhecan commented Mar 18, 2021

Summary

current code is (as-is)

  var event = {
      device_id: this.options.deviceId,
      user_id: this.options.userId,
      timestamp: eventTime,
      event_id: eventId,
      session_id: this._sessionId || -1,
      event_type: eventType ...
}

updated code is(to-be)

    var event = {
      device_id: this.options.deviceId,
      user_id: this.options.userId,
      timestamp: eventTime,
      event_id: eventId,
      session_id: this.options.sessionId || this._sessionId || -1,
      event_type: eventType...
}

using like

  amplitude
    .getInstance()
    .init('1231231231', userId, {
       sessionId: 'customId'      
       saveEvents: true,
      includeUtm: true,
      includeReferrer: true
    });

Motivations

In some cases like webView, web developers need to set a session ID obtaining from app when init amplitude and request it to amplitude.

@kimhecan kimhecan added the enhancement New feature or request label Mar 18, 2021
@kevinpagtakhan
Copy link
Contributor

@kimhecan Thanks for the creating an issue and putting up this suggestion! Do you feel strongly about setting the sessionId on init()? An alternative to that is calling setSessionId() after calling init();

For example:

amplitude.init(API_KEY)
amplitude.getInstance().setSessionId(12341234);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants