Skip to content

glmap: Snippets

Cyril Moreau edited this page May 22, 2025 · 3 revisions

Snippets are the GitLab equivalent of Gists but they are not linked necessarily to a user, they can be linked to a project. For more information on what you can do with snippets in GitLab, see the GitLab documentation.

With snippets, you can share part of code or text with other users and discuss it. You can find an example of a snippet used by the GitLab organization here.

In the case of snippets, only comments are registered in the activity feed. The creation, update and deletion of snippets can't be detected. The following table shows the mapping of the events generated by GitLab for snippets. A fully detailed mapping can be found below.

Action target_type action detection
CreateSnippetComment Note commented on note.noteable_type = Snippet
CreateSnippetThread DiscussionNote commented on note.noteable_type = Snippet
Activity Actions time window
CommentSnippet - CreateSnippetComment - Opt - Rep
- CreateSnippetThread - Opt - Rep
300s

1 - Actions

  • Detection are the values used to detect what action has been performed.
  • Details are information found in the payload of the event that can be used to group actions to activities. (name_in_action = name_in_payload)

1.1 - CreateSnippetComment

Event triggered when a comment is created in a snippet.

Detection:

  • action_name = commented on
  • target_type = Note
  • note.noteable_type = Snippet

Details:

  • snippet.id = note.noteable_id
  • snippet.title = target_title
  • comment.id = target_id
  • comment.body = note.body

1.2 - CreateSnippetThread

Event triggered when a comment is created in a snippet with a thread.

Detection:

  • action_name = commented on
  • target_type = DiscussionNote
  • note.noteable_type = Snippet

Details:

  • snippet.id = note.noteable_id
  • snippet.title = target_title
  • comment.id = target_id
  • comment.body = note.body

2 - Activities

Each activity is composed of one or more actions. Each action can be repeatable and can be optional. A maximum time window is also defined for each activity and it is used to group actions that are close to each other in time.

For each action, we can define a verification function (validate_with) to make sure that the action is part of the activity. (e.g comments are made on the same issue)

2.1 - CommentSnippet

time window: 300s

The idea here is to group all the comments made on the same snippet. It's based on what was done with issues and merge requests comments.

  • CreateSnippetComment - optional and repeatable
    • CreateSnippetComment: snippet.id = snippet.id
    • CreateSnippetThread: snippet.id = snippet.id
  • CreateSnippetThread - optional and repeatable
    • CreateSnippetComment: snippet.id = snippet.id
    • CreateSnippetThread: snippet.id = snippet.id

Clone this wiki locally