-
Notifications
You must be signed in to change notification settings - Fork 72
Updated cody analytics cookie name to SAMS cookie #1284
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9332eb1
Updated cody analytics cookie name to SAMS cookie
federubinstein c0dd8b6
Update docs/analytics/api.mdx
federubinstein ac34286
Added name change callout
federubinstein b1a3758
Changed SAMS mentions to Sourcegraph Accounts
federubinstein 946934c
Update docs/analytics/api.mdx
federubinstein ddc1d44
Update docs/analytics/api.mdx
federubinstein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,18 +7,19 @@ The Sourcegraph Analytics API is an API that provides programmatic access to you | |
For Sourcegraph Analytics, you can generate an access token for programmatic access. Tokens are long-lived with an optional expiry and have the same permissions to access instance data as the user who created them. | ||
|
||
### Getting Started | ||
> **_NOTE:_** As of July 2025, the authentication cookie has changed from `cas` to `accounts_session_v2` (Sourcegraph Accounts session cookie). If you have existing scripts using the old cookie name, please update them accordingly. | ||
|
||
Access tokens are created using the `cas` cookie for authentication to the token creation endpoint. Access tokens are longer lived than the `cas` cookie making them more suitable for programmatic access to the Sourcegraph Analytics API. | ||
Access tokens are created using the Sourcegraph Accounts session cookie (`accounts_session_v2`) for authentication to the token creation endpoint. Access tokens are longer lived than the Sourcegraph Accounts session cookie making them more suitable for programmatic access to the Sourcegraph Analytics API. | ||
|
||
- Sign in to [Sourcegraph Analytics](https://analytics.sourcegraph.com). | ||
- Retrieve your session cookie, `cas`, from your browser's developer tools. | ||
- Retrieve your Sourcegraph Accounts session cookie, `accounts_session_v2`, from your browser's developer tools. | ||
|
||
 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: I will update this image when https://github.com/sourcegraph/cody-analytics/pull/207 is merged, and we use accounts_session_v2 in production (so it says analyitcs.sourcegraph.com as the cookie source instead of localhost) |
||
|
||
- Export the cookie as an environment variable to use in the following commands: | ||
|
||
```sh | ||
export CAS_COOKIE="<CAS_COOKIE_VALUE>" | ||
export ACCOUNTS_COOKIE="<ACCOUNTS_SESSION_V2_VALUE>" | ||
``` | ||
|
||
#### Token creation | ||
|
@@ -28,7 +29,7 @@ Create the token by running the following command: | |
```sh | ||
curl -X POST https://analytics.sourcegraph.com/api/service-access-tokens \ | ||
-H "Content-Type: application/json" \ | ||
-H "Cookie: cas=$CAS_COOKIE" \ | ||
-H "Cookie: accounts_session_v2=$ACCOUNTS_COOKIE" \ | ||
-d '{}' | ||
|
||
# Optionally include displayName, expiresAt, or both in the request body. | ||
|
@@ -54,7 +55,7 @@ List the tokens by running the following command: | |
|
||
```sh | ||
curl -X GET https://analytics.sourcegraph.com/api/service-access-tokens \ | ||
-H "Cookie: cas=$CAS_COOKIE" | ||
-H "Cookie: accounts_session_v2=$ACCOUNTS_COOKIE" | ||
``` | ||
|
||
Each token in the response will include the token ID, creation date, a boolean indicating if the token has expired, and display name and expiration date if provided. For example: | ||
|
@@ -98,7 +99,7 @@ Revoke a token by running the following commands: | |
export TOKEN_ID="<TOKEN_ID>" | ||
|
||
curl -X DELETE https://analytics.sourcegraph.com/api/service-access-tokens/$TOKEN_ID \ | ||
-H "Cookie: cas=$CAS_COOKIE" | ||
-H "Cookie: accounts_session_v2=$ACCOUNTS_COOKIE" | ||
``` | ||
|
||
<Callout type="note">The revocation request does not produce output. To verify that a token has been revoked, list the tokens and verify that `isExpired` is `true`.</Callout> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is it worth adding an info callout block saying that on N date, the cookie used got changed?
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.
Good point. Added note!